From 1b4c690543451e1907a5b3df23eb76385ab87ada Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Sat, 30 May 2020 13:59:57 +0300 Subject: CUDA: Throw error if CUDA_SEPARABLE_COMPILATION is ON when using Clang Separable compilation isn't supported yet on Clang. Let's throw a helpful error instead of confusing errors during the build. --- Source/cmLocalGenerator.cxx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 3fca2d4..288def1 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1986,6 +1986,19 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, } } else if (lang == "CUDA") { target->AddCUDAArchitectureFlags(flags); + + std::string const& compiler = + this->Makefile->GetSafeDefinition("CMAKE_CUDA_COMPILER_ID"); + + if (compiler == "Clang") { + bool separable = target->GetPropertyAsBool("CUDA_SEPARABLE_COMPILATION"); + + if (separable) { + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + "CUDA_SEPARABLE_COMPILATION isn't supported on Clang."); + } + } } // Add MSVC runtime library flags. This is activated by the presence -- cgit v0.12 From b1243201e78b8ee403f1aa696a4a7f6f158caafb Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Tue, 2 Jun 2020 22:14:26 +0300 Subject: CUDA: Don't RunCMake generate separable compilation tests on Clang Building these targets was already previously disabled in RunCMakeTest.cmake. Now with us throwing an error for separable compilation during generation on Clang we also need to stop them from being generated. --- .../target_link_options/genex_DEVICE_LINK.cmake | 33 ++++++++++++---------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/Tests/RunCMake/target_link_options/genex_DEVICE_LINK.cmake b/Tests/RunCMake/target_link_options/genex_DEVICE_LINK.cmake index 4d0c02f..0126080 100644 --- a/Tests/RunCMake/target_link_options/genex_DEVICE_LINK.cmake +++ b/Tests/RunCMake/target_link_options/genex_DEVICE_LINK.cmake @@ -21,26 +21,29 @@ target_link_options (LinkOptions_private PRIVATE $) + # Separable compilation is only supported on NVCC. + if(NOT CMake_TEST_CUDA STREQUAL "Clang") + add_executable(LinkOptions_CMP0105_UNSET LinkOptionsDevice.cu) + set_property(TARGET LinkOptions_CMP0105_UNSET PROPERTY CUDA_SEPARABLE_COMPILATION ON) + target_link_options(LinkOptions_CMP0105_UNSET PRIVATE $) - cmake_policy(SET CMP0105 OLD) + cmake_policy(SET CMP0105 OLD) - add_executable(LinkOptions_CMP0105_OLD LinkOptionsDevice.cu) - set_property(TARGET LinkOptions_CMP0105_OLD PROPERTY CUDA_SEPARABLE_COMPILATION ON) - target_link_options(LinkOptions_CMP0105_OLD PRIVATE $) + add_executable(LinkOptions_CMP0105_OLD LinkOptionsDevice.cu) + set_property(TARGET LinkOptions_CMP0105_OLD PROPERTY CUDA_SEPARABLE_COMPILATION ON) + target_link_options(LinkOptions_CMP0105_OLD PRIVATE $) - cmake_policy(SET CMP0105 NEW) + cmake_policy(SET CMP0105 NEW) - add_executable(LinkOptions_CMP0105_NEW LinkOptionsDevice.cu) - set_property(TARGET LinkOptions_CMP0105_NEW PROPERTY CUDA_SEPARABLE_COMPILATION ON) - target_link_options(LinkOptions_CMP0105_NEW PRIVATE $) + add_executable(LinkOptions_CMP0105_NEW LinkOptionsDevice.cu) + set_property(TARGET LinkOptions_CMP0105_NEW PROPERTY CUDA_SEPARABLE_COMPILATION ON) + target_link_options(LinkOptions_CMP0105_NEW PRIVATE $) - add_executable(LinkOptions_device LinkOptionsDevice.cu) - set_property(TARGET LinkOptions_device PROPERTY CUDA_SEPARABLE_COMPILATION ON) - target_link_options(LinkOptions_device PRIVATE $ - $) + add_executable(LinkOptions_device LinkOptionsDevice.cu) + set_property(TARGET LinkOptions_device PROPERTY CUDA_SEPARABLE_COMPILATION ON) + target_link_options(LinkOptions_device PRIVATE $ + $) + endif() add_executable(LinkOptions_no_device LinkOptionsDevice.cu) target_link_options(LinkOptions_no_device PRIVATE $ -- cgit v0.12