summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2019-07-02 09:08:04 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2019-07-14 13:37:30 (GMT)
commitd9b2c7dae242868f13fc366773fb09448da26e8d (patch)
tree12e97152327bdff419861deded5b2f7d6a0961be /Source
parent81389a5e8f14a09d26a8efb22fd12063168caba6 (diff)
downloadCMake-d9b2c7dae242868f13fc366773fb09448da26e8d.zip
CMake-d9b2c7dae242868f13fc366773fb09448da26e8d.tar.gz
CMake-d9b2c7dae242868f13fc366773fb09448da26e8d.tar.bz2
Introduce memory management helper: cm_memory.hxx
Diffstat (limited to 'Source')
-rw-r--r--Source/CPack/cmCPackExternalGenerator.cxx3
-rw-r--r--Source/CTest/cmCTestRunTest.cxx3
-rw-r--r--Source/CTest/cmCTestUpdateHandler.cxx4
-rw-r--r--Source/cmAlgorithms.h15
-rw-r--r--Source/cmBinUtilsLinuxELFLinker.cxx5
-rw-r--r--Source/cmBinUtilsMacOSMachOLinker.cxx2
-rw-r--r--Source/cmBinUtilsWindowsPELinker.cxx5
-rw-r--r--Source/cmCTest.cxx3
-rw-r--r--Source/cmComputeLinkDepends.cxx2
-rw-r--r--Source/cmCryptoHash.cxx4
-rw-r--r--Source/cmExportFileGenerator.cxx3
-rw-r--r--Source/cmExportLibraryDependenciesCommand.cxx4
-rw-r--r--Source/cmFileCommand.cxx3
-rw-r--r--Source/cmFileTimes.cxx3
-rw-r--r--Source/cmFindPackageCommand.cxx3
-rw-r--r--Source/cmForEachCommand.cxx4
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx3
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.cxx3
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx3
-rw-r--r--Source/cmListCommand.cxx3
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx3
-rw-r--r--Source/cmMachO.cxx3
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.cxx3
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx3
-rw-r--r--Source/cmMakefileUtilityTargetGenerator.cxx4
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx3
-rw-r--r--Source/cmNinjaTargetGenerator.cxx3
-rw-r--r--Source/cmQtAutoGenGlobalInitializer.cxx4
-rw-r--r--Source/cmQtAutoGenInitializer.cxx2
-rw-r--r--Source/cmQtAutoGenerator.cxx5
-rw-r--r--Source/cmQtAutoMocUic.cxx3
-rw-r--r--Source/cmRuntimeDependencyArchive.cxx3
-rw-r--r--Source/cmServer.cxx4
-rw-r--r--Source/cmServerProtocol.cxx4
-rw-r--r--Source/cmState.cxx2
-rw-r--r--Source/cmTarget.cxx2
-rw-r--r--Source/cmUVProcessChain.cxx3
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx3
-rw-r--r--Source/cmWorkerPool.cxx2
-rw-r--r--Source/cmWorkerPool.h5
-rw-r--r--Source/cm_memory.hxx31
-rw-r--r--Source/cmake.cxx3
42 files changed, 114 insertions, 62 deletions
diff --git a/Source/CPack/cmCPackExternalGenerator.cxx b/Source/CPack/cmCPackExternalGenerator.cxx
index 9dc9853..b4c7a5a 100644
--- a/Source/CPack/cmCPackExternalGenerator.cxx
+++ b/Source/CPack/cmCPackExternalGenerator.cxx
@@ -2,7 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCPackExternalGenerator.h"
-#include "cmAlgorithms.h"
#include "cmCPackComponentGroup.h"
#include "cmCPackLog.h"
#include "cmMakefile.h"
@@ -17,6 +16,8 @@
#include <utility>
#include <vector>
+#include "cm_memory.hxx"
+
int cmCPackExternalGenerator::InitializeInternal()
{
this->SetOption("CPACK_EXTERNAL_KNOWN_VERSIONS", "1.0");
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index b865cab..f9ac1eb 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -11,7 +11,6 @@
#include "cmsys/RegularExpression.hxx"
#include <chrono>
-#include <cmAlgorithms.h>
#include <cstdint>
#include <cstring>
#include <iomanip>
@@ -20,6 +19,8 @@
#include <stdio.h>
#include <utility>
+#include "cm_memory.hxx"
+
cmCTestRunTest::cmCTestRunTest(cmCTestMultiProcessHandler& multiHandler)
: MultiTestHandler(multiHandler)
{
diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx
index fb97e9b..d80b5a5 100644
--- a/Source/CTest/cmCTestUpdateHandler.cxx
+++ b/Source/CTest/cmCTestUpdateHandler.cxx
@@ -2,7 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestUpdateHandler.h"
-#include "cmAlgorithms.h"
#include "cmCLocaleEnvironmentScope.h"
#include "cmCTest.h"
#include "cmCTestBZR.h"
@@ -18,9 +17,10 @@
#include "cmXMLWriter.h"
#include <chrono>
-#include <memory>
#include <sstream>
+#include "cm_memory.hxx"
+
static const char* cmCTestUpdateHandlerUpdateStrings[] = {
"Unknown", "CVS", "SVN", "BZR", "GIT", "HG", "P4"
};
diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index d1e32b0..d153076 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -11,7 +11,6 @@
#include <algorithm>
#include <functional>
#include <iterator>
-#include <memory>
#include <sstream>
#include <string.h>
#include <string>
@@ -340,20 +339,6 @@ inline void cmStripSuffixIfExists(std::string& str, const std::string& suffix)
namespace cm {
-#if defined(CMake_HAVE_CXX_MAKE_UNIQUE)
-
-using std::make_unique;
-
-#else
-
-template <typename T, typename... Args>
-std::unique_ptr<T> make_unique(Args&&... args)
-{
- return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
-}
-
-#endif
-
#if __cplusplus >= 201703L || defined(_MSVC_LANG) && _MSVC_LANG >= 201703L
using std::size;
diff --git a/Source/cmBinUtilsLinuxELFLinker.cxx b/Source/cmBinUtilsLinuxELFLinker.cxx
index 4fb15f2..86846cb 100644
--- a/Source/cmBinUtilsLinuxELFLinker.cxx
+++ b/Source/cmBinUtilsLinuxELFLinker.cxx
@@ -2,7 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmBinUtilsLinuxELFLinker.h"
-#include "cmAlgorithms.h"
+
#include "cmBinUtilsLinuxELFObjdumpGetRuntimeDependenciesTool.h"
#include "cmLDConfigLDConfigTool.h"
#include "cmMakefile.h"
@@ -12,9 +12,10 @@
#include <cmsys/RegularExpression.hxx>
-#include <memory>
#include <sstream>
+#include "cm_memory.hxx"
+
static std::string ReplaceOrigin(const std::string& rpath,
const std::string& origin)
{
diff --git a/Source/cmBinUtilsMacOSMachOLinker.cxx b/Source/cmBinUtilsMacOSMachOLinker.cxx
index e219847..ac93155 100644
--- a/Source/cmBinUtilsMacOSMachOLinker.cxx
+++ b/Source/cmBinUtilsMacOSMachOLinker.cxx
@@ -12,6 +12,8 @@
#include <string>
#include <vector>
+#include "cm_memory.hxx"
+
cmBinUtilsMacOSMachOLinker::cmBinUtilsMacOSMachOLinker(
cmRuntimeDependencyArchive* archive)
: cmBinUtilsLinker(archive)
diff --git a/Source/cmBinUtilsWindowsPELinker.cxx b/Source/cmBinUtilsWindowsPELinker.cxx
index 796e9ed..31602c4 100644
--- a/Source/cmBinUtilsWindowsPELinker.cxx
+++ b/Source/cmBinUtilsWindowsPELinker.cxx
@@ -2,16 +2,17 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmBinUtilsWindowsPELinker.h"
-#include "cmAlgorithms.h"
+
#include "cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool.h"
#include "cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.h"
#include "cmRuntimeDependencyArchive.h"
#include "cmSystemTools.h"
-#include <memory>
#include <sstream>
#include <vector>
+#include "cm_memory.hxx"
+
#ifdef _WIN32
# include <windows.h>
#endif
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index afdc039..83e3eff 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -15,7 +15,6 @@
#include <ctype.h>
#include <iostream>
#include <map>
-#include <memory>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
@@ -30,6 +29,8 @@
# include <unistd.h> // IWYU pragma: keep
#endif
+#include "cm_memory.hxx"
+
#include "cmAlgorithms.h"
#include "cmCTestBuildAndTestHandler.h"
#include "cmCTestBuildHandler.h"
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx
index a7618c7..54fc54c 100644
--- a/Source/cmComputeLinkDepends.cxx
+++ b/Source/cmComputeLinkDepends.cxx
@@ -23,6 +23,8 @@
#include <string.h>
#include <utility>
+#include "cm_memory.hxx"
+
/*
This file computes an ordered list of link items to use when linking a
diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx
index 4310eed..5e919af 100644
--- a/Source/cmCryptoHash.cxx
+++ b/Source/cmCryptoHash.cxx
@@ -2,13 +2,13 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCryptoHash.h"
-#include "cmAlgorithms.h"
#include "cm_kwiml.h"
#include "cm_rhash.h"
#include "cmsys/FStream.hxx"
+
#include <string.h>
-#include <memory>
+#include "cm_memory.hxx"
static unsigned int const cmCryptoHashAlgoToId[] = {
/* clang-format needs this comment to break after the opening brace */
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index e1c098d..29afc9f 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -20,11 +20,12 @@
#include "cmsys/FStream.hxx"
#include <assert.h>
-#include <memory>
#include <sstream>
#include <string.h>
#include <utility>
+#include "cm_memory.hxx"
+
static std::string cmExportFileGeneratorEscape(std::string const& str)
{
// Escape a property value for writing into a .cmake file.
diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx
index 2e86533..87ef2a9 100644
--- a/Source/cmExportLibraryDependenciesCommand.cxx
+++ b/Source/cmExportLibraryDependenciesCommand.cxx
@@ -4,10 +4,10 @@
#include "cmsys/FStream.hxx"
#include <map>
-#include <memory>
#include <utility>
-#include "cmAlgorithms.h"
+#include "cm_memory.hxx"
+
#include "cmGeneratedFileStream.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index dfba910..9871f49 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -13,7 +13,6 @@
#include <cmath>
#include <ctype.h>
#include <map>
-#include <memory>
#include <set>
#include <sstream>
#include <stdio.h>
@@ -21,6 +20,8 @@
#include <utility>
#include <vector>
+#include "cm_memory.hxx"
+
#include "cmAlgorithms.h"
#include "cmArgumentParser.h"
#include "cmCryptoHash.h"
diff --git a/Source/cmFileTimes.cxx b/Source/cmFileTimes.cxx
index fd4f679..3824e9b 100644
--- a/Source/cmFileTimes.cxx
+++ b/Source/cmFileTimes.cxx
@@ -2,11 +2,12 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmFileTimes.h"
-#include "cmAlgorithms.h"
#include "cm_sys_stat.h"
#include <utility>
+#include "cm_memory.hxx"
+
#if defined(_WIN32)
# include "cmSystemTools.h"
# include <windows.h>
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 783b5f6..85546bf 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -13,12 +13,13 @@
#include <deque>
#include <functional>
#include <iterator>
-#include <memory>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <utility>
+#include "cm_memory.hxx"
+
#include "cmAlgorithms.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx
index 7f189d6..94c1b1a 100644
--- a/Source/cmForEachCommand.cxx
+++ b/Source/cmForEachCommand.cxx
@@ -2,12 +2,12 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmForEachCommand.h"
-#include <memory>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
-#include "cmAlgorithms.h"
+#include "cm_memory.hxx"
+
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 98e8339..69a7da9 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -9,10 +9,11 @@
#include <algorithm>
#include <ctype.h>
#include <iterator>
-#include <memory>
#include <sstream>
#include <stdio.h>
+#include "cm_memory.hxx"
+
#include "cmAlgorithms.h"
#include "cmDocumentationEntry.h"
#include "cmFortranParser.h"
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index 93f5482..35af0e1 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -4,10 +4,11 @@
#include <algorithm>
#include <functional>
-#include <memory>
#include <sstream>
#include <utility>
+#include "cm_memory.hxx"
+
#include "cmAlgorithms.h"
#include "cmDocumentationEntry.h"
#include "cmGeneratedFileStream.h"
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 78e8f30..d99a906 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -5,11 +5,12 @@
#include "cmsys/RegularExpression.hxx"
#include <assert.h>
#include <iomanip>
-#include <memory>
#include <sstream>
#include <stdio.h>
#include <string.h>
+#include "cm_memory.hxx"
+
#include "cmAlgorithms.h"
#include "cmComputeLinkInformation.h"
#include "cmCustomCommand.h"
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx
index e9a4a6f..a2e665f 100644
--- a/Source/cmListCommand.cxx
+++ b/Source/cmListCommand.cxx
@@ -7,7 +7,6 @@
#include <assert.h>
#include <functional>
#include <iterator>
-#include <memory>
#include <set>
#include <sstream>
#include <stdexcept>
@@ -16,6 +15,8 @@
#include <utility>
#include <vector>
+#include "cm_memory.hxx"
+
#include "cmAlgorithms.h"
#include "cmGeneratorExpression.h"
#include "cmMakefile.h"
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 1b4f428..1ec1fd9 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -5,11 +5,12 @@
#include "cmsys/FStream.hxx"
#include "cmsys/Terminal.h"
#include <algorithm>
-#include <memory>
#include <sstream>
#include <stdio.h>
#include <utility>
+#include "cm_memory.hxx"
+
#include "cmAlgorithms.h"
#include "cmCustomCommand.h" // IWYU pragma: keep
#include "cmCustomCommandGenerator.h"
diff --git a/Source/cmMachO.cxx b/Source/cmMachO.cxx
index ac6dce9..bec3ad8 100644
--- a/Source/cmMachO.cxx
+++ b/Source/cmMachO.cxx
@@ -4,10 +4,13 @@
#include "cmAlgorithms.h"
#include "cmsys/FStream.hxx"
+
#include <cstddef>
#include <string>
#include <vector>
+#include "cm_memory.hxx"
+
// Include the Mach-O format information system header.
#include <mach-o/fat.h>
#include <mach-o/loader.h>
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index 2001c1f..dcee47e 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -2,13 +2,14 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMakefileExecutableTargetGenerator.h"
-#include <memory>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
+#include "cm_memory.hxx"
+
#include "cmAlgorithms.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index e5aed01..bdde4b8 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -2,13 +2,14 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMakefileLibraryTargetGenerator.h"
-#include <memory>
#include <set>
#include <sstream>
#include <stddef.h>
#include <utility>
#include <vector>
+#include "cm_memory.hxx"
+
#include "cmAlgorithms.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx
index 70d9fca..8ed6be5 100644
--- a/Source/cmMakefileUtilityTargetGenerator.cxx
+++ b/Source/cmMakefileUtilityTargetGenerator.cxx
@@ -2,13 +2,13 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMakefileUtilityTargetGenerator.h"
-#include <memory>
#include <ostream>
#include <string>
#include <utility>
#include <vector>
-#include "cmAlgorithms.h"
+#include "cm_memory.hxx"
+
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalUnixMakefileGenerator3.h"
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index d1af9e6..88040f8 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -6,11 +6,12 @@
#include <assert.h>
#include <iterator>
#include <map>
-#include <memory>
#include <set>
#include <sstream>
#include <utility>
+#include "cm_memory.hxx"
+
#include "cmAlgorithms.h"
#include "cmCustomCommand.h" // IWYU pragma: keep
#include "cmCustomCommandGenerator.h"
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 57e500e..de79817 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -8,10 +8,11 @@
#include <assert.h>
#include <iterator>
#include <map>
-#include <memory>
#include <ostream>
#include <utility>
+#include "cm_memory.hxx"
+
#include "cmAlgorithms.h"
#include "cmComputeLinkInformation.h"
#include "cmCustomCommandGenerator.h"
diff --git a/Source/cmQtAutoGenGlobalInitializer.cxx b/Source/cmQtAutoGenGlobalInitializer.cxx
index ef8a56b..f172b77 100644
--- a/Source/cmQtAutoGenGlobalInitializer.cxx
+++ b/Source/cmQtAutoGenGlobalInitializer.cxx
@@ -4,7 +4,6 @@
#include "cmQtAutoGen.h"
#include "cmQtAutoGenInitializer.h"
-#include "cmAlgorithms.h"
#include "cmCustomCommandLines.h"
#include "cmDuration.h"
#include "cmGeneratorTarget.h"
@@ -17,9 +16,10 @@
#include "cmSystemTools.h"
#include "cmTarget.h"
-#include <memory>
#include <utility>
+#include "cm_memory.hxx"
+
cmQtAutoGenGlobalInitializer::Keywords::Keywords()
: AUTOMOC("AUTOMOC")
, AUTOUIC("AUTOUIC")
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index 83a1bc4..4b12419 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -38,6 +38,8 @@
#include <utility>
#include <vector>
+#include "cm_memory.hxx"
+
static std::size_t GetParallelCPUCount()
{
static std::size_t count = 0;
diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx
index 3a3162d..2516d84 100644
--- a/Source/cmQtAutoGenerator.cxx
+++ b/Source/cmQtAutoGenerator.cxx
@@ -5,7 +5,8 @@
#include "cmsys/FStream.hxx"
-#include "cmAlgorithms.h"
+#include "cm_memory.hxx"
+
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmState.h"
@@ -14,8 +15,6 @@
#include "cmSystemTools.h"
#include "cmake.h"
-#include <memory>
-
cmQtAutoGenerator::Logger::Logger()
{
// Initialize logger
diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx
index 889f47d..44d2db0 100644
--- a/Source/cmQtAutoMocUic.cxx
+++ b/Source/cmQtAutoMocUic.cxx
@@ -5,11 +5,12 @@
#include <algorithm>
#include <array>
#include <list>
-#include <memory>
#include <set>
#include <sstream>
#include <utility>
+#include "cm_memory.hxx"
+
#include "cmAlgorithms.h"
#include "cmCryptoHash.h"
#include "cmGeneratedFileStream.h"
diff --git a/Source/cmRuntimeDependencyArchive.cxx b/Source/cmRuntimeDependencyArchive.cxx
index a1d1f95..45aff69 100644
--- a/Source/cmRuntimeDependencyArchive.cxx
+++ b/Source/cmRuntimeDependencyArchive.cxx
@@ -3,7 +3,6 @@
#include "cmRuntimeDependencyArchive.h"
-#include "cmAlgorithms.h"
#include "cmBinUtilsLinuxELFLinker.h"
#include "cmBinUtilsMacOSMachOLinker.h"
#include "cmBinUtilsWindowsPELinker.h"
@@ -27,6 +26,8 @@
#include <utility>
#include <vector>
+#include "cm_memory.hxx"
+
#if defined(_WIN32)
static void AddVisualStudioPath(std::vector<std::string>& paths,
const std::string& prefix,
diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx
index 1903fd9..9df1883 100644
--- a/Source/cmServer.cxx
+++ b/Source/cmServer.cxx
@@ -2,7 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmServer.h"
-#include "cmAlgorithms.h"
#include "cmConnection.h"
#include "cmFileMonitor.h"
#include "cmJsonObjectDictionary.h"
@@ -18,10 +17,11 @@
#include <cassert>
#include <cstdint>
#include <iostream>
-#include <memory>
#include <mutex>
#include <utility>
+#include "cm_memory.hxx"
+
void on_signal(uv_signal_t* signal, int signum)
{
auto conn = static_cast<cmServerBase*>(signal->data);
diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx
index 558391f..c5de742 100644
--- a/Source/cmServerProtocol.cxx
+++ b/Source/cmServerProtocol.cxx
@@ -2,7 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmServerProtocol.h"
-#include "cmAlgorithms.h"
#include "cmExternalMakefileProjectGenerator.h"
#include "cmFileMonitor.h"
#include "cmGlobalGenerator.h"
@@ -19,11 +18,12 @@
#include <algorithm>
#include <cassert>
#include <functional>
-#include <memory>
#include <string>
#include <utility>
#include <vector>
+#include "cm_memory.hxx"
+
// Get rid of some windows macros:
#undef max
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 587cda5..878d5b6 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -8,6 +8,8 @@
#include <string.h>
#include <utility>
+#include "cm_memory.hxx"
+
#include "cmAlgorithms.h"
#include "cmCacheManager.h"
#include "cmCommand.h"
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index b10b30f..28d8c64 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -12,6 +12,8 @@
#include <string.h>
#include <unordered_set>
+#include "cm_memory.hxx"
+
#include "cmAlgorithms.h"
#include "cmCustomCommand.h"
#include "cmGeneratorExpression.h"
diff --git a/Source/cmUVProcessChain.cxx b/Source/cmUVProcessChain.cxx
index 90ece0b..fbd5634 100644
--- a/Source/cmUVProcessChain.cxx
+++ b/Source/cmUVProcessChain.cxx
@@ -11,9 +11,10 @@
#include <assert.h>
#include <iterator>
-#include <memory>
#include <utility>
+#include "cm_memory.hxx"
+
struct cmUVProcessChain::InternalData
{
struct BasicStreamData
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index e2a4816..ae347fe 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -19,9 +19,10 @@
#include "windows.h"
#include <iterator>
-#include <memory>
#include <set>
+#include "cm_memory.hxx"
+
static void ConvertToWindowsSlash(std::string& s);
static std::string cmVS10EscapeXML(std::string arg)
diff --git a/Source/cmWorkerPool.cxx b/Source/cmWorkerPool.cxx
index cbf070e..974100b 100644
--- a/Source/cmWorkerPool.cxx
+++ b/Source/cmWorkerPool.cxx
@@ -16,6 +16,8 @@
#include <stddef.h>
#include <thread>
+#include "cm_memory.hxx"
+
/**
* @brief libuv pipe buffer class
*/
diff --git a/Source/cmWorkerPool.h b/Source/cmWorkerPool.h
index 5cc308b..d708118 100644
--- a/Source/cmWorkerPool.h
+++ b/Source/cmWorkerPool.h
@@ -5,14 +5,13 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmAlgorithms.h" // IWYU pragma: keep
-
-#include <memory>
#include <stdint.h>
#include <string>
#include <utility>
#include <vector>
+#include "cm_memory.hxx"
+
// -- Types
class cmWorkerPoolInternal;
diff --git a/Source/cm_memory.hxx b/Source/cm_memory.hxx
new file mode 100644
index 0000000..9f5e678
--- /dev/null
+++ b/Source/cm_memory.hxx
@@ -0,0 +1,31 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cm_memory_hxx
+#define cm_memory_hxx
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <memory> // IWYU pragma: export
+#if !defined(CMake_HAVE_CXX_MAKE_UNIQUE)
+# include <utility>
+#endif
+
+namespace cm {
+
+#if defined(CMake_HAVE_CXX_MAKE_UNIQUE)
+
+using std::make_unique;
+
+#else
+
+template <typename T, typename... Args>
+std::unique_ptr<T> make_unique(Args&&... args)
+{
+ return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
+}
+
+#endif
+
+} // namespace cm
+
+#endif
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index b8238a2..7250e51 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -2,6 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmake.h"
+#include "cm_memory.hxx"
+
#include "cmAlgorithms.h"
#include "cmCommands.h"
#include "cmDocumentation.h"
@@ -104,7 +106,6 @@
#include <cstring>
#include <initializer_list>
#include <iostream>
-#include <memory>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>