From 302868362c0e47982cbb88b7839c19604438026e Mon Sep 17 00:00:00 2001 From: Attila Krasznahorkay Date: Sun, 10 Nov 2024 08:27:26 +0100 Subject: [PATCH 1/2] Removed COVFIE_REQUIRE_CXX20. The C++20 standard is always required in the code since a while, the flag was not doing anything. --- .github/workflows/builds.yml | 1 - CMakeLists.txt | 6 ------ cmake/covfieConfig.cmake.in | 1 - docs/user/integration.rst | 4 ---- 4 files changed, 12 deletions(-) diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 7707ee8..26cbc76 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -58,7 +58,6 @@ jobs: run: cmake -DCMAKE_CXX_COMPILER=$(which ${{ matrix.COMPILER.CXX }}) -DCMAKE_BUILD_TYPE=${{ matrix.BUILD }} - -DCOVFIE_REQUIRE_CXX20=${{ matrix.CXX_STANDARD == 20 && 'On' || 'Off' }} -DCOVFIE_FAIL_ON_WARNINGS=TRUE -DCOVFIE_BUILD_TESTS=On -DCOVFIE_BUILD_EXAMPLES=On diff --git a/CMakeLists.txt b/CMakeLists.txt index 86bf97c..f0130a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,12 +26,6 @@ option(COVFIE_PLATFORM_CPU "Enable building of CPU code." On) option(COVFIE_PLATFORM_CUDA "Enable building of CUDA code.") # Additional options that may be useful in some cases, such as CI. -option( - COVFIE_REQUIRE_CXX20 - "Enforce the availability of C++20 features (especially concepts)." - Off -) - option( COVFIE_QUIET "Disable warnings about missing C++ features. Enabling this is strongly discouraged." diff --git a/cmake/covfieConfig.cmake.in b/cmake/covfieConfig.cmake.in index 1355467..71938ef 100644 --- a/cmake/covfieConfig.cmake.in +++ b/cmake/covfieConfig.cmake.in @@ -12,7 +12,6 @@ include(CMakeFindDependencyMacro) set(COVFIE_PLATFORM_CPU @COVFIE_PLATFORM_CPU@) set(COVFIE_PLATFORM_CUDA @COVFIE_PLATFORM_CUDA@) -set(COVFIE_REQUIRE_CXX20 @COVFIE_REQUIRE_CXX20@) set(COVFIE_QUIET @COVFIE_QUIET@) if(@COVFIE_PLATFORM_CUDA@) diff --git a/docs/user/integration.rst b/docs/user/integration.rst index 4867383..d8a8322 100644 --- a/docs/user/integration.rst +++ b/docs/user/integration.rst @@ -48,9 +48,5 @@ in which covfie was installed. Variables set are as follows: :code:`COVFIE_PLATFORM_CUDA` True iff the CUDA-specific headers were installed. -:code:`COVFIE_REQUIRE_CXX20` - True iff covfie was configured to reject compilers which do not support - C++20 concepts. - :code:`COVFIE_QUIET` Silences warnings about missing compiler features. From b40a9d36d6a9691350ad2d7ba881f4599fd4ed0f Mon Sep 17 00:00:00 2001 From: Attila Krasznahorkay Date: Sun, 10 Nov 2024 08:53:25 +0100 Subject: [PATCH 2/2] Put a covfie_ prefix on all libraries and executables. This is to ensure that common names like "core" and "cpu" would not clash with target names used in client projects. --- benchmarks/common/CMakeLists.txt | 8 ++--- benchmarks/cpu/CMakeLists.txt | 10 +++--- benchmarks/cuda/CMakeLists.txt | 10 +++--- benchmarks/openmp/CMakeLists.txt | 10 +++--- cmake/covfieConfig.cmake.in | 2 +- examples/common/bitmap/CMakeLists.txt | 4 +-- examples/core/CMakeLists.txt | 46 +++++++++++++-------------- examples/cpu/CMakeLists.txt | 20 ++++++------ examples/cuda/CMakeLists.txt | 20 ++++++------ lib/core/CMakeLists.txt | 21 ++++++++---- lib/cpu/CMakeLists.txt | 21 ++++++++---- lib/cuda/CMakeLists.txt | 21 ++++++++---- tests/core/CMakeLists.txt | 4 +-- tests/cpu/CMakeLists.txt | 4 +-- tests/cuda/CMakeLists.txt | 4 +-- tests/utils/CMakeLists.txt | 8 ++--- 16 files changed, 117 insertions(+), 96 deletions(-) diff --git a/benchmarks/common/CMakeLists.txt b/benchmarks/common/CMakeLists.txt index 8ce4c61..374083a 100644 --- a/benchmarks/common/CMakeLists.txt +++ b/benchmarks/common/CMakeLists.txt @@ -6,10 +6,10 @@ # v. 2.0. If a copy of the MPL was not distributed with this file, You can # obtain one at http://mozilla.org/MPL/2.0/. -add_library(benchmark test_field.cpp) +add_library(covfie_benchmark test_field.cpp) -target_include_directories(benchmark PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories(covfie_benchmark PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(benchmark PUBLIC core) +target_link_libraries(covfie_benchmark PUBLIC covfie::core) -target_compile_definitions(benchmark PRIVATE _CRT_SECURE_NO_WARNINGS) +target_compile_definitions(covfie_benchmark PRIVATE _CRT_SECURE_NO_WARNINGS) diff --git a/benchmarks/cpu/CMakeLists.txt b/benchmarks/cpu/CMakeLists.txt index 482a4c3..f8e8f4e 100644 --- a/benchmarks/cpu/CMakeLists.txt +++ b/benchmarks/cpu/CMakeLists.txt @@ -7,15 +7,15 @@ # obtain one at http://mozilla.org/MPL/2.0/. # Create the benchmark executable from the individual files. -add_executable(benchmark_cpu benchmark_cpu.cpp) +add_executable(covfie_benchmark_cpu benchmark_cpu.cpp) # Ensure that the tests are linked against the required libraries. target_link_libraries( - benchmark_cpu + covfie_benchmark_cpu PUBLIC - core - cpu - benchmark + covfie::core + covfie::cpu + covfie_benchmark benchmark::benchmark Boost::headers ) diff --git a/benchmarks/cuda/CMakeLists.txt b/benchmarks/cuda/CMakeLists.txt index 313e2ae..be72928 100644 --- a/benchmarks/cuda/CMakeLists.txt +++ b/benchmarks/cuda/CMakeLists.txt @@ -12,15 +12,15 @@ enable_language(CUDA) include(covfie-compiler-options-cuda) # Create the benchmark executable from the individual files. -add_executable(benchmark_cuda benchmark_cuda.cu) +add_executable(covfie_benchmark_cuda benchmark_cuda.cu) # Ensure that the tests are linked against the required libraries. target_link_libraries( - benchmark_cuda + covfie_benchmark_cuda PUBLIC - core - cuda - benchmark + covfie::core + covfie::cuda + covfie_benchmark benchmark::benchmark Boost::headers ) diff --git a/benchmarks/openmp/CMakeLists.txt b/benchmarks/openmp/CMakeLists.txt index 215be12..082e94f 100644 --- a/benchmarks/openmp/CMakeLists.txt +++ b/benchmarks/openmp/CMakeLists.txt @@ -10,15 +10,15 @@ find_package(OpenMP COMPONENTS CXX REQUIRED) # Create the benchmark executable from the individual files. -add_executable(benchmark_openmp benchmark_openmp.cpp) +add_executable(covfie_benchmark_openmp benchmark_openmp.cpp) # Ensure that the tests are linked against the required libraries. target_link_libraries( - benchmark_openmp + covfie_benchmark_openmp PUBLIC - core - cpu - benchmark + covfie::core + covfie::cpu + covfie_benchmark OpenMP::OpenMP_CXX benchmark::benchmark Boost::headers diff --git a/cmake/covfieConfig.cmake.in b/cmake/covfieConfig.cmake.in index 71938ef..bd47f6d 100644 --- a/cmake/covfieConfig.cmake.in +++ b/cmake/covfieConfig.cmake.in @@ -1,6 +1,6 @@ # This file is part of covfie, a part of the ACTS project # -# Copyright (c) 2022-2024 CERN +# Copyright (c) 2022 CERN # # This Source Code Form is subject to the terms of the Mozilla Public License, # v. 2.0. If a copy of the MPL was not distributed with this file, You can diff --git a/examples/common/bitmap/CMakeLists.txt b/examples/common/bitmap/CMakeLists.txt index f7dc0b7..5413d35 100644 --- a/examples/common/bitmap/CMakeLists.txt +++ b/examples/common/bitmap/CMakeLists.txt @@ -6,6 +6,6 @@ # v. 2.0. If a copy of the MPL was not distributed with this file, You can # obtain one at http://mozilla.org/MPL/2.0/. -add_library(bitmap bitmap.cpp) +add_library(covfie_bitmap bitmap.cpp) -target_include_directories(bitmap PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories(covfie_bitmap PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/examples/core/CMakeLists.txt b/examples/core/CMakeLists.txt index 03520b1..6461774 100644 --- a/examples/core/CMakeLists.txt +++ b/examples/core/CMakeLists.txt @@ -7,77 +7,77 @@ # obtain one at http://mozilla.org/MPL/2.0/. # Add the conversion of B-fields to our native format. -add_executable(convert_bfield convert_bfield.cpp) +add_executable(covfie_convert_bfield convert_bfield.cpp) target_link_libraries( - convert_bfield + covfie_convert_bfield PRIVATE - core + covfie::core Boost::log Boost::log_setup Boost::program_options ) # Add the conversion of B-fields from CSV to our native format. -add_executable(convert_bfield_csv convert_bfield_csv.cpp) +add_executable(covfie_convert_bfield_csv convert_bfield_csv.cpp) target_link_libraries( - convert_bfield_csv + covfie_convert_bfield_csv PRIVATE - core + covfie::core Boost::log Boost::log_setup Boost::program_options ) # Add the first example that can be found in the README. -add_executable(readme_example_1 readme_example_1.cpp) +add_executable(covfie_readme_example_1 readme_example_1.cpp) -target_link_libraries(readme_example_1 PRIVATE core) +target_link_libraries(covfie_readme_example_1 PRIVATE covfie::core) # Add the second example that can be found in the README. -add_executable(readme_example_2 readme_example_2.cpp) +add_executable(covfie_readme_example_2 readme_example_2.cpp) -target_link_libraries(readme_example_2 PRIVATE core) +target_link_libraries(covfie_readme_example_2 PRIVATE covfie::core) # Add the an executable to create 2D slices from 3D fields. -add_executable(slice3dto2d slice3dto2d.cpp) +add_executable(covfie_slice3dto2d slice3dto2d.cpp) target_link_libraries( - slice3dto2d + covfie_slice3dto2d PRIVATE - core + covfie::core Boost::log Boost::log_setup Boost::program_options ) # Add the an executable to scale up B-fields. -add_executable(scaleup_bfield scaleup_bfield.cpp) +add_executable(covfie_scaleup_bfield scaleup_bfield.cpp) target_link_libraries( - scaleup_bfield + covfie_scaleup_bfield PRIVATE - core + covfie::core Boost::log Boost::log_setup Boost::program_options ) -add_library(asm asm.cpp) -target_link_libraries(asm PRIVATE core) +add_library(covfie_asm asm.cpp) +target_link_libraries(covfie_asm PRIVATE covfie::core) # Some libraries which are designed to inspected by the user. -add_library(shuffle_asm shuffle_asm.cpp) -target_link_libraries(shuffle_asm PRIVATE core) +add_library(covfie_shuffle_asm shuffle_asm.cpp) +target_link_libraries(covfie_shuffle_asm PRIVATE covfie::core) # Executable for generating an testable field. -add_executable(generate_test_field generate_test_field.cpp) +add_executable(covfie_generate_test_field generate_test_field.cpp) target_link_libraries( - generate_test_field + covfie_generate_test_field PRIVATE - core + covfie::core Boost::log Boost::log_setup Boost::program_options diff --git a/examples/cpu/CMakeLists.txt b/examples/cpu/CMakeLists.txt index a51a1fc..b9fc046 100644 --- a/examples/cpu/CMakeLists.txt +++ b/examples/cpu/CMakeLists.txt @@ -7,27 +7,27 @@ # obtain one at http://mozilla.org/MPL/2.0/. # Add the 3D field slice rendering tool. -add_executable(render_slice_cpu render_slice.cpp) +add_executable(covfie_render_slice_cpu render_slice.cpp) target_link_libraries( - render_slice_cpu + covfie_render_slice_cpu PRIVATE - core - cpu - bitmap + covfie::core + covfie::cpu + covfie_bitmap Boost::log Boost::log_setup Boost::program_options ) -add_executable(render_image_cpu render_image.cpp) +add_executable(covfie_render_image_cpu render_image.cpp) target_link_libraries( - render_image_cpu + covfie_render_image_cpu PRIVATE - core - cpu - bitmap + covfie::core + covfie::cpu + covfie_bitmap Boost::log Boost::log_setup Boost::program_options diff --git a/examples/cuda/CMakeLists.txt b/examples/cuda/CMakeLists.txt index 138636d..a2693bf 100644 --- a/examples/cuda/CMakeLists.txt +++ b/examples/cuda/CMakeLists.txt @@ -14,28 +14,28 @@ enable_language(CUDA) include(covfie-compiler-options-cuda) # Add the 3D field slice rendering tool based on CUDA. -add_executable(render_slice_cuda render_slice.cu) +add_executable(covfie_render_slice_cuda render_slice.cu) target_link_libraries( - render_slice_cuda + covfie_render_slice_cuda PRIVATE - core - cuda - bitmap + covfie::core + covfie::cuda + covfie_bitmap Boost::log Boost::log_setup Boost::program_options ) # Add the 3D field slice rendering tool based on CUDA textures. -add_executable(render_slice_texture_cuda render_slice_texture.cu) +add_executable(covfie_render_slice_texture_cuda render_slice_texture.cu) target_link_libraries( - render_slice_texture_cuda + covfie_render_slice_texture_cuda PRIVATE - core - cuda - bitmap + covfie::core + covfie::cuda + covfie_bitmap Boost::log Boost::log_setup Boost::program_options diff --git a/lib/core/CMakeLists.txt b/lib/core/CMakeLists.txt index a8077d6..e750280 100644 --- a/lib/core/CMakeLists.txt +++ b/lib/core/CMakeLists.txt @@ -6,23 +6,30 @@ # v. 2.0. If a copy of the MPL was not distributed with this file, You can # obtain one at http://mozilla.org/MPL/2.0/. -add_library(core INTERFACE) +add_library(covfie_core INTERFACE) target_include_directories( - core + covfie_core INTERFACE $ $ ) -target_compile_features(core INTERFACE cxx_std_20) +target_compile_features(covfie_core INTERFACE cxx_std_20) if(COVFIE_QUIET) - target_compile_definitions(core INTERFACE COVFIE_QUIET) + target_compile_definitions(covfie_core INTERFACE COVFIE_QUIET) endif() # Logic to ensure that the core module can be installed properly. -install(TARGETS core EXPORT ${PROJECT_NAME}Targets) +set_target_properties( + covfie_core + PROPERTIES + EXPORT_NAME + core +) + +install(TARGETS covfie_core EXPORT ${PROJECT_NAME}Targets) install( DIRECTORY @@ -32,7 +39,7 @@ install( # Hack for people using the disgusting mal-practice of pullling in external # projects via "add_subdirectory"... -add_library(covfie::core ALIAS core) +add_library(covfie::core ALIAS covfie_core) # Test the public headers of covfie::core. if(COVFIE_TEST_HEADERS) @@ -45,7 +52,7 @@ if(COVFIE_TEST_HEADERS) ) covfie_test_public_headers( - core + covfie_core "${public_headers}" ) endif() diff --git a/lib/cpu/CMakeLists.txt b/lib/cpu/CMakeLists.txt index 37635ba..2e445b9 100644 --- a/lib/cpu/CMakeLists.txt +++ b/lib/cpu/CMakeLists.txt @@ -6,19 +6,26 @@ # v. 2.0. If a copy of the MPL was not distributed with this file, You can # obtain one at http://mozilla.org/MPL/2.0/. -add_library(cpu INTERFACE) +add_library(covfie_cpu INTERFACE) target_include_directories( - cpu + covfie_cpu INTERFACE $ $ ) -target_compile_features(cpu INTERFACE cxx_std_20) +target_compile_features(covfie_cpu INTERFACE cxx_std_20) # Logic to ensure that the CPU module can be installed properly. -install(TARGETS cpu EXPORT ${PROJECT_NAME}Targets) +set_target_properties( + covfie_cpu + PROPERTIES + EXPORT_NAME + cpu +) + +install(TARGETS covfie_cpu EXPORT ${PROJECT_NAME}Targets) install( DIRECTORY @@ -26,10 +33,10 @@ install( DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) -target_link_libraries(cpu INTERFACE covfie::core) +target_link_libraries(covfie_cpu INTERFACE covfie::core) # Hack for compatibility -add_library(covfie::cpu ALIAS cpu) +add_library(covfie::cpu ALIAS covfie_cpu) # Test the public headers of covfie::cpu. if(COVFIE_TEST_HEADERS) @@ -42,7 +49,7 @@ if(COVFIE_TEST_HEADERS) ) covfie_test_public_headers( - cpu + covfie_cpu "${public_headers}" ) endif() diff --git a/lib/cuda/CMakeLists.txt b/lib/cuda/CMakeLists.txt index 0102241..c5fd54e 100644 --- a/lib/cuda/CMakeLists.txt +++ b/lib/cuda/CMakeLists.txt @@ -8,26 +8,33 @@ find_package(CUDAToolkit REQUIRED) -add_library(cuda INTERFACE) +add_library(covfie_cuda INTERFACE) target_include_directories( - cuda + covfie_cuda INTERFACE $ $ ) -target_compile_features(cuda INTERFACE cxx_std_20) +target_compile_features(covfie_cuda INTERFACE cxx_std_20) target_link_libraries( - cuda + covfie_cuda INTERFACE CUDA::cudart covfie::core ) # Logic to ensure that the CUDA module can be installed properly. -install(TARGETS cuda EXPORT ${PROJECT_NAME}Targets) +set_target_properties( + covfie_cuda + PROPERTIES + EXPORT_NAME + cuda +) + +install(TARGETS covfie_cuda EXPORT ${PROJECT_NAME}Targets) install( DIRECTORY @@ -36,7 +43,7 @@ install( ) # Hack for compatibility -add_library(covfie::cuda ALIAS cuda) +add_library(covfie::cuda ALIAS covfie_cuda) # Test the public headers of covfie::cuda. if(COVFIE_TEST_HEADERS) @@ -49,7 +56,7 @@ if(COVFIE_TEST_HEADERS) ) covfie_test_public_headers( - cuda + covfie_cuda "${public_headers}" ) endif() diff --git a/tests/core/CMakeLists.txt b/tests/core/CMakeLists.txt index bb4b07b..a8e4cf9 100644 --- a/tests/core/CMakeLists.txt +++ b/tests/core/CMakeLists.txt @@ -35,9 +35,9 @@ add_executable( target_link_libraries( test_core PUBLIC - core + covfie::core GTest::gtest GTest::gtest_main Boost::filesystem - testing_utils + covfie_testing_utils ) diff --git a/tests/cpu/CMakeLists.txt b/tests/cpu/CMakeLists.txt index 1800c40..56bc689 100644 --- a/tests/cpu/CMakeLists.txt +++ b/tests/cpu/CMakeLists.txt @@ -13,8 +13,8 @@ add_executable(test_cpu test_cpu_array_backend.cpp) target_link_libraries( test_cpu PUBLIC - core - cpu + covfie::core + covfie::cpu GTest::gtest GTest::gtest_main ) diff --git a/tests/cuda/CMakeLists.txt b/tests/cuda/CMakeLists.txt index 8df0546..8f10a6d 100644 --- a/tests/cuda/CMakeLists.txt +++ b/tests/cuda/CMakeLists.txt @@ -19,8 +19,8 @@ add_executable(test_cuda test_cuda_array.cu) target_link_libraries( test_cuda PUBLIC - core - cuda + covfie::core + covfie::cuda GTest::gtest GTest::gtest_main ) diff --git a/tests/utils/CMakeLists.txt b/tests/utils/CMakeLists.txt index d0b0151..d8c199f 100644 --- a/tests/utils/CMakeLists.txt +++ b/tests/utils/CMakeLists.txt @@ -8,15 +8,15 @@ find_package(Boost 1.71.0 REQUIRED COMPONENTS filesystem) -add_library(testing_utils tmp_file.cpp) +add_library(covfie_testing_utils tmp_file.cpp) # Ensure that the utils. -target_link_libraries(testing_utils PUBLIC Boost::filesystem) +target_link_libraries(covfie_testing_utils PUBLIC Boost::filesystem) target_include_directories( - testing_utils + covfie_testing_utils PUBLIC $ ) -target_compile_definitions(testing_utils PRIVATE _CRT_SECURE_NO_WARNINGS) +target_compile_definitions(covfie_testing_utils PRIVATE _CRT_SECURE_NO_WARNINGS)