Przeglądaj źródła

Refactoring: use append functions from cmext/algorithm

Marc Chevrier 5 lat temu
rodzic
commit
f7d12609f0
60 zmienionych plików z 235 dodań i 208 usunięć
  1. 3 2
      Source/CTest/cmCTestBZR.cxx
  2. 3 2
      Source/CTest/cmCTestBuildHandler.cxx
  3. 7 6
      Source/CTest/cmCTestCoverageHandler.cxx
  4. 4 3
      Source/CTest/cmCTestCurl.cxx
  5. 3 2
      Source/CTest/cmCTestHG.cxx
  6. 4 2
      Source/CTest/cmCTestMultiProcessHandler.cxx
  7. 3 2
      Source/CTest/cmCTestP4.cxx
  8. 4 3
      Source/CTest/cmCTestSVN.cxx
  9. 9 7
      Source/CTest/cmCTestSubmitHandler.cxx
  10. 3 2
      Source/CTest/cmProcess.cxx
  11. 3 2
      Source/cmAddLibraryCommand.cxx
  12. 0 27
      Source/cmAlgorithms.h
  13. 5 5
      Source/cmCTest.cxx
  14. 3 1
      Source/cmConditionEvaluator.cxx
  15. 4 4
      Source/cmCustomCommand.cxx
  16. 4 3
      Source/cmCustomCommandGenerator.cxx
  17. 3 2
      Source/cmDocumentationSection.h
  18. 2 3
      Source/cmELF.cxx
  19. 3 2
      Source/cmExecuteProcessCommand.cxx
  20. 1 0
      Source/cmExportBuildFileGenerator.cxx
  21. 3 2
      Source/cmExportBuildFileGenerator.h
  22. 6 4
      Source/cmExtraCodeBlocksGenerator.cxx
  23. 3 2
      Source/cmFileAPICodemodel.cxx
  24. 6 6
      Source/cmFileCommand.cxx
  25. 3 2
      Source/cmFindBase.cxx
  26. 3 2
      Source/cmFindCommon.cxx
  27. 2 2
      Source/cmFunctionCommand.cxx
  28. 2 2
      Source/cmGeneratorExpressionParser.cxx
  29. 3 2
      Source/cmGlobalGenerator.h
  30. 1 1
      Source/cmGlobalJOMMakefileGenerator.cxx
  31. 1 1
      Source/cmGlobalNMakeMakefileGenerator.cxx
  32. 4 3
      Source/cmGlobalNinjaGenerator.cxx
  33. 2 2
      Source/cmGlobalUnixMakefileGenerator3.cxx
  34. 1 1
      Source/cmGlobalVisualStudio8Generator.cxx
  35. 3 2
      Source/cmGlobalXCodeGenerator.cxx
  36. 4 2
      Source/cmIDEOptions.cxx
  37. 4 3
      Source/cmIncludeDirectoryCommand.cxx
  38. 3 2
      Source/cmJsonObjects.cxx
  39. 2 1
      Source/cmLocalGenerator.cxx
  40. 3 2
      Source/cmLocalGhsMultiGenerator.cxx
  41. 3 2
      Source/cmLocalUnixMakefileGenerator3.cxx
  42. 3 1
      Source/cmLocalVisualStudio10Generator.cxx
  43. 2 2
      Source/cmMacroCommand.cxx
  44. 2 1
      Source/cmMakefile.cxx
  45. 4 4
      Source/cmMakefileExecutableTargetGenerator.cxx
  46. 5 5
      Source/cmMakefileLibraryTargetGenerator.cxx
  47. 13 11
      Source/cmMakefileTargetGenerator.cxx
  48. 2 2
      Source/cmNinjaTargetGenerator.cxx
  49. 4 2
      Source/cmOrderDirectories.cxx
  50. 4 2
      Source/cmQtAutoGen.cxx
  51. 7 7
      Source/cmQtAutoMocUic.cxx
  52. 3 2
      Source/cmQtAutoRcc.cxx
  53. 3 2
      Source/cmSetTargetPropertiesCommand.cxx
  54. 3 2
      Source/cmSetTestsPropertiesCommand.cxx
  55. 2 1
      Source/cmStateDirectory.cxx
  56. 9 8
      Source/cmSystemTools.cxx
  57. 17 16
      Source/cmTarget.cxx
  58. 3 1
      Source/cmake.cxx
  59. 11 10
      Source/cmakemain.cxx
  60. 5 3
      Source/cmcmd.cxx

+ 3 - 2
Source/CTest/cmCTestBZR.cxx

@@ -8,11 +8,12 @@
 #include <ostream>
 #include <vector>
 
+#include <cmext/algorithm>
+
 #include "cmsys/RegularExpression.hxx"
 
 #include "cm_expat.h"
 
-#include "cmAlgorithms.h"
 #include "cmCTest.h"
 #include "cmCTestVC.h"
 #include "cmProcessTools.h"
@@ -245,7 +246,7 @@ private:
 
   void CharacterDataHandler(const char* data, int length) override
   {
-    cmAppend(this->CData, data, data + length);
+    cm::append(this->CData, data, data + length);
   }
 
   void EndElement(const std::string& name) override

+ 3 - 2
Source/CTest/cmCTestBuildHandler.cxx

@@ -7,11 +7,12 @@
 #include <set>
 #include <utility>
 
+#include <cmext/algorithm>
+
 #include "cmsys/Directory.hxx"
 #include "cmsys/FStream.hxx"
 #include "cmsys/Process.h"
 
-#include "cmAlgorithms.h"
 #include "cmCTest.h"
 #include "cmDuration.h"
 #include "cmFileTimeCache.h"
@@ -969,7 +970,7 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, size_t length,
     if (it != queue->end()) {
       // Create a contiguous array for the line
       this->CurrentProcessingLine.clear();
-      cmAppend(this->CurrentProcessingLine, queue->begin(), it);
+      cm::append(this->CurrentProcessingLine, queue->begin(), it);
       this->CurrentProcessingLine.push_back(0);
       const char* line = this->CurrentProcessingLine.data();
 

+ 7 - 6
Source/CTest/cmCTestCoverageHandler.cxx

@@ -12,12 +12,13 @@
 #include <sstream>
 #include <utility>
 
+#include <cmext/algorithm>
+
 #include "cmsys/FStream.hxx"
 #include "cmsys/Glob.hxx"
 #include "cmsys/Process.h"
 #include "cmsys/RegularExpression.hxx"
 
-#include "cmAlgorithms.h"
 #include "cmCTest.h"
 #include "cmDuration.h"
 #include "cmGeneratedFileStream.h"
@@ -819,7 +820,7 @@ int cmCTestCoverageHandler::HandleJacocoCoverage(
   std::string binaryDir = this->CTest->GetCTestConfiguration("BuildDirectory");
   std::string binCoverageFile = binaryDir + "/*jacoco.xml";
   g2.FindFiles(binCoverageFile);
-  cmAppend(files, g2.GetFiles());
+  cm::append(files, g2.GetFiles());
 
   if (!files.empty()) {
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
@@ -1462,7 +1463,7 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
         "   looking for LCOV files in: " << daGlob << std::endl, this->Quiet);
       gl.FindFiles(daGlob);
       // Keep a list of all LCOV files
-      cmAppend(lcovFiles, gl.GetFiles());
+      cm::append(lcovFiles, gl.GetFiles());
 
       for (std::string const& file : lcovFiles) {
         lcovFile = file;
@@ -1599,10 +1600,10 @@ void cmCTestCoverageHandler::FindGCovFiles(std::vector<std::string>& files)
       "   globbing for coverage in: " << lm.first << std::endl, this->Quiet);
     std::string daGlob = cmStrCat(lm.first, "/*.da");
     gl.FindFiles(daGlob);
-    cmAppend(files, gl.GetFiles());
+    cm::append(files, gl.GetFiles());
     daGlob = cmStrCat(lm.first, "/*.gcda");
     gl.FindFiles(daGlob);
-    cmAppend(files, gl.GetFiles());
+    cm::append(files, gl.GetFiles());
   }
 }
 
@@ -1638,7 +1639,7 @@ bool cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files)
                "Error while finding files matching " << daGlob << std::endl);
     return false;
   }
-  cmAppend(files, gl.GetFiles());
+  cm::append(files, gl.GetFiles());
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
                      "Now searching in: " << daGlob << std::endl, this->Quiet);
   return true;

+ 4 - 3
Source/CTest/cmCTestCurl.cxx

@@ -5,7 +5,8 @@
 #include <cstdio>
 #include <ostream>
 
-#include "cmAlgorithms.h"
+#include <cmext/algorithm>
+
 #include "cmCTest.h"
 #include "cmCurl.h"
 #include "cmStringAlgorithms.h"
@@ -46,14 +47,14 @@ size_t curlWriteMemoryCallback(void* ptr, size_t size, size_t nmemb,
 {
   int realsize = static_cast<int>(size * nmemb);
   const char* chPtr = static_cast<char*>(ptr);
-  cmAppend(*static_cast<std::vector<char>*>(data), chPtr, chPtr + realsize);
+  cm::append(*static_cast<std::vector<char>*>(data), chPtr, chPtr + realsize);
   return realsize;
 }
 
 size_t curlDebugCallback(CURL* /*unused*/, curl_infotype /*unused*/,
                          char* chPtr, size_t size, void* data)
 {
-  cmAppend(*static_cast<std::vector<char>*>(data), chPtr, chPtr + size);
+  cm::append(*static_cast<std::vector<char>*>(data), chPtr, chPtr + size);
   return size;
 }
 }

+ 3 - 2
Source/CTest/cmCTestHG.cxx

@@ -5,9 +5,10 @@
 #include <ostream>
 #include <vector>
 
+#include <cmext/algorithm>
+
 #include "cmsys/RegularExpression.hxx"
 
-#include "cmAlgorithms.h"
 #include "cmCTest.h"
 #include "cmCTestVC.h"
 #include "cmProcessTools.h"
@@ -204,7 +205,7 @@ private:
 
   void CharacterDataHandler(const char* data, int length) override
   {
-    cmAppend(this->CData, data, data + length);
+    cm::append(this->CData, data, data + length);
   }
 
   void EndElement(const std::string& name) override

+ 4 - 2
Source/CTest/cmCTestMultiProcessHandler.cxx

@@ -19,6 +19,8 @@
 #include <utility>
 #include <vector>
 
+#include <cmext/algorithm>
+
 #include "cmsys/FStream.hxx"
 #include "cmsys/SystemInformation.hxx"
 
@@ -788,7 +790,7 @@ void cmCTestMultiProcessHandler::CreateParallelTestCostList()
   // Sort tests within each level by COST and append them to the cost list.
   for (TestSet const& currentSet : cmReverseRange(priorityStack)) {
     TestList sortedCopy;
-    cmAppend(sortedCopy, currentSet);
+    cm::append(sortedCopy, currentSet);
     std::stable_sort(sortedCopy.begin(), sortedCopy.end(),
                      TestComparator(this));
 
@@ -1154,7 +1156,7 @@ static Json::Value DumpCTestInfo(
     const std::vector<std::string>& args = testRun.GetArguments();
     if (!args.empty()) {
       commandAndArgs.reserve(args.size() + 1);
-      cmAppend(commandAndArgs, args);
+      cm::append(commandAndArgs, args);
     }
     testInfo["command"] = DumpToJsonArray(commandAndArgs);
   }

+ 3 - 2
Source/CTest/cmCTestP4.cxx

@@ -7,9 +7,10 @@
 #include <ostream>
 #include <utility>
 
+#include <cmext/algorithm>
+
 #include "cmsys/RegularExpression.hxx"
 
-#include "cmAlgorithms.h"
 #include "cmCTest.h"
 #include "cmCTestVC.h"
 #include "cmProcessTools.h"
@@ -326,7 +327,7 @@ void cmCTestP4::SetP4Options(std::vector<char const*>& CommandOptions)
     // The CTEST_P4_OPTIONS variable adds additional Perforce command line
     // options before the main command
     std::string opts = this->CTest->GetCTestConfiguration("P4Options");
-    cmAppend(P4Options, cmSystemTools::ParseArguments(opts));
+    cm::append(P4Options, cmSystemTools::ParseArguments(opts));
   }
 
   CommandOptions.clear();

+ 4 - 3
Source/CTest/cmCTestSVN.cxx

@@ -7,9 +7,10 @@
 #include <map>
 #include <ostream>
 
+#include <cmext/algorithm>
+
 #include "cmsys/RegularExpression.hxx"
 
-#include "cmAlgorithms.h"
 #include "cmCTest.h"
 #include "cmCTestVC.h"
 #include "cmProcessTools.h"
@@ -271,7 +272,7 @@ bool cmCTestSVN::RunSVNCommand(std::vector<char const*> const& parameters,
 
   std::vector<char const*> args;
   args.push_back(this->CommandLineTool.c_str());
-  cmAppend(args, parameters);
+  cm::append(args, parameters);
   args.push_back("--non-interactive");
 
   std::string userOptions = this->CTest->GetCTestConfiguration("SVNOptions");
@@ -344,7 +345,7 @@ private:
 
   void CharacterDataHandler(const char* data, int length) override
   {
-    cmAppend(this->CData, data, data + length);
+    cm::append(this->CData, data, data + length);
   }
 
   void EndElement(const std::string& name) override

+ 9 - 7
Source/CTest/cmCTestSubmitHandler.cxx

@@ -7,6 +7,8 @@
 #include <cstdlib>
 #include <sstream>
 
+#include <cmext/algorithm>
+
 #include "cm_curl.h"
 #include "cm_jsoncpp_reader.h"
 #include "cm_jsoncpp_value.h"
@@ -65,7 +67,7 @@ private:
 
   void CharacterDataHandler(const char* data, int length) override
   {
-    cmAppend(this->CurrentValue, data, data + length);
+    cm::append(this->CurrentValue, data, data + length);
   }
 
   void EndElement(const std::string& name) override
@@ -96,8 +98,8 @@ static size_t cmCTestSubmitHandlerWriteMemoryCallback(void* ptr, size_t size,
 {
   int realsize = static_cast<int>(size * nmemb);
   const char* chPtr = static_cast<char*>(ptr);
-  cmAppend(*static_cast<cmCTestSubmitHandlerVectorOfChar*>(data), chPtr,
-           chPtr + realsize);
+  cm::append(*static_cast<cmCTestSubmitHandlerVectorOfChar*>(data), chPtr,
+             chPtr + realsize);
   return realsize;
 }
 
@@ -106,8 +108,8 @@ static size_t cmCTestSubmitHandlerCurlDebugCallback(CURL* /*unused*/,
                                                     char* chPtr, size_t size,
                                                     void* data)
 {
-  cmAppend(*static_cast<cmCTestSubmitHandlerVectorOfChar*>(data), chPtr,
-           chPtr + size);
+  cm::append(*static_cast<cmCTestSubmitHandlerVectorOfChar*>(data), chPtr,
+             chPtr + size);
   return size;
 }
 
@@ -768,7 +770,7 @@ int cmCTestSubmitHandler::ProcessHandler()
 
   if (!this->Files.empty()) {
     // Submit the explicitly selected files:
-    cmAppend(files, this->Files);
+    cm::append(files, this->Files);
   }
 
   // Add to the list of files to submit from any selected, existing parts:
@@ -814,7 +816,7 @@ int cmCTestSubmitHandler::ProcessHandler()
     }
 
     // Submit files from this part.
-    cmAppend(files, this->CTest->GetSubmitFiles(p));
+    cm::append(files, this->CTest->GetSubmitFiles(p));
   }
 
   // Make sure files are unique, but preserve order.

+ 3 - 2
Source/CTest/cmProcess.cxx

@@ -6,9 +6,10 @@
 #include <iostream>
 #include <string>
 
+#include <cmext/algorithm>
+
 #include "cmsys/Process.h"
 
-#include "cmAlgorithms.h"
 #include "cmCTest.h"
 #include "cmCTestRunTest.h"
 #include "cmCTestTestHandler.h"
@@ -218,7 +219,7 @@ void cmProcess::OnRead(ssize_t nread, const uv_buf_t* buf)
   if (nread > 0) {
     std::string strdata;
     this->Conv.DecodeText(buf->base, static_cast<size_t>(nread), strdata);
-    cmAppend(this->Output, strdata);
+    cm::append(this->Output, strdata);
 
     while (this->Output.GetLine(line)) {
       this->Runner.CheckOutput(line);

+ 3 - 2
Source/cmAddLibraryCommand.cxx

@@ -2,7 +2,8 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmAddLibraryCommand.h"
 
-#include "cmAlgorithms.h"
+#include <cmext/algorithm>
+
 #include "cmExecutionStatus.h"
 #include "cmGeneratorExpression.h"
 #include "cmGlobalGenerator.h"
@@ -309,7 +310,7 @@ bool cmAddLibraryCommand(std::vector<std::string> const& args,
     return true;
   }
 
-  cmAppend(srclists, s, args.end());
+  cm::append(srclists, s, args.end());
 
   mf.AddLibrary(libName, type, srclists, excludeFromAll);
 

+ 0 - 27
Source/cmAlgorithms.h

@@ -145,33 +145,6 @@ void cmDeleteAll(Range const& r)
                 ContainerAlgorithms::DefaultDeleter<Range>());
 }
 
-template <typename T>
-void cmAppend(std::vector<std::unique_ptr<T>>& v,
-              std::vector<std::unique_ptr<T>>&& r)
-{
-  std::transform(r.begin(), r.end(), std::back_inserter(v),
-                 [](std::unique_ptr<T>& item) { return std::move(item); });
-}
-
-template <typename T>
-void cmAppend(std::vector<T*>& v, std::vector<std::unique_ptr<T>> const& r)
-{
-  std::transform(r.begin(), r.end(), std::back_inserter(v),
-                 [](const std::unique_ptr<T>& item) { return item.get(); });
-}
-
-template <typename T, typename Range>
-void cmAppend(std::vector<T>& v, Range const& r)
-{
-  v.insert(v.end(), r.begin(), r.end());
-}
-
-template <typename T, typename InputIt>
-void cmAppend(std::vector<T>& v, InputIt first, InputIt last)
-{
-  v.insert(v.end(), first, last);
-}
-
 template <typename Range>
 typename Range::const_iterator cmRemoveN(Range& r, size_t n)
 {

+ 5 - 5
Source/cmCTest.cxx

@@ -33,8 +33,8 @@
 #endif
 
 #include <cm/memory>
+#include <cmext/algorithm>
 
-#include "cmAlgorithms.h"
 #include "cmCTestBuildAndTestHandler.h"
 #include "cmCTestBuildHandler.h"
 #include "cmCTestConfigureHandler.h"
@@ -1280,7 +1280,7 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output,
   while (cmsysProcess_WaitForData(cp, &data, &length, nullptr)) {
     processOutput.DecodeText(data, length, strdata);
     if (output) {
-      cmAppend(tempOutput, data, data + length);
+      cm::append(tempOutput, data, data + length);
     }
     cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
                cmCTestLogWrite(strdata.c_str(), strdata.size()));
@@ -2243,7 +2243,7 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output)
   bool SRArgumentSpecified = false;
 
   // copy the command line
-  cmAppend(this->Impl->InitialCommandLineArguments, args);
+  cm::append(this->Impl->InitialCommandLineArguments, args);
 
   // process the command line arguments
   for (size_t i = 1; i < args.size(); ++i) {
@@ -3003,10 +3003,10 @@ bool cmCTest::RunCommand(std::vector<std::string> const& args,
     res = cmsysProcess_WaitForData(cp, &data, &length, nullptr);
     switch (res) {
       case cmsysProcess_Pipe_STDOUT:
-        cmAppend(tempOutput, data, data + length);
+        cm::append(tempOutput, data, data + length);
         break;
       case cmsysProcess_Pipe_STDERR:
-        cmAppend(tempError, data, data + length);
+        cm::append(tempError, data, data + length);
         break;
       default:
         done = true;

+ 3 - 1
Source/cmConditionEvaluator.cxx

@@ -9,6 +9,8 @@
 #include <sstream>
 #include <utility>
 
+#include <cmext/algorithm>
+
 #include "cmsys/RegularExpression.hxx"
 
 #include "cmAlgorithms.h"
@@ -396,7 +398,7 @@ bool cmConditionEvaluator::HandleLevel0(cmArgumentList& newArgs,
         // copy to the list structure
         auto argP1 = arg;
         argP1++;
-        cmAppend(newArgs2, argP1, argClose);
+        cm::append(newArgs2, argP1, argClose);
         newArgs2.pop_back();
         // now recursively invoke IsTrue to handle the values inside the
         // parenthetical expression

+ 4 - 4
Source/cmCustomCommand.cxx

@@ -4,7 +4,7 @@
 
 #include <utility>
 
-#include "cmAlgorithms.h"
+#include <cmext/algorithm>
 
 cmCustomCommand::cmCustomCommand(std::vector<std::string> outputs,
                                  std::vector<std::string> byproducts,
@@ -51,12 +51,12 @@ const char* cmCustomCommand::GetComment() const
 
 void cmCustomCommand::AppendCommands(const cmCustomCommandLines& commandLines)
 {
-  cmAppend(this->CommandLines, commandLines);
+  cm::append(this->CommandLines, commandLines);
 }
 
 void cmCustomCommand::AppendDepends(const std::vector<std::string>& depends)
 {
-  cmAppend(this->Depends, depends);
+  cm::append(this->Depends, depends);
 }
 
 bool cmCustomCommand::GetEscapeOldStyle() const
@@ -96,7 +96,7 @@ void cmCustomCommand::SetImplicitDepends(cmImplicitDependsList const& l)
 
 void cmCustomCommand::AppendImplicitDepends(cmImplicitDependsList const& l)
 {
-  cmAppend(this->ImplicitDepends, l);
+  cm::append(this->ImplicitDepends, l);
 }
 
 bool cmCustomCommand::GetUsesTerminal() const

+ 4 - 3
Source/cmCustomCommandGenerator.cxx

@@ -6,7 +6,8 @@
 #include <memory>
 #include <utility>
 
-#include "cmAlgorithms.h"
+#include <cmext/algorithm>
+
 #include "cmCustomCommand.h"
 #include "cmCustomCommandLines.h"
 #include "cmGeneratorExpression.h"
@@ -32,7 +33,7 @@ void AppendPaths(const std::vector<std::string>& inputs,
         it = cmSystemTools::CollapseFullPath(it);
       }
     }
-    cmAppend(output, result);
+    cm::append(output, result);
   }
 }
 }
@@ -56,7 +57,7 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
       std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(clarg);
       std::string parsed_arg = cge->Evaluate(this->LG, this->Config);
       if (this->CC.GetCommandExpandLists()) {
-        cmAppend(argv, cmExpandedList(parsed_arg));
+        cm::append(argv, cmExpandedList(parsed_arg));
       } else {
         argv.push_back(std::move(parsed_arg));
       }

+ 3 - 2
Source/cmDocumentationSection.h

@@ -8,7 +8,8 @@
 #include <string>
 #include <vector>
 
-#include "cmAlgorithms.h"
+#include <cmext/algorithm>
+
 #include "cmDocumentationEntry.h"
 
 // Low-level interface for custom documents:
@@ -47,7 +48,7 @@ public:
   }
   void Append(const std::vector<cmDocumentationEntry>& entries)
   {
-    cmAppend(this->Entries, entries);
+    cm::append(this->Entries, entries);
   }
 
   /** Append an entry to this section using NULL terminated chars */

+ 2 - 3
Source/cmELF.cxx

@@ -10,13 +10,12 @@
 #include <vector>
 
 #include <cm/memory>
+#include <cmext/algorithm>
 
 #include "cmsys/FStream.hxx"
 
 #include "cm_kwiml.h"
 
-#include "cmAlgorithms.h"
-
 // Include the ELF format information system header.
 #if defined(__OpenBSD__)
 #  include <elf_abi.h>
@@ -578,7 +577,7 @@ std::vector<char> cmELFInternalImpl<Types>::EncodeDynamicEntries(
     }
 
     char* pdyn = reinterpret_cast<char*>(&dyn);
-    cmAppend(result, pdyn, pdyn + sizeof(ELF_Dyn));
+    cm::append(result, pdyn, pdyn + sizeof(ELF_Dyn));
   }
 
   return result;

+ 3 - 2
Source/cmExecuteProcessCommand.cxx

@@ -9,11 +9,12 @@
 #include <memory>
 #include <vector>
 
+#include <cmext/algorithm>
+
 #include "cmsys/Process.h"
 
 #include "cm_static_string_view.hxx"
 
-#include "cmAlgorithms.h"
 #include "cmArgumentParser.h"
 #include "cmExecutionStatus.h"
 #include "cmMakefile.h"
@@ -402,6 +403,6 @@ void cmExecuteProcessCommandAppend(std::vector<char>& output, const char* data,
     --length;
   }
 #endif
-  cmAppend(output, data, data + length);
+  cm::append(output, data, data + length);
 }
 }

+ 1 - 0
Source/cmExportBuildFileGenerator.cxx

@@ -8,6 +8,7 @@
 #include <sstream>
 #include <utility>
 
+#include "cmAlgorithms.h"
 #include "cmExportSet.h"
 #include "cmGeneratorExpression.h"
 #include "cmGeneratorTarget.h"

+ 3 - 2
Source/cmExportBuildFileGenerator.h

@@ -10,7 +10,8 @@
 #include <utility>
 #include <vector>
 
-#include "cmAlgorithms.h"
+#include <cmext/algorithm>
+
 #include "cmExportFileGenerator.h"
 #include "cmStateTypes.h"
 
@@ -41,7 +42,7 @@ public:
   void GetTargets(std::vector<std::string>& targets) const;
   void AppendTargets(std::vector<std::string> const& targets)
   {
-    cmAppend(this->Targets, targets);
+    cm::append(this->Targets, targets);
   }
   void SetExportSet(cmExportSet*);
 

+ 6 - 4
Source/cmExtraCodeBlocksGenerator.cxx

@@ -8,6 +8,8 @@
 #include <set>
 #include <utility>
 
+#include <cmext/algorithm>
+
 #include "cmAlgorithms.h"
 #include "cmGeneratedFileStream.h"
 #include "cmGeneratorTarget.h"
@@ -210,7 +212,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
     // Collect all files
     std::vector<std::string> listFiles;
     for (cmLocalGenerator* lg : it.second) {
-      cmAppend(listFiles, lg->GetMakefile()->GetListFiles());
+      cm::append(listFiles, lg->GetMakefile()->GetListFiles());
     }
 
     // Convert
@@ -558,19 +560,19 @@ void cmExtraCodeBlocksGenerator::AppendTarget(
     {
       std::vector<std::string> includes;
       lg->GetIncludeDirectories(includes, target, "C", buildType);
-      cmAppend(allIncludeDirs, includes);
+      cm::append(allIncludeDirs, includes);
     }
 
     std::string systemIncludeDirs = makefile->GetSafeDefinition(
       "CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS");
     if (!systemIncludeDirs.empty()) {
-      cmAppend(allIncludeDirs, cmExpandedList(systemIncludeDirs));
+      cm::append(allIncludeDirs, cmExpandedList(systemIncludeDirs));
     }
 
     systemIncludeDirs = makefile->GetSafeDefinition(
       "CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS");
     if (!systemIncludeDirs.empty()) {
-      cmAppend(allIncludeDirs, cmExpandedList(systemIncludeDirs));
+      cm::append(allIncludeDirs, cmExpandedList(systemIncludeDirs));
     }
 
     auto end = cmRemoveDuplicates(allIncludeDirs);

+ 3 - 2
Source/cmFileAPICodemodel.cxx

@@ -15,9 +15,10 @@
 #include <utility>
 #include <vector>
 
+#include <cmext/algorithm>
+
 #include "cm_jsoncpp_value.h"
 
-#include "cmAlgorithms.h"
 #include "cmCryptoHash.h"
 #include "cmFileAPI.h"
 #include "cmGeneratorExpression.h"
@@ -555,7 +556,7 @@ Json::Value CodemodelConfig::DumpTargets()
   cmGlobalGenerator* gg =
     this->FileAPI.GetCMakeInstance()->GetGlobalGenerator();
   for (const auto& lg : gg->GetLocalGenerators()) {
-    cmAppend(targetList, lg->GetGeneratorTargets());
+    cm::append(targetList, lg->GetGeneratorTargets());
   }
   std::sort(targetList.begin(), targetList.end(),
             [](cmGeneratorTarget* l, cmGeneratorTarget* r) {

+ 6 - 6
Source/cmFileCommand.cxx

@@ -15,6 +15,7 @@
 #include <vector>
 
 #include <cm/memory>
+#include <cmext/algorithm>
 
 #include "cmsys/FStream.hxx"
 #include "cmsys/Glob.hxx"
@@ -24,7 +25,6 @@
 #include "cm_static_string_view.hxx"
 #include "cm_sys_stat.h"
 
-#include "cmAlgorithms.h"
 #include "cmArgumentParser.h"
 #include "cmCryptoHash.h"
 #include "cmExecutionStatus.h"
@@ -783,7 +783,7 @@ bool HandleGlobImpl(std::vector<std::string> const& args, bool recurse,
       }
 
       std::vector<std::string>& foundFiles = g.GetFiles();
-      cmAppend(files, foundFiles);
+      cm::append(files, foundFiles);
 
       if (configureDepends) {
         std::sort(foundFiles.begin(), foundFiles.end());
@@ -1394,8 +1394,8 @@ size_t cmWriteToMemoryCallback(void* ptr, size_t size, size_t nmemb,
 {
   int realsize = static_cast<int>(size * nmemb);
   const char* chPtr = static_cast<char*>(ptr);
-  cmAppend(*static_cast<cmFileCommandVectorOfChar*>(data), chPtr,
-           chPtr + realsize);
+  cm::append(*static_cast<cmFileCommandVectorOfChar*>(data), chPtr,
+             chPtr + realsize);
   return realsize;
 }
 
@@ -1408,7 +1408,7 @@ size_t cmFileCommandCurlDebugCallback(CURL*, curl_infotype type, char* chPtr,
     case CURLINFO_TEXT:
     case CURLINFO_HEADER_IN:
     case CURLINFO_HEADER_OUT:
-      cmAppend(vec, chPtr, chPtr + size);
+      cm::append(vec, chPtr, chPtr + size);
       break;
     case CURLINFO_DATA_IN:
     case CURLINFO_DATA_OUT:
@@ -1418,7 +1418,7 @@ size_t cmFileCommandCurlDebugCallback(CURL*, curl_infotype type, char* chPtr,
       int n = sprintf(buf, "[%" KWIML_INT_PRIu64 " bytes data]\n",
                       static_cast<KWIML_INT_uint64_t>(size));
       if (n > 0) {
-        cmAppend(vec, buf, buf + n);
+        cm::append(vec, buf, buf + n);
       }
     } break;
     default:

+ 3 - 2
Source/cmFindBase.cxx

@@ -7,7 +7,8 @@
 #include <iostream>
 #include <map>
 
-#include "cmAlgorithms.h"
+#include <cmext/algorithm>
+
 #include "cmMakefile.h"
 #include "cmRange.h"
 #include "cmSearchPath.h"
@@ -153,7 +154,7 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
     std::vector<std::string> shortArgs = this->Names;
     this->Names.clear(); // clear out any values in Names
     this->Names.push_back(shortArgs[0]);
-    cmAppend(this->UserGuessArgs, shortArgs.begin() + 1, shortArgs.end());
+    cm::append(this->UserGuessArgs, shortArgs.begin() + 1, shortArgs.end());
   }
   this->ExpandPaths();
 

+ 3 - 2
Source/cmFindCommon.cxx

@@ -7,7 +7,8 @@
 #include <cstring>
 #include <utility>
 
-#include "cmAlgorithms.h"
+#include <cmext/algorithm>
+
 #include "cmExecutionStatus.h"
 #include "cmMakefile.h"
 #include "cmStringAlgorithms.h"
@@ -249,7 +250,7 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths)
   // If searching both rooted and unrooted paths add the original
   // paths again.
   if (this->FindRootPathMode == RootPathModeBoth) {
-    cmAppend(paths, unrootedPaths);
+    cm::append(paths, unrootedPaths);
   }
 }
 

+ 2 - 2
Source/cmFunctionCommand.cxx

@@ -6,10 +6,10 @@
 
 #include <cm/memory>
 #include <cm/string_view>
+#include <cmext/algorithm>
 
 #include "cm_static_string_view.hxx"
 
-#include "cmAlgorithms.h"
 #include "cmExecutionStatus.h"
 #include "cmFunctionBlocker.h"
 #include "cmListFileCache.h"
@@ -181,7 +181,7 @@ bool cmFunctionCommand(std::vector<std::string> const& args,
 
   // create a function blocker
   auto fb = cm::make_unique<cmFunctionFunctionBlocker>();
-  cmAppend(fb->Args, args);
+  cm::append(fb->Args, args);
   status.GetMakefile().AddFunctionBlocker(std::move(fb));
 
   return true;

+ 2 - 2
Source/cmGeneratorExpressionParser.cxx

@@ -7,9 +7,9 @@
 #include <utility>
 
 #include <cm/memory>
+#include <cmext/algorithm>
 #include <cmext/memory>
 
-#include "cmAlgorithms.h"
 #include "cmGeneratorExpressionEvaluator.h"
 
 cmGeneratorExpressionParser::cmGeneratorExpressionParser(
@@ -57,7 +57,7 @@ static void extendResult(
         cm::static_reference_cast<TextContent>(contents.front()).GetLength());
     contents.erase(contents.begin());
   }
-  cmAppend(result, std::move(contents));
+  cm::append(result, std::move(contents));
 }
 
 void cmGeneratorExpressionParser::ParseGeneratorExpression(

+ 3 - 2
Source/cmGlobalGenerator.h

@@ -14,9 +14,10 @@
 #include <utility>
 #include <vector>
 
+#include <cmext/algorithm>
+
 #include "cm_codecvt.hxx"
 
-#include "cmAlgorithms.h"
 #include "cmCustomCommandLines.h"
 #include "cmDuration.h"
 #include "cmExportSet.h"
@@ -71,7 +72,7 @@ struct GeneratedMakeCommand
   void Add(std::vector<std::string>::const_iterator start,
            std::vector<std::string>::const_iterator end)
   {
-    cmAppend(PrimaryCommand, start, end);
+    cm::append(PrimaryCommand, start, end);
   }
 
   std::string Printable() const { return cmJoin(PrimaryCommand, " "); }

+ 1 - 1
Source/cmGlobalJOMMakefileGenerator.cxx

@@ -66,7 +66,7 @@ cmGlobalJOMMakefileGenerator::GenerateBuildCommand(
   // Since we have full control over the invocation of JOM, let us
   // make it quiet.
   jomMakeOptions.push_back(this->MakeSilentFlag);
-  cmAppend(jomMakeOptions, makeOptions);
+  cm::append(jomMakeOptions, makeOptions);
 
   // JOM does parallel builds by default, the -j is only needed if a specific
   // number is given

+ 1 - 1
Source/cmGlobalNMakeMakefileGenerator.cxx

@@ -66,7 +66,7 @@ cmGlobalNMakeMakefileGenerator::GenerateBuildCommand(
   // Since we have full control over the invocation of nmake, let us
   // make it quiet.
   nmakeMakeOptions.push_back(this->MakeSilentFlag);
-  cmAppend(nmakeMakeOptions, makeOptions);
+  cm::append(nmakeMakeOptions, makeOptions);
 
   return this->cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
     makeProgram, projectName, projectDir, targetNames, config, fast,

+ 4 - 3
Source/cmGlobalNinjaGenerator.cxx

@@ -9,6 +9,7 @@
 #include <sstream>
 
 #include <cm/memory>
+#include <cmext/algorithm>
 #include <cmext/memory>
 
 #include "cmsys/FStream.hxx"
@@ -1025,7 +1026,7 @@ void cmGlobalNinjaGenerator::AppendTargetDepends(
       }
     }
     std::sort(outs.begin(), outs.end());
-    cmAppend(outputs, outs);
+    cm::append(outputs, outs);
   }
 }
 
@@ -1035,7 +1036,7 @@ void cmGlobalNinjaGenerator::AppendTargetDependsClosure(
 {
   cmNinjaOuts outs;
   this->AppendTargetDependsClosure(target, outs, config, true);
-  cmAppend(outputs, outs);
+  cm::append(outputs, outs);
 }
 
 void cmGlobalNinjaGenerator::AppendTargetDependsClosure(
@@ -1585,7 +1586,7 @@ bool cmGlobalNinjaGenerator::WriteTargetCleanAdditional(std::ostream& os)
              << config << "\")\n";
         fout << "  file(REMOVE_RECURSE\n";
         for (std::string const& acf : it->second.AdditionalCleanFiles) {
-          fout << "    "
+          fout << "  "
                << cmOutputConverter::EscapeForCMake(ConvertToNinjaPath(acf))
                << '\n';
         }

+ 2 - 2
Source/cmGlobalUnixMakefileGenerator3.cxx

@@ -8,9 +8,9 @@
 #include <utility>
 
 #include <cm/memory>
+#include <cmext/algorithm>
 #include <cmext/memory>
 
-#include "cmAlgorithms.h"
 #include "cmDocumentationEntry.h"
 #include "cmGeneratedFileStream.h"
 #include "cmGeneratorTarget.h"
@@ -289,7 +289,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
   std::vector<std::string> lfiles;
   for (const auto& localGen : this->LocalGenerators) {
     // Get the list of files contributing to this generation step.
-    cmAppend(lfiles, localGen->GetMakefile()->GetListFiles());
+    cm::append(lfiles, localGen->GetMakefile()->GetListFiles());
   }
 
   cmake* cm = this->GetCMakeInstance();

+ 1 - 1
Source/cmGlobalVisualStudio8Generator.cxx

@@ -146,7 +146,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
     // project.
     std::vector<std::string> listFiles;
     for (const auto& gen : generators) {
-      cmAppend(listFiles, gen->GetMakefile()->GetListFiles());
+      cm::append(listFiles, gen->GetMakefile()->GetListFiles());
     }
 
     // Add a custom prebuild target to run the VerifyGlobs script.

+ 3 - 2
Source/cmGlobalXCodeGenerator.cxx

@@ -10,6 +10,7 @@
 #include <sstream>
 
 #include <cm/memory>
+#include <cmext/algorithm>
 
 #include "cmsys/RegularExpression.hxx"
 
@@ -577,7 +578,7 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile(
 {
   std::vector<std::string> lfiles;
   for (auto gen : gens) {
-    cmAppend(lfiles, gen->GetMakefile()->GetListFiles());
+    cm::append(lfiles, gen->GetMakefile()->GetListFiles());
   }
 
   // sort the array
@@ -1095,7 +1096,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets(
 {
   this->SetCurrentLocalGenerator(gen);
   std::vector<cmGeneratorTarget*> gts;
-  cmAppend(gts, this->CurrentLocalGenerator->GetGeneratorTargets());
+  cm::append(gts, this->CurrentLocalGenerator->GetGeneratorTargets());
   std::sort(gts.begin(), gts.end(),
             [this](cmGeneratorTarget const* l, cmGeneratorTarget const* r) {
               return this->TargetOrderIndex[l] < this->TargetOrderIndex[r];

+ 4 - 2
Source/cmIDEOptions.cxx

@@ -4,6 +4,8 @@
 
 #include <iterator>
 
+#include <cmext/algorithm>
+
 #include <string.h>
 
 #include "cmsys/String.h"
@@ -173,7 +175,7 @@ void cmIDEOptions::AddDefines(std::string const& defines)
 }
 void cmIDEOptions::AddDefines(const std::vector<std::string>& defines)
 {
-  cmAppend(this->Defines, defines);
+  cm::append(this->Defines, defines);
 }
 
 std::vector<std::string> const& cmIDEOptions::GetDefines() const
@@ -195,7 +197,7 @@ void cmIDEOptions::AddIncludes(std::string const& includes)
 }
 void cmIDEOptions::AddIncludes(const std::vector<std::string>& includes)
 {
-  cmAppend(this->Includes, includes);
+  cm::append(this->Includes, includes);
 }
 
 std::vector<std::string> const& cmIDEOptions::GetIncludes() const

+ 4 - 3
Source/cmIncludeDirectoryCommand.cxx

@@ -6,7 +6,8 @@
 #include <set>
 #include <utility>
 
-#include "cmAlgorithms.h"
+#include <cmext/algorithm>
+
 #include "cmExecutionStatus.h"
 #include "cmGeneratorExpression.h"
 #include "cmMakefile.h"
@@ -58,9 +59,9 @@ bool cmIncludeDirectoryCommand(std::vector<std::string> const& args,
     GetIncludes(mf, *i, includes);
 
     if (before) {
-      cmAppend(beforeIncludes, includes);
+      cm::append(beforeIncludes, includes);
     } else {
-      cmAppend(afterIncludes, includes);
+      cm::append(afterIncludes, includes);
     }
     if (system) {
       systemIncludes.insert(includes.begin(), includes.end());

+ 3 - 2
Source/cmJsonObjects.cxx

@@ -14,7 +14,8 @@
 #include <utility>
 #include <vector>
 
-#include "cmAlgorithms.h"
+#include <cmext/algorithm>
+
 #include "cmGeneratorExpression.h"
 #include "cmGeneratorTarget.h"
 #include "cmGlobalGenerator.h"
@@ -601,7 +602,7 @@ static Json::Value DumpTargetsList(
 
   std::vector<cmGeneratorTarget*> targetList;
   for (auto const& lgIt : generators) {
-    cmAppend(targetList, lgIt->GetGeneratorTargets());
+    cm::append(targetList, lgIt->GetGeneratorTargets());
   }
   std::sort(targetList.begin(), targetList.end());
 

+ 2 - 1
Source/cmLocalGenerator.cxx

@@ -16,6 +16,7 @@
 
 #include <cm/memory>
 #include <cm/string_view>
+#include <cmext/algorithm>
 
 #include "cmsys/RegularExpression.hxx"
 
@@ -392,7 +393,7 @@ void cmLocalGenerator::ProcessEvaluationFiles(
       return;
     }
 
-    cmAppend(generatedFiles, files);
+    cm::append(generatedFiles, files);
     std::inplace_merge(generatedFiles.begin(),
                        generatedFiles.end() - files.size(),
                        generatedFiles.end());

+ 3 - 2
Source/cmLocalGhsMultiGenerator.cxx

@@ -5,7 +5,8 @@
 #include <algorithm>
 #include <utility>
 
-#include "cmAlgorithms.h"
+#include <cmext/algorithm>
+
 #include "cmGeneratorTarget.h"
 #include "cmGhsMultiTargetGenerator.h"
 #include "cmGlobalGenerator.h"
@@ -52,7 +53,7 @@ void cmLocalGhsMultiGenerator::GenerateTargetsDepthFirst(
 void cmLocalGhsMultiGenerator::Generate()
 {
   std::vector<cmGeneratorTarget*> remaining;
-  cmAppend(remaining, this->GetGeneratorTargets());
+  cm::append(remaining, this->GetGeneratorTargets());
   for (auto& t : remaining) {
     if (t) {
       this->GenerateTargetsDepthFirst(t, remaining);

+ 3 - 2
Source/cmLocalUnixMakefileGenerator3.cxx

@@ -9,6 +9,7 @@
 #include <utility>
 
 #include <cm/memory>
+#include <cmext/algorithm>
 
 #include "cmsys/FStream.hxx"
 #include "cmsys/Terminal.h"
@@ -858,7 +859,7 @@ void cmLocalUnixMakefileGenerator3::AppendRuleDepends(
   // Add a dependency on the rule file itself unless an option to skip
   // it is specifically enabled by the user or project.
   if (!this->Makefile->IsOn("CMAKE_SKIP_RULE_DEPENDENCY")) {
-    cmAppend(depends, ruleFiles);
+    cm::append(depends, ruleFiles);
   }
 }
 
@@ -1031,7 +1032,7 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand(
   this->CreateCDCommand(commands1, dir, relative);
 
   // push back the custom commands
-  cmAppend(commands, commands1);
+  cm::append(commands, commands1);
 }
 
 void cmLocalUnixMakefileGenerator3::AppendCleanCommand(

+ 3 - 1
Source/cmLocalVisualStudio10Generator.cxx

@@ -2,6 +2,8 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmLocalVisualStudio10Generator.h"
 
+#include <cmext/algorithm>
+
 #include "cm_expat.h"
 
 #include "cmAlgorithms.h"
@@ -103,7 +105,7 @@ void cmLocalVisualStudio10Generator::GenerateTargetsDepthFirst(
 void cmLocalVisualStudio10Generator::Generate()
 {
   std::vector<cmGeneratorTarget*> remaining;
-  cmAppend(remaining, this->GetGeneratorTargets());
+  cm::append(remaining, this->GetGeneratorTargets());
   for (auto& t : remaining) {
     if (t) {
       this->GenerateTargetsDepthFirst(t, remaining);

+ 2 - 2
Source/cmMacroCommand.cxx

@@ -7,10 +7,10 @@
 
 #include <cm/memory>
 #include <cm/string_view>
+#include <cmext/algorithm>
 
 #include "cm_static_string_view.hxx"
 
-#include "cmAlgorithms.h"
 #include "cmExecutionStatus.h"
 #include "cmFunctionBlocker.h"
 #include "cmListFileCache.h"
@@ -190,7 +190,7 @@ bool cmMacroCommand(std::vector<std::string> const& args,
   // create a function blocker
   {
     auto fb = cm::make_unique<cmMacroFunctionBlocker>();
-    cmAppend(fb->Args, args);
+    cm::append(fb->Args, args);
     status.GetMakefile().AddFunctionBlocker(std::move(fb));
   }
   return true;

+ 2 - 1
Source/cmMakefile.cxx

@@ -15,6 +15,7 @@
 
 #include <cm/iterator>
 #include <cm/optional>
+#include <cmext/algorithm>
 
 #include "cmsys/FStream.hxx"
 #include "cmsys/RegularExpression.hxx"
@@ -2660,7 +2661,7 @@ const std::string& cmMakefile::GetSafeDefinition(const std::string& name) const
 std::vector<std::string> cmMakefile::GetDefinitions() const
 {
   std::vector<std::string> res = this->StateSnapshot.ClosureKeys();
-  cmAppend(res, this->GetState()->GetCacheEntryKeys());
+  cm::append(res, this->GetState()->GetCacheEntryKeys());
   std::sort(res.begin(), res.end());
   return res;
 }

+ 4 - 4
Source/cmMakefileExecutableTargetGenerator.cxx

@@ -9,8 +9,8 @@
 #include <vector>
 
 #include <cm/memory>
+#include <cmext/algorithm>
 
-#include "cmAlgorithms.h"
 #include "cmGeneratedFileStream.h"
 #include "cmGeneratorTarget.h"
 #include "cmGlobalUnixMakefileGenerator3.h"
@@ -263,7 +263,7 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule(
   this->LocalGenerator->CreateCDCommand(
     commands1, this->Makefile->GetCurrentBinaryDirectory(),
     this->LocalGenerator->GetBinaryDirectory());
-  cmAppend(commands, commands1);
+  cm::append(commands, commands1);
   commands1.clear();
 
   // Write the build rule.
@@ -630,7 +630,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
   this->LocalGenerator->CreateCDCommand(
     commands1, this->Makefile->GetCurrentBinaryDirectory(),
     this->LocalGenerator->GetBinaryDirectory());
-  cmAppend(commands, commands1);
+  cm::append(commands, commands1);
   commands1.clear();
 
   // Add a rule to create necessary symlinks for the library.
@@ -642,7 +642,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
     this->LocalGenerator->CreateCDCommand(
       commands1, this->Makefile->GetCurrentBinaryDirectory(),
       this->LocalGenerator->GetBinaryDirectory());
-    cmAppend(commands, commands1);
+    cm::append(commands, commands1);
     commands1.clear();
   }
 

+ 5 - 5
Source/cmMakefileLibraryTargetGenerator.cxx

@@ -9,8 +9,8 @@
 #include <vector>
 
 #include <cm/memory>
+#include <cmext/algorithm>
 
-#include "cmAlgorithms.h"
 #include "cmGeneratedFileStream.h"
 #include "cmGeneratorTarget.h"
 #include "cmGlobalUnixMakefileGenerator3.h"
@@ -397,7 +397,7 @@ void cmMakefileLibraryTargetGenerator::WriteDeviceLibraryRules(
   this->LocalGenerator->CreateCDCommand(
     commands1, this->Makefile->GetCurrentBinaryDirectory(),
     this->LocalGenerator->GetBinaryDirectory());
-  cmAppend(commands, commands1);
+  cm::append(commands, commands1);
   commands1.clear();
 
   // Compute the list of outputs.
@@ -571,7 +571,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
     this->LocalGenerator->CreateCDCommand(
       commands1, this->Makefile->GetCurrentBinaryDirectory(),
       this->LocalGenerator->GetBinaryDirectory());
-    cmAppend(commands, commands1);
+    cm::append(commands, commands1);
     commands1.clear();
   }
 
@@ -907,7 +907,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
   this->LocalGenerator->CreateCDCommand(
     commands1, this->Makefile->GetCurrentBinaryDirectory(),
     this->LocalGenerator->GetBinaryDirectory());
-  cmAppend(commands, commands1);
+  cm::append(commands, commands1);
   commands1.clear();
 
   // Add a rule to create necessary symlinks for the library.
@@ -921,7 +921,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
     this->LocalGenerator->CreateCDCommand(
       commands1, this->Makefile->GetCurrentBinaryDirectory(),
       this->LocalGenerator->GetBinaryDirectory());
-    cmAppend(commands, commands1);
+    cm::append(commands, commands1);
     commands1.clear();
   }
 

+ 13 - 11
Source/cmMakefileTargetGenerator.cxx

@@ -8,7 +8,8 @@
 #include <sstream>
 #include <utility>
 
-#include "cmAlgorithms.h"
+#include <cmext/algorithm>
+
 #include "cmComputeLinkInformation.h"
 #include "cmCustomCommand.h"
 #include "cmCustomCommandGenerator.h"
@@ -225,9 +226,10 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
     std::vector<cmCustomCommand> buildEventCommands =
       this->GeneratorTarget->GetPreBuildCommands();
 
-    cmAppend(buildEventCommands, this->GeneratorTarget->GetPreLinkCommands());
-    cmAppend(buildEventCommands,
-             this->GeneratorTarget->GetPostBuildCommands());
+    cm::append(buildEventCommands,
+               this->GeneratorTarget->GetPreLinkCommands());
+    cm::append(buildEventCommands,
+               this->GeneratorTarget->GetPostBuildCommands());
 
     for (const auto& be : buildEventCommands) {
       cmCustomCommandGenerator beg(be, this->GetConfigName(),
@@ -841,7 +843,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
     this->LocalGenerator->CreateCDCommand(
       compileCommands, this->LocalGenerator->GetCurrentBinaryDirectory(),
       this->LocalGenerator->GetBinaryDirectory());
-    cmAppend(commands, compileCommands);
+    cm::append(commands, compileCommands);
   }
 
   // Check for extra outputs created by the compilation.
@@ -900,7 +902,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
           preprocessCommands,
           this->LocalGenerator->GetCurrentBinaryDirectory(),
           this->LocalGenerator->GetBinaryDirectory());
-        cmAppend(commands, preprocessCommands);
+        cm::append(commands, preprocessCommands);
       } else {
         std::string cmd =
           cmStrCat("$(CMAKE_COMMAND) -E cmake_unimplemented_variable ",
@@ -944,7 +946,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
         this->LocalGenerator->CreateCDCommand(
           assemblyCommands, this->LocalGenerator->GetCurrentBinaryDirectory(),
           this->LocalGenerator->GetBinaryDirectory());
-        cmAppend(commands, assemblyCommands);
+        cm::append(commands, assemblyCommands);
       } else {
         std::string cmd =
           cmStrCat("$(CMAKE_COMMAND) -E cmake_unimplemented_variable ",
@@ -1192,7 +1194,7 @@ void cmMakefileTargetGenerator::DriveCustomCommands(
     if (cmCustomCommand* cc = source->GetCustomCommand()) {
       cmCustomCommandGenerator ccg(*cc, this->GetConfigName(),
                                    this->LocalGenerator);
-      cmAppend(depends, ccg.GetOutputs());
+      cm::append(depends, ccg.GetOutputs());
     }
   }
 }
@@ -1429,7 +1431,7 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule(
     }
 
     // Make sure the extra files are built.
-    cmAppend(depends, this->ExtraFiles);
+    cm::append(depends, this->ExtraFiles);
   }
 
   // Write the driver rule.
@@ -1451,7 +1453,7 @@ void cmMakefileTargetGenerator::AppendTargetDepends(
   const std::string& cfg = this->GetConfigName();
   if (cmComputeLinkInformation* cli =
         this->GeneratorTarget->GetLinkInformation(cfg)) {
-    cmAppend(depends, cli->GetDepends());
+    cm::append(depends, cli->GetDepends());
   }
 }
 
@@ -1467,7 +1469,7 @@ void cmMakefileTargetGenerator::AppendObjectDepends(
   }
 
   // Add dependencies on the external object files.
-  cmAppend(depends, this->ExternalObjects);
+  cm::append(depends, this->ExternalObjects);
 
   // Add a dependency on the rule file itself.
   this->LocalGenerator->AppendRuleDepend(depends,

+ 2 - 2
Source/cmNinjaTargetGenerator.cxx

@@ -10,11 +10,11 @@
 #include <utility>
 
 #include <cm/memory>
+#include <cmext/algorithm>
 
 #include "cm_jsoncpp_value.h"
 #include "cm_jsoncpp_writer.h"
 
-#include "cmAlgorithms.h"
 #include "cmComputeLinkInformation.h"
 #include "cmCustomCommandGenerator.h"
 #include "cmGeneratedFileStream.h"
@@ -870,7 +870,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements(
       DependOnTargetOrdering);
 
     // Add order-only dependencies on other files associated with the target.
-    cmAppend(orderOnlyDeps, this->Configs[config].ExtraFiles);
+    cm::append(orderOnlyDeps, this->Configs[config].ExtraFiles);
 
     // Add order-only dependencies on custom command outputs.
     for (cmCustomCommand const* cc : this->Configs[config].CustomCommands) {

+ 4 - 2
Source/cmOrderDirectories.cxx

@@ -8,6 +8,8 @@
 #include <sstream>
 #include <vector>
 
+#include <cmext/algorithm>
+
 #include "cmAlgorithms.h"
 #include "cmGeneratorTarget.h"
 #include "cmGlobalGenerator.h"
@@ -328,13 +330,13 @@ void cmOrderDirectories::AddLinkLibrary(std::string const& fullPath)
 void cmOrderDirectories::AddUserDirectories(
   std::vector<std::string> const& extra)
 {
-  cmAppend(this->UserDirectories, extra);
+  cm::append(this->UserDirectories, extra);
 }
 
 void cmOrderDirectories::AddLanguageDirectories(
   std::vector<std::string> const& dirs)
 {
-  cmAppend(this->LanguageDirectories, dirs);
+  cm::append(this->LanguageDirectories, dirs);
 }
 
 void cmOrderDirectories::SetImplicitDirectories(

+ 4 - 2
Source/cmQtAutoGen.cxx

@@ -8,6 +8,8 @@
 #include <sstream>
 #include <utility>
 
+#include <cmext/algorithm>
+
 #include "cmsys/FStream.hxx"
 #include "cmsys/RegularExpression.hxx"
 
@@ -67,7 +69,7 @@ void MergeOptions(std::vector<std::string>& baseOpts,
     }
   }
   // Append options
-  cmAppend(baseOpts, extraOpts);
+  cm::append(baseOpts, extraOpts);
 }
 
 // - Class definitions
@@ -328,7 +330,7 @@ bool cmQtAutoGen::RccLister::list(std::string const& qrcFile,
     {
       std::vector<std::string> cmd;
       cmd.emplace_back(this->RccExcutable_);
-      cmAppend(cmd, this->ListOptions_);
+      cm::append(cmd, this->ListOptions_);
       cmd.emplace_back(cmSystemTools::GetFilenameName(qrcFile));
 
       // Log command

+ 7 - 7
Source/cmQtAutoMocUic.cxx

@@ -16,13 +16,13 @@
 
 #include <cm/memory>
 #include <cm/string_view>
+#include <cmext/algorithm>
 
 #include "cmsys/FStream.hxx"
 #include "cmsys/RegularExpression.hxx"
 
 #include "cm_jsoncpp_value.h"
 
-#include "cmAlgorithms.h"
 #include "cmCryptoHash.h"
 #include "cmFileTime.h"
 #include "cmGeneratedFileStream.h"
@@ -808,9 +808,9 @@ void cmQtAutoMocUicT::JobMocPredefsT::Process()
       // Compose command
       std::vector<std::string> cmd = MocConst().PredefsCmd;
       // Add definitions
-      cmAppend(cmd, MocConst().OptionsDefinitions);
+      cm::append(cmd, MocConst().OptionsDefinitions);
       // Add includes
-      cmAppend(cmd, MocConst().OptionsIncludes);
+      cm::append(cmd, MocConst().OptionsIncludes);
       // Execute command
       if (!RunProcess(GenT::MOC, result, cmd, reason.get())) {
         LogCommandError(GenT::MOC,
@@ -1916,9 +1916,9 @@ void cmQtAutoMocUicT::JobCompileMocT::Process()
                 MocConst().OptionsExtra.size() + 16);
     cmd.push_back(MocConst().Executable);
     // Add definitions
-    cmAppend(cmd, MocConst().OptionsDefinitions);
+    cm::append(cmd, MocConst().OptionsDefinitions);
     // Add includes
-    cmAppend(cmd, MocConst().OptionsIncludes);
+    cm::append(cmd, MocConst().OptionsIncludes);
     // Add predefs include
     if (!MocConst().PredefsFileAbs.empty()) {
       cmd.emplace_back("--include");
@@ -1946,7 +1946,7 @@ void cmQtAutoMocUicT::JobCompileMocT::Process()
       }
     }
     // Add extra options
-    cmAppend(cmd, MocConst().OptionsExtra);
+    cm::append(cmd, MocConst().OptionsExtra);
     // Add output file
     cmd.emplace_back("-o");
     cmd.push_back(outputFile);
@@ -1994,7 +1994,7 @@ void cmQtAutoMocUicT::JobCompileUicT::Process()
       UicMergeOptions(allOpts, optionIt->second.Options,
                       (BaseConst().QtVersionMajor == 5));
     }
-    cmAppend(cmd, allOpts);
+    cm::append(cmd, allOpts);
   }
   cmd.emplace_back("-o");
   cmd.emplace_back(outputFile);

+ 3 - 2
Source/cmQtAutoRcc.cxx

@@ -6,7 +6,8 @@
 #include <string>
 #include <vector>
 
-#include "cmAlgorithms.h"
+#include <cmext/algorithm>
+
 #include "cmCryptoHash.h"
 #include "cmDuration.h"
 #include "cmFileLock.h"
@@ -405,7 +406,7 @@ bool cmQtAutoRccT::GenerateRcc()
   // Compose rcc command
   std::vector<std::string> cmd;
   cmd.push_back(RccExecutable_);
-  cmAppend(cmd, Options_);
+  cm::append(cmd, Options_);
   cmd.emplace_back("-o");
   cmd.push_back(RccFileOutput_);
   cmd.push_back(QrcFile_);

+ 3 - 2
Source/cmSetTargetPropertiesCommand.cxx

@@ -4,7 +4,8 @@
 
 #include <iterator>
 
-#include "cmAlgorithms.h"
+#include <cmext/algorithm>
+
 #include "cmExecutionStatus.h"
 #include "cmMakefile.h"
 #include "cmStringAlgorithms.h"
@@ -33,7 +34,7 @@ bool cmSetTargetPropertiesCommand(std::vector<std::string> const& args,
         status.SetError("called with incorrect number of arguments.");
         return false;
       }
-      cmAppend(propertyPairs, j, args.end());
+      cm::append(propertyPairs, j, args.end());
       break;
     }
     numFiles++;

+ 3 - 2
Source/cmSetTestsPropertiesCommand.cxx

@@ -4,7 +4,8 @@
 
 #include <iterator>
 
-#include "cmAlgorithms.h"
+#include <cmext/algorithm>
+
 #include "cmExecutionStatus.h"
 #include "cmMakefile.h"
 #include "cmStringAlgorithms.h"
@@ -36,7 +37,7 @@ bool cmSetTestsPropertiesCommand(std::vector<std::string> const& args,
         status.SetError("called with incorrect number of arguments.");
         return false;
       }
-      cmAppend(propertyPairs, j, args.end());
+      cm::append(propertyPairs, j, args.end());
       break;
     }
     numFiles++;

+ 2 - 1
Source/cmStateDirectory.cxx

@@ -8,6 +8,7 @@
 #include <vector>
 
 #include <cm/iterator>
+#include <cmext/algorithm>
 
 #include "cmAlgorithms.h"
 #include "cmProperty.h"
@@ -607,7 +608,7 @@ const char* cmStateDirectory::GetProperty(const std::string& prop,
   }
   if (prop == "VARIABLES") {
     std::vector<std::string> res = this->Snapshot_.ClosureKeys();
-    cmAppend(res, this->Snapshot_.State->GetCacheEntryKeys());
+    cm::append(res, this->Snapshot_.State->GetCacheEntryKeys());
     std::sort(res.begin(), res.end());
     output = cmJoin(res, ";");
     return output.c_str();

+ 9 - 8
Source/cmSystemTools.cxx

@@ -2,9 +2,10 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmSystemTools.h"
 
+#include <cmext/algorithm>
+
 #include "cm_uv.h"
 
-#include "cmAlgorithms.h"
 #include "cmDuration.h"
 #include "cmProcessOutput.h"
 #include "cmRange.h"
@@ -360,7 +361,7 @@ std::vector<std::string> cmSystemTools::HandleResponseFile(
 #else
         cmSystemTools::ParseUnixCommandLine(line.c_str(), args2);
 #endif
-        cmAppend(arg_full, args2);
+        cm::append(arg_full, args2);
       }
     } else {
       arg_full.push_back(arg);
@@ -585,7 +586,7 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command,
           cmSystemTools::Stdout(strdata);
         }
         if (captureStdOut) {
-          cmAppend(tempStdOut, data, data + length);
+          cm::append(tempStdOut, data, data + length);
         }
       } else if (pipe == cmsysProcess_Pipe_STDERR) {
         if (outputflag != OUTPUT_NONE) {
@@ -593,7 +594,7 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command,
           cmSystemTools::Stderr(strdata);
         }
         if (captureStdErr) {
-          cmAppend(tempStdErr, data, data + length);
+          cm::append(tempStdErr, data, data + length);
         }
       }
     }
@@ -1712,26 +1713,26 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line,
       processOutput.DecodeText(data, length, strdata, 1);
       // Append to the stdout buffer.
       std::vector<char>::size_type size = out.size();
-      cmAppend(out, strdata);
+      cm::append(out, strdata);
       outiter = out.begin() + size;
     } else if (pipe == cmsysProcess_Pipe_STDERR) {
       processOutput.DecodeText(data, length, strdata, 2);
       // Append to the stderr buffer.
       std::vector<char>::size_type size = err.size();
-      cmAppend(err, strdata);
+      cm::append(err, strdata);
       erriter = err.begin() + size;
     } else if (pipe == cmsysProcess_Pipe_None) {
       // Both stdout and stderr pipes have broken.  Return leftover data.
       processOutput.DecodeText(std::string(), strdata, 1);
       if (!strdata.empty()) {
         std::vector<char>::size_type size = out.size();
-        cmAppend(out, strdata);
+        cm::append(out, strdata);
         outiter = out.begin() + size;
       }
       processOutput.DecodeText(std::string(), strdata, 2);
       if (!strdata.empty()) {
         std::vector<char>::size_type size = err.size();
-        cmAppend(err, strdata);
+        cm::append(err, strdata);
         erriter = err.begin() + size;
       }
       if (!out.empty()) {

+ 17 - 16
Source/cmTarget.cxx

@@ -12,6 +12,7 @@
 #include <unordered_set>
 
 #include <cm/memory>
+#include <cmext/algorithm>
 
 #include "cmsys/RegularExpression.hxx"
 
@@ -439,30 +440,30 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
   if (!this->IsImported()) {
     // Initialize the INCLUDE_DIRECTORIES property based on the current value
     // of the same directory property:
-    cmAppend(impl->IncludeDirectoriesEntries,
-             impl->Makefile->GetIncludeDirectoriesEntries());
-    cmAppend(impl->IncludeDirectoriesBacktraces,
-             impl->Makefile->GetIncludeDirectoriesBacktraces());
+    cm::append(impl->IncludeDirectoriesEntries,
+               impl->Makefile->GetIncludeDirectoriesEntries());
+    cm::append(impl->IncludeDirectoriesBacktraces,
+               impl->Makefile->GetIncludeDirectoriesBacktraces());
 
     {
       auto const& sysInc = impl->Makefile->GetSystemIncludeDirectories();
       impl->SystemIncludeDirectories.insert(sysInc.begin(), sysInc.end());
     }
 
-    cmAppend(impl->CompileOptionsEntries,
-             impl->Makefile->GetCompileOptionsEntries());
-    cmAppend(impl->CompileOptionsBacktraces,
-             impl->Makefile->GetCompileOptionsBacktraces());
+    cm::append(impl->CompileOptionsEntries,
+               impl->Makefile->GetCompileOptionsEntries());
+    cm::append(impl->CompileOptionsBacktraces,
+               impl->Makefile->GetCompileOptionsBacktraces());
 
-    cmAppend(impl->LinkOptionsEntries,
-             impl->Makefile->GetLinkOptionsEntries());
-    cmAppend(impl->LinkOptionsBacktraces,
-             impl->Makefile->GetLinkOptionsBacktraces());
+    cm::append(impl->LinkOptionsEntries,
+               impl->Makefile->GetLinkOptionsEntries());
+    cm::append(impl->LinkOptionsBacktraces,
+               impl->Makefile->GetLinkOptionsBacktraces());
 
-    cmAppend(impl->LinkDirectoriesEntries,
-             impl->Makefile->GetLinkDirectoriesEntries());
-    cmAppend(impl->LinkDirectoriesBacktraces,
-             impl->Makefile->GetLinkDirectoriesBacktraces());
+    cm::append(impl->LinkDirectoriesEntries,
+               impl->Makefile->GetLinkDirectoriesEntries());
+    cm::append(impl->LinkDirectoriesBacktraces,
+               impl->Makefile->GetLinkDirectoriesBacktraces());
   }
 
   if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY &&

+ 3 - 1
Source/cmake.cxx

@@ -8,6 +8,8 @@
 #  include <cm/iterator>
 #endif
 
+#include <cmext/algorithm>
+
 #include "cm_sys_stat.h"
 
 #include "cmAlgorithms.h"
@@ -1049,7 +1051,7 @@ void cmake::GetRegisteredGenerators(std::vector<GeneratorInfo>& generators,
     std::vector<std::string> names = gen->GetGeneratorNames();
 
     if (includeNamesWithPlatform) {
-      cmAppend(names, gen->GetGeneratorNamesWithPlatform());
+      cm::append(names, gen->GetGeneratorNamesWithPlatform());
     }
 
     for (std::string const& name : names) {

+ 11 - 10
Source/cmakemain.cxx

@@ -1,7 +1,16 @@
 /* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
    file Copyright.txt or https://cmake.org/licensing for details.  */
 
-#include "cmAlgorithms.h"
+#include <cassert>
+#include <cctype>
+#include <climits>
+#include <cstring>
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include <cmext/algorithm>
+
 #include "cmDocumentationEntry.h" // IWYU pragma: keep
 #include "cmGlobalGenerator.h"
 #include "cmMakefile.h"
@@ -24,14 +33,6 @@
 #  include "cmsys/ConsoleBuf.hxx"
 #endif
 
-#include <cassert>
-#include <cctype>
-#include <climits>
-#include <cstring>
-#include <iostream>
-#include <string>
-#include <vector>
-
 namespace {
 #ifndef CMAKE_BOOTSTRAP
 const char* cmDocumentationName[][2] = {
@@ -100,7 +101,7 @@ int do_command(int ac, char const* const* av)
   std::vector<std::string> args;
   args.reserve(ac - 1);
   args.emplace_back(av[0]);
-  cmAppend(args, av + 2, av + ac);
+  cm::append(args, av + 2, av + ac);
   return cmcmd::ExecuteCMakeCommand(args);
 }
 

+ 5 - 3
Source/cmcmd.cxx

@@ -2,6 +2,8 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmcmd.h"
 
+#include <cmext/algorithm>
+
 #include "cmAlgorithms.h"
 #include "cmDuration.h"
 #include "cmGlobalGenerator.h"
@@ -198,7 +200,7 @@ static int HandleIWYU(const std::string& runCmd,
   // Construct the iwyu command line by taking what was given
   // and adding all the arguments we give to the compiler.
   std::vector<std::string> iwyu_cmd = cmExpandedList(runCmd, true);
-  cmAppend(iwyu_cmd, orig_cmd.begin() + 1, orig_cmd.end());
+  cm::append(iwyu_cmd, orig_cmd.begin() + 1, orig_cmd.end());
   // Run the iwyu command line.  Capture its stderr and hide its stdout.
   // Ignore its return code because the tool always returns non-zero.
   std::string stdErr;
@@ -229,7 +231,7 @@ static int HandleTidy(const std::string& runCmd, const std::string& sourceFile,
   std::vector<std::string> tidy_cmd = cmExpandedList(runCmd, true);
   tidy_cmd.push_back(sourceFile);
   tidy_cmd.emplace_back("--");
-  cmAppend(tidy_cmd, orig_cmd);
+  cm::append(tidy_cmd, orig_cmd);
 
   // Run the tidy command line.  Capture its stdout and hide its stderr.
   std::string stdOut;
@@ -2027,7 +2029,7 @@ int cmVSLink::RunMT(std::string const& out, bool notify)
   if (this->LinkGeneratesManifest) {
     mtCommand.push_back(this->LinkerManifestFile);
   }
-  cmAppend(mtCommand, this->UserManifests);
+  cm::append(mtCommand, this->UserManifests);
   mtCommand.push_back(out);
   if (notify) {
     // Add an undocumented option that enables a special return