[Cmake-commits] CMake branch, master, updated. v3.9.0-rc3-159-g396b618

Kitware Robot kwrobot at kitware.com
Thu Jun 22 10:05:08 EDT 2017


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  396b618c523d042df1c96cb08be1163e5c72d150 (commit)
       via  416e7919ec92d2899e27949132fce59a1926aeab (commit)
       via  a66f9bc0c4e3507b5478f8254585aa262f023171 (commit)
       via  9f3bf3cb9d014c3acce0709af7cce82554bc7a89 (commit)
       via  3b75421515835b2fc6713be3015cc3f7324bb5a8 (commit)
       via  f2059585e6302446707560b123c7b785df5f5859 (commit)
       via  fff782f6a64a64538254b23891dc00b18ecec4fe (commit)
       via  0db4c7a021437c1b2e0ec788bdda249417501490 (commit)
       via  51865fc67ecd61d9cbf984be0310f2e9fb8ff455 (commit)
      from  1218731a2a1f018f562808d7cd5ea857403dbad3 (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=396b618c523d042df1c96cb08be1163e5c72d150
commit 396b618c523d042df1c96cb08be1163e5c72d150
Merge: 416e791 3b75421
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Jun 22 14:04:34 2017 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Thu Jun 22 10:04:37 2017 -0400

    Merge topic 'vs-cuda-fix-flags'
    
    3b754215 VS: Improve workaround for CUDA -Xcompiler placement bug
    f2059585 VS: Fix target_compile_options for CUDA
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !996


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=416e7919ec92d2899e27949132fce59a1926aeab
commit 416e7919ec92d2899e27949132fce59a1926aeab
Merge: a66f9bc fff782f
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Jun 22 14:02:51 2017 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Thu Jun 22 10:03:02 2017 -0400

    Merge topic 'cuda-macos-rpath-in-tests'
    
    fff782f6 Tests: Simplify CUDA rpath on macOS
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !995


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a66f9bc0c4e3507b5478f8254585aa262f023171
commit a66f9bc0c4e3507b5478f8254585aa262f023171
Merge: 9f3bf3c 0db4c7a
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Jun 22 14:02:40 2017 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Thu Jun 22 10:02:43 2017 -0400

    Merge topic 'vs_fix_configuration_error'
    
    0db4c7a0 Tests: Verify registry value is not "/registry" before using
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !994


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9f3bf3cb9d014c3acce0709af7cce82554bc7a89
commit 9f3bf3cb9d014c3acce0709af7cce82554bc7a89
Merge: 1218731 51865fc
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Jun 22 13:58:23 2017 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Thu Jun 22 09:58:28 2017 -0400

    Merge topic 'vs_csharp_link_to_managed_cxx'
    
    51865fc6 Vs: allow CSharp targets to be linked to CXX targets
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !993


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3b75421515835b2fc6713be3015cc3f7324bb5a8
commit 3b75421515835b2fc6713be3015cc3f7324bb5a8
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Jun 21 14:15:23 2017 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Jun 21 14:24:11 2017 -0400

    VS: Improve workaround for CUDA -Xcompiler placement bug
    
    In commit v3.9.0-rc1~431^2~6 (VS: Place CUDA host compiler options in
    proper project file fields, 2017-03-07) we worked around a bug in the
    CUDA VS integration by dropping `AdditionalCompilerOptions`.  However,
    this silently drops `-Xcompiler=` options given by the user that don't
    map to one of CudaCompile's dedicated settings.  Improve the workaround
    to instead put the remaining `AdditionalCompilerOptions` into the
    `AdditionalOptions` field behind `-Xcompiler=` ourselves.

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

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f2059585e6302446707560b123c7b785df5f5859
commit f2059585e6302446707560b123c7b785df5f5859
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Jun 21 13:44:43 2017 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Jun 21 14:23:46 2017 -0400

    VS: Fix target_compile_options for CUDA
    
    Fix the VS generator to honor `COMPILE_OPTIONS` for CUDA.  The exclusion
    added by commit v3.9.0-rc1~431^2~7 (VS: Do not pass CUDA compile options
    to C compiler, 2017-03-07) was correct but we need additional logic to
    pass the CUDA compile options to the CUDA compiler.  Also we should
    still pass the CXX or C options to MSVC (ClCompile) when those languages
    are enabled even if the link language is CUDA.

diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 238c9e8..2a7d96b 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2,6 +2,7 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmVisualStudio10TargetGenerator.h"
 
+#include "cmAlgorithms.h"
 #include "cmComputeLinkInformation.h"
 #include "cmCustomCommandGenerator.h"
 #include "cmGeneratedFileStream.h"
@@ -2227,10 +2228,27 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
       this->Name.c_str());
     return false;
   }
-  if (linkLanguage == "C" || linkLanguage == "CXX" ||
-      linkLanguage == "Fortran" || linkLanguage == "CSharp") {
+
+  // Choose a language whose flags to use for ClCompile.
+  static const char* clLangs[] = { "CXX", "C", "Fortran", "CSharp" };
+  std::string langForClCompile;
+  if (std::find(cmArrayBegin(clLangs), cmArrayEnd(clLangs), linkLanguage) !=
+      cmArrayEnd(clLangs)) {
+    langForClCompile = linkLanguage;
+  } else {
+    std::set<std::string> languages;
+    this->GeneratorTarget->GetLanguages(languages, configName);
+    for (const char* const* l = cmArrayBegin(clLangs);
+         l != cmArrayEnd(clLangs); ++l) {
+      if (languages.find(*l) != languages.end()) {
+        langForClCompile = *l;
+        break;
+      }
+    }
+  }
+  if (!langForClCompile.empty()) {
     std::string baseFlagVar = "CMAKE_";
-    baseFlagVar += linkLanguage;
+    baseFlagVar += langForClCompile;
     baseFlagVar += "_FLAGS";
     flags =
       this->GeneratorTarget->Target->GetMakefile()->GetRequiredDefinition(
@@ -2241,6 +2259,8 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
     flags +=
       this->GeneratorTarget->Target->GetMakefile()->GetRequiredDefinition(
         flagVar.c_str());
+    this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget,
+                                            langForClCompile, configName);
   }
   // set the correct language
   if (linkLanguage == "C") {
@@ -2249,10 +2269,6 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
   if (linkLanguage == "CXX") {
     clOptions.AddFlag("CompileAs", "CompileAsCpp");
   }
-  if (linkLanguage != "CUDA") {
-    this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget,
-                                            linkLanguage, configName.c_str());
-  }
 
   // Check IPO related warning/error.
   this->GeneratorTarget->IsIPOEnabled(linkLanguage, configName);
@@ -2480,6 +2496,8 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions(
     std::string(this->Makefile->GetSafeDefinition("CMAKE_CUDA_FLAGS")) +
     std::string(" ") +
     std::string(this->Makefile->GetSafeDefinition(configFlagsVar));
+  this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, "CUDA",
+                                          configName);
 
   // Get preprocessor definitions for this directory.
   std::string defineFlags =
diff --git a/Tests/CudaOnly/WithDefs/CMakeLists.txt b/Tests/CudaOnly/WithDefs/CMakeLists.txt
index 38f2a44..e25f141 100644
--- a/Tests/CudaOnly/WithDefs/CMakeLists.txt
+++ b/Tests/CudaOnly/WithDefs/CMakeLists.txt
@@ -28,6 +28,7 @@ add_executable(CudaOnlyWithDefs ${main})
 
 target_compile_options(CudaOnlyWithDefs
   PRIVATE
+    -Xcompiler=-DHOST_DEFINE
     $<$<CONFIG:DEBUG>:$<BUILD_INTERFACE:${debug_compile_flags}>>
   )
 
diff --git a/Tests/CudaOnly/WithDefs/main.notcu b/Tests/CudaOnly/WithDefs/main.notcu
index 80ed3a5..d2eff3f 100644
--- a/Tests/CudaOnly/WithDefs/main.notcu
+++ b/Tests/CudaOnly/WithDefs/main.notcu
@@ -2,6 +2,10 @@
 #include <cuda_runtime.h>
 #include <iostream>
 
+#ifndef HOST_DEFINE
+#error "HOST_DEFINE not defined!"
+#endif
+
 #ifndef PACKED_DEFINE
 #error "PACKED_DEFINE not defined!"
 #endif

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fff782f6a64a64538254b23891dc00b18ecec4fe
commit fff782f6a64a64538254b23891dc00b18ecec4fe
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Jun 21 09:35:16 2017 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Jun 21 10:41:49 2017 -0400

    Tests: Simplify CUDA rpath on macOS
    
    Use the `BUILD_RPATH` property and reference the CMake-computed location
    of the runtime libraries.

diff --git a/Tests/Cuda/Complex/CMakeLists.txt b/Tests/Cuda/Complex/CMakeLists.txt
index 450ef48..a7137e3 100644
--- a/Tests/Cuda/Complex/CMakeLists.txt
+++ b/Tests/Cuda/Complex/CMakeLists.txt
@@ -42,7 +42,6 @@ add_executable(CudaComplex main.cpp)
 target_link_libraries(CudaComplex PUBLIC CudaComplexMixedLib)
 
 if(APPLE)
-  # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that
-  # the static cuda runtime can find it at runtime.
-  target_link_libraries(CudaComplex PRIVATE -Wl,-rpath,/usr/local/cuda/lib)
+  # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
+  set_property(TARGET CudaComplex PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
 endif()
diff --git a/Tests/Cuda/ObjectLibrary/CMakeLists.txt b/Tests/Cuda/ObjectLibrary/CMakeLists.txt
index 1d93be7..276dc92 100644
--- a/Tests/Cuda/ObjectLibrary/CMakeLists.txt
+++ b/Tests/Cuda/ObjectLibrary/CMakeLists.txt
@@ -10,8 +10,8 @@ add_library(CudaMixedObjectLib OBJECT static.cu static.cpp)
 add_executable(CudaObjectLibrary
                main.cpp
                $<TARGET_OBJECTS:CudaMixedObjectLib>)
+
 if(APPLE)
-  # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that
-  # the static cuda runtime can find it at runtime.
-  target_link_libraries(CudaObjectLibrary PRIVATE -Wl,-rpath,/usr/local/cuda/lib)
+  # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
+  set_property(TARGET CudaObjectLibrary PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
 endif()
diff --git a/Tests/Cuda/WithC/CMakeLists.txt b/Tests/Cuda/WithC/CMakeLists.txt
index 1f25ab4..831ce12 100644
--- a/Tests/Cuda/WithC/CMakeLists.txt
+++ b/Tests/Cuda/WithC/CMakeLists.txt
@@ -6,7 +6,6 @@ string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
 add_executable(CudaWithC main.c cuda.cu)
 
 if(APPLE)
-  # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that
-  # the static cuda runtime can find it at runtime.
-  target_link_libraries(CudaWithC PRIVATE -Wl,-rpath,/usr/local/cuda/lib)
+  # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
+  set_property(TARGET CudaWithC PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
 endif()
diff --git a/Tests/CudaOnly/ExportPTX/CMakeLists.txt b/Tests/CudaOnly/ExportPTX/CMakeLists.txt
index 10249c6..65d5243 100644
--- a/Tests/CudaOnly/ExportPTX/CMakeLists.txt
+++ b/Tests/CudaOnly/ExportPTX/CMakeLists.txt
@@ -67,9 +67,8 @@ target_compile_definitions(CudaOnlyExportPTX PRIVATE
                            "CONFIG_TYPE=gen_$<LOWER_CASE:$<CONFIG>>")
 
 if(APPLE)
-  # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that
-  # the static cuda runtime can find it at runtime.
-  target_link_libraries(CudaOnlyExportPTX PRIVATE -Wl,-rpath,/usr/local/cuda/lib)
+  # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
+  set_property(TARGET CudaOnlyExportPTX PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
 endif()
 
 #Verify that we can install object targets properly
diff --git a/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt b/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt
index b96bb98..8d6551b 100644
--- a/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt
+++ b/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt
@@ -46,7 +46,6 @@ add_executable(CudaOnlyResolveDeviceSymbols main.cu)
 target_link_libraries(CudaOnlyResolveDeviceSymbols PRIVATE CUDAResolveDeviceLib)
 
 if(APPLE)
-  # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that
-  # the static cuda runtime can find it at runtime.
-  target_link_libraries(CudaOnlyResolveDeviceSymbols PRIVATE -Wl,-rpath,/usr/local/cuda/lib)
+  # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
+  set_property(TARGET CudaOnlyResolveDeviceSymbols PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
 endif()
diff --git a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt
index 0a2542a..55fd79f 100644
--- a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt
+++ b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt
@@ -39,8 +39,7 @@ if (CMAKE_GENERATOR MATCHES "^Visual Studio")
                         PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
 endif()
 
-if (APPLE)
-  # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that
-  # the static cuda runtime can find it at runtime.
-  target_link_libraries(CudaOnlySeparateCompilation PRIVATE -Wl,-rpath,/usr/local/cuda/lib)
+if(APPLE)
+  # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
+  set_property(TARGET CudaOnlySeparateCompilation PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
 endif()
diff --git a/Tests/CudaOnly/WithDefs/CMakeLists.txt b/Tests/CudaOnly/WithDefs/CMakeLists.txt
index 38f2a44..fe0ccc6 100644
--- a/Tests/CudaOnly/WithDefs/CMakeLists.txt
+++ b/Tests/CudaOnly/WithDefs/CMakeLists.txt
@@ -36,8 +36,7 @@ target_compile_definitions(CudaOnlyWithDefs
     $<$<CONFIG:RELEASE>:$<BUILD_INTERFACE:${release_compile_defs}>>
   )
 
-#we need to add an rpath for the cuda library so that everything
-#loads properly on the mac
-if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
-  set_target_properties(CudaOnlyWithDefs PROPERTIES LINK_FLAGS "-Wl,-rpath,${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}")
+if(APPLE)
+  # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
+  set_property(TARGET CudaOnlyWithDefs PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
 endif()

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0db4c7a021437c1b2e0ec788bdda249417501490
commit 0db4c7a021437c1b2e0ec788bdda249417501490
Author:     Michael Stürmer <michael.stuermer at schaeffler.com>
AuthorDate: Wed Jun 21 10:44:54 2017 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Jun 21 08:49:42 2017 -0400

    Tests: Verify registry value is not "/registry" before using
    
    Fixes: #17002

diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index d138f58..4bc7839 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -2081,7 +2081,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
     set(reg_nasm "[HKEY_CURRENT_USER\\SOFTWARE\\nasm]")
     foreach(reg vs10 vs11 vs12 vs14 ws80 ws81 ws10_0 wp80 wp81 wince tegra nasm)
       get_filename_component(r "${reg_${reg}}" ABSOLUTE)
-      if(IS_DIRECTORY "${r}")
+      if(IS_DIRECTORY "${r}" AND NOT "${r}" STREQUAL "/registry")
         set(${reg} 1)
       else()
         set(${reg} 0)

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=51865fc67ecd61d9cbf984be0310f2e9fb8ff455
commit 51865fc67ecd61d9cbf984be0310f2e9fb8ff455
Author:     Michael Stürmer <michael.stuermer at schaeffler.com>
AuthorDate: Tue Jun 20 16:14:45 2017 +0200
Commit:     Michael Stürmer <michael.stuermer at schaeffler.com>
CommitDate: Wed Jun 21 08:37:15 2017 +0200

    Vs: allow CSharp targets to be linked to CXX targets
    
    Fixes: #16755

diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 238c9e8..f8534df 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -3475,10 +3475,6 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences()
           ->TargetIsFortranOnly(dt)) {
       continue;
     }
-    if (csproj == this->ProjectType &&
-        !this->GlobalGenerator->TargetIsCSharpOnly(dt)) {
-      continue;
-    }
     this->WriteString("<ProjectReference Include=\"", 2);
     cmLocalGenerator* lg = dt->GetLocalGenerator();
     std::string name = dt->GetName();
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index d138f58..d16df1c 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -331,6 +331,7 @@ if(BUILD_TESTING)
 
   if(${CMAKE_GENERATOR} MATCHES "Visual Studio ([^89]|[89][0-9])")
     ADD_TEST_MACRO(CSharpOnly CSharpOnly)
+    ADD_TEST_MACRO(CSharpLinkToCxx CSharpLinkToCxx)
   endif()
 
   ADD_TEST_MACRO(COnly COnly)
diff --git a/Tests/CSharpLinkToCxx/CMakeLists.txt b/Tests/CSharpLinkToCxx/CMakeLists.txt
new file mode 100644
index 0000000..c4269e0
--- /dev/null
+++ b/Tests/CSharpLinkToCxx/CMakeLists.txt
@@ -0,0 +1,17 @@
+# test if CSharp application correctly links
+# to managed C++ binary
+cmake_minimum_required(VERSION 3.9)
+project (CSharpLinkToCxx CXX CSharp)
+
+# we have to change the default flags for the
+# managed C++ project to build
+string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
+string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
+
+add_library(CLIApp SHARED cli.hpp cli.cpp)
+
+target_compile_options(CLIApp PRIVATE "/clr")
+
+add_executable(CSharpLinkToCxx csharp.cs)
+
+target_link_libraries(CSharpLinkToCxx CLIApp)
diff --git a/Tests/CSharpLinkToCxx/cli.cpp b/Tests/CSharpLinkToCxx/cli.cpp
new file mode 100644
index 0000000..97ac724
--- /dev/null
+++ b/Tests/CSharpLinkToCxx/cli.cpp
@@ -0,0 +1,10 @@
+#include "cli.hpp"
+
+using namespace System;
+
+namespace CLIApp {
+void MyCli::testMyCli()
+{
+  Console::WriteLine("#message from CLIApp");
+}
+}
diff --git a/Tests/CSharpLinkToCxx/cli.hpp b/Tests/CSharpLinkToCxx/cli.hpp
new file mode 100644
index 0000000..a8c116d
--- /dev/null
+++ b/Tests/CSharpLinkToCxx/cli.hpp
@@ -0,0 +1,10 @@
+#pragma once
+
+namespace CLIApp {
+public
+ref class MyCli
+{
+public:
+  void testMyCli();
+};
+}
diff --git a/Tests/CSharpLinkToCxx/csharp.cs b/Tests/CSharpLinkToCxx/csharp.cs
new file mode 100644
index 0000000..35c5cc3
--- /dev/null
+++ b/Tests/CSharpLinkToCxx/csharp.cs
@@ -0,0 +1,16 @@
+using System;
+using CLIApp;
+
+namespace CSharpLinkToCxx
+{
+  internal class CSharpLinkToCxx
+  {
+    public static void Main(string[] args)
+    {
+      Console.WriteLine("#message from CSharpLinkToCxx");
+
+      var app = new MyCli();
+      app.testMyCli();
+    }
+  }
+}

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

Summary of changes:
 Source/cmVisualStudio10TargetGenerator.cxx         |   49 ++++++++++++++------
 Tests/CMakeLists.txt                               |    3 +-
 Tests/CSharpLinkToCxx/CMakeLists.txt               |   17 +++++++
 Tests/CSharpLinkToCxx/cli.cpp                      |   10 ++++
 Tests/CSharpLinkToCxx/cli.hpp                      |   10 ++++
 Tests/CSharpLinkToCxx/csharp.cs                    |   16 +++++++
 Tests/Cuda/Complex/CMakeLists.txt                  |    5 +-
 Tests/Cuda/ObjectLibrary/CMakeLists.txt            |    6 +--
 Tests/Cuda/WithC/CMakeLists.txt                    |    5 +-
 Tests/CudaOnly/ExportPTX/CMakeLists.txt            |    5 +-
 Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt |    5 +-
 Tests/CudaOnly/SeparateCompilation/CMakeLists.txt  |   11 +++--
 Tests/CudaOnly/WithDefs/CMakeLists.txt             |    8 ++--
 Tests/CudaOnly/WithDefs/main.notcu                 |    4 ++
 14 files changed, 116 insertions(+), 38 deletions(-)
 create mode 100644 Tests/CSharpLinkToCxx/CMakeLists.txt
 create mode 100644 Tests/CSharpLinkToCxx/cli.cpp
 create mode 100644 Tests/CSharpLinkToCxx/cli.hpp
 create mode 100644 Tests/CSharpLinkToCxx/csharp.cs


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list