Просмотр исходного кода

CUDA: Use `.obj` object file extension on Windows

Brad King 9 лет назад
Родитель
Сommit
d470cb7007

+ 5 - 1
Modules/CMakeCUDAInformation.cmake

@@ -1,7 +1,11 @@
 # Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
 # file Copyright.txt or https://cmake.org/licensing for details.
 
-set(CMAKE_CUDA_OUTPUT_EXTENSION .o)
+if(UNIX)
+  set(CMAKE_CUDA_OUTPUT_EXTENSION .o)
+else()
+  set(CMAKE_CUDA_OUTPUT_EXTENSION .obj)
+endif()
 set(CMAKE_INCLUDE_FLAG_CUDA "-I")
 
 # Load compiler-specific information.

+ 3 - 1
Source/cmMakefileExecutableTargetGenerator.cxx

@@ -104,10 +104,12 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule(
 
   // Get the language to use for linking this library.
   std::string linkLanguage = "CUDA";
+  std::string const objExt =
+    this->Makefile->GetSafeDefinition("CMAKE_CUDA_OUTPUT_EXTENSION");
 
   // Get the name of the device object to generate.
   std::string const targetOutputReal =
-    this->GeneratorTarget->ObjectDirectory + "cmake_device_link.o";
+    this->GeneratorTarget->ObjectDirectory + "cmake_device_link" + objExt;
   this->DeviceLinkObject = targetOutputReal;
 
   this->NumberOfProgressActions++;

+ 3 - 1
Source/cmMakefileLibraryTargetGenerator.cxx

@@ -281,6 +281,8 @@ void cmMakefileLibraryTargetGenerator::WriteDeviceLibraryRules(
 
   // Get the language to use for linking this library.
   std::string linkLanguage = "CUDA";
+  std::string const objExt =
+    this->Makefile->GetSafeDefinition("CMAKE_CUDA_OUTPUT_EXTENSION");
 
   // Create set of linking flags.
   std::string linkFlags;
@@ -288,7 +290,7 @@ void cmMakefileLibraryTargetGenerator::WriteDeviceLibraryRules(
 
   // Get the name of the device object to generate.
   std::string const targetOutputReal =
-    this->GeneratorTarget->ObjectDirectory + "cmake_device_link.o";
+    this->GeneratorTarget->ObjectDirectory + "cmake_device_link" + objExt;
   this->DeviceLinkObject = targetOutputReal;
 
   this->NumberOfProgressActions++;

+ 4 - 2
Source/cmNinjaNormalTargetGenerator.cxx

@@ -602,10 +602,12 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement()
   // First and very important step is to make sure while inside this
   // step our link language is set to CUDA
   std::string cudaLinkLanguage = "CUDA";
+  std::string const objExt =
+    this->Makefile->GetSafeDefinition("CMAKE_CUDA_OUTPUT_EXTENSION");
 
   std::string const cfgName = this->GetConfigName();
-  std::string const targetOutputReal =
-    ConvertToNinjaPath(genTarget.ObjectDirectory + "cmake_device_link.o");
+  std::string const targetOutputReal = ConvertToNinjaPath(
+    genTarget.ObjectDirectory + "cmake_device_link" + objExt);
 
   std::string const targetOutputImplib =
     ConvertToNinjaPath(genTarget.GetFullPath(cfgName,