[Cmake-commits] CMake branch, master, updated. v3.9.0-rc4-171-gb43d0fd

Kitware Robot kwrobot at kitware.com
Tue Jun 27 09:25:05 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  b43d0fd04b635a5de56d104d7dc1ab908b739c00 (commit)
       via  126effbb9c345ccea9823f81c5323e7de1a6402c (commit)
       via  4fd6507a528ab1a9858eee2914e8d5a2b92bffdb (commit)
       via  33d6145f873029577e3498b843b6ef5646c594b8 (commit)
       via  43c3afa74538fd7b78bcf534bfb3fa93c3c1f191 (commit)
       via  dc11a20d7b308f15cc0080f6c14ea06d96dbc2c7 (commit)
       via  fd771df773224560a60850647b898280a0ec84fa (commit)
       via  1d86103846d4e8557c3cc77d3c1f2dce9231663d (commit)
       via  bbc1f3642cb86ce59908ee33eeb409d7921f73f8 (commit)
       via  a3e442bbfc8374c90aec9836ee40aa35a43c1bc2 (commit)
       via  e03a1b3b6185e36a5905db3d2551c9575fb074aa (commit)
       via  869904271ba0e8b855043894360b5dc7fe1e3b56 (commit)
       via  46d25e782ebd9b6c50771b6f30433c58fae03a51 (commit)
       via  ec409a116fd58a541a7700df12dfdfc045f0df17 (commit)
       via  dcdab5cf23b3777761d6c6dcaf0dfcefdd821792 (commit)
       via  0a8f469af921d64431ed237022a02d39cac3ebb5 (commit)
      from  b8858bd4046958b94b11e794e2a9aab9124414a4 (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=b43d0fd04b635a5de56d104d7dc1ab908b739c00
commit b43d0fd04b635a5de56d104d7dc1ab908b739c00
Merge: 126effb fd771df
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Jun 27 09:23:18 2017 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Jun 27 09:23:18 2017 -0400

    Merge branch 'release-3.9'


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=126effbb9c345ccea9823f81c5323e7de1a6402c
commit 126effbb9c345ccea9823f81c5323e7de1a6402c
Merge: 4fd6507 ec409a1
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Jun 27 13:21:17 2017 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Jun 27 09:21:38 2017 -0400

    Merge topic 'vs_csharp_custom_command'
    
    ec409a11 Vs: fix CSharp custom command by introducing inline MSBuild <Targets>s
    dcdab5cf Vs: factor out computation of <Link> tag for CSharp source files
    0a8f469a Vs: refactor WriteCustomRule for preparation of CSharp support
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !970


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4fd6507a528ab1a9858eee2914e8d5a2b92bffdb
commit 4fd6507a528ab1a9858eee2914e8d5a2b92bffdb
Merge: 33d6145 a3e442b
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Jun 27 13:21:02 2017 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Jun 27 09:21:15 2017 -0400

    Merge topic 'FindCUDA-no-empty-genex'
    
    a3e442bb FindCUDA: Fix CUDA_NVCC_FLAGS_<CONFIG> for separable compilation
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !1008


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=33d6145f873029577e3498b843b6ef5646c594b8
commit 33d6145f873029577e3498b843b6ef5646c594b8
Merge: 43c3afa 46d25e7
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Jun 27 13:20:42 2017 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Jun 27 09:20:51 2017 -0400

    Merge topic 'FindCUDA-no-find_host_program'
    
    46d25e78 FindCUDA: Use find_program if find_host_program is not available
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !1009


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=43c3afa74538fd7b78bcf534bfb3fa93c3c1f191
commit 43c3afa74538fd7b78bcf534bfb3fa93c3c1f191
Merge: dc11a20 e03a1b3
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Jun 27 13:20:28 2017 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Jun 27 09:20:32 2017 -0400

    Merge topic 'fix-crash-on-non-enabled-language-features'
    
    e03a1b3b target_compile_features: Do not crash on non-enabled language
    86990427 Tests: Enable languages explicitly in RunCMake.target_compile_features
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !1010


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dc11a20d7b308f15cc0080f6c14ea06d96dbc2c7
commit dc11a20d7b308f15cc0080f6c14ea06d96dbc2c7
Merge: b8858bd bbc1f36
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Jun 27 13:18:26 2017 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Jun 27 09:18:34 2017 -0400

    Merge topic 'vs-cuda-fix-flags'
    
    bbc1f364 VS: Fix support for nvcc flags not in our flag table
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !1007


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a3e442bbfc8374c90aec9836ee40aa35a43c1bc2
commit a3e442bbfc8374c90aec9836ee40aa35a43c1bc2
Author:     Robert Maynard <robert.maynard at kitware.com>
AuthorDate: Mon Jun 26 10:41:03 2017 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Jun 26 14:59:05 2017 -0400

    FindCUDA: Fix CUDA_NVCC_FLAGS_<CONFIG> for separable compilation
    
    Since commit v3.0.0-rc6~3^2 (FindCUDA: Use CUDA_NVCC_FLAGS* for
    separable compilation, 2014-05-18), using the feature for one
    configuration results in empty-string ("") arguments on the command line
    for other configurations.  This is because the generator expression for
    a non-matching configuration evaluates to an empty string but does not
    remove the argument.  Use `COMMAND_EXPAND_LISTS` to remove the empty
    arguments from the custom command after genex evaluation.
    
    Fixes: #16411

diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake
index a4dca54..7f1ff57 100644
--- a/Modules/FindCUDA.cmake
+++ b/Modules/FindCUDA.cmake
@@ -1698,6 +1698,7 @@ function(CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS output_file cuda_target options
         COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} -dlink ${object_files} -o ${output_file}
         ${flags}
         COMMENT "Building NVCC intermediate link file ${output_file_relative_path}"
+        COMMAND_EXPAND_LISTS
         ${_verbatim}
         )
     else()
@@ -1708,6 +1709,7 @@ function(CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS output_file cuda_target options
         COMMAND ${CMAKE_COMMAND} -E echo "Building NVCC intermediate link file ${output_file_relative_path}"
         COMMAND ${CMAKE_COMMAND} -E make_directory "${output_file_dir}"
         COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} ${flags} -dlink ${object_files} -o "${output_file}"
+        COMMAND_EXPAND_LISTS
         ${_verbatim}
         )
     endif()

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=46d25e782ebd9b6c50771b6f30433c58fae03a51
commit 46d25e782ebd9b6c50771b6f30433c58fae03a51
Author:     Maxime Roussin-Bélanger <maxime.roussinbelanger at gmail.com>
AuthorDate: Mon Jun 26 11:30:07 2017 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Jun 26 13:10:54 2017 -0400

    FindCUDA: Use find_program if find_host_program is not available
    
    CMake does not define the `find_host_program` command we've been using
    in the cross-compiling code path.  It was provided by a widely used
    Android toolchain file.  For compatibility, continue to use
    `find_host_program` if available, but otherwise use just `find_program`.
    
    Fixes: #16509

diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake
index a4dca54..77ca351 100644
--- a/Modules/FindCUDA.cmake
+++ b/Modules/FindCUDA.cmake
@@ -679,7 +679,11 @@ if(CMAKE_CROSSCOMPILING)
   # add known CUDA targetr root path to the set of directories we search for programs, libraries and headers
   set( CMAKE_FIND_ROOT_PATH "${CUDA_TOOLKIT_TARGET_DIR};${CMAKE_FIND_ROOT_PATH}")
   macro( cuda_find_host_program )
-    find_host_program( ${ARGN} )
+    if (COMMAND find_host_program)
+      find_host_program( ${ARGN} )
+    else()
+      find_program( ${ARGN} )
+    endif()
   endmacro()
 else()
   # for non-cross-compile, find_host_program == find_program and CUDA_TOOLKIT_TARGET_DIR == CUDA_TOOLKIT_ROOT_DIR

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ec409a116fd58a541a7700df12dfdfc045f0df17
commit ec409a116fd58a541a7700df12dfdfc045f0df17
Author:     Michael Stürmer <michael.stuermer at schaeffler.com>
AuthorDate: Thu Jun 22 21:40:48 2017 +0200
Commit:     Michael Stürmer <michael.stuermer at schaeffler.com>
CommitDate: Thu Jun 22 21:40:48 2017 +0200

    Vs: fix CSharp custom command by introducing inline MSBuild <Targets>s
    
    The custom command implementation is based on the Microsoft support article:
    
    https://docs.microsoft.com/en-us/visualstudio/msbuild/how-to-extend-the-visual-studio-build-process
    
    Fixes: #16960

diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 9612c90..dbd4571 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -27,6 +27,12 @@ static std::string cmVS10EscapeXML(std::string arg)
   return arg;
 }
 
+static std::string cmVS10EscapeQuotes(std::string arg)
+{
+  cmSystemTools::ReplaceString(arg, "\"", """);
+  return arg;
+}
+
 static std::string cmVS10EscapeComment(std::string comment)
 {
   // MSBuild takes the CDATA of a <Message></Message> element and just
@@ -578,6 +584,18 @@ void cmVisualStudio10TargetGenerator::Generate()
       this->WriteEvents(*i);
       this->WriteString("</PropertyGroup>\n", 1);
     }
+    // make sure custom commands are executed before build (if necessary)
+    this->WriteString("<PropertyGroup>\n", 1);
+    this->WriteString("<BuildDependsOn>\n", 2);
+    for (std::set<std::string>::const_iterator i =
+           this->CSharpCustomCommandNames.begin();
+         i != this->CSharpCustomCommandNames.end(); ++i) {
+      this->WriteString(i->c_str(), 3);
+      (*this->BuildFileStream) << ";\n";
+    }
+    this->WriteString("$(BuildDependsOn)\n", 3);
+    this->WriteString("</BuildDependsOn>\n", 2);
+    this->WriteString("</PropertyGroup>\n", 1);
   }
   this->WriteString("</Project>", 0);
   // The groups are stored in a separate file for VS 10
@@ -1151,6 +1169,7 @@ void cmVisualStudio10TargetGenerator::WriteNsightTegraConfigurationValues(
 void cmVisualStudio10TargetGenerator::WriteCustomCommands()
 {
   this->SourcesVisited.clear();
+  this->CSharpCustomCommandNames.clear();
   std::vector<cmSourceFile const*> customCommands;
   this->GeneratorTarget->GetCustomCommands(customCommands, "");
   for (std::vector<cmSourceFile const*>::const_iterator si =
@@ -1172,9 +1191,14 @@ void cmVisualStudio10TargetGenerator::WriteCustomCommand(
       }
     }
     if (cmCustomCommand const* command = sf->GetCustomCommand()) {
-      this->WriteString("<ItemGroup>\n", 1);
+      // C# projects write their <Target> within WriteCustomRule()
+      if (this->ProjectType != csproj) {
+        this->WriteString("<ItemGroup>\n", 1);
+      }
       this->WriteCustomRule(sf, *command);
-      this->WriteString("</ItemGroup>\n", 1);
+      if (this->ProjectType != csproj) {
+        this->WriteString("</ItemGroup>\n", 1);
+      }
     }
   }
 }
@@ -1209,8 +1233,20 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule(
   }
   cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
 
-  this->WriteSource("CustomBuild", source, ">\n");
-
+  if (this->ProjectType != csproj) {
+    this->WriteSource("CustomBuild", source, ">\n");
+  } else {
+    this->WriteString("<ItemGroup>\n", 1);
+    std::string link;
+    this->GetCSharpSourceLink(source, link);
+    this->WriteSource("None", source, ">\n");
+    if (!link.empty()) {
+      this->WriteString("<Link>", 3);
+      (*this->BuildFileStream) << link << "</Link>\n";
+    }
+    this->WriteString("</None>\n", 2);
+    this->WriteString("</ItemGroup>\n", 1);
+  }
   for (std::vector<std::string>::const_iterator i =
          this->Configurations.begin();
        i != this->Configurations.end(); ++i) {
@@ -1240,9 +1276,25 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule(
       outputs << sep << cmVS10EscapeXML(out);
       sep = ";";
     }
-    this->WriteCustomRuleCpp(*i, script, inputs.str(), outputs.str(), comment);
+    if (this->ProjectType == csproj) {
+      std::string name = "CustomCommand_" + *i + "_" +
+        cmSystemTools::ComputeStringMD5(sourcePath);
+      std::string inputs_s = inputs.str();
+      std::string outputs_s = outputs.str();
+      comment = cmVS10EscapeQuotes(comment);
+      script = cmVS10EscapeQuotes(script);
+      inputs_s = cmVS10EscapeQuotes(inputs_s);
+      outputs_s = cmVS10EscapeQuotes(outputs_s);
+      this->WriteCustomRuleCSharp(*i, name, script, inputs_s, outputs_s,
+                                  comment);
+    } else {
+      this->WriteCustomRuleCpp(*i, script, inputs.str(), outputs.str(),
+                               comment);
+    }
+  }
+  if (this->ProjectType != csproj) {
+    this->WriteString("</CustomBuild>\n", 2);
   }
-  this->WriteString("</CustomBuild>\n", 2);
 }
 
 void cmVisualStudio10TargetGenerator::WriteCustomRuleCpp(
@@ -1267,6 +1319,28 @@ void cmVisualStudio10TargetGenerator::WriteCustomRuleCpp(
   }
 }
 
+void cmVisualStudio10TargetGenerator::WriteCustomRuleCSharp(
+  std::string const& config, std::string const& name,
+  std::string const& script, std::string const& inputs,
+  std::string const& outputs, std::string const& comment)
+{
+  this->CSharpCustomCommandNames.insert(name);
+  std::stringstream attributes;
+  attributes << "\n    Name=\"" << name << "\"";
+  attributes << "\n    Inputs=\"" << inputs << "\"";
+  attributes << "\n    Outputs=\"" << outputs << "\"";
+  this->WritePlatformConfigTag("Target", config, 1, attributes.str().c_str(),
+                               "\n");
+  if (!comment.empty()) {
+    this->WriteString("<Exec Command=\"", 2);
+    (*this->BuildFileStream) << "echo " << cmVS10EscapeXML(comment)
+                             << "\" />\n";
+  }
+  this->WriteString("<Exec Command=\"", 2);
+  (*this->BuildFileStream) << script << "\" />\n";
+  this->WriteString("</Target>\n", 1);
+}
+
 std::string cmVisualStudio10TargetGenerator::ConvertPath(
   std::string const& path, bool forceRelative)
 {
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index 2518d5e..2d98994 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -131,6 +131,12 @@ private:
                           std::string const& inputs,
                           std::string const& outputs,
                           std::string const& comment);
+  void WriteCustomRuleCSharp(std::string const& config,
+                             std::string const& commandName,
+                             std::string const& script,
+                             std::string const& inputs,
+                             std::string const& outputs,
+                             std::string const& comment);
   void WriteCustomCommands();
   void WriteCustomCommand(cmSourceFile const* sf);
   void WriteGroups();
@@ -198,6 +204,7 @@ private:
   cmGeneratedFileStream* BuildFileStream;
   cmLocalVisualStudio7Generator* LocalGenerator;
   std::set<cmSourceFile const*> SourcesVisited;
+  std::set<std::string> CSharpCustomCommandNames;
   bool IsMissingFiles;
   std::vector<std::string> AddedFiles;
   std::string DefaultArtifactDir;
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 0369fa4..702ca17 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -376,3 +376,7 @@ if(CMake_TEST_ANDROID_NDK OR CMake_TEST_ANDROID_STANDALONE_TOOLCHAIN)
   endif()
   set_property(TEST RunCMake.Android PROPERTY TIMEOUT ${CMake_TEST_ANDROID_TIMEOUT})
 endif()
+
+if(${CMAKE_GENERATOR} MATCHES "Visual Studio ([^89]|[89][0-9])")
+  add_RunCMake_test(CSharpCustomCommand)
+endif()
diff --git a/Tests/RunCMake/CSharpCustomCommand/CMakeLists.txt b/Tests/RunCMake/CSharpCustomCommand/CMakeLists.txt
new file mode 100644
index 0000000..74b3ff8
--- /dev/null
+++ b/Tests/RunCMake/CSharpCustomCommand/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.3)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CSharpCustomCommand/CommandWithOutput-check.cmake b/Tests/RunCMake/CSharpCustomCommand/CommandWithOutput-check.cmake
new file mode 100644
index 0000000..60d77eb
--- /dev/null
+++ b/Tests/RunCMake/CSharpCustomCommand/CommandWithOutput-check.cmake
@@ -0,0 +1,21 @@
+if(checkLevel EQUAL 0)
+  message("checking generation (${srcName} does not exist)")
+  if(EXISTS "${generatedFileName}")
+    set(RunCMake_TEST_FAILED "file \"${generatedFileName}\" should not exist")
+  endif()
+elseif(checkLevel EQUAL 1)
+  message("checking build 1 (generate ${srcName})")
+  if(NOT "${actual_stdout}" MATCHES "${commandComment}")
+    set(RunCMake_TEST_FAILED "command not executed")
+  endif()
+elseif(checkLevel EQUAL 2)
+  message("checking build 2 (no change in ${srcName}.in)")
+  if("${actual_stdout}" MATCHES "${commandComment}")
+    set(RunCMake_TEST_FAILED "command executed")
+  endif()
+elseif(checkLevel EQUAL 3)
+  message("checking build 3 (update ${srcName})")
+  if(NOT "${actual_stdout}" MATCHES "${commandComment}")
+    set(RunCMake_TEST_FAILED "command not executed")
+  endif()
+endif()
diff --git a/Tests/RunCMake/CSharpCustomCommand/CommandWithOutput.cmake b/Tests/RunCMake/CSharpCustomCommand/CommandWithOutput.cmake
new file mode 100644
index 0000000..68341fa
--- /dev/null
+++ b/Tests/RunCMake/CSharpCustomCommand/CommandWithOutput.cmake
@@ -0,0 +1,13 @@
+enable_language(CSharp)
+
+add_executable(CSharpCustomCommand dummy.cs)
+
+add_custom_command(OUTPUT ${generatedFileName}
+  COMMAND ${CMAKE_COMMAND} -E copy_if_different
+    ${inputFileName} ${generatedFileName}
+  MAIN_DEPENDENCY ${inputFileName}
+  COMMENT "${commandComment}")
+
+target_sources(CSharpCustomCommand PRIVATE
+  ${inputFileName}
+  ${generatedFileName})
diff --git a/Tests/RunCMake/CSharpCustomCommand/RunCMakeTest.cmake b/Tests/RunCMake/CSharpCustomCommand/RunCMakeTest.cmake
new file mode 100644
index 0000000..fa5618a
--- /dev/null
+++ b/Tests/RunCMake/CSharpCustomCommand/RunCMakeTest.cmake
@@ -0,0 +1,34 @@
+include(RunCMake)
+
+# Use a single build tree for a few tests without cleaning.
+set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CommandWithOutput-build)
+set(RunCMake_TEST_NO_CLEAN 1)
+file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+set(RunCMake-check-file CommandWithOutput-check.cmake)
+
+set(srcName "test.cs")
+set(srcFileName "${CMAKE_CURRENT_LIST_DIR}/${srcName}.in")
+set(inputFileName "${RunCMake_TEST_BINARY_DIR}/${srcName}.in")
+set(generatedFileName "${RunCMake_TEST_BINARY_DIR}/${srcName}")
+set(commandComment "Generating ${srcName}")
+
+# copy the input file to build dir to avoid changing files in cmake
+# source tree.
+file(COPY "${srcFileName}" DESTINATION "${RunCMake_TEST_BINARY_DIR}")
+
+set(RunCMake_TEST_OPTIONS ${RunCMake_TEST_OPTIONS}
+  "-DinputFileName=${inputFileName}"
+  "-DgeneratedFileName=${generatedFileName}"
+  "-DcommandComment=${commandComment}")
+
+set(checkLevel 0)
+run_cmake(CommandWithOutput)
+set(checkLevel 1)
+run_cmake_command(CommandWithOutput-build1 ${CMAKE_COMMAND} --build . --config Debug)
+set(checkLevel 2)
+run_cmake_command(CommandWithOutput-build2 ${CMAKE_COMMAND} --build . --config Debug)
+# change file content to trigger custom command with next build
+file(APPEND ${inputFileName} "\n")
+set(checkLevel 3)
+run_cmake_command(CommandWithOutput-build3 ${CMAKE_COMMAND} --build . --config Debug)
diff --git a/Tests/RunCMake/CSharpCustomCommand/dummy.cs b/Tests/RunCMake/CSharpCustomCommand/dummy.cs
new file mode 100644
index 0000000..e69de29
diff --git a/Tests/RunCMake/CSharpCustomCommand/test.cs.in b/Tests/RunCMake/CSharpCustomCommand/test.cs.in
new file mode 100644
index 0000000..05a7531
--- /dev/null
+++ b/Tests/RunCMake/CSharpCustomCommand/test.cs.in
@@ -0,0 +1,8 @@
+class TestCs
+{
+  public static int Main(string[] args)
+  {
+    System.Console.WriteLine("Test C#");
+    return 0;
+  }
+}

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dcdab5cf23b3777761d6c6dcaf0dfcefdd821792
commit dcdab5cf23b3777761d6c6dcaf0dfcefdd821792
Author:     Michael Stürmer <michael.stuermer at schaeffler.com>
AuthorDate: Sat Jun 17 09:32:19 2017 +0200
Commit:     Michael Stürmer <michael.stuermer at schaeffler.com>
CommitDate: Thu Jun 22 21:39:37 2017 +0200

    Vs: factor out computation of <Link> tag for CSharp source files

diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index d163ddb..9612c90 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2056,14 +2056,10 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
     typedef std::map<std::string, std::string> CsPropMap;
     CsPropMap sourceFileTags;
     // set <Link> tag if necessary
-    if (!this->InSourceBuild) {
-      const std::string stripFromPath =
-        this->Makefile->GetCurrentSourceDirectory();
-      if (f.find(stripFromPath) != std::string::npos) {
-        std::string link = f.substr(stripFromPath.length() + 1);
-        this->ConvertToWindowsSlash(link);
-        sourceFileTags["Link"] = link;
-      }
+    std::string link;
+    this->GetCSharpSourceLink(source, link);
+    if (!link.empty()) {
+      sourceFileTags["Link"] = link;
     }
     this->GetCSharpSourceProperties(&sf, sourceFileTags);
     // write source file specific tags
@@ -4380,6 +4376,23 @@ void cmVisualStudio10TargetGenerator::WriteCSharpSourceProperties(
   }
 }
 
+void cmVisualStudio10TargetGenerator::GetCSharpSourceLink(
+  cmSourceFile const* sf, std::string& link)
+{
+  std::string f = sf->GetFullPath();
+  if (!this->InSourceBuild) {
+    const std::string stripFromPath =
+      this->Makefile->GetCurrentSourceDirectory();
+    if (f.find(stripFromPath) != std::string::npos) {
+      link = f.substr(stripFromPath.length() + 1);
+      if (const char* l = sf->GetProperty("VS_CSHARP_Link")) {
+        link = l;
+      }
+      this->ConvertToWindowsSlash(link);
+    }
+  }
+}
+
 std::string cmVisualStudio10TargetGenerator::GetCMakeFilePath(
   const char* relativeFilePath) const
 {
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index 007c6fa..2518d5e 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -162,6 +162,7 @@ private:
                                  std::map<std::string, std::string>& tags);
   void WriteCSharpSourceProperties(
     const std::map<std::string, std::string>& tags);
+  void GetCSharpSourceLink(cmSourceFile const* sf, std::string& link);
 
 private:
   typedef cmVisualStudioGeneratorOptions Options;

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0a8f469af921d64431ed237022a02d39cac3ebb5
commit 0a8f469af921d64431ed237022a02d39cac3ebb5
Author:     Michael Stürmer <michael.stuermer at schaeffler.com>
AuthorDate: Thu Jun 15 14:30:29 2017 +0200
Commit:     Michael Stürmer <michael.stuermer at schaeffler.com>
CommitDate: Thu Jun 22 16:52:37 2017 +0200

    Vs: refactor WriteCustomRule for preparation of CSharp support

diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 6d796be..d163ddb 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -1218,43 +1218,55 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule(
     std::string comment = lg->ConstructComment(ccg);
     comment = cmVS10EscapeComment(comment);
     std::string script = cmVS10EscapeXML(lg->ConstructScript(ccg));
-    this->WritePlatformConfigTag("Message", i->c_str(), 3);
-    (*this->BuildFileStream) << cmVS10EscapeXML(comment) << "</Message>\n";
-    this->WritePlatformConfigTag("Command", i->c_str(), 3);
-    (*this->BuildFileStream) << script << "</Command>\n";
-    this->WritePlatformConfigTag("AdditionalInputs", i->c_str(), 3);
-
-    (*this->BuildFileStream) << cmVS10EscapeXML(source->GetFullPath());
+    // input files for custom command
+    std::stringstream inputs;
+    inputs << cmVS10EscapeXML(source->GetFullPath());
     for (std::vector<std::string>::const_iterator d = ccg.GetDepends().begin();
          d != ccg.GetDepends().end(); ++d) {
       std::string dep;
       if (this->LocalGenerator->GetRealDependency(d->c_str(), i->c_str(),
                                                   dep)) {
         this->ConvertToWindowsSlash(dep);
-        (*this->BuildFileStream) << ";" << cmVS10EscapeXML(dep);
+        inputs << ";" << cmVS10EscapeXML(dep);
       }
     }
-    (*this->BuildFileStream) << ";%(AdditionalInputs)</AdditionalInputs>\n";
-    this->WritePlatformConfigTag("Outputs", i->c_str(), 3);
+    // output files for custom command
+    std::stringstream outputs;
     const char* sep = "";
     for (std::vector<std::string>::const_iterator o = ccg.GetOutputs().begin();
          o != ccg.GetOutputs().end(); ++o) {
       std::string out = *o;
       this->ConvertToWindowsSlash(out);
-      (*this->BuildFileStream) << sep << cmVS10EscapeXML(out);
+      outputs << sep << cmVS10EscapeXML(out);
       sep = ";";
     }
-    (*this->BuildFileStream) << "</Outputs>\n";
-    if (this->LocalGenerator->GetVersion() >
-        cmGlobalVisualStudioGenerator::VS10) {
-      // VS >= 11 let us turn off linking of custom command outputs.
-      this->WritePlatformConfigTag("LinkObjects", i->c_str(), 3);
-      (*this->BuildFileStream) << "false</LinkObjects>\n";
-    }
+    this->WriteCustomRuleCpp(*i, script, inputs.str(), outputs.str(), comment);
   }
   this->WriteString("</CustomBuild>\n", 2);
 }
 
+void cmVisualStudio10TargetGenerator::WriteCustomRuleCpp(
+  std::string const& config, std::string const& script,
+  std::string const& inputs, std::string const& outputs,
+  std::string const& comment)
+{
+  this->WritePlatformConfigTag("Message", config, 3);
+  (*this->BuildFileStream) << cmVS10EscapeXML(comment) << "</Message>\n";
+  this->WritePlatformConfigTag("Command", config, 3);
+  (*this->BuildFileStream) << script << "</Command>\n";
+  this->WritePlatformConfigTag("AdditionalInputs", config, 3);
+  (*this->BuildFileStream) << inputs;
+  (*this->BuildFileStream) << ";%(AdditionalInputs)</AdditionalInputs>\n";
+  this->WritePlatformConfigTag("Outputs", config, 3);
+  (*this->BuildFileStream) << outputs << "</Outputs>\n";
+  if (this->LocalGenerator->GetVersion() >
+      cmGlobalVisualStudioGenerator::VS10) {
+    // VS >= 11 let us turn off linking of custom command outputs.
+    this->WritePlatformConfigTag("LinkObjects", config, 3);
+    (*this->BuildFileStream) << "false</LinkObjects>\n";
+  }
+}
+
 std::string cmVisualStudio10TargetGenerator::ConvertPath(
   std::string const& path, bool forceRelative)
 {
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index 0852459..007c6fa 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -127,6 +127,10 @@ private:
   void OutputLinkIncremental(std::string const& configName);
   void WriteCustomRule(cmSourceFile const* source,
                        cmCustomCommand const& command);
+  void WriteCustomRuleCpp(std::string const& config, std::string const& script,
+                          std::string const& inputs,
+                          std::string const& outputs,
+                          std::string const& comment);
   void WriteCustomCommands();
   void WriteCustomCommand(cmSourceFile const* sf);
   void WriteGroups();

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

Summary of changes:
 Modules/FindCUDA.cmake                             |    8 +-
 Source/cmMakefile.cxx                              |   21 ++-
 Source/cmVisualStudio10TargetGenerator.cxx         |  165 ++++++++++++++++----
 Source/cmVisualStudio10TargetGenerator.h           |   12 ++
 Tests/CudaOnly/SeparateCompilation/CMakeLists.txt  |    5 +
 Tests/RunCMake/CMakeLists.txt                      |    4 +
 .../CMakeLists.txt                                 |    0
 .../CommandWithOutput-check.cmake                  |   21 +++
 .../CSharpCustomCommand/CommandWithOutput.cmake    |   13 ++
 .../CSharpCustomCommand/RunCMakeTest.cmake         |   34 ++++
 .../RunCMake/CSharpCustomCommand/dummy.cs          |    0
 Tests/RunCMake/CSharpCustomCommand/test.cs.in      |    8 +
 .../target_compile_features/CMakeLists.txt         |    2 +-
 .../target_compile_features/RunCMakeTest.cmake     |    1 +
 .../alias_target-stderr.txt                        |    2 +-
 .../target_compile_features/alias_target.cmake     |    1 +
 .../cxx_not_enabled-result.txt}                    |    0
 .../cxx_not_enabled-stderr.txt                     |    4 +
 .../target_compile_features/cxx_not_enabled.cmake  |    2 +
 .../imported_target-stderr.txt                     |    2 +-
 .../target_compile_features/imported_target.cmake  |    1 +
 .../invalid_args-stderr.txt                        |    2 +-
 .../target_compile_features/invalid_args.cmake     |    1 +
 .../invalid_args_on_interface-stderr.txt           |    2 +-
 .../invalid_args_on_interface.cmake                |    1 +
 .../no_matching_c_feature-stderr.txt               |    2 +-
 .../no_matching_c_feature.cmake                    |    1 +
 .../no_matching_cxx_feature-stderr.txt             |    2 +-
 .../no_matching_cxx_feature.cmake                  |    1 +
 .../target_compile_features/no_target-stderr.txt   |    2 +-
 .../target_compile_features/no_target.cmake        |    1 +
 .../not_a_c_feature-stderr.txt                     |    2 +-
 .../target_compile_features/not_a_c_feature.cmake  |    1 +
 .../not_a_cxx_feature-stderr.txt                   |    2 +-
 .../not_a_cxx_feature.cmake                        |    1 +
 .../not_enough_args-stderr.txt                     |    2 +-
 .../target_compile_features/not_enough_args.cmake  |    1 +
 .../utility_target-stderr.txt                      |    2 +-
 38 files changed, 284 insertions(+), 48 deletions(-)
 copy Tests/RunCMake/{BuildDepends => CSharpCustomCommand}/CMakeLists.txt (100%)
 create mode 100644 Tests/RunCMake/CSharpCustomCommand/CommandWithOutput-check.cmake
 create mode 100644 Tests/RunCMake/CSharpCustomCommand/CommandWithOutput.cmake
 create mode 100644 Tests/RunCMake/CSharpCustomCommand/RunCMakeTest.cmake
 copy Modules/IntelVSImplicitPath/hello.f => Tests/RunCMake/CSharpCustomCommand/dummy.cs (100%)
 create mode 100644 Tests/RunCMake/CSharpCustomCommand/test.cs.in
 copy Tests/RunCMake/{Android/BadSYSROOT-result.txt => target_compile_features/cxx_not_enabled-result.txt} (100%)
 create mode 100644 Tests/RunCMake/target_compile_features/cxx_not_enabled-stderr.txt
 create mode 100644 Tests/RunCMake/target_compile_features/cxx_not_enabled.cmake


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list