summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/release/dev/cuda-clang-windows.rst5
-rw-r--r--Modules/CMakeDetermineCUDACompiler.cmake4
-rw-r--r--Modules/Compiler/Clang.cmake1
-rw-r--r--Modules/Platform/Windows-Clang-CUDA.cmake16
-rw-r--r--Modules/Platform/Windows-Clang.cmake7
-rw-r--r--Tests/Cuda/CMakeLists.txt6
-rw-r--r--Tests/CudaOnly/CMakeLists.txt4
-rw-r--r--Tests/MSVCDebugInformationFormat/override-CUDA.cmake1
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/Common.cmake2
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/CudaSimple.cmake3
10 files changed, 39 insertions, 10 deletions
diff --git a/Help/release/dev/cuda-clang-windows.rst b/Help/release/dev/cuda-clang-windows.rst
new file mode 100644
index 0000000..082fe2f
--- /dev/null
+++ b/Help/release/dev/cuda-clang-windows.rst
@@ -0,0 +1,5 @@
+cuda-clang-windows
+------------------
+
+* The ``CUDA`` language can now be compiled with Clang on Windows
+ using its GNU-like frontend, ``clang++``.
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)
diff --git a/Tests/Cuda/CMakeLists.txt b/Tests/Cuda/CMakeLists.txt
index efe0358..04ef86d 100644
--- a/Tests/Cuda/CMakeLists.txt
+++ b/Tests/Cuda/CMakeLists.txt
@@ -9,8 +9,10 @@ add_cuda_test_macro(Cuda.ObjectLibrary CudaObjectLibrary)
add_cuda_test_macro(Cuda.MixedStandardLevels1 MixedStandardLevels1)
add_cuda_test_macro(Cuda.MixedStandardLevels2 MixedStandardLevels2)
add_cuda_test_macro(Cuda.MixedStandardLevels3 MixedStandardLevels3)
-add_cuda_test_macro(Cuda.MixedStandardLevels4 MixedStandardLevels4)
-add_cuda_test_macro(Cuda.MixedStandardLevels5 MixedStandardLevels5)
+if(NOT WIN32 OR NOT CMake_TEST_CUDA STREQUAL "Clang") # MSVC std lib needs C++14
+ add_cuda_test_macro(Cuda.MixedStandardLevels4 MixedStandardLevels4)
+ add_cuda_test_macro(Cuda.MixedStandardLevels5 MixedStandardLevels5)
+endif()
add_cuda_test_macro(Cuda.NotEnabled CudaNotEnabled)
add_cuda_test_macro(Cuda.SeparableCompCXXOnly SeparableCompCXXOnly)
add_cuda_test_macro(Cuda.StubRPATH StubRPATH)
diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt
index 9f49498..128d371 100644
--- a/Tests/CudaOnly/CMakeLists.txt
+++ b/Tests/CudaOnly/CMakeLists.txt
@@ -11,7 +11,9 @@ add_cuda_test_macro(CudaOnly.EnableStandard CudaOnlyEnableStandard)
add_cuda_test_macro(CudaOnly.ExportPTX CudaOnlyExportPTX)
add_cuda_test_macro(CudaOnly.SharedRuntimePlusToolkit CudaOnlySharedRuntimePlusToolkit)
add_cuda_test_macro(CudaOnly.StaticRuntimePlusToolkit CudaOnlyStaticRuntimePlusToolkit)
-add_cuda_test_macro(CudaOnly.Standard98 CudaOnlyStandard98)
+if(NOT WIN32 OR NOT CMake_TEST_CUDA STREQUAL "Clang") # MSVC std lib needs C++14
+ add_cuda_test_macro(CudaOnly.Standard98 CudaOnlyStandard98)
+endif()
set(CudaOnly.Toolkit_BUILD_OPTIONS -DHAS_CUPTI:BOOL=${CMake_TEST_CUDA_CUPTI})
add_cuda_test_macro(CudaOnly.Toolkit CudaOnlyToolkit)
add_cuda_test_macro(CudaOnly.ToolkitBeforeLang CudaOnlyToolkitBeforeLang)
diff --git a/Tests/MSVCDebugInformationFormat/override-CUDA.cmake b/Tests/MSVCDebugInformationFormat/override-CUDA.cmake
index f870775..eaa7bff 100644
--- a/Tests/MSVCDebugInformationFormat/override-CUDA.cmake
+++ b/Tests/MSVCDebugInformationFormat/override-CUDA.cmake
@@ -1,5 +1,6 @@
set(var "CMAKE_CUDA_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_Embedded")
string(REPLACE "-Z7" "-Z7;-DTEST_Z7" "${var}" "${${var}}")
+string(REPLACE "-gcodeview" "-gcodeview;-DTEST_Z7" "${var}" "${${var}}")
set(var "CMAKE_CUDA_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase")
string(REPLACE "-Zi" "-Zi;-DTEST_Zi" "${var}" "${${var}}")
set(var "CMAKE_CUDA_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_EditAndContinue")
diff --git a/Tests/RunCMake/NinjaMultiConfig/Common.cmake b/Tests/RunCMake/NinjaMultiConfig/Common.cmake
index 6c0d82a..9343eaf 100644
--- a/Tests/RunCMake/NinjaMultiConfig/Common.cmake
+++ b/Tests/RunCMake/NinjaMultiConfig/Common.cmake
@@ -37,7 +37,7 @@ function(generate_output_files)
set(exe_file " [==[$<TARGET_FILE_DIR:${tgt}>/$<TARGET_FILE_PREFIX:${tgt}>$<TARGET_FILE_BASE_NAME:${tgt}>$<TARGET_FILE_SUFFIX:${tgt}>]==]")
set(exe_filename " [==[$<TARGET_FILE_PREFIX:${tgt}>$<TARGET_FILE_BASE_NAME:${tgt}>$<TARGET_FILE_SUFFIX:${tgt}>]==]")
- if(WIN32)
+ if(WIN32 AND NOT generate_output_files_NO_EXE_LIB)
set(exe_lib_file " [==[$<TARGET_FILE_DIR:${tgt}>/$<TARGET_FILE_PREFIX:${tgt}>$<TARGET_FILE_BASE_NAME:${tgt}>.lib]==]")
string(APPEND content "set(TARGET_EXE_LIB_FILE_${tgt}_$<CONFIG>${exe_lib_file})\n")
endif()
diff --git a/Tests/RunCMake/NinjaMultiConfig/CudaSimple.cmake b/Tests/RunCMake/NinjaMultiConfig/CudaSimple.cmake
index 00d8a1b..b5fc5b6 100644
--- a/Tests/RunCMake/NinjaMultiConfig/CudaSimple.cmake
+++ b/Tests/RunCMake/NinjaMultiConfig/CudaSimple.cmake
@@ -16,6 +16,9 @@ set_target_properties(simplecudaobj simplecudashared
add_executable(simplecudaexe main.cu )
target_link_libraries(simplecudaexe PRIVATE simplecudashared)
+if(WIN32 AND CMAKE_CUDA_COMPILER_ID STREQUAL "Clang")
+ set(generate_output_files_NO_EXE_LIB 1)
+endif()
include(${CMAKE_CURRENT_LIST_DIR}/Common.cmake)
generate_output_files(simplecudaexe simplecudashared simplecudaobj)