diff options
author | Brad King <brad.king@kitware.com> | 2024-01-23 19:55:56 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2024-01-23 19:56:16 (GMT) |
commit | 4571ce5f1a7181f71794fc03837482e0a388a862 (patch) | |
tree | 9c88728ac6966e3719fca40b1a71baad13ecf916 /Modules | |
parent | 77dc558d1ed595887477410c5ac69b3e57cfbf0e (diff) | |
parent | 88c740462c63b09a20b4eeac0aa6ef182cb0c5dd (diff) | |
download | CMake-4571ce5f1a7181f71794fc03837482e0a388a862.zip CMake-4571ce5f1a7181f71794fc03837482e0a388a862.tar.gz CMake-4571ce5f1a7181f71794fc03837482e0a388a862.tar.bz2 |
Merge topic 'cuda-clang-windows'
88c740462c CUDA/Clang: Add support for MSVC ABI on Windows using GNU-like frontend
Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Raul Tambre <raul@tambre.ee>
Merge-request: !9172
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CMakeDetermineCUDACompiler.cmake | 4 | ||||
-rw-r--r-- | Modules/Compiler/Clang.cmake | 1 | ||||
-rw-r--r-- | Modules/Platform/Windows-Clang-CUDA.cmake | 16 | ||||
-rw-r--r-- | Modules/Platform/Windows-Clang.cmake | 7 |
4 files changed, 22 insertions, 6 deletions
diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake index 6ac4dad..70528da 100644 --- a/Modules/CMakeDetermineCUDACompiler.cmake +++ b/Modules/CMakeDetermineCUDACompiler.cmake @@ -74,10 +74,6 @@ if(NOT CMAKE_CUDA_COMPILER_ID_RUN) set(CMAKE_CUDA_COMPILER_ID_VENDOR_REGEX_Clang "(clang version)") CMAKE_DETERMINE_COMPILER_ID_VENDOR(CUDA "--version") - if(CMAKE_CUDA_COMPILER_ID STREQUAL "Clang" AND WIN32) - message(FATAL_ERROR "Clang with CUDA is not yet supported on Windows. See CMake issue #20776.") - endif() - # Find the CUDA toolkit to get: # - CMAKE_CUDA_COMPILER_TOOLKIT_VERSION # - CMAKE_CUDA_COMPILER_TOOLKIT_ROOT diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake index 4c033ca..4f8a9b7 100644 --- a/Modules/Compiler/Clang.cmake +++ b/Modules/Compiler/Clang.cmake @@ -17,6 +17,7 @@ set(__pch_header_OBJCXX "objective-c++-header") if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" OR "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC" + OR "x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC" OR "x${CMAKE_Fortran_SIMULATE_ID}" STREQUAL "xMSVC") macro(__compiler_clang lang) endmacro() diff --git a/Modules/Platform/Windows-Clang-CUDA.cmake b/Modules/Platform/Windows-Clang-CUDA.cmake new file mode 100644 index 0000000..c37df3b --- /dev/null +++ b/Modules/Platform/Windows-Clang-CUDA.cmake @@ -0,0 +1,16 @@ +include(Platform/Windows-Clang) +__windows_compiler_clang(CUDA) + +# Tell Clang where to find the CUDA libraries. +set(__IMPLICIT_LINKS) +foreach(dir ${CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES}) + string(APPEND __IMPLICIT_LINKS " -L\"${dir}\"") +endforeach() +string(APPEND CMAKE_CUDA_LINK_EXECUTABLE "${__IMPLICIT_LINKS}") +string(APPEND CMAKE_CUDA_CREATE_SHARED_LIBRARY "${__IMPLICIT_LINKS}") +string(APPEND CMAKE_CUDA_CREATE_SHARED_MODULE "${__IMPLICIT_LINKS}") +unset(__IMPLICIT_LINKS) + +# Device linking is just regular linking so these are the same. +set(CMAKE_CUDA_DEVICE_LINKER_WRAPPER_FLAG ${CMAKE_CUDA_LINKER_WRAPPER_FLAG}) +set(CMAKE_CUDA_DEVICE_LINKER_WRAPPER_FLAG_SEP ${CMAKE_CUDA_LINKER_WRAPPER_FLAG_SEP}) diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index f081f42..db48150 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -53,6 +53,7 @@ macro(__windows_compiler_clang_gnu lang) set(CMAKE_${lang}_LINK_OPTIONS_PIE "") set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "") set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "") + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") set(CMAKE_${lang}_LINK_LIBRARIES_PROCESSING ORDER=FORWARD UNICITY=ALL) @@ -184,18 +185,19 @@ endmacro() if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" OR "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC" + OR "x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC" OR "x${CMAKE_HIP_SIMULATE_ID}" STREQUAL "xMSVC") __verify_same_language_values(COMPILER_ID "The current configuration mixes Clang and MSVC or " "some other CL compatible compiler tool. This is not supported. " - "Use either clang or MSVC as both C, C++ and/or HIP compilers.") + "Use either Clang or MSVC as the compiler for all of C, C++, CUDA and/or HIP.") __verify_same_language_values(COMPILER_FRONTEND_VARIANT "The current configuration uses the Clang compiler " "tool with mixed frontend variants, both the GNU and in MSVC CL " "like variants. This is not supported. Use either clang/clang++ " - "or clang-cl as both C, C++ and/or HIP compilers.") + "or clang-cl as all C, C++, CUDA and/or HIP compilers.") if(NOT CMAKE_RC_COMPILER_INIT) # Check if rc is already in the path @@ -217,6 +219,7 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" if ( "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" OR "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" + OR "x${CMAKE_CUDA_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" OR "x${CMAKE_HIP_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC") include(Platform/Windows-MSVC) |