-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cmake_format.py to improve cmake formatting in pre-commit: modify all cmake files
- Loading branch information
1 parent
99179b8
commit 8db4984
Showing
6 changed files
with
145 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
with section("format"): | ||
line_width = 120 | ||
tab_size = 2 | ||
line_ending = "auto" | ||
|
||
with section("markup"): | ||
bullet_char = "-" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--- | ||
name: DEB Packages | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: | ||
- v11 | ||
- main | ||
push: | ||
tags: ['*'] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
image: ['debian:10', 'debian:11', 'debian:12', 'ubuntu:20.04', 'ubuntu:22.04', 'ubuntu:24.04'] | ||
container: ${{ matrix.image }} | ||
steps: | ||
- name: Install packages | ||
run: | | ||
export DEBIAN_FRONTEND="noninteractive" | ||
apt-get -y update | ||
apt-get -y --no-install-recommends install build-essential coreutils debhelper git ca-certificates curl | ||
apt-get -y install ninja-build | ||
apt-get -y install zip pkg-config # for vcpkkg | ||
curl -LO "https://github.com/Kitware/CMake/releases/download/v3.30.3/cmake-3.30.3-linux-x86_64.sh" | ||
bash cmake-3.30.3-linux-x86_64.sh --prefix=/usr/local/ --exclude-subdir | ||
- name: Checkout sources | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
- name: Configure CMake | ||
run: | | ||
cmake -B builds -S . -G Ninja -D CMAKE_BUILD_TYPE=Release -D CMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake | ||
cmake -S . -B builds -G Ninja -D CMAKE_BUILD_TYPE=Release -D CMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake | ||
- name: Build | ||
run: | | ||
cmake --build builds --target khiopsdriver_file_gcs | ||
- name: Build package with CPack | ||
run: cd builds/ && cpack -G DEB | ||
- name: Rename the packages to include the ubuntu codename | ||
run: | | ||
source /etc/os-release | ||
cd builds/packages/ | ||
for filename in *.deb | ||
do | ||
mv -v $filename ${filename%_*}-${VERSION_CODENAME}.${filename##*_} | ||
done | ||
- name: Upload the packages as artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
# We add a `deb-` prefix so we can later recover all artifacts with the pattern `deb-*` | ||
# Note: The more natural pattern `*-deb` or `*` does not work | ||
name: deb-${{ env.ID }}-${{ env.VERSION_CODENAME }} | ||
path: builds/packages/*.deb | ||
if-no-files-found: error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
# CMakeLists.txt | ||
|
||
# Ensure to pick up the default triplet from the environment if any. This helps | ||
# driving the vcpkg triplet in the same way either when starting vcpkg directly, | ||
# or when letting CMake start vcpkg at configure/generate time. Note: this logic | ||
# must happen before PROJECT command. | ||
# Ensure to pick up the default triplet from the environment if any. This helps driving the vcpkg triplet in the same | ||
# way either when starting vcpkg directly, or when letting CMake start vcpkg at configure/generate time. Note: this | ||
# logic must happen before PROJECT command. | ||
if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET) | ||
set(VCPKG_TARGET_TRIPLET | ||
"$ENV{VCPKG_DEFAULT_TRIPLET}" | ||
|
@@ -40,45 +39,34 @@ set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) | |
|
||
# Set the location of the built artifacts: | ||
# | ||
# * Shared and static library target directory: lib | ||
# * Executable target directory: bin | ||
# * We must use these weird generator expressions to avoid the Debug and Release | ||
# directories in VS | ||
# * More info: https://stackoverflow.com/q/47175912 | ||
# - Shared and static library target directory: lib | ||
# - Executable target directory: bin | ||
# - We must use these weird generator expressions to avoid the Debug and Release directories in VS | ||
# - More info: https://stackoverflow.com/q/47175912 | ||
# | ||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY $<1:${CMAKE_BINARY_DIR}/lib/>) | ||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY $<1:${CMAKE_BINARY_DIR}/lib/>) | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_BINARY_DIR}/bin/>) | ||
message(STATUS "Executables will be stored in ${CMAKE_BINARY_DIR}/bin/") | ||
message(STATUS "Libraries will be stored in ${CMAKE_BINARY_DIR}/lib/") | ||
|
||
if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND NOT (CMAKE_BUILD_TYPE STREQUAL | ||
"Release")) | ||
if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND NOT (CMAKE_BUILD_TYPE STREQUAL "Release")) | ||
message("Build system == Linux, build with sanitizer tools") | ||
add_compile_options(-fsanitize=undefined -fsanitize=address | ||
-fno-sanitize-recover=all) | ||
add_link_options(-fsanitize=undefined -fsanitize=address | ||
-fno-sanitize-recover=all) | ||
add_compile_options(-fsanitize=undefined -fsanitize=address -fno-sanitize-recover=all) | ||
add_link_options(-fsanitize=undefined -fsanitize=address -fno-sanitize-recover=all) | ||
include(CodeCoverage) | ||
set(CMAKE_CXX_FLAGS_DEBUG | ||
"${CMAKE_CXX_FLAGS_COVERAGE} ${CMAKE_CXX_FLAGS_DEBUG}") | ||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_COVERAGE} ${CMAKE_CXX_FLAGS_DEBUG}") | ||
setup_target_for_coverage(${PROJECT_NAME}_coverage basic_test coverage) | ||
setup_target_for_coverage_cobertura( | ||
${PROJECT_NAME}_cobertura basic_test coverage | ||
--gtest_output=xml:coverage.junit.xml) | ||
setup_target_for_coverage_cobertura(${PROJECT_NAME}_cobertura basic_test coverage | ||
--gtest_output=xml:coverage.junit.xml) | ||
endif() | ||
|
||
add_library(khiopsdriver_file_gcs SHARED | ||
src/gcsplugin.h src/gcsplugin_internal.h src/gcsplugin.cpp) | ||
add_library(khiopsdriver_file_gcs SHARED src/gcsplugin.h src/gcsplugin_internal.h src/gcsplugin.cpp) | ||
|
||
target_link_options(khiopsdriver_file_gcs PRIVATE $<$<CONFIG:RELEASE>:-s> | ||
)# stripping | ||
target_link_libraries(khiopsdriver_file_gcs PRIVATE google-cloud-cpp::storage | ||
spdlog::spdlog) | ||
target_link_options(khiopsdriver_file_gcs PRIVATE $<$<CONFIG:RELEASE>:-s>) # stripping | ||
target_link_libraries(khiopsdriver_file_gcs PRIVATE google-cloud-cpp::storage spdlog::spdlog) | ||
|
||
set_target_properties( | ||
khiopsdriver_file_gcs PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR} | ||
VERSION ${PROJECT_VERSION}) | ||
set_target_properties(khiopsdriver_file_gcs PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR} VERSION ${PROJECT_VERSION}) | ||
|
||
target_compile_options( | ||
khiopsdriver_file_gcs | ||
|
@@ -91,8 +79,7 @@ if(BUILD_TESTS) | |
add_executable(KhiopsPluginTest src/khiopsplugintest.cpp) | ||
target_link_libraries(KhiopsPluginTest PRIVATE fmt::fmt ${CMAKE_DL_LIBS}) | ||
add_executable(drivertest src/drivertest.cpp) | ||
target_link_libraries(drivertest ${CMAKE_DL_LIBS} google-cloud-cpp::storage | ||
)# Link to dl | ||
target_link_libraries(drivertest ${CMAKE_DL_LIBS} google-cloud-cpp::storage) # Link to dl | ||
endif(BUILD_TESTS) | ||
|
||
add_subdirectory(test) | ||
|
@@ -111,8 +98,7 @@ set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") | |
set(CPACK_PACKAGE_VENDOR "Orange") | ||
set(CPACK_PACKAGE_CONTACT "Khiops Team <[email protected]>") | ||
set(CPACK_SOURCE_IGNORE_FILES .git) | ||
set(CPACK_PACKAGE_DESCRIPTION | ||
"This driver allows Khiops to access the Google Cloud storage.") | ||
set(CPACK_PACKAGE_DESCRIPTION "This driver allows Khiops to access the Google Cloud storage.") | ||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "GCS driver for the Khiops tool") | ||
set(CPACK_PACKAGE_NAME "khiops-driver-gcs") | ||
|
||
|
@@ -131,33 +117,31 @@ set(CPACK_ARCHIVE_FILE_NAME kkhiops-driver-gcs-${PROJECT_VERSION}) | |
|
||
# ########### DEB Generator ############################# | ||
|
||
# Package release ("This is the numbering of the DEB package itself, i.e. the | ||
# version of the packaging and not the version of the content") | ||
# Package release ("This is the numbering of the DEB package itself, i.e. the version of the packaging and not the | ||
# version of the content") | ||
set(CPACK_DEBIAN_PACKAGE_RELEASE 1) | ||
|
||
# package name for deb. | ||
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) | ||
|
||
# Packages version: the full KHIOPS_VERSION (N.N.N_aN) instead of the | ||
# PROJECT_VERSION (N.N.N) set(CPACK_DEBIAN_PACKAGE_VERSION ${KHIOPS_VERSION}) | ||
# Packages version: the full KHIOPS_VERSION (N.N.N_aN) instead of the PROJECT_VERSION (N.N.N) | ||
# set(CPACK_DEBIAN_PACKAGE_VERSION ${KHIOPS_VERSION}) | ||
|
||
set(CPACK_DEB_COMPONENT_INSTALL YES) | ||
set(CPACK_DEBIAN_PACKAGE_SECTION "math") | ||
|
||
# runtime path setting | ||
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) | ||
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON) | ||
# binaries in deb building will search shared library in the build tree. We | ||
# should use directly CMAKE_LIBRARY_OUTPUT_DIRECTORY but it produces a bug in | ||
# dpkg-shlibdeps | ||
# binaries in deb building will search shared library in the build tree. We should use directly | ||
# CMAKE_LIBRARY_OUTPUT_DIRECTORY but it produces a bug in dpkg-shlibdeps | ||
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS_PRIVATE_DIRS ${CMAKE_BINARY_DIR}/lib/) | ||
|
||
# packages recommends | ||
set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "khiops") | ||
|
||
# packages posinst and triggers | ||
set(CPACK_DEBIAN_KNI_PACKAGE_CONTROL_EXTRA | ||
"${PROJECT_SOURCE_DIR}/packaging/linux/debian/kni/triggers") | ||
# packages posinst and triggers set(CPACK_DEBIAN_KNI_PACKAGE_CONTROL_EXTRA | ||
# ${PROJECT_SOURCE_DIR}/packaging/linux/debian/kni/triggers") | ||
|
||
# set(CPACK_DEBIAN_PACKAGE_DEBUG ON) | ||
set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE) | ||
|
@@ -180,10 +164,8 @@ set(CPACK_RPM_FILE_NAME RPM-DEFAULT) | |
|
||
# packages summary set(CPACK_RPM_PACKAGE_SUMMARY "Khiops tools") | ||
|
||
# packages post/postun install scripts | ||
# set(CPACK_RPM_KNI_POST_INSTALL_SCRIPT_FILE | ||
# "${PROJECT_SOURCE_DIR}/packaging/linux/redhat/kni.post") | ||
# set(CPACK_RPM_KNI_POSTUN_INSTALL_SCRIPT_FILE | ||
# packages post/postun install scripts set(CPACK_RPM_KNI_POST_INSTALL_SCRIPT_FILE | ||
# "${PROJECT_SOURCE_DIR}/packaging/linux/redhat/kni.post") set(CPACK_RPM_KNI_POSTUN_INSTALL_SCRIPT_FILE | ||
# "${PROJECT_SOURCE_DIR}/packaging/linux/redhat/kni.postun") | ||
|
||
include(CPack) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.