Skip to content

Commit 01dba8c

Browse files
authored
CMake Updates, main branch (2024.04.12.) (acts-project#715)
* Introduced DETRAY_FAIL_ON_WARNINGS. Instead of only using -Werror in debug builds, made its use configurable through this flag. At the same time simplified the SYCL build flag configuration a bit (which current VecMem versions now allow us to do), and made the CUDA flag configuration just a little more robust. * Introduced CMake presets for the project. At the same time updated "some of" the CI configurations to make use of them.
1 parent 74c590c commit 01dba8c

8 files changed

Lines changed: 116 additions & 51 deletions

.github/workflows/builds.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ jobs:
3737
- uses: actions/checkout@v2
3838
# Run the CMake configuration.
3939
- name: Configure
40-
run: cmake -DCMAKE_BUILD_TYPE=${{ matrix.BUILD_TYPE }}
41-
-DDETRAY_EIGEN_PLUGIN=ON
42-
-DDETRAY_VC_PLUGIN=ON
43-
-DDETRAY_BUILD_CUDA=FALSE
40+
run: cmake --preset default-fp64
41+
-DCMAKE_BUILD_TYPE=${{ matrix.BUILD_TYPE }}
42+
-DDETRAY_FAIL_ON_WARNINGS=ON
4443
-S ${{ github.workspace }} -B build
4544
-G "${{ matrix.PLATFORM.GENERATOR }}"
4645
# Perform the build.
@@ -86,7 +85,7 @@ jobs:
8685
- name: Configure
8786
run: |
8887
source ${GITHUB_WORKSPACE}/.github/ci_setup.sh ${{ matrix.PLATFORM.NAME }}
89-
cmake -DCMAKE_BUILD_TYPE=${{ matrix.BUILD_TYPE }} -DDETRAY_CUSTOM_SCALARTYPE=${{ matrix.SCALAR_TYPE }} ${{ matrix.PLATFORM.OPTIONS }} -S ${GITHUB_WORKSPACE} -B build
88+
cmake -DDETRAY_FAIL_ON_WARNINGS=ON -DCMAKE_BUILD_TYPE=${{ matrix.BUILD_TYPE }} -DDETRAY_CUSTOM_SCALARTYPE=${{ matrix.SCALAR_TYPE }} ${{ matrix.PLATFORM.OPTIONS }} -S ${GITHUB_WORKSPACE} -B build
9089
# Perform the build.
9190
- name: Build
9291
run: |
@@ -139,7 +138,7 @@ jobs:
139138
- name: Configure
140139
run: |
141140
source ${GITHUB_WORKSPACE}/.github/ci_setup.sh ${{ matrix.PLATFORM.NAME }}
142-
cmake -DCMAKE_BUILD_TYPE=${{ matrix.BUILD_TYPE }} -DDETRAY_CUSTOM_SCALARTYPE=${{ matrix.SCALAR_TYPE }} ${{ matrix.PLATFORM.OPTIONS }} -S ${GITHUB_WORKSPACE} -B build
141+
cmake -DDETRAY_FAIL_ON_WARNINGS=ON -DCMAKE_BUILD_TYPE=${{ matrix.BUILD_TYPE }} -DDETRAY_CUSTOM_SCALARTYPE=${{ matrix.SCALAR_TYPE }} ${{ matrix.PLATFORM.OPTIONS }} -S ${GITHUB_WORKSPACE} -B build
143142
# Perform the build.
144143
- name: Build
145144
run: |

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/bin
88
/build
99
/run
10+
/out
1011

1112
# python files
1213
**/__pycache__
@@ -16,4 +17,4 @@
1617
**/*.so
1718
**/*C_ACLiC*
1819
**/thread_*
19-
**/merged/
20+
**/merged/

.gitlab-ci.yml

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Detray library, part of the ACTS project (R&D line)
2+
#
3+
# (c) 2021-2024 CERN for the benefit of the ACTS project
4+
#
5+
# Mozilla Public License Version 2.0
6+
17
stages:
28
- build
39
- test
@@ -14,15 +20,11 @@ build_cuda:
1420
- git clone $CLONE_URL src
1521
- git -C src checkout $HEAD_SHA
1622
- >
17-
cmake -S src -B build
23+
cmake --preset cuda -S src -B build
1824
-DCMAKE_BUILD_TYPE=Release
19-
-DDETRAY_CUSTOM_SCALARTYPE=float
2025
-DBUILD_TESTING=ON
2126
-DDETRAY_BUILD_TESTING=ON
22-
-DDETRAY_BUILD_CUDA=ON
23-
-DDETRAY_VC_PLUGIN=OFF
24-
-DDETRAY_SMATRIX_PLUGIN=OFF
25-
-DDETRAY_EIGEN_PLUGIN=ON
27+
-DDETRAY_FAIL_ON_WARNINGS=ON
2628
- cmake --build build
2729

2830

@@ -57,16 +59,11 @@ build_sycl:
5759
- git -C src checkout $HEAD_SHA
5860
- source src/.github/ci_setup.sh SYCL
5961
- >
60-
cmake -S src -B build
62+
cmake --preset sycl -S src -B build
6163
-DCMAKE_BUILD_TYPE=Release
62-
-DDETRAY_CUSTOM_SCALARTYPE=float
63-
-DDETRAY_BUILD_CUDA=OFF
64-
-DDETRAY_BUILD_SYCL=ON
65-
-DBUILD_TESTING=ON
64+
-DBUILD_TESTING=ON
6665
-DDETRAY_BUILD_TESTING=ON
67-
-DDETRAY_VC_PLUGIN=OFF
68-
-DDETRAY_SMATRIX_PLUGIN=OFF
69-
-DDETRAY_EIGEN_PLUGIN=ON
66+
-DDETRAY_FAIL_ON_WARNINGS=ON
7067
- cmake --build build
7168

7269

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Detray library, part of the ACTS project (R&D line)
22
#
3-
# (c) 2021-2023 CERN for the benefit of the ACTS project
3+
# (c) 2021-2024 CERN for the benefit of the ACTS project
44
#
55
# Mozilla Public License Version 2.0
66

@@ -62,6 +62,8 @@ cmake_dependent_option( DETRAY_BENCHMARKS "Enable benchmark tests" TRUE
6262
"DETRAY_BUILD_TESTING" OFF )
6363
option( DETRAY_BUILD_TUTORIALS "Build the tutorial executables of Detray"
6464
ON )
65+
option( DETRAY_FAIL_ON_WARNINGS
66+
"Make the build fail on compiler/linker warnings" FALSE )
6567

6668
# Clean up.
6769
unset( DETRAY_BUILD_CUDA_DEFAULT )

CMakePresets.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"version" : 3,
3+
"configurePresets": [
4+
{
5+
"name" : "base",
6+
"displayName" : "Base Developer Configuration",
7+
"warnings": {
8+
"deprecated": true
9+
},
10+
"cacheVariables": {
11+
"CMAKE_BUILD_TYPE" : "RelWithDebInfo"
12+
}
13+
},
14+
{
15+
"name" : "default-fp64",
16+
"displayName" : "FP64 Developer Configuration",
17+
"inherits" : [ "base" ],
18+
"cacheVariables" : {
19+
"DETRAY_CUSTOM_SCALARTYPE" : "double"
20+
}
21+
},
22+
{
23+
"name" : "default-fp32",
24+
"displayName" : "FP32 Developer Configuration",
25+
"inherits" : [ "base" ],
26+
"cacheVariables" : {
27+
"DETRAY_CUSTOM_SCALARTYPE" : "float"
28+
}
29+
},
30+
{
31+
"name" : "cuda",
32+
"displayName" : "CUDA Developer Configuration",
33+
"inherits" : [ "default-fp32" ],
34+
"cacheVariables" : {
35+
"DETRAY_BUILD_CUDA" : "TRUE",
36+
"DETRAY_VC_PLUGIN" : "FALSE",
37+
"DETRAY_SMATRIX_PLUGIN" : "FALSE"
38+
}
39+
},
40+
{
41+
"name" : "sycl",
42+
"displayName" : "SYCL Developer Configuration",
43+
"inherits" : [ "default-fp32" ],
44+
"cacheVariables" : {
45+
"DETRAY_BUILD_SYCL" : "TRUE",
46+
"DETRAY_VC_PLUGIN" : "FALSE",
47+
"DETRAY_SMATRIX_PLUGIN" : "FALSE"
48+
}
49+
},
50+
{
51+
"name" : "smatrix",
52+
"displayName" : "SMatrix Developer Configuration",
53+
"inherits" : [ "default-fp64" ],
54+
"cacheVariables" : {
55+
"DETRAY_SMATRIX_PLUGIN" : "TRUE"
56+
}
57+
}
58+
]
59+
}

cmake/detray-compiler-options-cpp.cmake

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Detray library, part of the ACTS project (R&D line)
22
#
3-
# (c) 2021-2023 CERN for the benefit of the ACTS project
3+
# (c) 2021-2024 CERN for the benefit of the ACTS project
44
#
55
# Mozilla Public License Version 2.0
66

@@ -30,19 +30,23 @@ if(("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR
3030
detray_add_flag(CMAKE_CXX_FLAGS "-Wextra")
3131
detray_add_flag(CMAKE_CXX_FLAGS "-Wshadow")
3232
detray_add_flag(CMAKE_CXX_FLAGS "-Wunused-local-typedefs")
33-
34-
# More rigorous tests for the Debug builds.
35-
detray_add_flag(CMAKE_CXX_FLAGS_DEBUG "-Werror")
36-
detray_add_flag(CMAKE_CXX_FLAGS_DEBUG "-pedantic")
33+
detray_add_flag(CMAKE_CXX_FLAGS "-pedantic")
3734
# No implicit single to double conversions from floating point literals
38-
detray_add_flag(CMAKE_CXX_FLAGS_DEBUG "-Wconversion")
35+
detray_add_flag(CMAKE_CXX_FLAGS "-Wconversion")
36+
37+
# Fail on warnings, if asked for that behaviour.
38+
if(DETRAY_FAIL_ON_WARNINGS)
39+
detray_add_flag(CMAKE_CXX_FLAGS "-Werror")
40+
endif()
3941

4042
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
4143
# Basic flags for all build modes.
4244
string(REGEX REPLACE "/W[0-9]" "" CMAKE_CXX_FLAGS
4345
"${CMAKE_CXX_FLAGS}")
4446
detray_add_flag(CMAKE_CXX_FLAGS "/W4")
4547

46-
# More rigorous tests for the Debug builds.
47-
detray_add_flag(CMAKE_CXX_FLAGS_DEBUG "/WX")
48+
# Fail on warnings, if asked for that behaviour.
49+
if(DETRAY_FAIL_ON_WARNINGS)
50+
detray_add_flag(CMAKE_CXX_FLAGS "/WX")
51+
endif()
4852
endif()

cmake/detray-compiler-options-cuda.cmake

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Detray library, part of the ACTS project (R&D line)
22
#
3-
# (c) 2021-2022 CERN for the benefit of the ACTS project
3+
# (c) 2021-2024 CERN for the benefit of the ACTS project
44
#
55
# Mozilla Public License Version 2.0
66

@@ -35,7 +35,12 @@ endif()
3535
# build.
3636
detray_add_flag( CMAKE_CUDA_FLAGS_DEBUG "-G" )
3737

38-
# More rigorous tests for the Debug builds.
39-
if( "${CUDAToolkit_VERSION}" VERSION_GREATER_EQUAL "10.2" )
40-
detray_add_flag( CMAKE_CUDA_FLAGS_DEBUG "-Werror all-warnings" )
38+
# Fail on warnings, if asked for that behaviour.
39+
if( DETRAY_FAIL_ON_WARNINGS )
40+
if( ( "${CUDAToolkit_VERSION}" VERSION_GREATER_EQUAL "10.2" ) AND
41+
( "${CMAKE_CUDA_COMPILER_ID}" MATCHES "NVIDIA" ) )
42+
detray_add_flag( CMAKE_CUDA_FLAGS "-Werror all-warnings" )
43+
elseif( "${CMAKE_CUDA_COMPILER_ID}" MATCHES "Clang" )
44+
detray_add_flag( CMAKE_CUDA_FLAGS "-Werror" )
45+
endif()
4146
endif()
Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
11
# TRACCC library, part of the ACTS project (R&D line)
22
#
3-
# (c) 2023 CERN for the benefit of the ACTS project
3+
# (c) 2023-2024 CERN for the benefit of the ACTS project
44
#
55
# Mozilla Public License Version 2.0
66

77
# Include the helper function(s).
88
include( detray-functions )
99

1010
# Basic flags for all build modes.
11-
foreach( mode RELEASE RELWITHDEBINFO MINSIZEREL DEBUG )
12-
detray_add_flag( CMAKE_SYCL_FLAGS_${mode} "-Wall" )
13-
detray_add_flag( CMAKE_SYCL_FLAGS_${mode} "-Wextra" )
14-
detray_add_flag( CMAKE_SYCL_FLAGS_${mode} "-Wno-unknown-cuda-version" )
15-
detray_add_flag( CMAKE_SYCL_FLAGS_${mode} "-Wshadow" )
16-
detray_add_flag( CMAKE_SYCL_FLAGS_${mode} "-Wunused-local-typedefs" )
17-
endforeach()
18-
19-
# More rigorous tests for the Debug builds.
20-
detray_add_flag( CMAKE_SYCL_FLAGS_DEBUG "-Werror" )
11+
detray_add_flag( CMAKE_SYCL_FLAGS "-Wall" )
12+
detray_add_flag( CMAKE_SYCL_FLAGS "-Wextra" )
13+
detray_add_flag( CMAKE_SYCL_FLAGS "-Wno-unknown-cuda-version" )
14+
detray_add_flag( CMAKE_SYCL_FLAGS "-Wshadow" )
15+
detray_add_flag( CMAKE_SYCL_FLAGS "-Wunused-local-typedefs" )
2116
if( NOT WIN32 )
22-
detray_add_flag( CMAKE_SYCL_FLAGS_DEBUG "-pedantic" )
17+
detray_add_flag( CMAKE_SYCL_FLAGS "-pedantic" )
2318
endif()
2419

2520
# Avoid issues coming from MSVC<->DPC++ argument differences.
2621
if( "${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC" )
27-
foreach( mode RELEASE RELWITHDEBINFO MINSIZEREL DEBUG )
28-
detray_add_flag( CMAKE_SYCL_FLAGS_${mode}
29-
"-Wno-unused-command-line-argument" )
30-
endforeach()
31-
endif()
22+
detray_add_flag( CMAKE_SYCL_FLAGS
23+
"-Wno-unused-command-line-argument" )
24+
endif()
25+
26+
# Fail on warnings, if asked for that behaviour.
27+
if( DETRAY_FAIL_ON_WARNINGS )
28+
detray_add_flag( CMAKE_SYCL_FLAGS "-Werror" )
29+
endif()

0 commit comments

Comments
 (0)