Skip to content

Commit

Permalink
Merge pull request #101 from krasznaa/CMakeUpdates-main-20230329
Browse files Browse the repository at this point in the history
CMake Updates, main branch (2023.03.29.)
  • Loading branch information
krasznaa authored Mar 30, 2023
2 parents e50c1de + d0f7963 commit de546e3
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 22 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ jobs:
-DALGEBRA_PLUGINS_INCLUDE_FASTOR=TRUE
-DALGEBRA_PLUGINS_SETUP_FASTOR=TRUE
-DALGEBRA_PLUGINS_USE_SYSTEM_FASTOR=FALSE
-DALGEBRA_PLUGINS_BUILD_BENCHMARKS=TRUE
-DALGEBRA_PLUGINS_FAIL_ON_WARNINGS=TRUE
-S ${{ github.workspace }} -B build
-G "${{ matrix.PLATFORM.GENERATOR }}"
# Perform the build.
Expand Down Expand Up @@ -111,7 +113,7 @@ jobs:
- name: Configure
run: |
source ${GITHUB_WORKSPACE}/.github/ci_setup.sh ${{ matrix.PLATFORM.NAME }}
cmake -DCMAKE_BUILD_TYPE=${{ matrix.BUILD_TYPE }} ${{ matrix.PLATFORM.OPTIONS }} -DALGEBRA_PLUGINS_BUILD_BENCHMARKS=TRUE -S ${GITHUB_WORKSPACE} -B build
cmake -DCMAKE_BUILD_TYPE=${{ matrix.BUILD_TYPE }} ${{ matrix.PLATFORM.OPTIONS }} -DALGEBRA_PLUGINS_BUILD_BENCHMARKS=TRUE -DALGEBRA_PLUGINS_FAIL_ON_WARNINGS=TRUE -S ${GITHUB_WORKSPACE} -B build
# Perform the build.
- name: Build
run: |
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ option( ALGEBRA_PLUGINS_BUILD_TESTING "Build the unit tests of Algebra Plugins"
TRUE )
option( ALGEBRA_PLUGINS_BUILD_BENCHMARKS "Build the benchmark suite of Algebra Plugins"
FALSE )
option( ALGEBRA_PLUGINS_FAIL_ON_WARNINGS
"Make the build fail on compiler/linker warnings" FALSE )

# Include the Algebra Plugins CMake code.
list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" )
Expand Down
25 changes: 13 additions & 12 deletions cmake/algebra-plugins-compiler-options-cpp.cmake
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
# Algebra plugins library, part of the ACTS project (R&D line)
#
# (c) 2021-2022 CERN for the benefit of the ACTS project
# (c) 2021-2023 CERN for the benefit of the ACTS project
#
# Mozilla Public License Version 2.0

# Include the helper function(s).
include( algebra-plugins-functions )

# Turn on the correct setting for the __cplusplus macro with MSVC.
if( "${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC" )
algebra_add_flag( CMAKE_CXX_FLAGS "/Zc:__cplusplus" )
algebra_add_flag( CMAKE_CUDA_FLAGS "-Xcompiler /Zc:__cplusplus" )
endif()

# Turn on a number of warnings for the "known compilers".
if( ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" ) OR
( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" ) )
Expand All @@ -22,10 +16,12 @@ if( ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" ) OR
algebra_add_flag( CMAKE_CXX_FLAGS "-Wextra" )
algebra_add_flag( CMAKE_CXX_FLAGS "-Wshadow" )
algebra_add_flag( CMAKE_CXX_FLAGS "-Wunused-local-typedefs" )
algebra_add_flag( CMAKE_CXX_FLAGS "-pedantic" )

# More rigorous tests for the Debug builds.
algebra_add_flag( CMAKE_CXX_FLAGS_DEBUG "-Werror" )
algebra_add_flag( CMAKE_CXX_FLAGS_DEBUG "-pedantic" )
# Fail on warnings, if asked for that behaviour.
if( ALGEBRA_PLUGINS_FAIL_ON_WARNINGS )
algebra_add_flag( CMAKE_CXX_FLAGS "-Werror" )
endif()

elseif( "${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC" )

Expand All @@ -34,7 +30,12 @@ elseif( "${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC" )
"${CMAKE_CXX_FLAGS}" )
algebra_add_flag( CMAKE_CXX_FLAGS "/W4" )

# More rigorous tests for the Debug builds.
algebra_add_flag( CMAKE_CXX_FLAGS_DEBUG "/WX" )
# Fail on warnings, if asked for that behaviour.
if( ALGEBRA_PLUGINS_FAIL_ON_WARNINGS )
algebra_add_flag( CMAKE_CXX_FLAGS "/WX" )
endif()

# Turn on the correct setting for the __cplusplus macro with MSVC.
algebra_add_flag( CMAKE_CXX_FLAGS "/Zc:__cplusplus" )

endif()
22 changes: 17 additions & 5 deletions cmake/algebra-plugins-compiler-options-cuda.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Algebra plugins library, part of the ACTS project (R&D line)
#
# (c) 2021-2022 CERN for the benefit of the ACTS project
# (c) 2021-2023 CERN for the benefit of the ACTS project
#
# Mozilla Public License Version 2.0

Expand All @@ -17,11 +17,23 @@ find_package( CUDAToolkit REQUIRED )
set( CMAKE_CUDA_ARCHITECTURES "52" CACHE STRING
"CUDA architectures to build device code for" )

# Turn on the correct setting for the __cplusplus macro with MSVC.
if( "${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC" )
algebra_add_flag( CMAKE_CUDA_FLAGS "-Xcompiler /Zc:__cplusplus" )
endif()

# Make CUDA generate debug symbols for the device code as well in a debug
# build.
algebra_add_flag( CMAKE_CUDA_FLAGS_DEBUG "-G" )
if( "${CMAKE_CUDA_COMPILER_ID}" MATCHES "NVIDIA" )
algebra_add_flag( CMAKE_CUDA_FLAGS_DEBUG "-G" )
endif()

# More rigorous tests for the Debug builds.
if( "${CUDAToolkit_VERSION}" VERSION_GREATER_EQUAL "10.2" )
algebra_add_flag( CMAKE_CUDA_FLAGS_DEBUG "-Werror all-warnings" )
# Fail on warnings, if asked for that behaviour.
if( ALGEBRA_PLUGINS_FAIL_ON_WARNINGS )
if( ( "${CUDAToolkit_VERSION}" VERSION_GREATER_EQUAL "10.2" ) AND
( "${CMAKE_CUDA_COMPILER_ID}" MATCHES "NVIDIA" ) )
algebra_add_flag( CMAKE_CUDA_FLAGS "-Werror all-warnings" )
elseif( "${CMAKE_CUDA_COMPILER_ID}" MATCHES "Clang" )
algebra_add_flag( CMAKE_CUDA_FLAGS "-Werror" )
endif()
endif()
15 changes: 11 additions & 4 deletions cmake/algebra-plugins-compiler-options-sycl.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Algebra plugins library, part of the ACTS project (R&D line)
#
# (c) 2021-2022 CERN for the benefit of the ACTS project
# (c) 2021-2023 CERN for the benefit of the ACTS project
#
# Mozilla Public License Version 2.0

Expand All @@ -15,10 +15,10 @@ foreach( mode RELEASE RELWITHDEBINFO MINSIZEREL DEBUG )
algebra_add_flag( CMAKE_SYCL_FLAGS_${mode} "-Wshadow" )
algebra_add_flag( CMAKE_SYCL_FLAGS_${mode} "-Wunused-local-typedefs" )
endforeach()

# More rigorous tests for the Debug builds.
if( NOT WIN32 )
algebra_add_flag( CMAKE_SYCL_FLAGS_DEBUG "-pedantic" )
foreach( mode RELEASE RELWITHDEBINFO MINSIZEREL DEBUG )
algebra_add_flag( CMAKE_SYCL_FLAGS_${mode} "-pedantic" )
endforeach()
endif()

# Avoid issues coming from MSVC<->DPC++ argument differences.
Expand All @@ -28,3 +28,10 @@ if( "${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC" )
"-Wno-unused-command-line-argument" )
endforeach()
endif()

# Fail on warnings, if asked for that behaviour.
if( ALGEBRA_PLUGINS_FAIL_ON_WARNINGS )
foreach( mode RELEASE RELWITHDEBINFO MINSIZEREL DEBUG )
algebra_add_flag( CMAKE_SYCL_FLAGS_${mode} "-Werror" )
endforeach()
endif()

0 comments on commit de546e3

Please sign in to comment.