[Cmake-commits] CMake branch, master, updated. v3.15.0-428-gdcd4d3e

Kitware Robot kwrobot at kitware.com
Tue Jul 23 07:33:09 EDT 2019


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  dcd4d3e9bfa95f62718d0bb561a6f328d508cda5 (commit)
       via  5396c5fce4eae4f4b0a9b974e0a0304c7afda459 (commit)
       via  6f476a41697eab23c46a33d93f5a17138c79dad2 (commit)
       via  75c99bfb219028871fc69c239e3ebc19aa344c6e (commit)
       via  680a3c63bb3a6485a1774a457f3f2a63ad96b728 (commit)
       via  301f5356fd1cb6d30f662b9b4071108a378063cd (commit)
       via  dfaa87f1b3335b2e80f68726fd5e1b3bbd87d667 (commit)
       via  62b5d1e4adf4f21a953557edf6552e3a81f47c07 (commit)
       via  28f2d12a055e025aa0ddeb9842f204f29181eaff (commit)
       via  de77d355ac1808164b7247290f45b8133ce1246b (commit)
       via  0101ace1319b5c97472649ec809b67299e2a46ce (commit)
       via  015001aaf138119f4825e3c84c0845c5127f9088 (commit)
       via  1eebc2956321c2e7da00a5d35e207bedb899c804 (commit)
       via  dd3e4767863dfe1307d4dccd2445e5312b55473e (commit)
      from  63dfa74f5f8773d839d2e35fb6a9bbb2007a4017 (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=dcd4d3e9bfa95f62718d0bb561a6f328d508cda5
commit dcd4d3e9bfa95f62718d0bb561a6f328d508cda5
Merge: 5396c5f 301f535
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Jul 23 11:32:14 2019 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Jul 23 07:32:30 2019 -0400

    Merge topic 'cmHasLiteralPrefix_cm_string_view'
    
    301f5356fd cmAlgorithms: Make cmHasPrefix and cmHasSuffix cm::string_view based
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Acked-by: Daniel Pfeifer <daniel at pfeifer-mail.de>
    Merge-request: !3583


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5396c5fce4eae4f4b0a9b974e0a0304c7afda459
commit 5396c5fce4eae4f4b0a9b974e0a0304c7afda459
Merge: 6f476a4 680a3c6
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Jul 23 11:30:43 2019 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Jul 23 07:30:53 2019 -0400

    Merge topic 'make-imported-targets-more-equal'
    
    680a3c63bb target_*: Allow setting INTERFACE properties of UNKNOWN IMPORTED targets
    62b5d1e4ad cmTargetPropCommandBase: Order target type condition by order in enum
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !3581


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6f476a41697eab23c46a33d93f5a17138c79dad2
commit 6f476a41697eab23c46a33d93f5a17138c79dad2
Merge: 75c99bf dfaa87f
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Jul 23 11:29:01 2019 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Jul 23 07:29:11 2019 -0400

    Merge topic 'command-refactoring3'
    
    dfaa87f1b3 cmState: Support BuiltinCommands as free functions
    28f2d12a05 cmCommand: De-virtualize function InvokeInitialPass
    de77d355ac cmState: Add scripted commands by value
    0101ace131 cmUnexpectedCommand: Replace with lambda expression
    015001aaf1 cmState: Hold commands by value
    1eebc29563 cmCommand: deprecate functions GetMakefile and SetError
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !3574


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=75c99bfb219028871fc69c239e3ebc19aa344c6e
commit 75c99bfb219028871fc69c239e3ebc19aa344c6e
Merge: 63dfa74 dd3e476
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Jul 23 11:26:23 2019 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Jul 23 07:26:33 2019 -0400

    Merge topic 'ssl-warning'
    
    dd3e476786 OpenSSL: Issue an error if OpenSSL is not found
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Acked-by: Brad King <brad.king at kitware.com>
    Merge-request: !3565


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=680a3c63bb3a6485a1774a457f3f2a63ad96b728
commit 680a3c63bb3a6485a1774a457f3f2a63ad96b728
Author:     Avraham Shukron <avraham.shukron at gmail.com>
AuthorDate: Fri Jul 19 22:50:59 2019 +0300
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Jul 22 10:23:39 2019 -0400

    target_*: Allow setting INTERFACE properties of UNKNOWN IMPORTED targets
    
    Extend the change made by commit fe4b25ec2f (Teach target_* commands to
    set INTERFACE properties of IMPORTED targets, 2017-09-18,
    v3.11.0-rc1~433^2~2) to work with imported targets of type `UNKNOWN`.
    
    Fixes: #19434

diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx
index 2f93e39..3aa845c 100644
--- a/Source/cmTargetPropCommandBase.cxx
+++ b/Source/cmTargetPropCommandBase.cxx
@@ -37,7 +37,8 @@ bool cmTargetPropCommandBase::HandleArguments(
       (this->Target->GetType() != cmStateEnums::SHARED_LIBRARY) &&
       (this->Target->GetType() != cmStateEnums::MODULE_LIBRARY) &&
       (this->Target->GetType() != cmStateEnums::OBJECT_LIBRARY) &&
-      (this->Target->GetType() != cmStateEnums::INTERFACE_LIBRARY)) {
+      (this->Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) &&
+      (this->Target->GetType() != cmStateEnums::UNKNOWN_LIBRARY)) {
     this->SetError("called with non-compilable target type");
     return false;
   }
diff --git a/Tests/RunCMake/add_library/UNKNOWNwithOnlyObjectSources-stderr.txt b/Tests/RunCMake/add_library/UNKNOWNwithOnlyObjectSources-stderr.txt
index e332281..838992b 100644
--- a/Tests/RunCMake/add_library/UNKNOWNwithOnlyObjectSources-stderr.txt
+++ b/Tests/RunCMake/add_library/UNKNOWNwithOnlyObjectSources-stderr.txt
@@ -1,4 +1,4 @@
 ^CMake Error at UNKNOWNwithOnlyObjectSources.cmake:[0-9]+ \(target_sources\):
-  target_sources called with non-compilable target type
+  target_sources may only set INTERFACE properties on IMPORTED targets
 Call Stack \(most recent call first\):
   CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/target_compile_definitions/RunCMakeTest.cmake b/Tests/RunCMake/target_compile_definitions/RunCMakeTest.cmake
index b67c598..a419cc9 100644
--- a/Tests/RunCMake/target_compile_definitions/RunCMakeTest.cmake
+++ b/Tests/RunCMake/target_compile_definitions/RunCMakeTest.cmake
@@ -1,3 +1,4 @@
 include(RunCMake)
 
 run_cmake(empty_keyword_args)
+run_cmake(unknown_imported_target)
diff --git a/Tests/RunCMake/target_compile_definitions/unknown_imported_target.cmake b/Tests/RunCMake/target_compile_definitions/unknown_imported_target.cmake
new file mode 100644
index 0000000..4ae1c0d
--- /dev/null
+++ b/Tests/RunCMake/target_compile_definitions/unknown_imported_target.cmake
@@ -0,0 +1,11 @@
+# Test that target_compile_definitions works on UNKNOWN IMPORTED target
+add_library(imported UNKNOWN IMPORTED)
+target_compile_definitions(imported INTERFACE FOO)
+
+get_target_property(IMPORTED_INTERFACE_CDS imported INTERFACE_COMPILE_DEFINITIONS)
+
+if (NOT FOO IN_LIST IMPORTED_INTERFACE_CDS)
+  message(
+    FATAL_ERROR "FOO should be in INTERFACE_COMPILE_DEFINITIONS.\n"
+    "Actual INTERFACE_COMPILE_DEFINITIONS: " ${IMPORTED_INTERFACE_CDS})
+endif()

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=301f5356fd1cb6d30f662b9b4071108a378063cd
commit 301f5356fd1cb6d30f662b9b4071108a378063cd
Author:     Sebastian Holtermann <sebholt at xwmw.org>
AuthorDate: Sat Jul 20 11:17:12 2019 +0200
Commit:     Sebastian Holtermann <sebholt at xwmw.org>
CommitDate: Mon Jul 22 16:04:22 2019 +0200

    cmAlgorithms: Make cmHasPrefix and cmHasSuffix cm::string_view based
    
    Make `cmHasPrefix`, `cmHasSuffix` and `cmStripSuffixIfExists` accept
    arguments as `cm::string_view` instead of `const std::string&`.
    This lets them accept literal strings without having to allocate a temporary
    `std::string`.
    Add variants of `cmHasPrefix`, `cmHasSuffix` and `cmStripSuffixIfExists` that
    accept a single character as second argument.

diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index d153076..b4b480b 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -8,6 +8,7 @@
 #include "cmRange.h"
 
 #include "cm_kwiml.h"
+#include "cm_string_view.hxx"
 #include <algorithm>
 #include <functional>
 #include <iterator>
@@ -314,23 +315,41 @@ std::reverse_iterator<Iter> cmMakeReverseIterator(Iter it)
   return std::reverse_iterator<Iter>(it);
 }
 
-inline bool cmHasPrefix(std::string const& str, std::string const& prefix)
+/** Returns true if string @a str starts with the character @a prefix.  **/
+inline bool cmHasPrefix(cm::string_view str, char prefix)
+{
+  return !str.empty() && (str.front() == prefix);
+}
+
+/** Returns true if string @a str starts with string @a prefix.  **/
+inline bool cmHasPrefix(cm::string_view str, cm::string_view prefix)
 {
-  if (str.size() < prefix.size()) {
-    return false;
-  }
   return str.compare(0, prefix.size(), prefix) == 0;
 }
 
-inline bool cmHasSuffix(const std::string& str, const std::string& suffix)
+/** Returns true if string @a str ends with the character @a suffix.  **/
+inline bool cmHasSuffix(cm::string_view str, char suffix)
 {
-  if (str.size() < suffix.size()) {
-    return false;
+  return !str.empty() && (str.back() == suffix);
+}
+
+/** Returns true if string @a str ends with string @a suffix.  **/
+inline bool cmHasSuffix(cm::string_view str, cm::string_view suffix)
+{
+  return str.size() >= suffix.size() &&
+    str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
+}
+
+/** Removes an existing suffix character of from the string @a str.  **/
+inline void cmStripSuffixIfExists(std::string& str, char suffix)
+{
+  if (cmHasSuffix(str, suffix)) {
+    str.pop_back();
   }
-  return str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
 }
 
-inline void cmStripSuffixIfExists(std::string& str, const std::string& suffix)
+/** Removes an existing suffix string of from the string @a str.  **/
+inline void cmStripSuffixIfExists(std::string& str, cm::string_view suffix)
 {
   if (cmHasSuffix(str, suffix)) {
     str.resize(str.size() - suffix.size());

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dfaa87f1b3335b2e80f68726fd5e1b3bbd87d667
commit dfaa87f1b3335b2e80f68726fd5e1b3bbd87d667
Author:     Regina Pfeifer <regina at mailbox.org>
AuthorDate: Mon Apr 8 09:55:52 2019 +0200
Commit:     Regina Pfeifer <regina at mailbox.org>
CommitDate: Mon Jul 22 15:27:56 2019 +0200

    cmState: Support BuiltinCommands as free functions

diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index 9ae2f71..f351ff8 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -162,7 +162,7 @@ void GetScriptingCommands(cmState* state)
   state->AddBuiltinCommand("option", cm::make_unique<cmOptionCommand>());
   state->AddBuiltinCommand("cmake_parse_arguments",
                            cm::make_unique<cmParseArgumentsCommand>());
-  state->AddBuiltinCommand("return", cm::make_unique<cmReturnCommand>());
+  state->AddBuiltinCommand("return", cmReturnCommand);
   state->AddBuiltinCommand("separate_arguments",
                            cm::make_unique<cmSeparateArgumentsCommand>());
   state->AddBuiltinCommand("set", cm::make_unique<cmSetCommand>());
@@ -255,8 +255,7 @@ void GetProjectCommands(cmState* state)
                            cm::make_unique<cmDefinePropertyCommand>());
   state->AddBuiltinCommand("enable_language",
                            cm::make_unique<cmEnableLanguageCommand>());
-  state->AddBuiltinCommand("enable_testing",
-                           cm::make_unique<cmEnableTestingCommand>());
+  state->AddBuiltinCommand("enable_testing", cmEnableTestingCommand);
   state->AddBuiltinCommand("get_source_file_property",
                            cm::make_unique<cmGetSourceFilePropertyCommand>());
   state->AddBuiltinCommand("get_target_property",
diff --git a/Source/cmEnableTestingCommand.cxx b/Source/cmEnableTestingCommand.cxx
index 6a64450..89212c8 100644
--- a/Source/cmEnableTestingCommand.cxx
+++ b/Source/cmEnableTestingCommand.cxx
@@ -2,15 +2,12 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmEnableTestingCommand.h"
 
+#include "cmExecutionStatus.h"
 #include "cmMakefile.h"
 
-class cmExecutionStatus;
-
-// we do this in the final pass so that we now the subdirs have all
-// been defined
-bool cmEnableTestingCommand::InitialPass(std::vector<std::string> const&,
-                                         cmExecutionStatus&)
+bool cmEnableTestingCommand(std::vector<std::string> const&,
+                            cmExecutionStatus& status)
 {
-  this->Makefile->AddDefinition("CMAKE_TESTING_ENABLED", "1");
+  status.GetMakefile().AddDefinition("CMAKE_TESTING_ENABLED", "1");
   return true;
 }
diff --git a/Source/cmEnableTestingCommand.h b/Source/cmEnableTestingCommand.h
index fd50ebc..e4593f2 100644
--- a/Source/cmEnableTestingCommand.h
+++ b/Source/cmEnableTestingCommand.h
@@ -8,13 +8,9 @@
 #include <string>
 #include <vector>
 
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
 class cmExecutionStatus;
 
-/** \class cmEnableTestingCommand
+/**
  * \brief Enable testing for this directory and below.
  *
  * Produce the output testfile. This produces a file in the build directory
@@ -27,23 +23,7 @@ class cmExecutionStatus;
  * Note that CTest expects to find this file in the build directory root;
  * therefore, this command should be in the source directory root too.
  */
-class cmEnableTestingCommand : public cmCommand
-{
-public:
-  /**
-   * This is a virtual constructor for the command.
-   */
-  std::unique_ptr<cmCommand> Clone() override
-  {
-    return cm::make_unique<cmEnableTestingCommand>();
-  }
-
-  /**
-   * This is called when the command is first encountered in
-   * the CMakeLists.txt file.
-   */
-  bool InitialPass(std::vector<std::string> const&,
-                   cmExecutionStatus&) override;
-};
+bool cmEnableTestingCommand(std::vector<std::string> const&,
+                            cmExecutionStatus&);
 
 #endif
diff --git a/Source/cmReturnCommand.cxx b/Source/cmReturnCommand.cxx
index ceea8b4..5905669 100644
--- a/Source/cmReturnCommand.cxx
+++ b/Source/cmReturnCommand.cxx
@@ -5,8 +5,8 @@
 #include "cmExecutionStatus.h"
 
 // cmReturnCommand
-bool cmReturnCommand::InitialPass(std::vector<std::string> const&,
-                                  cmExecutionStatus& status)
+bool cmReturnCommand(std::vector<std::string> const&,
+                     cmExecutionStatus& status)
 {
   status.SetReturnInvoked();
   return true;
diff --git a/Source/cmReturnCommand.h b/Source/cmReturnCommand.h
index e9264d2..2404a36 100644
--- a/Source/cmReturnCommand.h
+++ b/Source/cmReturnCommand.h
@@ -8,34 +8,10 @@
 #include <string>
 #include <vector>
 
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
 class cmExecutionStatus;
 
-/** \class cmReturnCommand
- * \brief Return from a directory or function
- *
- * cmReturnCommand returns from a directory or function
- */
-class cmReturnCommand : public cmCommand
-{
-public:
-  /**
-   * This is a virtual constructor for the command.
-   */
-  std::unique_ptr<cmCommand> Clone() override
-  {
-    return cm::make_unique<cmReturnCommand>();
-  }
-
-  /**
-   * This is called when the command is first encountered in
-   * the CMakeLists.txt file.
-   */
-  bool InitialPass(std::vector<std::string> const& args,
-                   cmExecutionStatus& status) override;
-};
+/// Return from a directory or function
+bool cmReturnCommand(std::vector<std::string> const& args,
+                     cmExecutionStatus& status);
 
 #endif
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 441f11c..0b12a65 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -432,6 +432,23 @@ void cmState::AddBuiltinCommand(std::string const& name, Command command)
   this->BuiltinCommands.emplace(name, std::move(command));
 }
 
+void cmState::AddBuiltinCommand(std::string const& name,
+                                BuiltinCommand command)
+{
+  this->AddBuiltinCommand(
+    name,
+    [command](const std::vector<cmListFileArgument>& args,
+              cmExecutionStatus& status) -> bool {
+      std::vector<std::string> expandedArguments;
+      if (!status.GetMakefile().ExpandArguments(args, expandedArguments)) {
+        // There was an error expanding arguments.  It was already
+        // reported, so we can skip this command without error.
+        return true;
+      }
+      return command(expandedArguments, status);
+    });
+}
+
 void cmState::AddDisallowedCommand(std::string const& name,
                                    std::unique_ptr<cmCommand> command,
                                    cmPolicies::PolicyID policy,
diff --git a/Source/cmState.h b/Source/cmState.h
index 07c1c9b..8847f3b 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -145,6 +145,8 @@ public:
 
   using Command = std::function<bool(std::vector<cmListFileArgument> const&,
                                      cmExecutionStatus&)>;
+  using BuiltinCommand = bool (*)(std::vector<std::string> const&,
+                                  cmExecutionStatus&);
 
   // Returns a command from its name, case insensitive, or nullptr
   Command GetCommand(std::string const& name) const;
@@ -154,6 +156,7 @@ public:
   void AddBuiltinCommand(std::string const& name,
                          std::unique_ptr<cmCommand> command);
   void AddBuiltinCommand(std::string const& name, Command command);
+  void AddBuiltinCommand(std::string const& name, BuiltinCommand command);
   void AddDisallowedCommand(std::string const& name,
                             std::unique_ptr<cmCommand> command,
                             cmPolicies::PolicyID policy, const char* message);

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=62b5d1e4adf4f21a953557edf6552e3a81f47c07
commit 62b5d1e4adf4f21a953557edf6552e3a81f47c07
Author:     Avraham Shukron <avraham.shukron at gmail.com>
AuthorDate: Fri Jul 19 22:48:20 2019 +0300
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Jul 22 08:53:52 2019 -0400

    cmTargetPropCommandBase: Order target type condition by order in enum
    
    This improves readability.

diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx
index 1b8ee81..2f93e39 100644
--- a/Source/cmTargetPropCommandBase.cxx
+++ b/Source/cmTargetPropCommandBase.cxx
@@ -32,12 +32,12 @@ bool cmTargetPropCommandBase::HandleArguments(
     this->HandleMissingTarget(args[0]);
     return false;
   }
-  if ((this->Target->GetType() != cmStateEnums::SHARED_LIBRARY) &&
+  if ((this->Target->GetType() != cmStateEnums::EXECUTABLE) &&
       (this->Target->GetType() != cmStateEnums::STATIC_LIBRARY) &&
-      (this->Target->GetType() != cmStateEnums::OBJECT_LIBRARY) &&
+      (this->Target->GetType() != cmStateEnums::SHARED_LIBRARY) &&
       (this->Target->GetType() != cmStateEnums::MODULE_LIBRARY) &&
-      (this->Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) &&
-      (this->Target->GetType() != cmStateEnums::EXECUTABLE)) {
+      (this->Target->GetType() != cmStateEnums::OBJECT_LIBRARY) &&
+      (this->Target->GetType() != cmStateEnums::INTERFACE_LIBRARY)) {
     this->SetError("called with non-compilable target type");
     return false;
   }

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=28f2d12a055e025aa0ddeb9842f204f29181eaff
commit 28f2d12a055e025aa0ddeb9842f204f29181eaff
Author:     Regina Pfeifer <regina at mailbox.org>
AuthorDate: Sun Apr 7 21:46:46 2019 +0200
Commit:     Regina Pfeifer <regina at mailbox.org>
CommitDate: Sun Jul 21 09:25:32 2019 +0200

    cmCommand: De-virtualize function InvokeInitialPass

diff --git a/Source/cmCommand.h b/Source/cmCommand.h
index 9e978b3..bcb178d 100644
--- a/Source/cmCommand.h
+++ b/Source/cmCommand.h
@@ -52,8 +52,8 @@ public:
    * encountered in the CMakeLists.txt file.  It expands the command's
    * arguments and then invokes the InitialPass.
    */
-  virtual bool InvokeInitialPass(const std::vector<cmListFileArgument>& args,
-                                 cmExecutionStatus& status);
+  bool InvokeInitialPass(const std::vector<cmListFileArgument>& args,
+                         cmExecutionStatus& status);
 
   /**
    * This is called when the command is first encountered in
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index 96c7105..9ae2f71 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -147,7 +147,7 @@ void GetScriptingCommands(cmState* state)
                            cm::make_unique<cmGetFilenameComponentCommand>());
   state->AddBuiltinCommand("get_property",
                            cm::make_unique<cmGetPropertyCommand>());
-  state->AddBuiltinCommand("if", cm::make_unique<cmIfCommand>());
+  state->AddBuiltinCommand("if", cmIfCommand);
   state->AddBuiltinCommand("include", cm::make_unique<cmIncludeCommand>());
   state->AddBuiltinCommand("include_guard",
                            cm::make_unique<cmIncludeGuardCommand>());
@@ -173,7 +173,7 @@ void GetScriptingCommands(cmState* state)
   state->AddBuiltinCommand("site_name", cm::make_unique<cmSiteNameCommand>());
   state->AddBuiltinCommand("string", cm::make_unique<cmStringCommand>());
   state->AddBuiltinCommand("unset", cm::make_unique<cmUnsetCommand>());
-  state->AddBuiltinCommand("while", cm::make_unique<cmWhileCommand>());
+  state->AddBuiltinCommand("while", cmWhileCommand);
 
   state->AddUnexpectedCommand(
     "else",
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx
index 4edea17..385022c 100644
--- a/Source/cmIfCommand.cxx
+++ b/Source/cmIfCommand.cxx
@@ -13,6 +13,7 @@
 #include "cmSystemTools.h"
 #include "cmake.h"
 
+#include <string>
 #include <utility>
 
 static std::string cmIfCommandError(
@@ -176,19 +177,19 @@ bool cmIfFunctionBlocker::ShouldRemove(const cmListFileFunction& lff,
 }
 
 //=========================================================================
-bool cmIfCommand::InvokeInitialPass(
-  const std::vector<cmListFileArgument>& args, cmExecutionStatus&)
+bool cmIfCommand(std::vector<cmListFileArgument> const& args,
+                 cmExecutionStatus& inStatus)
 {
+  cmMakefile& makefile = inStatus.GetMakefile();
   std::string errorString;
 
   std::vector<cmExpandedCommandArgument> expandedArguments;
-  this->Makefile->ExpandArguments(args, expandedArguments);
+  makefile.ExpandArguments(args, expandedArguments);
 
   MessageType status;
 
   cmConditionEvaluator conditionEvaluator(
-    *(this->Makefile), this->Makefile->GetExecutionContext(),
-    this->Makefile->GetBacktrace());
+    makefile, makefile.GetExecutionContext(), makefile.GetBacktrace());
 
   bool isTrue =
     conditionEvaluator.IsTrue(expandedArguments, errorString, status);
@@ -197,11 +198,11 @@ bool cmIfCommand::InvokeInitialPass(
     std::string err = "if " + cmIfCommandError(expandedArguments);
     err += errorString;
     if (status == MessageType::FATAL_ERROR) {
-      this->Makefile->IssueMessage(MessageType::FATAL_ERROR, err);
+      makefile.IssueMessage(MessageType::FATAL_ERROR, err);
       cmSystemTools::SetFatalErrorOccured();
       return true;
     }
-    this->Makefile->IssueMessage(status, err);
+    makefile.IssueMessage(status, err);
   }
 
   {
@@ -213,7 +214,7 @@ bool cmIfCommand::InvokeInitialPass(
       fb->HasRun = true;
     }
     fb->Args = args;
-    this->Makefile->AddFunctionBlocker(std::move(fb));
+    makefile.AddFunctionBlocker(std::move(fb));
   }
 
   return true;
diff --git a/Source/cmIfCommand.h b/Source/cmIfCommand.h
index 4a67760..775e609 100644
--- a/Source/cmIfCommand.h
+++ b/Source/cmIfCommand.h
@@ -5,17 +5,12 @@
 
 #include "cmConfigure.h" // IWYU pragma: keep
 
-#include <string>
 #include <vector>
 
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
 #include "cmFunctionBlocker.h"
 #include "cmListFileCache.h"
 
 class cmExecutionStatus;
-class cmExpandedCommandArgument;
 class cmMakefile;
 
 class cmIfFunctionBlocker : public cmFunctionBlocker
@@ -34,37 +29,7 @@ public:
 };
 
 /// Starts an if block
-class cmIfCommand : public cmCommand
-{
-public:
-  /**
-   * This is a virtual constructor for the command.
-   */
-  std::unique_ptr<cmCommand> Clone() override
-  {
-    return cm::make_unique<cmIfCommand>();
-  }
-
-  /**
-   * This overrides the default InvokeInitialPass implementation.
-   * It records the arguments before expansion.
-   */
-  bool InvokeInitialPass(const std::vector<cmListFileArgument>& args,
-                         cmExecutionStatus&) override;
-
-  /**
-   * This is called when the command is first encountered in
-   * the CMakeLists.txt file.
-   */
-  bool InitialPass(std::vector<std::string> const&,
-                   cmExecutionStatus&) override
-  {
-    return false;
-  }
-
-  // Filter the given variable definition based on policy CMP0054.
-  static const char* GetDefinitionIfUnquoted(
-    const cmMakefile* mf, cmExpandedCommandArgument const& argument);
-};
+bool cmIfCommand(std::vector<cmListFileArgument> const& args,
+                 cmExecutionStatus& status);
 
 #endif
diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx
index 434c298..37d1c74 100644
--- a/Source/cmWhileCommand.cxx
+++ b/Source/cmWhileCommand.cxx
@@ -11,6 +11,7 @@
 #include "cmMessageType.h"
 #include "cmSystemTools.h"
 
+#include <string>
 #include <utility>
 
 cmWhileFunctionBlocker::cmWhileFunctionBlocker(cmMakefile* mf)
@@ -129,19 +130,20 @@ bool cmWhileFunctionBlocker::ShouldRemove(const cmListFileFunction& lff,
   return false;
 }
 
-bool cmWhileCommand::InvokeInitialPass(
-  const std::vector<cmListFileArgument>& args, cmExecutionStatus&)
+bool cmWhileCommand(std::vector<cmListFileArgument> const& args,
+                    cmExecutionStatus& status)
 {
   if (args.empty()) {
-    this->SetError("called with incorrect number of arguments");
+    status.SetError("called with incorrect number of arguments");
     return false;
   }
 
   // create a function blocker
   {
-    auto fb = cm::make_unique<cmWhileFunctionBlocker>(this->Makefile);
+    cmMakefile& makefile = status.GetMakefile();
+    auto fb = cm::make_unique<cmWhileFunctionBlocker>(&makefile);
     fb->Args = args;
-    this->Makefile->AddFunctionBlocker(std::move(fb));
+    makefile.AddFunctionBlocker(std::move(fb));
   }
   return true;
 }
diff --git a/Source/cmWhileCommand.h b/Source/cmWhileCommand.h
index 857d1c8..2257799 100644
--- a/Source/cmWhileCommand.h
+++ b/Source/cmWhileCommand.h
@@ -5,12 +5,8 @@
 
 #include "cmConfigure.h" // IWYU pragma: keep
 
-#include <string>
 #include <vector>
 
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
 #include "cmFunctionBlocker.h"
 #include "cmListFileCache.h"
 
@@ -35,33 +31,7 @@ private:
 };
 
 /// \brief Starts a while loop
-class cmWhileCommand : public cmCommand
-{
-public:
-  /**
-   * This is a virtual constructor for the command.
-   */
-  std::unique_ptr<cmCommand> Clone() override
-  {
-    return cm::make_unique<cmWhileCommand>();
-  }
-
-  /**
-   * This overrides the default InvokeInitialPass implementation.
-   * It records the arguments before expansion.
-   */
-  bool InvokeInitialPass(const std::vector<cmListFileArgument>& args,
-                         cmExecutionStatus&) override;
-
-  /**
-   * This is called when the command is first encountered in
-   * the CMakeLists.txt file.
-   */
-  bool InitialPass(std::vector<std::string> const&,
-                   cmExecutionStatus&) override
-  {
-    return false;
-  }
-};
+bool cmWhileCommand(std::vector<cmListFileArgument> const& args,
+                    cmExecutionStatus& status);
 
 #endif

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=de77d355ac1808164b7247290f45b8133ce1246b
commit de77d355ac1808164b7247290f45b8133ce1246b
Author:     Regina Pfeifer <regina at mailbox.org>
AuthorDate: Sun Apr 7 21:27:41 2019 +0200
Commit:     Regina Pfeifer <regina at mailbox.org>
CommitDate: Sun Jul 21 09:25:32 2019 +0200

    cmState: Add scripted commands by value

diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx
index 4041d62..8b664ad 100644
--- a/Source/cmFunctionCommand.cxx
+++ b/Source/cmFunctionCommand.cxx
@@ -5,8 +5,6 @@
 #include <sstream>
 #include <utility>
 
-#include "cm_memory.hxx"
-
 #include "cmAlgorithms.h"
 #include "cmExecutionStatus.h"
 #include "cmMakefile.h"
@@ -15,35 +13,15 @@
 #include "cmState.h"
 
 // define the class for function commands
-class cmFunctionHelperCommand : public cmCommand
+class cmFunctionHelperCommand
 {
 public:
   /**
-   * This is a virtual constructor for the command.
-   */
-  std::unique_ptr<cmCommand> Clone() override
-  {
-    auto newC = cm::make_unique<cmFunctionHelperCommand>();
-    // we must copy when we clone
-    newC->Args = this->Args;
-    newC->Functions = this->Functions;
-    newC->Policies = this->Policies;
-    newC->FilePath = this->FilePath;
-    return std::unique_ptr<cmCommand>(std::move(newC));
-  }
-
-  /**
    * This is called when the command is first encountered in
    * the CMakeLists.txt file.
    */
-  bool InvokeInitialPass(const std::vector<cmListFileArgument>& args,
-                         cmExecutionStatus&) override;
-
-  bool InitialPass(std::vector<std::string> const&,
-                   cmExecutionStatus&) override
-  {
-    return false;
-  }
+  bool operator()(std::vector<cmListFileArgument> const& args,
+                  cmExecutionStatus& inStatus) const;
 
   std::vector<std::string> Args;
   std::vector<cmListFileFunction> Functions;
@@ -51,12 +29,15 @@ public:
   std::string FilePath;
 };
 
-bool cmFunctionHelperCommand::InvokeInitialPass(
-  const std::vector<cmListFileArgument>& args, cmExecutionStatus& inStatus)
+bool cmFunctionHelperCommand::operator()(
+  std::vector<cmListFileArgument> const& args,
+  cmExecutionStatus& inStatus) const
 {
+  cmMakefile& makefile = inStatus.GetMakefile();
+
   // Expand the argument list to the function.
   std::vector<std::string> expandedArgs;
-  this->Makefile->ExpandArguments(args, expandedArgs);
+  makefile.ExpandArguments(args, expandedArgs);
 
   // make sure the number of arguments passed is at least the number
   // required by the signature
@@ -64,30 +45,30 @@ bool cmFunctionHelperCommand::InvokeInitialPass(
     std::string errorMsg =
       "Function invoked with incorrect arguments for function named: ";
     errorMsg += this->Args[0];
-    this->SetError(errorMsg);
+    inStatus.SetError(errorMsg);
     return false;
   }
 
-  cmMakefile::FunctionPushPop functionScope(this->Makefile, this->FilePath,
+  cmMakefile::FunctionPushPop functionScope(&makefile, this->FilePath,
                                             this->Policies);
 
   // set the value of argc
   std::ostringstream strStream;
   strStream << expandedArgs.size();
-  this->Makefile->AddDefinition("ARGC", strStream.str().c_str());
-  this->Makefile->MarkVariableAsUsed("ARGC");
+  makefile.AddDefinition("ARGC", strStream.str().c_str());
+  makefile.MarkVariableAsUsed("ARGC");
 
   // set the values for ARGV0 ARGV1 ...
   for (unsigned int t = 0; t < expandedArgs.size(); ++t) {
     std::ostringstream tmpStream;
     tmpStream << "ARGV" << t;
-    this->Makefile->AddDefinition(tmpStream.str(), expandedArgs[t].c_str());
-    this->Makefile->MarkVariableAsUsed(tmpStream.str());
+    makefile.AddDefinition(tmpStream.str(), expandedArgs[t].c_str());
+    makefile.MarkVariableAsUsed(tmpStream.str());
   }
 
   // define the formal arguments
   for (unsigned int j = 1; j < this->Args.size(); ++j) {
-    this->Makefile->AddDefinition(this->Args[j], expandedArgs[j - 1].c_str());
+    makefile.AddDefinition(this->Args[j], expandedArgs[j - 1].c_str());
   }
 
   // define ARGV and ARGN
@@ -95,17 +76,16 @@ bool cmFunctionHelperCommand::InvokeInitialPass(
   std::vector<std::string>::const_iterator eit =
     expandedArgs.begin() + (this->Args.size() - 1);
   std::string argnDef = cmJoin(cmMakeRange(eit, expandedArgs.end()), ";");
-  this->Makefile->AddDefinition("ARGV", argvDef.c_str());
-  this->Makefile->MarkVariableAsUsed("ARGV");
-  this->Makefile->AddDefinition("ARGN", argnDef.c_str());
-  this->Makefile->MarkVariableAsUsed("ARGN");
+  makefile.AddDefinition("ARGV", argvDef.c_str());
+  makefile.MarkVariableAsUsed("ARGV");
+  makefile.AddDefinition("ARGN", argnDef.c_str());
+  makefile.MarkVariableAsUsed("ARGN");
 
   // Invoke all the functions that were collected in the block.
   // for each function
   for (cmListFileFunction const& func : this->Functions) {
-    cmExecutionStatus status(*this->GetMakefile());
-    if (!this->Makefile->ExecuteCommand(func, status) ||
-        status.GetNestedError()) {
+    cmExecutionStatus status(makefile);
+    if (!makefile.ExecuteCommand(func, status) || status.GetNestedError()) {
       // The error message should have already included the call stack
       // so we do not need to report an error here.
       functionScope.Quiet();
@@ -132,11 +112,11 @@ bool cmFunctionFunctionBlocker::IsFunctionBlocked(
     // if this is the endfunction for this function then execute
     if (!this->Depth) {
       // create a new command and add it to cmake
-      auto f = cm::make_unique<cmFunctionHelperCommand>();
-      f->Args = this->Args;
-      f->Functions = this->Functions;
-      f->FilePath = this->GetStartingContext().FilePath;
-      mf.RecordPolicies(f->Policies);
+      cmFunctionHelperCommand f;
+      f.Args = this->Args;
+      f.Functions = this->Functions;
+      f.FilePath = this->GetStartingContext().FilePath;
+      mf.RecordPolicies(f.Policies);
       mf.GetState()->AddScriptedCommand(this->Args[0], std::move(f));
       // remove the function blocker now that the function is defined
       mf.RemoveFunctionBlocker(this, lff);
diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx
index f5da2ee..78f4f83 100644
--- a/Source/cmLoadCommandCommand.cxx
+++ b/Source/cmLoadCommandCommand.cxx
@@ -247,7 +247,8 @@ bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args,
   // function blocker
   if (initFunction) {
     this->Makefile->GetState()->AddScriptedCommand(
-      args[0], cm::make_unique<cmLoadedCommand>(initFunction));
+      args[0],
+      cmLegacyCommandWrapper(cm::make_unique<cmLoadedCommand>(initFunction)));
     return true;
   }
   this->SetError("Attempt to load command failed. "
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 11f4bf8..22748b4 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -17,35 +17,15 @@
 #include "cmSystemTools.h"
 
 // define the class for macro commands
-class cmMacroHelperCommand : public cmCommand
+class cmMacroHelperCommand
 {
 public:
   /**
-   * This is a virtual constructor for the command.
-   */
-  std::unique_ptr<cmCommand> Clone() override
-  {
-    auto newC = cm::make_unique<cmMacroHelperCommand>();
-    // we must copy when we clone
-    newC->Args = this->Args;
-    newC->Functions = this->Functions;
-    newC->FilePath = this->FilePath;
-    newC->Policies = this->Policies;
-    return std::unique_ptr<cmCommand>(std::move(newC));
-  }
-
-  /**
    * This is called when the command is first encountered in
    * the CMakeLists.txt file.
    */
-  bool InvokeInitialPass(const std::vector<cmListFileArgument>& args,
-                         cmExecutionStatus&) override;
-
-  bool InitialPass(std::vector<std::string> const&,
-                   cmExecutionStatus&) override
-  {
-    return false;
-  }
+  bool operator()(std::vector<cmListFileArgument> const& args,
+                  cmExecutionStatus& inStatus) const;
 
   std::vector<std::string> Args;
   std::vector<cmListFileFunction> Functions;
@@ -53,12 +33,15 @@ public:
   std::string FilePath;
 };
 
-bool cmMacroHelperCommand::InvokeInitialPass(
-  const std::vector<cmListFileArgument>& args, cmExecutionStatus& inStatus)
+bool cmMacroHelperCommand::operator()(
+  std::vector<cmListFileArgument> const& args,
+  cmExecutionStatus& inStatus) const
 {
+  cmMakefile& makefile = inStatus.GetMakefile();
+
   // Expand the argument list to the macro.
   std::vector<std::string> expandedArgs;
-  this->Makefile->ExpandArguments(args, expandedArgs);
+  makefile.ExpandArguments(args, expandedArgs);
 
   // make sure the number of arguments passed is at least the number
   // required by the signature
@@ -66,11 +49,11 @@ bool cmMacroHelperCommand::InvokeInitialPass(
     std::string errorMsg =
       "Macro invoked with incorrect arguments for macro named: ";
     errorMsg += this->Args[0];
-    this->SetError(errorMsg);
+    inStatus.SetError(errorMsg);
     return false;
   }
 
-  cmMakefile::MacroPushPop macroScope(this->Makefile, this->FilePath,
+  cmMakefile::MacroPushPop macroScope(&makefile, this->FilePath,
                                       this->Policies);
 
   // set the value of argc
@@ -132,9 +115,8 @@ bool cmMacroHelperCommand::InvokeInitialPass(
       arg.Line = k.Line;
       newLFF.Arguments.push_back(std::move(arg));
     }
-    cmExecutionStatus status(*this->GetMakefile());
-    if (!this->Makefile->ExecuteCommand(newLFF, status) ||
-        status.GetNestedError()) {
+    cmExecutionStatus status(makefile);
+    if (!makefile.ExecuteCommand(newLFF, status) || status.GetNestedError()) {
       // The error message should have already included the call stack
       // so we do not need to report an error here.
       macroScope.Quiet();
@@ -166,11 +148,11 @@ bool cmMacroFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
     if (!this->Depth) {
       mf.AppendProperty("MACROS", this->Args[0].c_str());
       // create a new command and add it to cmake
-      auto f = cm::make_unique<cmMacroHelperCommand>();
-      f->Args = this->Args;
-      f->Functions = this->Functions;
-      f->FilePath = this->GetStartingContext().FilePath;
-      mf.RecordPolicies(f->Policies);
+      cmMacroHelperCommand f;
+      f.Args = this->Args;
+      f.Functions = this->Functions;
+      f.FilePath = this->GetStartingContext().FilePath;
+      mf.RecordPolicies(f.Policies);
       mf.GetState()->AddScriptedCommand(this->Args[0], std::move(f));
       // remove the function blocker now that the macro is defined
       mf.RemoveFunctionBlocker(this, lff);
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 82b0a52..441f11c 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -458,8 +458,7 @@ void cmState::AddUnexpectedCommand(std::string const& name, const char* error)
     });
 }
 
-void cmState::AddScriptedCommand(std::string const& name,
-                                 std::unique_ptr<cmCommand> command)
+void cmState::AddScriptedCommand(std::string const& name, Command command)
 {
   std::string sName = cmSystemTools::LowerCase(name);
 
@@ -468,7 +467,7 @@ void cmState::AddScriptedCommand(std::string const& name,
     this->ScriptedCommands["_" + sName] = oldCmd;
   }
 
-  this->ScriptedCommands[sName] = cmLegacyCommandWrapper(std::move(command));
+  this->ScriptedCommands[sName] = std::move(command);
 }
 
 cmState::Command cmState::GetCommand(std::string const& name) const
diff --git a/Source/cmState.h b/Source/cmState.h
index a6e9386..07c1c9b 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -158,8 +158,7 @@ public:
                             std::unique_ptr<cmCommand> command,
                             cmPolicies::PolicyID policy, const char* message);
   void AddUnexpectedCommand(std::string const& name, const char* error);
-  void AddScriptedCommand(std::string const& name,
-                          std::unique_ptr<cmCommand> command);
+  void AddScriptedCommand(std::string const& name, Command command);
   void RemoveBuiltinCommand(std::string const& name);
   void RemoveUserDefinedCommands();
   std::vector<std::string> GetCommandNames() const;

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0101ace1319b5c97472649ec809b67299e2a46ce
commit 0101ace1319b5c97472649ec809b67299e2a46ce
Author:     Regina Pfeifer <regina at mailbox.org>
AuthorDate: Sun Apr 7 20:40:59 2019 +0200
Commit:     Regina Pfeifer <regina at mailbox.org>
CommitDate: Sun Jul 21 09:25:32 2019 +0200

    cmUnexpectedCommand: Replace with lambda expression

diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 0316532..8117916 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -662,8 +662,6 @@ set(SRCS
   cmTryCompileCommand.h
   cmTryRunCommand.cxx
   cmTryRunCommand.h
-  cmUnexpectedCommand.cxx
-  cmUnexpectedCommand.h
   cmUnsetCommand.cxx
   cmUnsetCommand.h
   cmUseMangledMesaCommand.cxx
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 57ae324..82b0a52 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -5,6 +5,7 @@
 #include "cmsys/RegularExpression.hxx"
 #include <algorithm>
 #include <assert.h>
+#include <stdlib.h>
 #include <string.h>
 #include <utility>
 
@@ -15,12 +16,13 @@
 #include "cmCommand.h"
 #include "cmDefinitions.h"
 #include "cmDisallowedCommand.h"
+#include "cmExecutionStatus.h"
 #include "cmGlobVerificationManager.h"
 #include "cmListFileCache.h"
+#include "cmMakefile.h"
 #include "cmStatePrivate.h"
 #include "cmStateSnapshot.h"
 #include "cmSystemTools.h"
-#include "cmUnexpectedCommand.h"
 #include "cmake.h"
 
 cmState::cmState()
@@ -420,10 +422,14 @@ void cmState::SetIsGeneratorMultiConfig(bool b)
 void cmState::AddBuiltinCommand(std::string const& name,
                                 std::unique_ptr<cmCommand> command)
 {
+  this->AddBuiltinCommand(name, cmLegacyCommandWrapper(std::move(command)));
+}
+
+void cmState::AddBuiltinCommand(std::string const& name, Command command)
+{
   assert(name == cmSystemTools::LowerCase(name));
   assert(this->BuiltinCommands.find(name) == this->BuiltinCommands.end());
-  this->BuiltinCommands.emplace(name,
-                                cmLegacyCommandWrapper(std::move(command)));
+  this->BuiltinCommands.emplace(name, std::move(command));
 }
 
 void cmState::AddDisallowedCommand(std::string const& name,
@@ -438,8 +444,18 @@ void cmState::AddDisallowedCommand(std::string const& name,
 
 void cmState::AddUnexpectedCommand(std::string const& name, const char* error)
 {
-  this->AddBuiltinCommand(name,
-                          cm::make_unique<cmUnexpectedCommand>(name, error));
+  this->AddBuiltinCommand(
+    name,
+    [name, error](std::vector<cmListFileArgument> const&,
+                  cmExecutionStatus& status) -> bool {
+      const char* versionValue =
+        status.GetMakefile().GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION");
+      if (name == "endif" && (!versionValue || atof(versionValue) <= 1.4)) {
+        return true;
+      }
+      status.SetError(error);
+      return false;
+    });
 }
 
 void cmState::AddScriptedCommand(std::string const& name,
diff --git a/Source/cmState.h b/Source/cmState.h
index ed70bd6..a6e9386 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -153,6 +153,7 @@ public:
 
   void AddBuiltinCommand(std::string const& name,
                          std::unique_ptr<cmCommand> command);
+  void AddBuiltinCommand(std::string const& name, Command command);
   void AddDisallowedCommand(std::string const& name,
                             std::unique_ptr<cmCommand> command,
                             cmPolicies::PolicyID policy, const char* message);
diff --git a/Source/cmUnexpectedCommand.cxx b/Source/cmUnexpectedCommand.cxx
deleted file mode 100644
index a8de9e6..0000000
--- a/Source/cmUnexpectedCommand.cxx
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
-   file Copyright.txt or https://cmake.org/licensing for details.  */
-#include "cmUnexpectedCommand.h"
-
-#include <stdlib.h>
-
-#include "cmMakefile.h"
-
-class cmExecutionStatus;
-
-bool cmUnexpectedCommand::InitialPass(std::vector<std::string> const&,
-                                      cmExecutionStatus&)
-{
-  const char* versionValue =
-    this->Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION");
-  if (this->Name == "endif" && (!versionValue || atof(versionValue) <= 1.4)) {
-    return true;
-  }
-
-  this->SetError(this->Error);
-  return false;
-}
diff --git a/Source/cmUnexpectedCommand.h b/Source/cmUnexpectedCommand.h
deleted file mode 100644
index 6e4cee5..0000000
--- a/Source/cmUnexpectedCommand.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
-   file Copyright.txt or https://cmake.org/licensing for details.  */
-#ifndef cmUnexpectedCommand_h
-#define cmUnexpectedCommand_h
-
-#include "cmConfigure.h" // IWYU pragma: keep
-
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
-class cmExecutionStatus;
-
-class cmUnexpectedCommand : public cmCommand
-{
-public:
-  cmUnexpectedCommand(std::string name, const char* error)
-    : Name(std::move(name))
-    , Error(error)
-  {
-  }
-
-  std::unique_ptr<cmCommand> Clone() override
-  {
-    return cm::make_unique<cmUnexpectedCommand>(this->Name, this->Error);
-  }
-
-  bool InitialPass(std::vector<std::string> const& args,
-                   cmExecutionStatus& status) override;
-
-private:
-  std::string Name;
-  const char* Error;
-};
-
-#endif
diff --git a/bootstrap b/bootstrap
index c2194fe..bb5229b 100755
--- a/bootstrap
+++ b/bootstrap
@@ -440,7 +440,6 @@ CMAKE_CXX_SOURCES="\
   cmTimestamp \
   cmTryCompileCommand \
   cmTryRunCommand \
-  cmUnexpectedCommand \
   cmUnsetCommand \
   cmUVHandlePtr \
   cmUVProcessChain \

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=015001aaf138119f4825e3c84c0845c5127f9088
commit 015001aaf138119f4825e3c84c0845c5127f9088
Author:     Regina Pfeifer <regina at mailbox.org>
AuthorDate: Sun Apr 7 20:18:32 2019 +0200
Commit:     Regina Pfeifer <regina at mailbox.org>
CommitDate: Sun Jul 21 09:25:32 2019 +0200

    cmState: Hold commands by value

diff --git a/Source/cmCommand.cxx b/Source/cmCommand.cxx
index 99bdd1e..0c2734e 100644
--- a/Source/cmCommand.cxx
+++ b/Source/cmCommand.cxx
@@ -2,6 +2,8 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmCommand.h"
 
+#include <utility>
+
 #include "cmExecutionStatus.h"
 #include "cmMakefile.h"
 
@@ -29,3 +31,29 @@ void cmCommand::SetError(const std::string& e)
 {
   this->Status->SetError(e);
 }
+
+cmLegacyCommandWrapper::cmLegacyCommandWrapper(std::unique_ptr<cmCommand> cmd)
+  : Command(std::move(cmd))
+{
+}
+
+cmLegacyCommandWrapper::cmLegacyCommandWrapper(
+  cmLegacyCommandWrapper const& other)
+  : Command(other.Command->Clone())
+{
+}
+
+cmLegacyCommandWrapper& cmLegacyCommandWrapper::operator=(
+  cmLegacyCommandWrapper const& other)
+{
+  this->Command = other.Command->Clone();
+  return *this;
+}
+
+bool cmLegacyCommandWrapper::operator()(
+  std::vector<cmListFileArgument> const& args, cmExecutionStatus& status) const
+{
+  auto cmd = this->Command->Clone();
+  cmd->SetExecutionStatus(&status);
+  return cmd->InvokeInitialPass(args, status);
+}
diff --git a/Source/cmCommand.h b/Source/cmCommand.h
index 6d3a5fa..9e978b3 100644
--- a/Source/cmCommand.h
+++ b/Source/cmCommand.h
@@ -79,4 +79,22 @@ private:
   cmExecutionStatus* Status = nullptr;
 };
 
+class cmLegacyCommandWrapper
+{
+public:
+  explicit cmLegacyCommandWrapper(std::unique_ptr<cmCommand> cmd);
+
+  cmLegacyCommandWrapper(cmLegacyCommandWrapper const& other);
+  cmLegacyCommandWrapper& operator=(cmLegacyCommandWrapper const& other);
+
+  cmLegacyCommandWrapper(cmLegacyCommandWrapper&&) = default;
+  cmLegacyCommandWrapper& operator=(cmLegacyCommandWrapper&&) = default;
+
+  bool operator()(std::vector<cmListFileArgument> const& args,
+                  cmExecutionStatus& status) const;
+
+private:
+  std::unique_ptr<cmCommand> Command;
+};
+
 #endif
diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx
index e7e91c1..2907f4a 100644
--- a/Source/cmConditionEvaluator.cxx
+++ b/Source/cmConditionEvaluator.cxx
@@ -4,6 +4,7 @@
 
 #include "cmsys/RegularExpression.hxx"
 #include <algorithm>
+#include <functional>
 #include <sstream>
 #include <stdio.h>
 #include <stdlib.h>
@@ -17,7 +18,6 @@
 #include "cmSystemTools.h"
 #include "cmake.h"
 
-class cmCommand;
 class cmTest;
 
 static std::string const keyAND = "AND";
@@ -452,7 +452,7 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&,
       }
       // does a command exist
       if (this->IsKeyword(keyCOMMAND, *arg) && argP1 != newArgs.end()) {
-        cmCommand* command =
+        cmState::Command command =
           this->Makefile.GetState()->GetCommand(argP1->c_str());
         this->HandlePredicate(command != nullptr, reducible, arg, newArgs,
                               argP1, argP2);
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index cb7e94b..3177adc 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -16,7 +16,6 @@
 #include <utility>
 
 #include "cmAlgorithms.h"
-#include "cmCommand.h"
 #include "cmCommandArgumentParserHelper.h"
 #include "cmCustomCommand.h"
 #include "cmCustomCommandLines.h"
@@ -388,12 +387,8 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
   }
 
   // Lookup the command prototype.
-  if (cmCommand* proto =
+  if (cmState::Command command =
         this->GetState()->GetCommandByExactName(lff.Name.Lower)) {
-    // Clone the prototype.
-    std::unique_ptr<cmCommand> pcmd(proto->Clone());
-    pcmd->SetExecutionStatus(&status);
-
     // Decide whether to invoke the command.
     if (!cmSystemTools::GetFatalErrorOccured()) {
       // if trace is enabled, print out invoke information
@@ -401,7 +396,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
         this->PrintCommandTrace(lff);
       }
       // Try invoking the command.
-      bool invokeSucceeded = pcmd->InvokeInitialPass(lff.Arguments, status);
+      bool invokeSucceeded = command(lff.Arguments, status);
       bool hadNestedError = status.GetNestedError();
       if (!invokeSucceeded || hadNestedError) {
         if (!hadNestedError) {
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 9748cf5..57ae324 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -6,7 +6,6 @@
 #include <algorithm>
 #include <assert.h>
 #include <string.h>
-#include <type_traits>
 #include <utility>
 
 #include "cm_memory.hxx"
@@ -423,9 +422,8 @@ void cmState::AddBuiltinCommand(std::string const& name,
 {
   assert(name == cmSystemTools::LowerCase(name));
   assert(this->BuiltinCommands.find(name) == this->BuiltinCommands.end());
-  this->BuiltinCommands.insert(
-    std::map<std::string, std::unique_ptr<cmCommand>>::value_type(
-      name, std::move(command)));
+  this->BuiltinCommands.emplace(name,
+                                cmLegacyCommandWrapper(std::move(command)));
 }
 
 void cmState::AddDisallowedCommand(std::string const& name,
@@ -450,39 +448,27 @@ void cmState::AddScriptedCommand(std::string const& name,
   std::string sName = cmSystemTools::LowerCase(name);
 
   // if the command already exists, give a new name to the old command.
-  if (cmCommand* oldCmd = this->GetCommand(sName)) {
-    std::string const newName = "_" + sName;
-    auto pos = this->ScriptedCommands.find(newName);
-    if (pos != this->ScriptedCommands.end()) {
-      this->ScriptedCommands.erase(pos);
-    }
-    this->ScriptedCommands.insert(std::make_pair(newName, oldCmd->Clone()));
+  if (Command oldCmd = this->GetCommand(sName)) {
+    this->ScriptedCommands["_" + sName] = oldCmd;
   }
 
-  // if the command already exists, free the old one
-  auto pos = this->ScriptedCommands.find(sName);
-  if (pos != this->ScriptedCommands.end()) {
-    this->ScriptedCommands.erase(pos);
-  }
-  this->ScriptedCommands.insert(
-    std::map<std::string, std::unique_ptr<cmCommand>>::value_type(
-      sName, std::move(command)));
+  this->ScriptedCommands[sName] = cmLegacyCommandWrapper(std::move(command));
 }
 
-cmCommand* cmState::GetCommand(std::string const& name) const
+cmState::Command cmState::GetCommand(std::string const& name) const
 {
   return GetCommandByExactName(cmSystemTools::LowerCase(name));
 }
 
-cmCommand* cmState::GetCommandByExactName(std::string const& name) const
+cmState::Command cmState::GetCommandByExactName(std::string const& name) const
 {
   auto pos = this->ScriptedCommands.find(name);
   if (pos != this->ScriptedCommands.end()) {
-    return pos->second.get();
+    return pos->second;
   }
   pos = this->BuiltinCommands.find(name);
   if (pos != this->BuiltinCommands.end()) {
-    return pos->second.get();
+    return pos->second;
   }
   return nullptr;
 }
@@ -507,9 +493,7 @@ std::vector<std::string> cmState::GetCommandNames() const
 void cmState::RemoveBuiltinCommand(std::string const& name)
 {
   assert(name == cmSystemTools::LowerCase(name));
-  auto i = this->BuiltinCommands.find(name);
-  assert(i != this->BuiltinCommands.end());
-  this->BuiltinCommands.erase(i);
+  this->BuiltinCommands.erase(name);
 }
 
 void cmState::RemoveUserDefinedCommands()
diff --git a/Source/cmState.h b/Source/cmState.h
index 7e88030..ed70bd6 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -5,6 +5,7 @@
 
 #include "cmConfigure.h" // IWYU pragma: keep
 
+#include <functional>
 #include <map>
 #include <memory>
 #include <set>
@@ -27,6 +28,7 @@ class cmGlobVerificationManager;
 class cmPropertyDefinition;
 class cmStateSnapshot;
 class cmMessenger;
+class cmExecutionStatus;
 
 class cmState
 {
@@ -141,10 +143,13 @@ public:
   bool GetIsGeneratorMultiConfig() const;
   void SetIsGeneratorMultiConfig(bool b);
 
+  using Command = std::function<bool(std::vector<cmListFileArgument> const&,
+                                     cmExecutionStatus&)>;
+
   // Returns a command from its name, case insensitive, or nullptr
-  cmCommand* GetCommand(std::string const& name) const;
+  Command GetCommand(std::string const& name) const;
   // Returns a command from its name, or nullptr
-  cmCommand* GetCommandByExactName(std::string const& name) const;
+  Command GetCommandByExactName(std::string const& name) const;
 
   void AddBuiltinCommand(std::string const& name,
                          std::unique_ptr<cmCommand> command);
@@ -212,8 +217,8 @@ private:
 
   std::map<cmProperty::ScopeType, cmPropertyDefinitionMap> PropertyDefinitions;
   std::vector<std::string> EnabledLanguages;
-  std::map<std::string, std::unique_ptr<cmCommand>> BuiltinCommands;
-  std::map<std::string, std::unique_ptr<cmCommand>> ScriptedCommands;
+  std::map<std::string, Command> BuiltinCommands;
+  std::map<std::string, Command> ScriptedCommands;
   cmPropertyMap GlobalProperties;
   std::unique_ptr<cmCacheManager> CacheManager;
   std::unique_ptr<cmGlobVerificationManager> GlobVerificationManager;

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1eebc2956321c2e7da00a5d35e207bedb899c804
commit 1eebc2956321c2e7da00a5d35e207bedb899c804
Author:     Daniel Pfeifer <daniel at pfeifer-mail.de>
AuthorDate: Mon Dec 26 10:38:36 2016 +0100
Commit:     Regina Pfeifer <regina at mailbox.org>
CommitDate: Sun Jul 21 09:25:32 2019 +0200

    cmCommand: deprecate functions GetMakefile and SetError
    
    Replace the members for the Makefile and the Error with a
    cmExecutionStatus.  Re-implement GetMakefile and SetError based on that.
    
    Both functions should be called directly on the cmExecutionStatus that is
    passed to InitialPass.  This will help us make all Commands immutable and
    remove the need for cloning.

diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx
index adf9553..2b73d40 100644
--- a/Source/CTest/cmCTestHandlerCommand.cxx
+++ b/Source/CTest/cmCTestHandlerCommand.cxx
@@ -4,6 +4,7 @@
 
 #include "cmCTest.h"
 #include "cmCTestGenericHandler.h"
+#include "cmExecutionStatus.h"
 #include "cmMakefile.h"
 #include "cmMessageType.h"
 #include "cmSystemTools.h"
@@ -13,8 +14,6 @@
 #include <sstream>
 #include <stdlib.h>
 
-class cmExecutionStatus;
-
 cmCTestHandlerCommand::cmCTestHandlerCommand()
 {
   const size_t INIT_SIZE = 100;
@@ -86,7 +85,7 @@ private:
 }
 
 bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
-                                        cmExecutionStatus& /*unused*/)
+                                        cmExecutionStatus& status)
 {
   // save error state and restore it if needed
   SaveRestoreErrorState errorState;
@@ -126,7 +125,7 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
     if (capureCMakeError) {
       this->Makefile->AddDefinition(this->Values[ct_CAPTURE_CMAKE_ERROR],
                                     "-1");
-      std::string const err = this->GetName() + " " + this->GetError();
+      std::string const err = this->GetName() + " " + status.GetError();
       if (!cmSystemTools::FindLastString(err.c_str(), "unknown error.")) {
         cmCTestLog(this->CTest, ERROR_MESSAGE, err << " error from command\n");
       }
@@ -195,8 +194,8 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
     if (capureCMakeError) {
       this->Makefile->AddDefinition(this->Values[ct_CAPTURE_CMAKE_ERROR],
                                     "-1");
-      const char* err = this->GetError();
-      if (err && !cmSystemTools::FindLastString(err, "unknown error.")) {
+      std::string const& err = status.GetError();
+      if (!cmSystemTools::FindLastString(err.c_str(), "unknown error.")) {
         cmCTestLog(this->CTest, ERROR_MESSAGE, err << " error from command\n");
       }
       return true;
@@ -220,7 +219,7 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
       this->Makefile->AddDefinition(this->Values[ct_CAPTURE_CMAKE_ERROR],
                                     "-1");
       cmCTestLog(this->CTest, ERROR_MESSAGE,
-                 this->GetName() << " " << this->GetError() << "\n");
+                 this->GetName() << " " << status.GetError() << "\n");
       // return success because failure is recorded in CAPTURE_CMAKE_ERROR
       return true;
     }
@@ -240,10 +239,10 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
     const char* returnString = "0";
     if (cmSystemTools::GetErrorOccuredFlag()) {
       returnString = "-1";
-      const char* err = this->GetError();
+      std::string const& err = status.GetError();
       // print out the error if it is not "unknown error" which means
       // there was no message
-      if (err && !cmSystemTools::FindLastString(err, "unknown error.")) {
+      if (!cmSystemTools::FindLastString(err.c_str(), "unknown error.")) {
         cmCTestLog(this->CTest, ERROR_MESSAGE, err);
       }
     }
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx
index 255a8e6..8c2d987 100644
--- a/Source/cmCPluginAPI.cxx
+++ b/Source/cmCPluginAPI.cxx
@@ -421,7 +421,7 @@ int CCONV cmExecuteCommand(void* arg, const char* name, int numArgs,
     // Assume all arguments are quoted.
     lff.Arguments.emplace_back(args[i], cmListFileArgument::Quoted, 0);
   }
-  cmExecutionStatus status;
+  cmExecutionStatus status(*mf);
   return mf->ExecuteCommand(lff, status);
 }
 
diff --git a/Source/cmCommand.cxx b/Source/cmCommand.cxx
index d349c91..99bdd1e 100644
--- a/Source/cmCommand.cxx
+++ b/Source/cmCommand.cxx
@@ -2,11 +2,17 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmCommand.h"
 
+#include "cmExecutionStatus.h"
 #include "cmMakefile.h"
 
-class cmExecutionStatus;
 struct cmListFileArgument;
 
+void cmCommand::SetExecutionStatus(cmExecutionStatus* status)
+{
+  this->Status = status;
+  this->Makefile = &status->GetMakefile();
+}
+
 bool cmCommand::InvokeInitialPass(const std::vector<cmListFileArgument>& args,
                                   cmExecutionStatus& status)
 {
@@ -19,15 +25,7 @@ bool cmCommand::InvokeInitialPass(const std::vector<cmListFileArgument>& args,
   return this->InitialPass(expandedArguments, status);
 }
 
-const char* cmCommand::GetError()
-{
-  if (this->Error.empty()) {
-    return "unknown error.";
-  }
-  return this->Error.c_str();
-}
-
 void cmCommand::SetError(const std::string& e)
 {
-  this->Error = e;
+  this->Status->SetError(e);
 }
diff --git a/Source/cmCommand.h b/Source/cmCommand.h
index b210f27..6d3a5fa 100644
--- a/Source/cmCommand.h
+++ b/Source/cmCommand.h
@@ -42,9 +42,11 @@ public:
   /**
    * Specify the makefile.
    */
-  void SetMakefile(cmMakefile* m) { this->Makefile = m; }
   cmMakefile* GetMakefile() { return this->Makefile; }
 
+  void SetExecutionStatus(cmExecutionStatus* s);
+  cmExecutionStatus* GetExecutionStatus() { return this->Status; };
+
   /**
    * This is called by the cmMakefile when the command is first
    * encountered in the CMakeLists.txt file.  It expands the command's
@@ -66,11 +68,6 @@ public:
   virtual std::unique_ptr<cmCommand> Clone() = 0;
 
   /**
-   * Return the last error string.
-   */
-  const char* GetError();
-
-  /**
    * Set the error message
    */
   void SetError(const std::string& e);
@@ -79,7 +76,7 @@ protected:
   cmMakefile* Makefile = nullptr;
 
 private:
-  std::string Error;
+  cmExecutionStatus* Status = nullptr;
 };
 
 #endif
diff --git a/Source/cmDisallowedCommand.cxx b/Source/cmDisallowedCommand.cxx
index 418d98c..aa1f90b 100644
--- a/Source/cmDisallowedCommand.cxx
+++ b/Source/cmDisallowedCommand.cxx
@@ -24,8 +24,6 @@ bool cmDisallowedCommand::InitialPass(std::vector<std::string> const& args,
       return true;
   }
 
-  this->Command->SetMakefile(this->GetMakefile());
-  bool const ret = this->Command->InitialPass(args, status);
-  this->SetError(this->Command->GetError());
-  return ret;
+  this->Command->SetExecutionStatus(this->GetExecutionStatus());
+  return this->Command->InitialPass(args, status);
 }
diff --git a/Source/cmExecutionStatus.h b/Source/cmExecutionStatus.h
index 56199dd..bcacc2f 100644
--- a/Source/cmExecutionStatus.h
+++ b/Source/cmExecutionStatus.h
@@ -3,6 +3,11 @@
 #ifndef cmExecutionStatus_h
 #define cmExecutionStatus_h
 
+#include <cmConfigure.h> // IWYU pragma: keep
+#include <string>
+
+class cmMakefile;
+
 /** \class cmExecutionStatus
  * \brief Superclass for all command status classes
  *
@@ -11,14 +16,26 @@
 class cmExecutionStatus
 {
 public:
+  cmExecutionStatus(cmMakefile& makefile)
+    : Makefile(makefile)
+    , Error("unknown error.")
+  {
+  }
+
   void Clear()
   {
+    this->Error = "unknown error.";
     this->ReturnInvoked = false;
     this->BreakInvoked = false;
     this->ContinueInvoked = false;
     this->NestedError = false;
   }
 
+  cmMakefile& GetMakefile() { return this->Makefile; }
+
+  void SetError(std::string const& e) { this->Error = e; }
+  std::string const& GetError() const { return this->Error; }
+
   void SetReturnInvoked() { this->ReturnInvoked = true; }
   bool GetReturnInvoked() const { return this->ReturnInvoked; }
 
@@ -32,6 +49,8 @@ public:
   bool GetNestedError() const { return this->NestedError; }
 
 private:
+  cmMakefile& Makefile;
+  std::string Error;
   bool ReturnInvoked = false;
   bool BreakInvoked = false;
   bool ContinueInvoked = false;
diff --git a/Source/cmFileCopier.cxx b/Source/cmFileCopier.cxx
index 49e8cd5..4f1a158 100644
--- a/Source/cmFileCopier.cxx
+++ b/Source/cmFileCopier.cxx
@@ -174,11 +174,8 @@ bool cmFileCopier::GetDefaultDirectoryPermissions(mode_t** mode)
     cmSystemTools::ExpandListArgument(default_dir_install_permissions, items);
     for (const auto& arg : items) {
       if (!this->CheckPermissions(arg, **mode)) {
-        std::ostringstream e;
-        e << this->FileCommand->GetError()
-          << " Set with CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS "
-             "variable.";
-        this->FileCommand->SetError(e.str());
+        this->FileCommand->SetError(
+          " Set with CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS variable.");
         return false;
       }
     }
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx
index a30ebe1..e3918b5 100644
--- a/Source/cmForEachCommand.cxx
+++ b/Source/cmForEachCommand.cxx
@@ -55,7 +55,7 @@ bool cmForEachFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
         // set the variable to the loop value
         mf.AddDefinition(this->Args[0], arg.c_str());
         // Invoke all the functions that were collected in the block.
-        cmExecutionStatus status;
+        cmExecutionStatus status(mf);
         for (cmListFileFunction const& func : this->Functions) {
           status.Clear();
           mf.ExecuteCommand(func, status);
diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx
index 6d06531..4041d62 100644
--- a/Source/cmFunctionCommand.cxx
+++ b/Source/cmFunctionCommand.cxx
@@ -103,7 +103,7 @@ bool cmFunctionHelperCommand::InvokeInitialPass(
   // Invoke all the functions that were collected in the block.
   // for each function
   for (cmListFileFunction const& func : this->Functions) {
-    cmExecutionStatus status;
+    cmExecutionStatus status(*this->GetMakefile());
     if (!this->Makefile->ExecuteCommand(func, status) ||
         status.GetNestedError()) {
       // The error message should have already included the call stack
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx
index 625dd45..4edea17 100644
--- a/Source/cmIfCommand.cxx
+++ b/Source/cmIfCommand.cxx
@@ -47,7 +47,7 @@ bool cmIfFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
       }
 
       // execute the functions for the true parts of the if statement
-      cmExecutionStatus status;
+      cmExecutionStatus status(mf);
       int scopeDepth = 0;
       for (cmListFileFunction const& func : this->Functions) {
         // keep track of scope depth
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 6e65c6b..11f4bf8 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -132,7 +132,7 @@ bool cmMacroHelperCommand::InvokeInitialPass(
       arg.Line = k.Line;
       newLFF.Arguments.push_back(std::move(arg));
     }
-    cmExecutionStatus status;
+    cmExecutionStatus status(*this->GetMakefile());
     if (!this->Makefile->ExecuteCommand(newLFF, status) ||
         status.GetNestedError()) {
       // The error message should have already included the call stack
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 1723c5a..cb7e94b 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -392,7 +392,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
         this->GetState()->GetCommandByExactName(lff.Name.Lower)) {
     // Clone the prototype.
     std::unique_ptr<cmCommand> pcmd(proto->Clone());
-    pcmd->SetMakefile(this);
+    pcmd->SetExecutionStatus(&status);
 
     // Decide whether to invoke the command.
     if (!cmSystemTools::GetFatalErrorOccured()) {
@@ -407,7 +407,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
         if (!hadNestedError) {
           // The command invocation requested that we report an error.
           std::string const error =
-            std::string(lff.Name.Original) + " " + pcmd->GetError();
+            std::string(lff.Name.Original) + " " + status.GetError();
           this->IssueMessage(MessageType::FATAL_ERROR, error);
         }
         result = false;
@@ -657,7 +657,7 @@ void cmMakefile::ReadListFile(cmListFile const& listFile,
   // Run the parsed commands.
   const size_t numberFunctions = listFile.Functions.size();
   for (size_t i = 0; i < numberFunctions; ++i) {
-    cmExecutionStatus status;
+    cmExecutionStatus status(*this);
     this->ExecuteCommand(listFile.Functions[i], status);
     if (cmSystemTools::GetFatalErrorOccured()) {
       break;
diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx
index afc0b76..83a774d 100644
--- a/Source/cmVariableWatchCommand.cxx
+++ b/Source/cmVariableWatchCommand.cxx
@@ -55,7 +55,7 @@ static void cmVariableWatchCommandVariableAccessed(const std::string& variable,
     newLFF.Arguments.emplace_back(stack, cmListFileArgument::Quoted, 9999);
     newLFF.Name = data->Command;
     newLFF.Line = 9999;
-    cmExecutionStatus status;
+    cmExecutionStatus status(*makefile);
     if (!makefile->ExecuteCommand(newLFF, status)) {
       std::ostringstream error;
       error << "Error in cmake code at\nUnknown:0:\n"
diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx
index a902964..434c298 100644
--- a/Source/cmWhileCommand.cxx
+++ b/Source/cmWhileCommand.cxx
@@ -82,7 +82,7 @@ bool cmWhileFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
 
         // Invoke all the functions that were collected in the block.
         for (cmListFileFunction const& fn : this->Functions) {
-          cmExecutionStatus status;
+          cmExecutionStatus status(mf);
           mf.ExecuteCommand(fn, status);
           if (status.GetReturnInvoked()) {
             inStatus.SetReturnInvoked();

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dd3e4767863dfe1307d4dccd2445e5312b55473e
commit dd3e4767863dfe1307d4dccd2445e5312b55473e
Author:     Kyle Edwards <kyle.edwards at kitware.com>
AuthorDate: Wed Jul 17 14:00:01 2019 -0400
Commit:     Kyle Edwards <kyle.edwards at kitware.com>
CommitDate: Thu Jul 18 11:10:36 2019 -0400

    OpenSSL: Issue an error if OpenSSL is not found
    
    When building with the built-in Curl, CMAKE_USE_OPENSSL is only set
    to ON by default if an OpenSSL installation is detected. However, this
    can cause the user to mistakenly build without OpenSSL support if
    OpenSSL is not installed, because CMAKE_USE_OPENSSL is set to OFF in
    that case. Always set CMAKE_USE_OPENSSL to ON by default on systems
    where it could be available, skipping the initial detection, resulting
    in an error when we try to use OpenSSL later on. Detect this error
    and advise the user to either install OpenSSL or set CMAKE_USE_OPENSSL
    to OFF.
    
    Co-Authored-by: Brad King <brad.king at kitware.com>

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 399e79c..5efa077 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -429,10 +429,7 @@ macro (CMAKE_BUILD_UTILITIES)
     set(_CMAKE_USE_OPENSSL_DEFAULT OFF)
     if(NOT DEFINED CMAKE_USE_OPENSSL AND NOT WIN32 AND NOT APPLE
         AND CMAKE_SYSTEM_NAME MATCHES "(Linux|FreeBSD)")
-      find_package(OpenSSL QUIET)
-      if(OPENSSL_FOUND)
-        set(_CMAKE_USE_OPENSSL_DEFAULT ON)
-      endif()
+      set(_CMAKE_USE_OPENSSL_DEFAULT ON)
     endif()
     option(CMAKE_USE_OPENSSL "Use OpenSSL." ${_CMAKE_USE_OPENSSL_DEFAULT})
     mark_as_advanced(CMAKE_USE_OPENSSL)
diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt
index 37522fc..bc8a7dc 100644
--- a/Utilities/cmcurl/CMakeLists.txt
+++ b/Utilities/cmcurl/CMakeLists.txt
@@ -449,7 +449,12 @@ if(CMAKE_USE_SECTRANSP)
 endif()
 
 if(CMAKE_USE_OPENSSL)
-  find_package(OpenSSL REQUIRED)
+  find_package(OpenSSL)
+  if(NOT OpenSSL_FOUND)
+    message(FATAL_ERROR
+      "Could not find OpenSSL. Install an OpenSSL development package or "
+      "configure CMake with -DCMAKE_USE_OPENSSL=OFF to build without OpenSSL.")
+  endif()
   set(SSL_ENABLED ON)
   set(USE_OPENSSL ON)
   set(HAVE_LIBCRYPTO ON)

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

Summary of changes:
 CMakeLists.txt                                     |  5 +-
 Source/CMakeLists.txt                              |  2 -
 Source/CTest/cmCTestHandlerCommand.cxx             | 17 +++--
 Source/cmAlgorithms.h                              | 37 +++++++---
 Source/cmCPluginAPI.cxx                            |  2 +-
 Source/cmCommand.cxx                               | 42 +++++++++---
 Source/cmCommand.h                                 | 33 ++++++---
 Source/cmCommands.cxx                              |  9 ++-
 Source/cmConditionEvaluator.cxx                    |  4 +-
 Source/cmDisallowedCommand.cxx                     |  6 +-
 Source/cmEnableTestingCommand.cxx                  | 11 ++-
 Source/cmEnableTestingCommand.h                    | 26 +-------
 Source/cmExecutionStatus.h                         | 19 ++++++
 Source/cmFileCopier.cxx                            |  7 +-
 Source/cmForEachCommand.cxx                        |  2 +-
 Source/cmFunctionCommand.cxx                       | 74 ++++++++------------
 Source/cmIfCommand.cxx                             | 19 +++---
 Source/cmIfCommand.h                               | 39 +----------
 Source/cmLoadCommandCommand.cxx                    |  3 +-
 Source/cmMacroCommand.cxx                          | 54 +++++----------
 Source/cmMakefile.cxx                              | 13 ++--
 Source/cmReturnCommand.cxx                         |  4 +-
 Source/cmReturnCommand.h                           | 30 +--------
 Source/cmState.cxx                                 | 78 +++++++++++++---------
 Source/cmState.h                                   | 20 ++++--
 Source/cmTargetPropCommandBase.cxx                 |  7 +-
 Source/cmUnexpectedCommand.cxx                     | 22 ------
 Source/cmUnexpectedCommand.h                       | 40 -----------
 Source/cmVariableWatchCommand.cxx                  |  2 +-
 Source/cmWhileCommand.cxx                          | 14 ++--
 Source/cmWhileCommand.h                            | 34 +---------
 .../UNKNOWNwithOnlyObjectSources-stderr.txt        |  2 +-
 .../target_compile_definitions/RunCMakeTest.cmake  |  1 +
 .../unknown_imported_target.cmake                  | 11 +++
 Utilities/cmcurl/CMakeLists.txt                    |  7 +-
 bootstrap                                          |  1 -
 36 files changed, 296 insertions(+), 401 deletions(-)
 delete mode 100644 Source/cmUnexpectedCommand.cxx
 delete mode 100644 Source/cmUnexpectedCommand.h
 create mode 100644 Tests/RunCMake/target_compile_definitions/unknown_imported_target.cmake


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list