Imported Upstream version 3.25.0
[platform/upstream/cmake.git] / Modules / Compiler / Clang-CUDA.cmake
1 include(Compiler/Clang)
2 __compiler_clang(CUDA)
3
4 # Set explicitly, because __compiler_clang() doesn't set this if we're simulating MSVC.
5 set(CMAKE_DEPFILE_FLAGS_CUDA "-MD -MT <DEP_TARGET> -MF <DEP_FILE>")
6 if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER)
7     AND CMAKE_GENERATOR MATCHES "Makefiles|WMake")
8   # dependencies are computed by the compiler itself
9   set(CMAKE_CUDA_DEPFILE_FORMAT gcc)
10   set(CMAKE_CUDA_DEPENDS_USE_COMPILER TRUE)
11 endif()
12
13 # C++03 isn't supported for CXX, but is for CUDA, so we need to set these manually.
14 # Do this before __compiler_clang_cxx_standards() since that adds the feature.
15 set(CMAKE_CUDA03_STANDARD_COMPILE_OPTION "-std=c++03")
16 set(CMAKE_CUDA03_EXTENSION_COMPILE_OPTION "-std=gnu++03")
17 __compiler_clang_cxx_standards(CUDA)
18
19 set(CMAKE_CUDA_COMPILER_HAS_DEVICE_LINK_PHASE TRUE)
20 set(_CMAKE_COMPILE_AS_CUDA_FLAG "-x cuda")
21 set(_CMAKE_CUDA_WHOLE_FLAG "-c")
22 set(_CMAKE_CUDA_RDC_FLAG "-fgpu-rdc")
23 set(_CMAKE_CUDA_PTX_FLAG "--cuda-device-only -S")
24
25 # Device linking is just regular linking so these are the same.
26 set(CMAKE_CUDA_DEVICE_LINKER_WRAPPER_FLAG ${CMAKE_CUDA_LINKER_WRAPPER_FLAG})
27 set(CMAKE_CUDA_DEVICE_LINKER_WRAPPER_FLAG_SEP ${CMAKE_CUDA_LINKER_WRAPPER_FLAG_SEP})
28
29 # RulePlaceholderExpander expands crosscompile variables like sysroot and target only for CMAKE_<LANG>_COMPILER. Override the default.
30 set(CMAKE_CUDA_LINK_EXECUTABLE "<CMAKE_CUDA_COMPILER> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>${__IMPLICIT_LINKS}")
31 set(CMAKE_CUDA_CREATE_SHARED_LIBRARY "<CMAKE_CUDA_COMPILER> <CMAKE_SHARED_LIBRARY_CUDA_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CUDA_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>${__IMPLICIT_LINKS}")
32
33 set(CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT "STATIC")
34 set(CMAKE_CUDA_RUNTIME_LIBRARY_LINK_OPTIONS_STATIC "cudadevrt;cudart_static")
35 set(CMAKE_CUDA_RUNTIME_LIBRARY_LINK_OPTIONS_SHARED "cudadevrt;cudart")
36 set(CMAKE_CUDA_RUNTIME_LIBRARY_LINK_OPTIONS_NONE   "")
37
38 # Clang doesn't support CUDA device LTO
39 set(_CMAKE_CUDA_IPO_SUPPORTED_BY_CMAKE NO)
40 set(_CMAKE_CUDA_IPO_MAY_BE_SUPPORTED_BY_COMPILER NO)
41
42 if(UNIX)
43   list(APPEND CMAKE_CUDA_RUNTIME_LIBRARY_LINK_OPTIONS_STATIC "rt" "pthread" "dl")
44 endif()