From d9b2c7dae242868f13fc366773fb09448da26e8d Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Tue, 2 Jul 2019 11:08:04 +0200 Subject: Introduce memory management helper: cm_memory.hxx --- Source/CPack/cmCPackExternalGenerator.cxx | 3 ++- Source/CTest/cmCTestRunTest.cxx | 3 ++- Source/CTest/cmCTestUpdateHandler.cxx | 4 ++-- Source/cmAlgorithms.h | 15 ------------- Source/cmBinUtilsLinuxELFLinker.cxx | 5 +++-- Source/cmBinUtilsMacOSMachOLinker.cxx | 2 ++ Source/cmBinUtilsWindowsPELinker.cxx | 5 +++-- Source/cmCTest.cxx | 3 ++- Source/cmComputeLinkDepends.cxx | 2 ++ Source/cmCryptoHash.cxx | 4 ++-- Source/cmExportFileGenerator.cxx | 3 ++- Source/cmExportLibraryDependenciesCommand.cxx | 4 ++-- Source/cmFileCommand.cxx | 3 ++- Source/cmFileTimes.cxx | 3 ++- Source/cmFindPackageCommand.cxx | 3 ++- Source/cmForEachCommand.cxx | 4 ++-- Source/cmGlobalNinjaGenerator.cxx | 3 ++- Source/cmGlobalUnixMakefileGenerator3.cxx | 3 ++- Source/cmGlobalXCodeGenerator.cxx | 3 ++- Source/cmListCommand.cxx | 3 ++- Source/cmLocalUnixMakefileGenerator3.cxx | 3 ++- Source/cmMachO.cxx | 3 +++ Source/cmMakefileExecutableTargetGenerator.cxx | 3 ++- Source/cmMakefileLibraryTargetGenerator.cxx | 3 ++- Source/cmMakefileUtilityTargetGenerator.cxx | 4 ++-- Source/cmNinjaNormalTargetGenerator.cxx | 3 ++- Source/cmNinjaTargetGenerator.cxx | 3 ++- Source/cmQtAutoGenGlobalInitializer.cxx | 4 ++-- Source/cmQtAutoGenInitializer.cxx | 2 ++ Source/cmQtAutoGenerator.cxx | 5 ++--- Source/cmQtAutoMocUic.cxx | 3 ++- Source/cmRuntimeDependencyArchive.cxx | 3 ++- Source/cmServer.cxx | 4 ++-- Source/cmServerProtocol.cxx | 4 ++-- Source/cmState.cxx | 2 ++ Source/cmTarget.cxx | 2 ++ Source/cmUVProcessChain.cxx | 3 ++- Source/cmVisualStudio10TargetGenerator.cxx | 3 ++- Source/cmWorkerPool.cxx | 2 ++ Source/cmWorkerPool.h | 5 ++--- Source/cm_memory.hxx | 31 ++++++++++++++++++++++++++ Source/cmake.cxx | 3 ++- Tests/CMakeLib/testUVProcessChain.cxx | 3 ++- Utilities/IWYU/mapping.imp | 2 ++ 44 files changed, 118 insertions(+), 63 deletions(-) create mode 100644 Source/cm_memory.hxx 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 #include +#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 -#include #include #include #include @@ -20,6 +19,8 @@ #include #include +#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 -#include #include +#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 #include #include -#include #include #include #include @@ -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 -std::unique_ptr make_unique(Args&&... args) -{ - return std::unique_ptr(new T(std::forward(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 -#include #include +#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 #include +#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 #include #include +#include "cm_memory.hxx" + #ifdef _WIN32 # include #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 #include #include -#include #include #include #include @@ -30,6 +29,8 @@ # include // 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 #include +#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 -#include +#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 -#include #include #include #include +#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 -#include #include -#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 #include #include -#include #include #include #include @@ -21,6 +20,8 @@ #include #include +#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 +#include "cm_memory.hxx" + #if defined(_WIN32) # include "cmSystemTools.h" # include 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 #include #include -#include #include #include #include #include +#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 #include #include #include -#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 #include #include -#include #include #include +#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 #include -#include #include #include +#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 #include -#include #include #include #include +#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 #include #include -#include #include #include #include @@ -16,6 +15,8 @@ #include #include +#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 -#include #include #include #include +#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 #include #include +#include "cm_memory.hxx" + // Include the Mach-O format information system header. #include #include 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 #include #include #include #include #include +#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 #include #include #include #include #include +#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 #include #include #include #include -#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 #include #include -#include #include #include #include +#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 #include #include -#include #include #include +#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 #include +#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 #include +#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 - 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 #include #include -#include #include #include #include +#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 #include +#include "cm_memory.hxx" + #if defined(_WIN32) static void AddVisualStudioPath(std::vector& 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 #include #include -#include #include #include +#include "cm_memory.hxx" + void on_signal(uv_signal_t* signal, int signum) { auto conn = static_cast(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 #include #include -#include #include #include #include +#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 #include +#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 #include +#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 #include -#include #include +#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 -#include #include +#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 #include +#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 #include #include #include #include +#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 // IWYU pragma: export +#if !defined(CMake_HAVE_CXX_MAKE_UNIQUE) +# include +#endif + +namespace cm { + +#if defined(CMake_HAVE_CXX_MAKE_UNIQUE) + +using std::make_unique; + +#else + +template +std::unique_ptr make_unique(Args&&... args) +{ + return std::unique_ptr(new T(std::forward(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 #include #include -#include #include #include #include diff --git a/Tests/CMakeLib/testUVProcessChain.cxx b/Tests/CMakeLib/testUVProcessChain.cxx index e926350..2c1202e 100644 --- a/Tests/CMakeLib/testUVProcessChain.cxx +++ b/Tests/CMakeLib/testUVProcessChain.cxx @@ -1,6 +1,5 @@ #include "cmUVProcessChain.h" -#include "cmAlgorithms.h" #include "cmGetPipes.h" #include "cmUVHandlePtr.h" #include "cmUVStreambuf.h" @@ -17,6 +16,8 @@ #include +#include "cm_memory.hxx" + struct ExpectedStatus { bool Finished; diff --git a/Utilities/IWYU/mapping.imp b/Utilities/IWYU/mapping.imp index 4e00214..9fff442 100644 --- a/Utilities/IWYU/mapping.imp +++ b/Utilities/IWYU/mapping.imp @@ -51,7 +51,9 @@ { symbol: [ "std::allocator_traits >::value_type", private, "", public ] }, { symbol: [ "std::allocator_traits >::value_type", private, "", public ] }, { symbol: [ "std::allocator_traits > >::value_type", private, "", public ] }, + { symbol: [ "std::allocator_traits, std::allocator > > >::value_type", private, "", public ] }, { symbol: [ "std::allocator_traits, std::allocator > > > >::value_type", private, "", public ] }, + { symbol: [ "std::allocator_traits, std::allocator >, std::allocator, std::allocator > > > > >::value_type", private, "", public ] }, { symbol: [ "std::allocator_traits >::value_type", private, "", public ] }, # TODO: enable this block and remove some includes? -- cgit v0.12