diff options
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 13 | ||||
-rw-r--r-- | Tests/CudaOnly/SeparateCompilation/CMakeLists.txt | 4 |
2 files changed, 14 insertions, 3 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 2a7d96b..32ece3f 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2523,9 +2523,16 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions( cudaOptions.AddTable(gg->GetCudaHostFlagTable()); cudaOptions.Reparse("AdditionalCompilerOptions"); - // `CUDA 8.0.targets` places these before nvcc! Just drop whatever - // did not parse and hope it works. - cudaOptions.RemoveFlag("AdditionalCompilerOptions"); + // `CUDA 8.0.targets` places AdditionalCompilerOptions before nvcc! + // Pass them through -Xcompiler in AdditionalOptions instead. + if (const char* acoPtr = cudaOptions.GetFlag("AdditionalCompilerOptions")) { + std::string aco = acoPtr; + cudaOptions.RemoveFlag("AdditionalCompilerOptions"); + if (!aco.empty()) { + aco = this->LocalGenerator->EscapeForShell(aco, false); + cudaOptions.AppendFlag("AdditionalOptions", "-Xcompiler=" + aco); + } + } cudaOptions.FixCudaCodeGeneration(); diff --git a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt index 0a2542a..f42324e 100644 --- a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt +++ b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt @@ -15,6 +15,10 @@ set(CMAKE_CUDA_STANDARD 11) add_library(CUDASeparateLibA STATIC file1.cu file2.cu file3.cu) +if(CMAKE_CUDA_SIMULATE_ID STREQUAL "MSVC") + target_compile_options(CUDASeparateLibA PRIVATE -Xcompiler=-bigobj) +endif() + #Having file4/file5 in a shared library causes serious problems #with the nvcc linker and it will generate bad entries that will #cause a segv when trying to run the executable |