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  a29b8d285e176b40c9c5f1ce506dd97ed38f9c97 (commit)
       via  df982c4e189c01896db487ec5edfe85d27911007 (commit)
       via  7847fef51056432e2e822b64d72b598a993e9524 (commit)
       via  fd3a39461457540157ea9bee2f9ea7620dfd1c7f (commit)
       via  a1cc6b4447787b84777fdf9a860e8c39f0f4a090 (commit)
       via  cbb861ade85e3b7e550bb1f150513b237efc1f02 (commit)
      from  5fa625d611414ac567fd7a6bb5b3b416ea93eca2 (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=a29b8d285e176b40c9c5f1ce506dd97ed38f9c97
commit a29b8d285e176b40c9c5f1ce506dd97ed38f9c97
Merge: df982c4 7847fef
Author:     Brad King <brad.k...@kitware.com>
AuthorDate: Thu Sep 26 13:49:36 2019 +0000
Commit:     Kitware Robot <kwro...@kitware.com>
CommitDate: Thu Sep 26 09:49:56 2019 -0400

    Merge topic 'fix-vsmacro-access-violation'
    
    7847fef510 VS: Fix access violation when calling Visual Studio macro
    
    Acked-by: Kitware Robot <kwro...@kitware.com>
    Merge-request: !3853


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=df982c4e189c01896db487ec5edfe85d27911007
commit df982c4e189c01896db487ec5edfe85d27911007
Merge: 5fa625d fd3a394
Author:     Brad King <brad.k...@kitware.com>
AuthorDate: Thu Sep 26 13:47:41 2019 +0000
Commit:     Kitware Robot <kwro...@kitware.com>
CommitDate: Thu Sep 26 09:47:51 2019 -0400

    Merge topic 'add-custom-target-byproduct-checks'
    
    fd3a394614 add_custom_command: Format files in error message in a single 
line
    a1cc6b4447 add_custom_target: Add output checks for custom target byproducts
    cbb861ade8 add_custom_command: Add tests for custom command output checks
    
    Acked-by: Kitware Robot <kwro...@kitware.com>
    Merge-request: !3850


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7847fef51056432e2e822b64d72b598a993e9524
commit 7847fef51056432e2e822b64d72b598a993e9524
Author:     Daniel Eiband <daniel.eib...@brainlab.com>
AuthorDate: Sun Sep 22 17:55:12 2019 +0200
Commit:     Daniel Eiband <daniel.eib...@brainlab.com>
CommitDate: Tue Sep 24 17:44:28 2019 +0200

    VS: Fix access violation when calling Visual Studio macro
    
    Fixes: #19730

diff --git a/Source/cmGlobalVisualStudio7Generator.cxx 
b/Source/cmGlobalVisualStudio7Generator.cxx
index 92316d3..188aef2 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -45,6 +45,14 @@ static cmVS7FlagTable cmVS7ExtraFlagTable[] = {
   { "", "", "", "", 0 }
 };
 
+namespace {
+std::string GetSLNFile(cmLocalGenerator* root)
+{
+  return cmStrCat(root->GetCurrentBinaryDirectory(), '/',
+                  root->GetProjectName(), ".sln");
+}
+}
+
 cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator(
   cmake* cm, std::string const& platformInGeneratorName)
   : cmGlobalVisualStudioGenerator(cm, platformInGeneratorName)
@@ -286,8 +294,10 @@ void cmGlobalVisualStudio7Generator::Generate()
   this->OutputSLNFile();
   // If any solution or project files changed during the generation,
   // tell Visual Studio to reload them...
-  if (!cmSystemTools::GetErrorOccuredFlag()) {
-    this->CallVisualStudioMacro(MacroReload);
+  if (!cmSystemTools::GetErrorOccuredFlag() &&
+      !this->LocalGenerators.empty()) {
+    this->CallVisualStudioMacro(MacroReload,
+                                GetSLNFile(this->LocalGenerators[0]));
   }
 }
 
@@ -298,8 +308,7 @@ void cmGlobalVisualStudio7Generator::OutputSLNFile(
     return;
   }
   this->CurrentProject = root->GetProjectName();
-  std::string fname = cmStrCat(root->GetCurrentBinaryDirectory(), '/',
-                               root->GetProjectName(), ".sln");
+  std::string fname = GetSLNFile(root);
   cmGeneratedFileStream fout(fname.c_str());
   fout.SetCopyIfDifferent(true);
   if (!fout) {
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx 
b/Source/cmGlobalVisualStudioGenerator.cxx
index 61e8f58..1cb8b53 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -288,11 +288,10 @@ void 
cmGlobalVisualStudioGenerator::ConfigureCMakeVisualStudioMacros()
 }
 
 void cmGlobalVisualStudioGenerator::CallVisualStudioMacro(
-  MacroName m, const char* vsSolutionFile)
+  MacroName m, const std::string& vsSolutionFile)
 {
   // If any solution or project files changed during the generation,
   // tell Visual Studio to reload them...
-  cmMakefile* mf = this->LocalGenerators[0]->GetMakefile();
   std::string dir = this->GetUserMacrosDirectory();
 
   // Only really try to call the macro if:
@@ -307,27 +306,18 @@ void cmGlobalVisualStudioGenerator::CallVisualStudioMacro(
     if (cmSystemTools::FileExists(macrosFile.c_str()) &&
         IsVisualStudioMacrosFileRegistered(
           macrosFile, this->GetUserMacrosRegKeyBase(), nextSubkeyName)) {
-      std::string topLevelSlnName;
-      if (vsSolutionFile) {
-        topLevelSlnName = vsSolutionFile;
-      } else {
-        topLevelSlnName =
-          cmStrCat(mf->GetCurrentBinaryDirectory(), '/',
-                   this->LocalGenerators[0]->GetProjectName(), ".sln");
-      }
-
       if (m == MacroReload) {
         std::vector<std::string> filenames;
         this->GetFilesReplacedDuringGenerate(filenames);
         if (!filenames.empty()) {
           std::string projects = cmJoin(filenames, ";");
           cmCallVisualStudioMacro::CallMacro(
-            topLevelSlnName, CMAKE_VSMACROS_RELOAD_MACRONAME, projects,
+            vsSolutionFile, CMAKE_VSMACROS_RELOAD_MACRONAME, projects,
             this->GetCMakeInstance()->GetDebugOutput());
         }
       } else if (m == MacroStop) {
         cmCallVisualStudioMacro::CallMacro(
-          topLevelSlnName, CMAKE_VSMACROS_STOP_MACRONAME, "",
+          vsSolutionFile, CMAKE_VSMACROS_STOP_MACRONAME, "",
           this->GetCMakeInstance()->GetDebugOutput());
       }
     }
diff --git a/Source/cmGlobalVisualStudioGenerator.h 
b/Source/cmGlobalVisualStudioGenerator.h
index bd615ec..4f2007f 100644
--- a/Source/cmGlobalVisualStudioGenerator.h
+++ b/Source/cmGlobalVisualStudioGenerator.h
@@ -90,7 +90,7 @@ public:
    * Call the ReloadProjects macro if necessary based on
    * GetFilesReplacedDuringGenerate results.
    */
-  void CallVisualStudioMacro(MacroName m, const char* vsSolutionFile = 0);
+  void CallVisualStudioMacro(MacroName m, const std::string& vsSolutionFile);
 
   // return true if target is fortran only
   bool TargetIsFortranOnly(const cmGeneratorTarget* gt);
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 96d903e..b96eedb 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -1751,7 +1751,7 @@ int cmake::Run(const std::vector<std::string>& args, bool 
noconfigure)
       cmGlobalVisualStudioGenerator* gg =
         static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator);
       gg->CallVisualStudioMacro(cmGlobalVisualStudioGenerator::MacroStop,
-                                this->VSSolutionFile.c_str());
+                                this->VSSolutionFile);
     }
 #endif
     return ret;
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index c663484..29d9b66 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -167,7 +167,7 @@ if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix 
Makefiles|Ninja")
   add_RunCMake_test(CompilerChange)
 endif()
 add_RunCMake_test(CompilerNotFound)
-add_RunCMake_test(Configure)
+add_RunCMake_test(Configure -DMSVC_IDE=${MSVC_IDE})
 add_RunCMake_test(DisallowedCommands)
 add_RunCMake_test(ExternalData)
 add_RunCMake_test(FeatureSummary)
diff --git a/Tests/RunCMake/Configure/RerunCMake-build3-result.txt 
b/Tests/RunCMake/Configure/RerunCMake-build3-result.txt
new file mode 100644
index 0000000..d197c91
--- /dev/null
+++ b/Tests/RunCMake/Configure/RerunCMake-build3-result.txt
@@ -0,0 +1 @@
+[^0]
diff --git a/Tests/RunCMake/Configure/RerunCMake-build3-stdout.txt 
b/Tests/RunCMake/Configure/RerunCMake-build3-stdout.txt
new file mode 100644
index 0000000..dde2ea6
--- /dev/null
+++ b/Tests/RunCMake/Configure/RerunCMake-build3-stdout.txt
@@ -0,0 +1 @@
+Rerun error 3
diff --git a/Tests/RunCMake/Configure/RerunCMake-build4-result.txt 
b/Tests/RunCMake/Configure/RerunCMake-build4-result.txt
new file mode 100644
index 0000000..d197c91
--- /dev/null
+++ b/Tests/RunCMake/Configure/RerunCMake-build4-result.txt
@@ -0,0 +1 @@
+[^0]
diff --git a/Tests/RunCMake/Configure/RerunCMake-build4-stdout.txt 
b/Tests/RunCMake/Configure/RerunCMake-build4-stdout.txt
new file mode 100644
index 0000000..b8727e1
--- /dev/null
+++ b/Tests/RunCMake/Configure/RerunCMake-build4-stdout.txt
@@ -0,0 +1 @@
+Rerun error 4
diff --git a/Tests/RunCMake/Configure/RerunCMake.cmake 
b/Tests/RunCMake/Configure/RerunCMake.cmake
index 5a561bf..c0b0798 100644
--- a/Tests/RunCMake/Configure/RerunCMake.cmake
+++ b/Tests/RunCMake/Configure/RerunCMake.cmake
@@ -9,3 +9,9 @@ set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS 
${depend})
 file(READ ${depend} content)
 file(WRITE ${output} "${content}")
 set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS RerunCMake.txt)
+
+set(error  ${CMAKE_CURRENT_BINARY_DIR}/CustomCMakeError.txt)
+if(EXISTS ${error})
+  file(READ ${error} content)
+  message(FATAL_ERROR "Rerun error ${content}")
+endif()
diff --git a/Tests/RunCMake/Configure/RunCMakeTest.cmake 
b/Tests/RunCMake/Configure/RunCMakeTest.cmake
index 4a135be..76d843c 100644
--- a/Tests/RunCMake/Configure/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Configure/RunCMakeTest.cmake
@@ -14,6 +14,7 @@ set(input  "${RunCMake_TEST_BINARY_DIR}/CustomCMakeInput.txt")
 set(stamp  "${RunCMake_TEST_BINARY_DIR}/CustomCMakeStamp.txt")
 set(depend "${RunCMake_TEST_BINARY_DIR}/CustomCMakeDepend.txt")
 set(output "${RunCMake_TEST_BINARY_DIR}/CustomCMakeOutput.txt")
+set(error  "${RunCMake_TEST_BINARY_DIR}/CustomCMakeError.txt")
 file(WRITE "${input}" "1")
 file(WRITE "${depend}" "1")
 run_cmake(RerunCMake)
@@ -22,6 +23,22 @@ file(WRITE "${input}" "2")
 run_cmake_command(RerunCMake-build1 ${CMAKE_COMMAND} --build .)
 file(WRITE "${depend}" "2")
 run_cmake_command(RerunCMake-build2 ${CMAKE_COMMAND} --build .)
+execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1) # handle 1s resolution
+file(WRITE "${depend}" "3")
+file(WRITE "${error}" "3")
+set(RunCMake_TEST_OUTPUT_MERGE 1)
+run_cmake_command(RerunCMake-build3 ${CMAKE_COMMAND} --build .)
+if(MSVC_IDE)
+  # Make sure that for Visual Studio the error occurs from within the build
+  # system.
+  file(REMOVE "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/generate.stamp.list")
+  file(WRITE "${error}" "4")
+  # With Visual Studio the error must be on stdout, otherwise the error was not
+  # emitted by ZERO_CHECK.
+  set(RunCMake_TEST_OUTPUT_MERGE 0)
+  run_cmake_command(RerunCMake-build4 ${CMAKE_COMMAND} --build .)
+endif()
+unset(RunCMake_TEST_OUTPUT_MERGE)
 unset(RunCMake_TEST_BINARY_DIR)
 unset(RunCMake_TEST_NO_CLEAN)
 

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fd3a39461457540157ea9bee2f9ea7620dfd1c7f
commit fd3a39461457540157ea9bee2f9ea7620dfd1c7f
Author:     Daniel Eiband <daniel.eib...@brainlab.com>
AuthorDate: Mon Sep 23 23:39:07 2019 +0200
Commit:     Daniel Eiband <daniel.eib...@brainlab.com>
CommitDate: Mon Sep 23 23:39:07 2019 +0200

    add_custom_command: Format files in error message in a single line

diff --git a/Source/cmAddCustomCommandCommand.cxx 
b/Source/cmAddCustomCommandCommand.cxx
index 9d665c4..94de851 100644
--- a/Source/cmAddCustomCommandCommand.cxx
+++ b/Source/cmAddCustomCommandCommand.cxx
@@ -320,8 +320,8 @@ bool cmAddCustomCommandCommand(std::vector<std::string> 
const& args,
 
     // No command for this output exists.
     status.SetError(
-      cmStrCat("given APPEND option with output\n\"", output[0],
-               "\"\nwhich is not already a custom command output."));
+      cmStrCat("given APPEND option with output\n  ", output[0],
+               "\nwhich is not already a custom command output."));
     return false;
   }
 
diff --git a/Source/cmCheckCustomOutputs.cxx b/Source/cmCheckCustomOutputs.cxx
index a401738..7645c88 100644
--- a/Source/cmCheckCustomOutputs.cxx
+++ b/Source/cmCheckCustomOutputs.cxx
@@ -17,8 +17,8 @@ bool cmCheckCustomOutputs(const std::vector<std::string>& 
outputs,
     // directory during an out of source build.
     if (!mf.CanIWriteThisFile(o)) {
       status.SetError(
-        cmStrCat("attempted to have a file\n\"", o,
-                 "\"\nin a source directory as an output of custom command."));
+        cmStrCat("attempted to have a file\n  ", o,
+                 "\nin a source directory as an output of custom command."));
       cmSystemTools::SetFatalErrorOccured();
       return false;
     }
diff --git a/Tests/RunCMake/add_custom_command/AppendNotOutput-stderr.txt 
b/Tests/RunCMake/add_custom_command/AppendNotOutput-stderr.txt
index cd542d8..b7ee23a 100644
--- a/Tests/RunCMake/add_custom_command/AppendNotOutput-stderr.txt
+++ b/Tests/RunCMake/add_custom_command/AppendNotOutput-stderr.txt
@@ -1,7 +1,7 @@
 CMake Error at AppendNotOutput.cmake:1 \(add_custom_command\):
   add_custom_command given APPEND option with output
 
-  .*RunCMake/add_custom_command/AppendNotOutput-build/out.*
+    .*RunCMake/add_custom_command/AppendNotOutput-build/out
 
   which is not already a custom command output.
 Call Stack \(most recent call first\):
diff --git a/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt 
b/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt
index 97b9cca..086e397 100644
--- a/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt
+++ b/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt
@@ -29,7 +29,7 @@ Call Stack \(most recent call first\):
 CMake Error at BadByproduct.cmake:6 \(add_custom_command\):
   add_custom_command attempted to have a file
 
-  .*/f".*
+    .*RunCMake/add_custom_command/f
 
   in a source directory as an output of custom command.
 Call Stack \(most recent call first\):
diff --git a/Tests/RunCMake/add_custom_command/BadOutput-stderr.txt 
b/Tests/RunCMake/add_custom_command/BadOutput-stderr.txt
index 584aa88..731e58d 100644
--- a/Tests/RunCMake/add_custom_command/BadOutput-stderr.txt
+++ b/Tests/RunCMake/add_custom_command/BadOutput-stderr.txt
@@ -29,7 +29,7 @@ Call Stack \(most recent call first\):
 CMake Error at BadOutput.cmake:6 \(add_custom_command\):
   add_custom_command attempted to have a file
 
-  .*/e".*
+    .*RunCMake/add_custom_command/e
 
   in a source directory as an output of custom command.
 Call Stack \(most recent call first\):
diff --git a/Tests/RunCMake/add_custom_target/BadByproduct-stderr.txt 
b/Tests/RunCMake/add_custom_target/BadByproduct-stderr.txt
index 7390e6a..0f58550 100644
--- a/Tests/RunCMake/add_custom_target/BadByproduct-stderr.txt
+++ b/Tests/RunCMake/add_custom_target/BadByproduct-stderr.txt
@@ -29,7 +29,7 @@ Call Stack \(most recent call first\):
 CMake Error at BadByproduct.cmake:6 \(add_custom_target\):
   add_custom_target attempted to have a file
 
-  .*/j".*
+    .*RunCMake/add_custom_target/j
 
   in a source directory as an output of custom command.
 Call Stack \(most recent call first\):

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a1cc6b4447787b84777fdf9a860e8c39f0f4a090
commit a1cc6b4447787b84777fdf9a860e8c39f0f4a090
Author:     Daniel Eiband <daniel.eib...@brainlab.com>
AuthorDate: Mon Sep 23 22:18:36 2019 +0200
Commit:     Daniel Eiband <daniel.eib...@brainlab.com>
CommitDate: Mon Sep 23 22:18:36 2019 +0200

    add_custom_target: Add output checks for custom target byproducts
    
    Use the output checks for byproducts of add_custom_command also for 
byproducts
    of add_custom_target.

diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 8ed7b2f..71a7dbd 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -168,6 +168,8 @@ set(SRCS
   cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.h
   cmCacheManager.cxx
   cmCacheManager.h
+  cmCheckCustomOutputs.h
+  cmCheckCustomOutputs.cxx
   cmCLocaleEnvironmentScope.h
   cmCLocaleEnvironmentScope.cxx
   cmCommandArgumentParserHelper.cxx
diff --git a/Source/cmAddCustomCommandCommand.cxx 
b/Source/cmAddCustomCommandCommand.cxx
index defefaf..9d665c4 100644
--- a/Source/cmAddCustomCommandCommand.cxx
+++ b/Source/cmAddCustomCommandCommand.cxx
@@ -5,6 +5,7 @@
 #include <sstream>
 #include <unordered_set>
 
+#include "cmCheckCustomOutputs.h"
 #include "cmCustomCommand.h"
 #include "cmCustomCommandLines.h"
 #include "cmExecutionStatus.h"
@@ -16,9 +17,6 @@
 #include "cmSystemTools.h"
 #include "cmTarget.h"
 
-static bool cmAddCustomCommandCommandCheckOutputs(
-  const std::vector<std::string>& outputs, cmExecutionStatus& status);
-
 bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
                                cmExecutionStatus& status)
 {
@@ -307,9 +305,9 @@ bool cmAddCustomCommandCommand(std::vector<std::string> 
const& args,
   }
 
   // Make sure the output names and locations are safe.
-  if (!cmAddCustomCommandCommandCheckOutputs(output, status) ||
-      !cmAddCustomCommandCommandCheckOutputs(outputs, status) ||
-      !cmAddCustomCommandCommandCheckOutputs(byproducts, status)) {
+  if (!cmCheckCustomOutputs(output, "OUTPUT", status) ||
+      !cmCheckCustomOutputs(outputs, "OUTPUTS", status) ||
+      !cmCheckCustomOutputs(byproducts, "BYPRODUCTS", status)) {
     return false;
   }
 
@@ -387,29 +385,3 @@ bool cmAddCustomCommandCommand(std::vector<std::string> 
const& args,
 
   return true;
 }
-
-bool cmAddCustomCommandCommandCheckOutputs(
-  const std::vector<std::string>& outputs, cmExecutionStatus& status)
-{
-  cmMakefile& mf = status.GetMakefile();
-  for (std::string const& o : outputs) {
-    // Make sure the file will not be generated into the source
-    // directory during an out of source build.
-    if (!mf.CanIWriteThisFile(o)) {
-      std::string e = "attempted to have a file\n\"" + o +
-        "\"\nin a source directory as an output of custom command.";
-      status.SetError(e);
-      cmSystemTools::SetFatalErrorOccured();
-      return false;
-    }
-
-    // Make sure the output file name has no invalid characters.
-    std::string::size_type pos = o.find_first_of("#<>");
-    if (pos != std::string::npos) {
-      status.SetError(cmStrCat("called with OUTPUT containing a \"", o[pos],
-                               "\".  This character is not allowed."));
-      return false;
-    }
-  }
-  return true;
-}
diff --git a/Source/cmAddCustomTargetCommand.cxx 
b/Source/cmAddCustomTargetCommand.cxx
index 9fd1234..b580c43 100644
--- a/Source/cmAddCustomTargetCommand.cxx
+++ b/Source/cmAddCustomTargetCommand.cxx
@@ -4,6 +4,7 @@
 
 #include <utility>
 
+#include "cmCheckCustomOutputs.h"
 #include "cmCustomCommandLines.h"
 #include "cmExecutionStatus.h"
 #include "cmGeneratorExpression.h"
@@ -205,6 +206,11 @@ bool cmAddCustomTargetCommand(std::vector<std::string> 
const& args,
     return false;
   }
 
+  // Make sure the byproduct names and locations are safe.
+  if (!cmCheckCustomOutputs(byproducts, "BYPRODUCTS", status)) {
+    return false;
+  }
+
   // Add the utility target to the makefile.
   bool escapeOldStyle = !verbatim;
   cmTarget* target = mf.AddUtilityCommand(
diff --git a/Source/cmCheckCustomOutputs.cxx b/Source/cmCheckCustomOutputs.cxx
new file mode 100644
index 0000000..a401738
--- /dev/null
+++ b/Source/cmCheckCustomOutputs.cxx
@@ -0,0 +1,36 @@
+/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
+   file Copyright.txt or https://cmake.org/licensing for details.  */
+#include "cmCheckCustomOutputs.h"
+
+#include "cmExecutionStatus.h"
+#include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+
+bool cmCheckCustomOutputs(const std::vector<std::string>& outputs,
+                          cm::string_view keyword, cmExecutionStatus& status)
+{
+  cmMakefile& mf = status.GetMakefile();
+
+  for (std::string const& o : outputs) {
+    // Make sure the file will not be generated into the source
+    // directory during an out of source build.
+    if (!mf.CanIWriteThisFile(o)) {
+      status.SetError(
+        cmStrCat("attempted to have a file\n\"", o,
+                 "\"\nin a source directory as an output of custom command."));
+      cmSystemTools::SetFatalErrorOccured();
+      return false;
+    }
+
+    // Make sure the output file name has no invalid characters.
+    std::string::size_type pos = o.find_first_of("#<>");
+    if (pos != std::string::npos) {
+      status.SetError(cmStrCat("called with ", keyword, " containing a \"",
+                               o[pos], "\".  This character is not allowed."));
+      return false;
+    }
+  }
+
+  return true;
+}
diff --git a/Source/cmCheckCustomOutputs.h b/Source/cmCheckCustomOutputs.h
new file mode 100644
index 0000000..7c4b3fe
--- /dev/null
+++ b/Source/cmCheckCustomOutputs.h
@@ -0,0 +1,18 @@
+/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
+   file Copyright.txt or https://cmake.org/licensing for details.  */
+#ifndef cmCheckCustomOutputs_h
+#define cmCheckCustomOutputs_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <cm/string_view>
+
+#include <string>
+#include <vector>
+
+class cmExecutionStatus;
+
+bool cmCheckCustomOutputs(const std::vector<std::string>& outputs,
+                          cm::string_view keyword, cmExecutionStatus& status);
+
+#endif
diff --git a/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt 
b/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt
index 6315c8b..97b9cca 100644
--- a/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt
+++ b/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt
@@ -1,27 +1,27 @@
 CMake Error at BadByproduct.cmake:2 \(add_custom_command\):
-  add_custom_command called with OUTPUT containing a "#".  This character is
-  not allowed.
+  add_custom_command called with BYPRODUCTS containing a "#".  This character
+  is not allowed.
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)
 
 
 CMake Error at BadByproduct.cmake:3 \(add_custom_command\):
-  add_custom_command called with OUTPUT containing a "<".  This character is
-  not allowed.
+  add_custom_command called with BYPRODUCTS containing a "<".  This character
+  is not allowed.
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)
 
 
 CMake Error at BadByproduct.cmake:4 \(add_custom_command\):
-  add_custom_command called with OUTPUT containing a ">".  This character is
-  not allowed.
+  add_custom_command called with BYPRODUCTS containing a ">".  This character
+  is not allowed.
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)
 
 
 CMake Error at BadByproduct.cmake:5 \(add_custom_command\):
-  add_custom_command called with OUTPUT containing a "<".  This character is
-  not allowed.
+  add_custom_command called with BYPRODUCTS containing a "<".  This character
+  is not allowed.
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)
 
diff --git a/Tests/RunCMake/add_custom_target/BadByproduct-result.txt 
b/Tests/RunCMake/add_custom_target/BadByproduct-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/add_custom_target/BadByproduct-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/add_custom_target/BadByproduct-stderr.txt 
b/Tests/RunCMake/add_custom_target/BadByproduct-stderr.txt
new file mode 100644
index 0000000..7390e6a
--- /dev/null
+++ b/Tests/RunCMake/add_custom_target/BadByproduct-stderr.txt
@@ -0,0 +1,36 @@
+CMake Error at BadByproduct.cmake:2 \(add_custom_target\):
+  add_custom_target called with BYPRODUCTS containing a "#".  This character
+  is not allowed.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+
+
+CMake Error at BadByproduct.cmake:3 \(add_custom_target\):
+  add_custom_target called with BYPRODUCTS containing a "<".  This character
+  is not allowed.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+
+
+CMake Error at BadByproduct.cmake:4 \(add_custom_target\):
+  add_custom_target called with BYPRODUCTS containing a ">".  This character
+  is not allowed.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+
+
+CMake Error at BadByproduct.cmake:5 \(add_custom_target\):
+  add_custom_target called with BYPRODUCTS containing a "<".  This character
+  is not allowed.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+
+
+CMake Error at BadByproduct.cmake:6 \(add_custom_target\):
+  add_custom_target attempted to have a file
+
+  .*/j".*
+
+  in a source directory as an output of custom command.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/add_custom_target/BadByproduct.cmake 
b/Tests/RunCMake/add_custom_target/BadByproduct.cmake
new file mode 100644
index 0000000..963d641
--- /dev/null
+++ b/Tests/RunCMake/add_custom_target/BadByproduct.cmake
@@ -0,0 +1,6 @@
+set(CMAKE_DISABLE_SOURCE_CHANGES ON)
+add_custom_target(a BYPRODUCTS "a#" COMMAND b)
+add_custom_target(c BYPRODUCTS "a<" COMMAND d)
+add_custom_target(e BYPRODUCTS "a>" COMMAND f)
+add_custom_target(g BYPRODUCTS "$<CONFIG>/#" COMMAND h)
+add_custom_target(i BYPRODUCTS ${CMAKE_CURRENT_SOURCE_DIR}/j COMMAND k)
diff --git a/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake 
b/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake
index 49c7d3e..f5d5dd2 100644
--- a/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake
+++ b/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake
@@ -1,11 +1,12 @@
 include(RunCMake)
 
-run_cmake(CommandExpandsEmpty)
-run_cmake(GeneratedProperty)
-run_cmake(NoArguments)
+run_cmake(BadByproduct)
 run_cmake(BadTargetName)
 run_cmake(ByproductsNoCommand)
+run_cmake(CommandExpandsEmpty)
+run_cmake(GeneratedProperty)
 run_cmake(LiteralQuotes)
+run_cmake(NoArguments)
 run_cmake(UsesTerminalNoCommand)
 
 function(run_TargetOrder)
diff --git a/bootstrap b/bootstrap
index 0923dd4..42f869b 100755
--- a/bootstrap
+++ b/bootstrap
@@ -278,6 +278,7 @@ CMAKE_CXX_SOURCES="\
   cmCMakePolicyCommand \
   cmCPackPropertiesGenerator \
   cmCacheManager \
+  cmCheckCustomOutputs \
   cmCommand \
   cmCommandArgumentParserHelper \
   cmCommands \

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cbb861ade85e3b7e550bb1f150513b237efc1f02
commit cbb861ade85e3b7e550bb1f150513b237efc1f02
Author:     Daniel Eiband <daniel.eib...@brainlab.com>
AuthorDate: Sat Sep 21 15:16:36 2019 +0200
Commit:     Daniel Eiband <daniel.eib...@brainlab.com>
CommitDate: Mon Sep 23 22:15:31 2019 +0200

    add_custom_command: Add tests for custom command output checks

diff --git a/Source/cmAddCustomCommandCommand.cxx 
b/Source/cmAddCustomCommandCommand.cxx
index 35db6a4..defefaf 100644
--- a/Source/cmAddCustomCommandCommand.cxx
+++ b/Source/cmAddCustomCommandCommand.cxx
@@ -396,8 +396,8 @@ bool cmAddCustomCommandCommandCheckOutputs(
     // Make sure the file will not be generated into the source
     // directory during an out of source build.
     if (!mf.CanIWriteThisFile(o)) {
-      std::string e = "attempted to have a file \"" + o +
-        "\" in a source directory as an output of custom command.";
+      std::string e = "attempted to have a file\n\"" + o +
+        "\"\nin a source directory as an output of custom command.";
       status.SetError(e);
       cmSystemTools::SetFatalErrorOccured();
       return false;
diff --git a/Tests/RunCMake/add_custom_command/BadByproduct-result.txt 
b/Tests/RunCMake/add_custom_command/BadByproduct-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/BadByproduct-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt 
b/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt
new file mode 100644
index 0000000..6315c8b
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt
@@ -0,0 +1,36 @@
+CMake Error at BadByproduct.cmake:2 \(add_custom_command\):
+  add_custom_command called with OUTPUT containing a "#".  This character is
+  not allowed.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+
+
+CMake Error at BadByproduct.cmake:3 \(add_custom_command\):
+  add_custom_command called with OUTPUT containing a "<".  This character is
+  not allowed.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+
+
+CMake Error at BadByproduct.cmake:4 \(add_custom_command\):
+  add_custom_command called with OUTPUT containing a ">".  This character is
+  not allowed.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+
+
+CMake Error at BadByproduct.cmake:5 \(add_custom_command\):
+  add_custom_command called with OUTPUT containing a "<".  This character is
+  not allowed.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+
+
+CMake Error at BadByproduct.cmake:6 \(add_custom_command\):
+  add_custom_command attempted to have a file
+
+  .*/f".*
+
+  in a source directory as an output of custom command.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/add_custom_command/BadByproduct.cmake 
b/Tests/RunCMake/add_custom_command/BadByproduct.cmake
new file mode 100644
index 0000000..91bca52
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/BadByproduct.cmake
@@ -0,0 +1,6 @@
+set(CMAKE_DISABLE_SOURCE_CHANGES ON)
+add_custom_command(OUTPUT a BYPRODUCTS "a#")
+add_custom_command(OUTPUT b BYPRODUCTS "a<")
+add_custom_command(OUTPUT c BYPRODUCTS "a>")
+add_custom_command(OUTPUT d BYPRODUCTS "$<CONFIG>/#")
+add_custom_command(OUTPUT e BYPRODUCTS ${CMAKE_CURRENT_SOURCE_DIR}/f)
diff --git a/Tests/RunCMake/add_custom_command/BadOutput-result.txt 
b/Tests/RunCMake/add_custom_command/BadOutput-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/BadOutput-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/add_custom_command/BadOutput-stderr.txt 
b/Tests/RunCMake/add_custom_command/BadOutput-stderr.txt
new file mode 100644
index 0000000..584aa88
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/BadOutput-stderr.txt
@@ -0,0 +1,36 @@
+CMake Error at BadOutput.cmake:2 \(add_custom_command\):
+  add_custom_command called with OUTPUT containing a "#".  This character is
+  not allowed.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+
+
+CMake Error at BadOutput.cmake:3 \(add_custom_command\):
+  add_custom_command called with OUTPUT containing a "<".  This character is
+  not allowed.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+
+
+CMake Error at BadOutput.cmake:4 \(add_custom_command\):
+  add_custom_command called with OUTPUT containing a ">".  This character is
+  not allowed.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+
+
+CMake Error at BadOutput.cmake:5 \(add_custom_command\):
+  add_custom_command called with OUTPUT containing a "<".  This character is
+  not allowed.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+
+
+CMake Error at BadOutput.cmake:6 \(add_custom_command\):
+  add_custom_command attempted to have a file
+
+  .*/e".*
+
+  in a source directory as an output of custom command.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/add_custom_command/BadOutput.cmake 
b/Tests/RunCMake/add_custom_command/BadOutput.cmake
new file mode 100644
index 0000000..6875fe9
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/BadOutput.cmake
@@ -0,0 +1,6 @@
+set(CMAKE_DISABLE_SOURCE_CHANGES ON)
+add_custom_command(OUTPUT "a#" COMMAND a)
+add_custom_command(OUTPUT "a<" COMMAND b)
+add_custom_command(OUTPUT "a>" COMMAND c)
+add_custom_command(OUTPUT "$<CONFIG>/#" COMMAND d)
+add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/e COMMAND f)
diff --git a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake 
b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake
index 270df2f..96642fa 100644
--- a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake
+++ b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake
@@ -4,6 +4,8 @@ run_cmake(AppendLiteralQuotes)
 run_cmake(AppendNoOutput)
 run_cmake(AppendNotOutput)
 run_cmake(BadArgument)
+run_cmake(BadByproduct)
+run_cmake(BadOutput)
 run_cmake(GeneratedProperty)
 run_cmake(LiteralQuotes)
 run_cmake(NoArguments)

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

Summary of changes:
 Source/CMakeLists.txt                              |  2 ++
 Source/cmAddCustomCommandCommand.cxx               | 40 ++++------------------
 Source/cmAddCustomTargetCommand.cxx                |  6 ++++
 Source/cmCheckCustomOutputs.cxx                    | 36 +++++++++++++++++++
 ...DefinitionsCommand.h => cmCheckCustomOutputs.h} | 10 +++---
 Source/cmGlobalVisualStudio7Generator.cxx          | 17 ++++++---
 Source/cmGlobalVisualStudioGenerator.cxx           | 16 ++-------
 Source/cmGlobalVisualStudioGenerator.h             |  2 +-
 Source/cmake.cxx                                   |  2 +-
 Tests/RunCMake/CMakeLists.txt                      |  2 +-
 .../RerunCMake-build3-result.txt}                  |  0
 .../Configure/RerunCMake-build3-stdout.txt         |  1 +
 .../RerunCMake-build4-result.txt}                  |  0
 .../Configure/RerunCMake-build4-stdout.txt         |  1 +
 Tests/RunCMake/Configure/RerunCMake.cmake          |  6 ++++
 Tests/RunCMake/Configure/RunCMakeTest.cmake        | 17 +++++++++
 .../add_custom_command/AppendNotOutput-stderr.txt  |  2 +-
 .../BadByproduct-result.txt}                       |  0
 .../add_custom_command/BadByproduct-stderr.txt     | 36 +++++++++++++++++++
 .../RunCMake/add_custom_command/BadByproduct.cmake |  6 ++++
 .../BadOutput-result.txt}                          |  0
 .../add_custom_command/BadOutput-stderr.txt        | 36 +++++++++++++++++++
 Tests/RunCMake/add_custom_command/BadOutput.cmake  |  6 ++++
 .../RunCMake/add_custom_command/RunCMakeTest.cmake |  2 ++
 .../BadByproduct-result.txt}                       |  0
 .../add_custom_target/BadByproduct-stderr.txt      | 36 +++++++++++++++++++
 .../RunCMake/add_custom_target/BadByproduct.cmake  |  6 ++++
 .../RunCMake/add_custom_target/RunCMakeTest.cmake  |  7 ++--
 bootstrap                                          |  1 +
 29 files changed, 234 insertions(+), 62 deletions(-)
 create mode 100644 Source/cmCheckCustomOutputs.cxx
 copy Source/{cmAddDefinitionsCommand.h => cmCheckCustomOutputs.h} (53%)
 copy Tests/RunCMake/{GoogleTest/GoogleTest-test-missing-result.txt => 
Configure/RerunCMake-build3-result.txt} (100%)
 create mode 100644 Tests/RunCMake/Configure/RerunCMake-build3-stdout.txt
 copy Tests/RunCMake/{GoogleTest/GoogleTest-test-missing-result.txt => 
Configure/RerunCMake-build4-result.txt} (100%)
 create mode 100644 Tests/RunCMake/Configure/RerunCMake-build4-stdout.txt
 copy Tests/RunCMake/{while/MissingArgument-result.txt => 
add_custom_command/BadByproduct-result.txt} (100%)
 create mode 100644 Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt
 create mode 100644 Tests/RunCMake/add_custom_command/BadByproduct.cmake
 copy Tests/RunCMake/{while/MissingArgument-result.txt => 
add_custom_command/BadOutput-result.txt} (100%)
 create mode 100644 Tests/RunCMake/add_custom_command/BadOutput-stderr.txt
 create mode 100644 Tests/RunCMake/add_custom_command/BadOutput.cmake
 copy Tests/RunCMake/{while/MissingArgument-result.txt => 
add_custom_target/BadByproduct-result.txt} (100%)
 create mode 100644 Tests/RunCMake/add_custom_target/BadByproduct-stderr.txt
 create mode 100644 Tests/RunCMake/add_custom_target/BadByproduct.cmake


hooks/post-receive
-- 
CMake
_______________________________________________
Cmake-commits mailing list
Cmake-commits@cmake.org
https://cmake.org/mailman/listinfo/cmake-commits

Reply via email to