From 141e3074845675d37a8c7f7c3efcc09d0ab5158c Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 19 Aug 2019 15:39:02 -0400 Subject: cmConfigure.h: Tell windows.h not to define min/max macros --- Source/cmConfigure.cmake.h.in | 4 ++++ bootstrap | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in index 19b1cd4..4de1c5d 100644 --- a/Source/cmConfigure.cmake.h.in +++ b/Source/cmConfigure.cmake.h.in @@ -26,4 +26,8 @@ #define CM_FALLTHROUGH cmsys_FALLTHROUGH +#if defined(_WIN32) && !defined(NOMINMAX) +# define NOMINMAX +#endif + #endif diff --git a/bootstrap b/bootstrap index 4581239..c7e3945 100755 --- a/bootstrap +++ b/bootstrap @@ -1364,6 +1364,12 @@ cmake_report cmConfigure.h${_tmp} "#define CMAKE_BIN_DIR \"/bootstrap-not-insall cmake_report cmConfigure.h${_tmp} "#define CMAKE_DATA_DIR \"/bootstrap-not-insalled\"" cmake_report cmConfigure.h${_tmp} "#define CM_FALLTHROUGH" +if ${cmake_system_mingw}; then + cmake_report cmConfigure.h${_tmp} "#if defined(_WIN32) && !defined(NOMINMAX)" + cmake_report cmConfigure.h${_tmp} "# define NOMINMAX" + cmake_report cmConfigure.h${_tmp} "#endif" +fi + # Regenerate configured headers for h in Configure VersionConfig; do if "${_diff}" cm${h}.h cm${h}.h${_tmp} > /dev/null 2> /dev/null; then -- cgit v0.12 From c1787cb5eb82ad815a824f88d4cc636e949fae73 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 20 Aug 2019 08:55:03 -0400 Subject: cpack.cxx: Re-order include blocks to follow our conventions --- Source/CPack/cpack.cxx | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 3cf0c10..5abf0ab 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -1,20 +1,6 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmsys/CommandLineArguments.hxx" -#include "cmsys/Encoding.hxx" -#include -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP) -# include "cmsys/ConsoleBuf.hxx" -#endif - #include "cmCPackGenerator.h" #include "cmCPackGeneratorFactory.h" #include "cmCPackLog.h" @@ -29,6 +15,21 @@ #include "cmSystemTools.h" #include "cmake.h" +#include "cmsys/CommandLineArguments.hxx" +#include "cmsys/Encoding.hxx" + +#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP) +# include "cmsys/ConsoleBuf.hxx" +#endif + +#include +#include +#include +#include +#include +#include +#include + namespace { const char* cmDocumentationName[][2] = { { nullptr, " cpack - Packaging driver provided by CMake." }, -- cgit v0.12 From e07e2bc8bbf25178270e8086575ff398dd1fa0c6 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 19 Aug 2019 15:33:06 -0400 Subject: bootstrap: Compile cm::String --- bootstrap | 1 + 1 file changed, 1 insertion(+) diff --git a/bootstrap b/bootstrap index c7e3945..eaccfc8 100755 --- a/bootstrap +++ b/bootstrap @@ -423,6 +423,7 @@ CMAKE_CXX_SOURCES="\ cmState \ cmStateDirectory \ cmStateSnapshot \ + cmString \ cmStringAlgorithms \ cmStringReplaceHelper \ cmStringCommand \ -- cgit v0.12 From be7807478c463c5c875798a3e2e72e148c0d0c3e Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 8 Aug 2019 14:50:09 -0400 Subject: cmDefinitions: Reduce allocation of keys and values in MakeClosure Use `cm::String` to store keys and values so that `MakeClosure` does not need to allocate new copies of all of them. Issue: #19581 --- Source/cmDefinitions.cxx | 18 +++++++++--------- Source/cmDefinitions.h | 8 ++++---- Source/cmGeneratorExpressionNode.cxx | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index cc38d84..e688890 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -17,7 +17,7 @@ cmDefinitions::Def const& cmDefinitions::GetInternal(const std::string& key, { assert(begin != end); { - auto it = begin->Map.find(key); + auto it = begin->Map.find(cm::String::borrow(key)); if (it != begin->Map.end()) { it->second.Used = true; return it->second; @@ -39,7 +39,7 @@ const std::string* cmDefinitions::Get(const std::string& key, StackIter begin, StackIter end) { Def const& def = cmDefinitions::GetInternal(key, begin, end, false); - return def.Exists ? &def.Value : nullptr; + return def.Value ? def.Value.str_if_stable() : nullptr; } void cmDefinitions::Raise(const std::string& key, StackIter begin, @@ -52,7 +52,7 @@ bool cmDefinitions::HasKey(const std::string& key, StackIter begin, StackIter end) { for (StackIter it = begin; it != end; ++it) { - if (it->Map.find(key) != it->Map.end()) { + if (it->Map.find(cm::String::borrow(key)) != it->Map.end()) { return true; } } @@ -68,11 +68,11 @@ cmDefinitions cmDefinitions::MakeClosure(StackIter begin, StackIter end) for (auto const& mi : it->Map) { // Use this key if it is not already set or unset. if (closure.Map.find(mi.first) == closure.Map.end() && - undefined.find(mi.first) == undefined.end()) { - if (mi.second.Exists) { + undefined.find(mi.first.view()) == undefined.end()) { + if (mi.second.Value) { closure.Map.insert(mi); } else { - undefined.emplace(mi.first); + undefined.emplace(mi.first.view()); } } } @@ -90,8 +90,8 @@ std::vector cmDefinitions::ClosureKeys(StackIter begin, defined.reserve(defined.size() + it->Map.size()); for (auto const& mi : it->Map) { // Use this key if it is not already set or unset. - if (bound.emplace(mi.first).second && mi.second.Exists) { - defined.push_back(mi.first); + if (bound.emplace(mi.first.view()).second && mi.second.Value) { + defined.push_back(*mi.first.str_if_stable()); } } } @@ -116,7 +116,7 @@ std::vector cmDefinitions::UnusedKeys() const // Consider local definitions. for (auto const& mi : this->Map) { if (!mi.second.Used) { - keys.push_back(mi.first); + keys.push_back(*mi.first.str_if_stable()); } } return keys; diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index 787471a..b4d6419 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -8,7 +8,9 @@ #include "cm_string_view.hxx" #include "cmLinkedTree.h" +#include "cmString.hxx" +#include #include #include #include @@ -57,16 +59,14 @@ private: Def() = default; Def(cm::string_view value) : Value(value) - , Exists(true) { } - std::string Value; - bool Exists = false; + cm::String Value; bool Used = false; }; static Def NoDef; - std::unordered_map Map; + std::unordered_map Map; static Def const& GetInternal(const std::string& key, StackIter begin, StackIter end, bool raise); diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 9f761ed..78facf8 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -19,11 +19,11 @@ #include "cmState.h" #include "cmStateSnapshot.h" #include "cmStateTypes.h" +#include "cmString.hxx" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cm_static_string_view.hxx" -#include "cm_string_view.hxx" #include "cmake.h" #include "cmsys/RegularExpression.hxx" -- cgit v0.12