[Cmake-commits] CMake branch, master, updated. v3.10.2-980-g4499cc8

Kitware Robot kwrobot at kitware.com
Wed Jan 31 08:45:04 EST 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, master has been updated
       via  4499cc8bb65e217e1cb2959452ed391af82e757b (commit)
       via  fa583869f7e75cdc4c7499f0dbfab2cdac5061bd (commit)
      from  a7ee918f197300ffed8f4ae0fafe6c3c2f4ea1b6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4499cc8bb65e217e1cb2959452ed391af82e757b
commit 4499cc8bb65e217e1cb2959452ed391af82e757b
Merge: a7ee918 fa58386
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Jan 31 13:36:18 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Wed Jan 31 08:36:24 2018 -0500

    Merge topic 'msvc_cuda_files_use_consistent_obj_names'
    
    fa583869 CUDA: Use MSVC default pattern for naming object files
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !1722


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fa583869f7e75cdc4c7499f0dbfab2cdac5061bd
commit fa583869f7e75cdc4c7499f0dbfab2cdac5061bd
Author:     Robert Maynard <robert.maynard at kitware.com>
AuthorDate: Thu Jan 18 16:05:59 2018 -0500
Commit:     Robert Maynard <robert.maynard at kitware.com>
CommitDate: Tue Jan 30 09:14:02 2018 -0500

    CUDA: Use MSVC default pattern for naming object files
    
    The default that CUDA uses causes failures when you try to embed
    CUDA obj's into another target.

diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index e15e833..7840e1f 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2078,9 +2078,15 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
     (*this->BuildFileStream) << firstString;
     firstString = "";
     hasFlags = true;
-    this->WriteString("<ObjectFileName>", 3);
-    (*this->BuildFileStream) << "$(IntDir)/" << objectName
-                             << "</ObjectFileName>\n";
+    if (lang == "CUDA") {
+      this->WriteString("<CompileOut>", 3);
+      (*this->BuildFileStream) << "$(IntDir)/" << objectName
+                               << "</CompileOut>\n";
+    } else {
+      this->WriteString("<ObjectFileName>", 3);
+      (*this->BuildFileStream) << "$(IntDir)/" << objectName
+                               << "</ObjectFileName>\n";
+    }
   }
   for (std::string const& config : this->Configurations) {
     std::string configUpper = cmSystemTools::UpperCase(config);
@@ -2688,6 +2694,11 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions(
     cudaOptions.AddFlag("GPUDebugInfo", "false");
   }
 
+  // The extension on object libraries the CUDA gives isn't
+  // consistent with how MSVC generates object libraries for C+, so set
+  // the default to not have any extension
+  cudaOptions.AddFlag("CompileOut", "$(IntDir)%(Filename).obj");
+
   bool notPtx = true;
   if (this->GeneratorTarget->GetPropertyAsBool("CUDA_SEPARABLE_COMPILATION")) {
     cudaOptions.AddFlag("GenerateRelocatableDeviceCode", "true");
diff --git a/Tests/Cuda/ObjectLibrary/CMakeLists.txt b/Tests/Cuda/ObjectLibrary/CMakeLists.txt
index 276dc92..da5fb87 100644
--- a/Tests/Cuda/ObjectLibrary/CMakeLists.txt
+++ b/Tests/Cuda/ObjectLibrary/CMakeLists.txt
@@ -1,15 +1,18 @@
 cmake_minimum_required(VERSION 3.7)
 project (CudaObjectLibrary CUDA CXX)
 #Goal for this example:
-
-#build a object files some with cuda and some without than
-#embed these into an executable
+#
+#Build C++ and CUDA object files and than use them to make an executable
+#Make sure that CMake logic to handle object output when multiple files
+#with the same name works
+add_subdirectory(Conflicts)
 
 add_library(CudaMixedObjectLib OBJECT static.cu static.cpp)
 
 add_executable(CudaObjectLibrary
                main.cpp
-               $<TARGET_OBJECTS:CudaMixedObjectLib>)
+               $<TARGET_OBJECTS:CudaMixedObjectLib>
+               $<TARGET_OBJECTS:CudaConflicts>)
 
 if(APPLE)
   # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
diff --git a/Tests/Cuda/ObjectLibrary/Conflicts/CMakeLists.txt b/Tests/Cuda/ObjectLibrary/Conflicts/CMakeLists.txt
new file mode 100644
index 0000000..1602f8a
--- /dev/null
+++ b/Tests/Cuda/ObjectLibrary/Conflicts/CMakeLists.txt
@@ -0,0 +1,2 @@
+
+add_library(CudaConflicts OBJECT static.cu)
diff --git a/Tests/Cuda/ObjectLibrary/static.cu b/Tests/Cuda/ObjectLibrary/Conflicts/static.cu
similarity index 62%
copy from Tests/Cuda/ObjectLibrary/static.cu
copy to Tests/Cuda/ObjectLibrary/Conflicts/static.cu
index aa35729..586e8c6 100644
--- a/Tests/Cuda/ObjectLibrary/static.cu
+++ b/Tests/Cuda/ObjectLibrary/Conflicts/static.cu
@@ -3,7 +3,7 @@
 #include <cuda_runtime.h>
 #include <iostream>
 
-int __host__ file1_sq_func(int x)
+int __host__ cu2_sq_func(int x)
 {
   cudaError_t err;
   int nDevices = 0;
@@ -13,9 +13,5 @@ int __host__ file1_sq_func(int x)
     std::cerr << "err: " << err << std::endl;
     return 1;
   }
-  std::cout << "this library uses cuda code" << std::endl;
-  std::cout << "you have " << nDevices << " devices that support cuda"
-            << std::endl;
-
   return x * x;
 }
diff --git a/Tests/Cuda/ObjectLibrary/main.cpp b/Tests/Cuda/ObjectLibrary/main.cpp
index 4d2f890..e28f088 100644
--- a/Tests/Cuda/ObjectLibrary/main.cpp
+++ b/Tests/Cuda/ObjectLibrary/main.cpp
@@ -1,22 +1,18 @@
 
 #include <iostream>
 
-int static_func(int);
-int file1_sq_func(int);
+int cpp_sq_func(int);
+int cu1_sq_func(int);
+int cu2_sq_func(int);
 
-int test_functions()
+bool test_functions()
 {
-  return file1_sq_func(static_func(42));
+  return (cu1_sq_func(42) == cpp_sq_func(42)) &&
+    (cu2_sq_func(42) == cpp_sq_func(42));
 }
 
 int main(int argc, char** argv)
 {
-  if (test_functions() == 1) {
-    return 1;
-  }
-  std::cout
-    << "this executable doesn't use cuda code, just call methods defined"
-    << std::endl;
-  std::cout << "in object files that have cuda code" << std::endl;
-  return 0;
+  int result = test_functions() ? 0 : 1;
+  return result;
 }
diff --git a/Tests/Cuda/ObjectLibrary/static.cpp b/Tests/Cuda/ObjectLibrary/static.cpp
index 6db1f91..527f7f5 100644
--- a/Tests/Cuda/ObjectLibrary/static.cpp
+++ b/Tests/Cuda/ObjectLibrary/static.cpp
@@ -1,6 +1,6 @@
 int file1_sq_func(int);
 
-int static_func(int x)
+int cpp_sq_func(int x)
 {
-  return file1_sq_func(x);
+  return x * x;
 }
diff --git a/Tests/Cuda/ObjectLibrary/static.cu b/Tests/Cuda/ObjectLibrary/static.cu
index aa35729..37bb839 100644
--- a/Tests/Cuda/ObjectLibrary/static.cu
+++ b/Tests/Cuda/ObjectLibrary/static.cu
@@ -3,7 +3,7 @@
 #include <cuda_runtime.h>
 #include <iostream>
 
-int __host__ file1_sq_func(int x)
+int __host__ cu1_sq_func(int x)
 {
   cudaError_t err;
   int nDevices = 0;
@@ -13,9 +13,5 @@ int __host__ file1_sq_func(int x)
     std::cerr << "err: " << err << std::endl;
     return 1;
   }
-  std::cout << "this library uses cuda code" << std::endl;
-  std::cout << "you have " << nDevices << " devices that support cuda"
-            << std::endl;
-
   return x * x;
 }

-----------------------------------------------------------------------

Summary of changes:
 Source/cmVisualStudio10TargetGenerator.cxx         |   17 ++++++++++++++---
 Tests/Cuda/ObjectLibrary/CMakeLists.txt            |   11 +++++++----
 Tests/Cuda/ObjectLibrary/Conflicts/CMakeLists.txt  |    2 ++
 Tests/Cuda/ObjectLibrary/{ => Conflicts}/static.cu |    6 +-----
 Tests/Cuda/ObjectLibrary/main.cpp                  |   20 ++++++++------------
 Tests/Cuda/ObjectLibrary/static.cpp                |    4 ++--
 Tests/Cuda/ObjectLibrary/static.cu                 |    6 +-----
 7 files changed, 35 insertions(+), 31 deletions(-)
 create mode 100644 Tests/Cuda/ObjectLibrary/Conflicts/CMakeLists.txt
 copy Tests/Cuda/ObjectLibrary/{ => Conflicts}/static.cu (62%)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list