Warning, /acts/Traccc/cmake/traccc-compiler-options-cuda.cmake is written in an unsupported language. File is not indexed.
0001 # TRACCC library, part of the ACTS project (R&D line)
0002 #
0003 # (c) 2021-2026 CERN for the benefit of the ACTS project
0004 #
0005 # Mozilla Public License Version 2.0
0006
0007 # FindCUDAToolkit needs at least CMake 3.17, and C++17 support
0008 # (set in the project's main CMakeLists.txt file) needs CMake 3.18.
0009 cmake_minimum_required(VERSION 3.18)
0010
0011 # Include the helper function(s).
0012 include(traccc-functions)
0013
0014 # Figure out the properties of CUDA being used.
0015 find_package(CUDAToolkit REQUIRED)
0016
0017 # Turn on the correct setting for the __cplusplus macro with MSVC.
0018 if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
0019 traccc_add_flag( CMAKE_CUDA_FLAGS "-Xcompiler /Zc:__cplusplus" )
0020 endif()
0021
0022 if("${CMAKE_CUDA_COMPILER_ID}" MATCHES "NVIDIA")
0023 traccc_add_flag( CMAKE_CUDA_FLAGS "-Wall" )
0024 traccc_add_flag( CMAKE_CUDA_FLAGS "-Wextra" )
0025 traccc_add_flag( CMAKE_CUDA_FLAGS "-Wconversion" )
0026 endif()
0027
0028 # Allow to use functions in device code that are constexpr, even if they are
0029 # not marked with __device__.
0030 traccc_add_flag( CMAKE_CUDA_FLAGS "--use_fast_math" )
0031
0032 # Make CUDA generate debug symbols for the device code as well in a debug
0033 # build.
0034 traccc_add_flag( CMAKE_CUDA_FLAGS_DEBUG "-G --keep" )
0035
0036 # Work around a bug in CUDA 12.8. Enabling the embedding of C++ source code in
0037 # generated PTX code causes a ptxas error. A solution was promised for
0038 # CUDA 13.1, but this has not yet surfaced.
0039 #
0040 # TODO: Add an upper bound to this statement when a fix in CUDA is presented.
0041 if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL "12.8")
0042 message(
0043 STATUS
0044 "Disabling C++ source in PTX in order to work around a bug in CUDA 12.8:"
0045 )
0046 else()
0047 traccc_add_flag( CMAKE_CUDA_FLAGS_DEBUG "-src-in-ptx" )
0048 endif()
0049
0050 # Ensure that line information is embedded in debugging builds so that
0051 # profilers have access to line data.
0052 traccc_add_flag( CMAKE_CUDA_FLAGS_RELWITHDEBINFO "-lineinfo" )
0053
0054 # Fail on warnings, if asked for that behaviour.
0055 if(TRACCC_FAIL_ON_WARNINGS)
0056 if(
0057 ("${CUDAToolkit_VERSION}" VERSION_GREATER_EQUAL "10.2")
0058 AND ("${CMAKE_CUDA_COMPILER_ID}" MATCHES "NVIDIA")
0059 )
0060 traccc_add_flag( CMAKE_CUDA_FLAGS "-Werror all-warnings" )
0061 elseif("${CMAKE_CUDA_COMPILER_ID}" MATCHES "Clang")
0062 traccc_add_flag( CMAKE_CUDA_FLAGS "-Werror" )
0063 endif()
0064 endif()