From 39d540b22d05b2659b8b1663c68f065c6db66a74 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Mon, 25 Nov 2024 09:26:16 +0100 Subject: [PATCH 1/3] Modernize cmake files Use FILE_SET HEADERS for simplify installation Set VERIFY_INTERFACE_HEADER_SETS property Prevent use of include(CTest) Prepare CPack to easy distribution Add all_verify_interface_header_sets to CI builds Prevent in-source builds Ignore cmake configure trash --- .github/workflows/ci_tests.yml | 4 +-- .gitignore | 2 ++ CMakeLists.txt | 49 +++++++++++++++++++++++----------- 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 8fe6056..631de18 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -104,7 +104,7 @@ jobs: - name: Build Release run: | cmake --build build --config Release --verbose - # TODO: cmake --build build --config Release --target all_verify_interface_header_sets + cmake --build build --config Release --target all_verify_interface_header_sets cmake --install build --config Release --prefix /tmp/beman.inplace_vector find /tmp/beman.inplace_vector -type f - name: Test Release @@ -112,7 +112,7 @@ jobs: - name: Build Debug run: | cmake --build build --config Debug --verbose - # TODO: cmake --build build --config Debug --target all_verify_interface_header_sets + cmake --build build --config Debug --target all_verify_interface_header_sets cmake --install build --config Debug --prefix /tmp/beman.inplace_vector find /tmp/beman.inplace_vector -type f - name: Test Debug diff --git a/.gitignore b/.gitignore index 172d4ef..65d887b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /build /out CMakeUserPresets.json +CMakeCache.txt +CMakeFiles/ diff --git a/CMakeLists.txt b/CMakeLists.txt index e7d6744..0ef0c38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,9 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # cmake-format: on -cmake_minimum_required(VERSION 3.23) +set(CMAKE_SKIP_TEST_ALL_DEPENDENCY FALSE) + +cmake_minimum_required(VERSION 3.25...3.31) project( beman.inplace_vector @@ -13,6 +15,10 @@ project( LANGUAGES CXX ) +if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) + message(FATAL_ERROR "In-source builds are not allowed!") +endif() + # [CMAKE.SKIP_EXAMPLES] option( BEMAN_EXEMPLAR_BUILD_EXAMPLES @@ -27,38 +33,49 @@ option( ${PROJECT_IS_TOP_LEVEL} ) +set(CPACK_GENERATOR TGZ) + +# includes include(GNUInstallDirs) +include(CPack) add_library(beman.inplace_vector INTERFACE) # [CMAKE.LIBRARY_ALIAS] add_library(beman::inplace_vector ALIAS beman.inplace_vector) -target_include_directories( +target_sources( + beman.inplace_vector + PUBLIC + FILE_SET inplace_vector_public_headers + TYPE HEADERS + BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include + FILES + "${CMAKE_CURRENT_SOURCE_DIR}/include/beman/inplace_vector/inplace_vector.hpp" +) +set_target_properties( + beman.inplace_vector + PROPERTIES VERIFY_INTERFACE_HEADER_SETS ON +) +target_compile_features( beman.inplace_vector INTERFACE - $ - $ + "$<$:cxx_std_23>" + "$<$>:cxx_std_20>" ) +set(TARGET_PACKAGE_NAME ${PROJECT_NAME}-config) +set(TARGETS_EXPORT_NAME ${PROJECT_NAME}-targets) +set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) + # Install the InplaceVector library to the appropriate destination install( TARGETS beman.inplace_vector EXPORT ${TARGETS_EXPORT_NAME} - DESTINATION - ${CMAKE_INSTALL_LIBDIR} -) - -# Install the header files to the appropriate destination -install( - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME} - FILES_MATCHING - PATTERN - "${CMAKE_CURRENT_SOURCE_DIR}/include/beman/inplace_vector/inplace_vector.hpp" + FILE_SET inplace_vector_public_headers ) if(BEMAN_INPLACE_VECTOR_BUILD_TESTS) - include(CTest) + enable_testing() add_subdirectory(tests/beman/inplace_vector) endif() From d744137b2d9b1094049ec088f4c67bcca470af86 Mon Sep 17 00:00:00 2001 From: Claus Klein Date: Fri, 6 Dec 2024 07:26:48 +0100 Subject: [PATCH 2/3] Update CMakeLists.txt Co-authored-by: David Sankel --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ef0c38..5abdf88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,6 @@ option( set(CPACK_GENERATOR TGZ) -# includes include(GNUInstallDirs) include(CPack) From d462d55a1aaf3e11f085cc8ec9c617b630909e1e Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Fri, 6 Dec 2024 08:10:10 +0100 Subject: [PATCH 3/3] Rebased and minor fixes after review --- CMakeLists.txt | 7 +------ README.md | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5abdf88..367b769 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,12 +55,7 @@ set_target_properties( beman.inplace_vector PROPERTIES VERIFY_INTERFACE_HEADER_SETS ON ) -target_compile_features( - beman.inplace_vector - INTERFACE - "$<$:cxx_std_23>" - "$<$>:cxx_std_20>" -) +target_compile_features(beman.inplace_vector INTERFACE cxx_std_23) set(TARGET_PACKAGE_NAME ${PROJECT_NAME}-config) set(TARGETS_EXPORT_NAME ${PROJECT_NAME}-targets) diff --git a/README.md b/README.md index f1936fd..1ed79b6 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ TODO: tested platforms. ```text # Configure build -$ cmake -S . -B build -DCMAKE_CXX_STANDARD=20 +$ cmake -S . -B build -DCMAKE_CXX_STANDARD=23 -- The CXX compiler identification is GNU 11.4.0 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done