Warning, /acts/Detray/cmake/detray-compiler-options-cuda.cmake is written in an unsupported language. File is not indexed.
0001 # This file is part of the ACTS project.
0002 #
0003 # Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 #
0005 # This Source Code Form is subject to the terms of the Mozilla Public
0006 # License, v. 2.0. If a copy of the MPL was not distributed with this
0007 # file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008
0009 cmake_minimum_required(VERSION 3.21)
0010
0011 # Only set these compiler flags if we are the top level project.
0012 if(PROJECT_IS_TOP_LEVEL)
0013 # Include the helper function(s).
0014 include(detray-functions)
0015
0016 # Figure out the properties of CUDA being used.
0017 find_package(CUDAToolkit REQUIRED)
0018
0019 # Turn on the correct setting for the __cplusplus macro with MSVC.
0020 if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
0021 detray_add_flag( CMAKE_CUDA_FLAGS "-Xcompiler /Zc:__cplusplus" )
0022 endif()
0023
0024 # Set the CUDA architecture to build code for.
0025 set(CMAKE_CUDA_ARCHITECTURES
0026 "52"
0027 CACHE STRING
0028 "CUDA architectures to build device code for"
0029 )
0030
0031 if("${CMAKE_CUDA_COMPILER_ID}" MATCHES "NVIDIA")
0032 # Allow to use functions in device code that are constexpr, even if they are
0033 # not marked with __device__.
0034 detray_add_flag( CMAKE_CUDA_FLAGS "--expt-relaxed-constexpr" )
0035 endif()
0036
0037 # Make CUDA generate debug symbols for the device code as well in a debug
0038 # build.
0039 detray_add_flag( CMAKE_CUDA_FLAGS_DEBUG "-G -src-in-ptx" )
0040 detray_add_flag( CMAKE_CUDA_FLAGS_RELWITHDEBINFO "-lineinfo -src-in-ptx" )
0041
0042 # Fail on warnings, if asked for that behaviour.
0043 if(DETRAY_FAIL_ON_WARNINGS)
0044 if(
0045 ("${CUDAToolkit_VERSION}" VERSION_GREATER_EQUAL "10.2")
0046 AND ("${CMAKE_CUDA_COMPILER_ID}" MATCHES "NVIDIA")
0047 )
0048 detray_add_flag( CMAKE_CUDA_FLAGS "-Werror all-warnings" )
0049 elseif("${CMAKE_CUDA_COMPILER_ID}" MATCHES "Clang")
0050 detray_add_flag( CMAKE_CUDA_FLAGS "-Werror" )
0051 endif()
0052 endif()
0053 endif()