-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setting compiler flags as in the other R&D projects.
- Loading branch information
Showing
10 changed files
with
149 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# This file is part of covfie, a part of the ACTS project | ||
# | ||
# Copyright (c) 2023 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 | ||
# obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
# Include the helper function(s). | ||
include( covfie-functions ) | ||
|
||
# Turn on a number of warnings for the "known compilers". | ||
if( ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" ) OR | ||
( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" ) ) | ||
|
||
# Basic flags for all build modes. | ||
covfie_add_flag( CMAKE_CXX_FLAGS "-Wall" ) | ||
covfie_add_flag( CMAKE_CXX_FLAGS "-Wextra" ) | ||
covfie_add_flag( CMAKE_CXX_FLAGS "-Wshadow" ) | ||
covfie_add_flag( CMAKE_CXX_FLAGS "-Wunused-local-typedefs" ) | ||
covfie_add_flag( CMAKE_CXX_FLAGS "-pedantic" ) | ||
|
||
# Fail on warnings, if asked for that behaviour. | ||
if( COVFIE_FAIL_ON_WARNINGS ) | ||
covfie_add_flag( CMAKE_CXX_FLAGS "-Werror" ) | ||
endif() | ||
|
||
elseif( "${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC" ) | ||
|
||
# Basic flags for all build modes. | ||
string( REGEX REPLACE "/W[0-9]" "" CMAKE_CXX_FLAGS | ||
"${CMAKE_CXX_FLAGS}" ) | ||
covfie_add_flag( CMAKE_CXX_FLAGS "/W4" ) | ||
|
||
# Fail on warnings, if asked for that behaviour. | ||
if( COVFIE_FAIL_ON_WARNINGS ) | ||
covfie_add_flag( CMAKE_CXX_FLAGS "/WX" ) | ||
endif() | ||
|
||
# Turn on the correct setting for the __cplusplus macro with MSVC. | ||
covfie_add_flag( CMAKE_CXX_FLAGS "/Zc:__cplusplus" ) | ||
|
||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# This file is part of covfie, a part of the ACTS project | ||
# | ||
# Copyright (c) 2023 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 | ||
# obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
# FindCUDAToolkit needs at least CMake 3.17. | ||
cmake_minimum_required( VERSION 3.17 ) | ||
|
||
# Include the helper function(s). | ||
include( covfie-functions ) | ||
|
||
# Figure out the properties of CUDA being used. | ||
find_package( CUDAToolkit REQUIRED ) | ||
|
||
# Set the architecture to build code for. | ||
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" ) | ||
covfie_add_flag( CMAKE_CUDA_FLAGS "-Xcompiler /Zc:__cplusplus" ) | ||
endif() | ||
|
||
if( "${CMAKE_CUDA_COMPILER_ID}" MATCHES "NVIDIA" ) | ||
# Make CUDA generate debug symbols for the device code as well in a debug | ||
# build. | ||
covfie_add_flag( CMAKE_CUDA_FLAGS_DEBUG "-G" ) | ||
# Allow to use functions in device code that are constexpr, even if they are | ||
# not marked with __device__. | ||
covfie_add_flag( CMAKE_CUDA_FLAGS "--expt-relaxed-constexpr" ) | ||
endif() | ||
|
||
# Fail on warnings, if asked for that behaviour. | ||
if( COVFIE_FAIL_ON_WARNINGS ) | ||
if( ( "${CUDAToolkit_VERSION}" VERSION_GREATER_EQUAL "10.2" ) AND | ||
( "${CMAKE_CUDA_COMPILER_ID}" MATCHES "NVIDIA" ) ) | ||
covfie_add_flag( CMAKE_CUDA_FLAGS "-Werror all-warnings" ) | ||
elseif( "${CMAKE_CUDA_COMPILER_ID}" MATCHES "Clang" ) | ||
covfie_add_flag( CMAKE_CUDA_FLAGS "-Werror" ) | ||
endif() | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# This file is part of covfie, a part of the ACTS project | ||
# | ||
# Copyright (c) 2023 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 | ||
# obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
# Helper function for adding individual flags to "flag variables". | ||
# | ||
# Usage: covfie_add_flag( CMAKE_CXX_FLAGS "-Wall" ) | ||
# | ||
function( covfie_add_flag name value ) | ||
|
||
# Escape special characters in the value: | ||
set( matchedValue "${value}" ) | ||
foreach( c "*" "." "^" "$" "+" "?" ) | ||
string( REPLACE "${c}" "\\${c}" matchedValue "${matchedValue}" ) | ||
endforeach() | ||
|
||
# Check if the variable already has this value in it: | ||
if( "${${name}}" MATCHES "${matchedValue}" ) | ||
return() | ||
endif() | ||
|
||
# If not, then let's add it now: | ||
set( ${name} "${${name}} ${value}" PARENT_SCOPE ) | ||
|
||
endfunction( covfie_add_flag ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters