Browse Source

Merge branch 'vs-cuda-pdb' into release-3.13

Merge-request: !2473
Brad King 7 years ago
parent
commit
bcfb245703

+ 18 - 7
Source/cmVisualStudio10TargetGenerator.cxx

@@ -2679,6 +2679,13 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
     // Specify the compiler program database file if configured.
     std::string pdb = this->GeneratorTarget->GetCompilePDBPath(configName);
     if (!pdb.empty()) {
+      if (this->GlobalGenerator->IsCudaEnabled()) {
+        // CUDA does not quote paths with spaces correctly when forwarding
+        // this to the host compiler.  Use a relative path to avoid spaces.
+        // FIXME: We can likely do this even when CUDA is not involved,
+        // but for now we will make a minimal change.
+        pdb = this->ConvertPath(pdb, true);
+      }
       ConvertToWindowsSlash(pdb);
       e2.Element("ProgramDataBaseFileName", pdb);
     }
@@ -2819,15 +2826,19 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions(
   // Specify the compiler program database file if configured.
   std::string pdb = this->GeneratorTarget->GetCompilePDBPath(configName);
   if (!pdb.empty()) {
-    // CUDA does not have a field for this and does not honor the
-    // ProgramDataBaseFileName field in ClCompile.  Work around this
-    // limitation by creating the directory and passing the flag ourselves.
+    // CUDA does not make the directory if it is non-standard.
     std::string const pdbDir = cmSystemTools::GetFilenamePath(pdb);
     cmSystemTools::MakeDirectory(pdbDir);
-    pdb = this->ConvertPath(pdb, true);
-    ConvertToWindowsSlash(pdb);
-    std::string const clFd = "-Xcompiler=\"-Fd\\\"" + pdb + "\\\"\"";
-    cudaOptions.AppendFlagString("AdditionalOptions", clFd);
+    if (cmSystemTools::VersionCompareGreaterEq(
+          "9.2", this->GlobalGenerator->GetPlatformToolsetCudaString())) {
+      // CUDA does not have a field for this and does not honor the
+      // ProgramDataBaseFileName field in ClCompile.  Work around this
+      // limitation by creating the directory and passing the flag ourselves.
+      pdb = this->ConvertPath(pdb, true);
+      ConvertToWindowsSlash(pdb);
+      std::string const clFd = "-Xcompiler=\"-Fd\\\"" + pdb + "\\\"\"";
+      cudaOptions.AppendFlagString("AdditionalOptions", clFd);
+    }
   }
 
   // CUDA automatically passes the proper '--machine' flag to nvcc

+ 1 - 1
Tests/Cuda/Complex/CMakeLists.txt

@@ -1,6 +1,6 @@
 
 cmake_minimum_required(VERSION 3.7)
-project (CudaComplex CXX CUDA)
+project (Complex CXX CUDA)
 #Goal for this example:
 
 #build a cpp dynamic library base

+ 1 - 1
Tests/Cuda/ConsumeCompileFeatures/CMakeLists.txt

@@ -1,6 +1,6 @@
 
 cmake_minimum_required(VERSION 3.7)
-project (CudaConsumeCompileFeatures CXX CUDA)
+project (ConsumeCompileFeatures CXX CUDA)
 #Goal for this example:
 
 #build a c++11 library that express a c++11 public compile feature

+ 1 - 1
Tests/Cuda/MixedStandardLevels/CMakeLists.txt

@@ -1,5 +1,5 @@
 cmake_minimum_required(VERSION 3.7)
-project(CudaComplex CXX CUDA)
+project(MixedStandardLevels CXX CUDA)
 
 string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
 

+ 1 - 1
Tests/Cuda/ObjectLibrary/CMakeLists.txt

@@ -1,5 +1,5 @@
 cmake_minimum_required(VERSION 3.7)
-project (CudaObjectLibrary CUDA CXX)
+project (ObjectLibrary CUDA CXX)
 #Goal for this example:
 #
 #Build C++ and CUDA object files and than use them to make an executable

+ 1 - 1
Tests/Cuda/WithC/CMakeLists.txt

@@ -1,5 +1,5 @@
 cmake_minimum_required(VERSION 3.7)
-project(CudaComplex CUDA C)
+project(WithC CUDA C)
 
 string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
 

+ 1 - 1
Tests/CudaOnly/CircularLinkLine/CMakeLists.txt

@@ -1,5 +1,5 @@
 cmake_minimum_required(VERSION 3.7)
-project (CudaOnlyCircularLinkLine CUDA)
+project (CircularLinkLine CUDA)
 
 #Goal for this example:
 # Verify that we de-duplicate the device link line

+ 1 - 1
Tests/CudaOnly/EnableStandard/CMakeLists.txt

@@ -1,6 +1,6 @@
 
 cmake_minimum_required(VERSION 3.7)
-project (CudaOnlyEnableStandard CUDA)
+project (EnableStandard CUDA)
 
 #Goal for this example:
 #build cuda sources that require C++11 to be enabled.

+ 1 - 1
Tests/CudaOnly/ExportPTX/CMakeLists.txt

@@ -1,5 +1,5 @@
 cmake_minimum_required(VERSION 3.8)
-project (CudaOnlyExportPTX CUDA)
+project (ExportPTX CUDA)
 
 #Goal for this example:
 # How to generate PTX files instead of OBJECT files

+ 1 - 1
Tests/CudaOnly/GPUDebugFlag/CMakeLists.txt

@@ -1,6 +1,6 @@
 
 cmake_minimum_required(VERSION 3.7)
-project (CudaOnlGPUDebugFlag CUDA)
+project (GPUDebugFlag CUDA)
 
 #Goal for this example:
 #verify that -G enables gpu debug flags

+ 1 - 1
Tests/CudaOnly/LinkSystemDeviceLibraries/CMakeLists.txt

@@ -1,5 +1,5 @@
 cmake_minimum_required(VERSION 3.8)
-project(CudaOnlyLinkSystemDeviceLibraries CUDA)
+project(LinkSystemDeviceLibraries CUDA)
 
 string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_35,code=compute_35 -gencode arch=compute_35,code=sm_35")
 set(CMAKE_CUDA_STANDARD 11)

+ 1 - 1
Tests/CudaOnly/PDB/CMakeLists.txt

@@ -1,5 +1,5 @@
 cmake_minimum_required(VERSION 3.11)
-project (CudaOnlyPDB CUDA)
+project (PDB CUDA)
 
 add_executable(CudaOnlyPDB main.cu)
 set_target_properties(CudaOnlyPDB PROPERTIES

+ 1 - 1
Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt

@@ -1,5 +1,5 @@
 cmake_minimum_required(VERSION 3.7)
-project (CudaOnlyResolveDeviceSymbols CUDA)
+project (ResolveDeviceSymbols CUDA)
 
 # Find nm and dumpbin
 if(CMAKE_NM)

+ 1 - 1
Tests/CudaOnly/SeparateCompilation/CMakeLists.txt

@@ -1,6 +1,6 @@
 
 cmake_minimum_required(VERSION 3.7)
-project (CudaOnlySeparateCompilation CUDA)
+project (SeparateCompilation CUDA)
 
 #Goal for this example:
 #Build a static library that defines multiple methods and kernels that

+ 1 - 1
Tests/CudaOnly/WithDefs/CMakeLists.txt

@@ -1,6 +1,6 @@
 
 cmake_minimum_required(VERSION 3.7)
-project (CudaOnlyWithDefs CUDA)
+project (WithDefs CUDA)
 
 #verify that we can pass explicit cuda arch flags
 string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")