Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake Updates, main branch (2024.11.10.) #41

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
8 changes: 4 additions & 4 deletions benchmarks/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Comment on lines +9 to +15
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not on board with the benchmarks, tests, and examples being renamed; these should never be installed anyway, so there is no way for any name collisions to occur.

10 changes: 5 additions & 5 deletions benchmarks/cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep the original name on this.


# 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
)
10 changes: 5 additions & 5 deletions benchmarks/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And on this.


# 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
)
10 changes: 5 additions & 5 deletions benchmarks/openmp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions cmake/covfieConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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@)
Expand Down
4 changes: 0 additions & 4 deletions docs/user/integration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
4 changes: 2 additions & 2 deletions examples/common/bitmap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
46 changes: 23 additions & 23 deletions examples/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions examples/cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions examples/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 14 additions & 7 deletions lib/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

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)
Comment on lines +25 to +32
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to make this so complicated? Can't we just set install(... NAMESPACE something_)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't touch the code that specifies the NAMESPACE. The EXPORT_NAME needs to be specified, because without it, the exported library would now be called covfie::covfie_core.

This is exactly how the "trick" of using vecmem::core, detray::core, etc. is achieved, whether or not we're using the project directly, or we're finding an installed version of it. (With the "actual target names" being vecmem_core, detray_core, etc.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but this is what I am saying, just like Google Benchmark does it, the target should be named e.g. core and then the namespace should be added to it, so that the full name becomes covfie::core.


install(
DIRECTORY
Expand All @@ -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)
Expand All @@ -45,7 +52,7 @@ if(COVFIE_TEST_HEADERS)
)

covfie_test_public_headers(
core
covfie_core
"${public_headers}"
)
endif()
Loading
Loading