diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMakeVersion.cmake | 4 | ||||
-rw-r--r-- | Source/CursesDialog/ccmake.cxx | 2 | ||||
-rw-r--r-- | Source/QtDialog/CMakeSetup.cxx | 2 | ||||
-rw-r--r-- | Source/cmExportFileGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmFindPackageCommand.cxx | 7 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 2 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 8 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 20 | ||||
-rw-r--r-- | Source/cmMakefileProfilingData.cxx | 60 | ||||
-rw-r--r-- | Source/cmMakefileProfilingData.h | 30 | ||||
-rw-r--r-- | Source/cmState.cxx | 2 | ||||
-rw-r--r-- | Source/cmState.h | 1 | ||||
-rw-r--r-- | Source/cmTimestamp.cxx | 63 | ||||
-rw-r--r-- | Source/cmTimestamp.h | 4 | ||||
-rw-r--r-- | Source/cmake.cxx | 21 | ||||
-rw-r--r-- | Source/cmake.h | 27 | ||||
-rw-r--r-- | Source/cmakemain.cxx | 2 |
17 files changed, 221 insertions, 38 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index c51f421..f561678 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,8 +1,8 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 25) -set(CMake_VERSION_PATCH 0) -set(CMake_VERSION_RC 2) +set(CMake_VERSION_PATCH 20221031) +#set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) # Start with the full version number used in tags. It has no dev info. diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx index 1f7776c..70ed648 100644 --- a/Source/CursesDialog/ccmake.cxx +++ b/Source/CursesDialog/ccmake.cxx @@ -77,7 +77,7 @@ int main(int argc, char const* const* argv) cmDocumentation doc; doc.addCMakeStandardDocSections(); if (doc.CheckOptions(argc, argv)) { - cmake hcm(cmake::RoleInternal, cmState::Unknown); + cmake hcm(cmake::RoleInternal, cmState::Help); hcm.SetHomeDirectory(""); hcm.SetHomeOutputDirectory(""); hcm.AddCMakePaths(); diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index fb12b7d..591b793 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -79,7 +79,7 @@ int main(int argc, char** argv) doc.addCMakeStandardDocSections(); if (argc2 > 1 && doc.CheckOptions(argc2, argv2)) { // Construct and print requested documentation. - cmake hcm(cmake::RoleInternal, cmState::Unknown); + cmake hcm(cmake::RoleInternal, cmState::Help); hcm.SetHomeDirectory(""); hcm.SetHomeOutputDirectory(""); hcm.AddCMakePaths(); diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 50bc78c..2c61163 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -939,13 +939,13 @@ void cmExportFileGenerator::GeneratePolicyHeaderCode(std::ostream& os) // Isolate the file policy level. // Support CMake versions as far back as 2.6 but also support using NEW - // policy settings for up to CMake 3.23 (this upper limit may be reviewed + // policy settings for up to CMake 3.24 (this upper limit may be reviewed // and increased from time to time). This reduces the opportunity for CMake // warnings when an older export file is later used with newer CMake // versions. /* clang-format off */ os << "cmake_policy(PUSH)\n" - << "cmake_policy(VERSION 2.8.3...3.23)\n"; + << "cmake_policy(VERSION 2.8.3...3.24)\n"; /* clang-format on */ } diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 3f8378b..60b0a7b 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -377,6 +377,8 @@ private: # pragma diag_suppress 1222 // invalid error number (3288, but works anyway) # define CM_LCC_DIAG_SUPPRESS_3288 # pragma diag_suppress 3288 // parameter was declared but never referenced +# define CM_LCC_DIAG_SUPPRESS_3301 +# pragma diag_suppress 3301 // parameter was declared but never referenced #endif void ResetGenerator() @@ -421,6 +423,11 @@ bool TryGeneratedPaths(CallbackFn&& filesCollector, return false; } +#ifdef CM_LCC_DIAG_SUPPRESS_3301 +# undef CM_LCC_DIAG_SUPPRESS_3301 +# pragma diag_default 3301 +#endif + #ifdef CM_LCC_DIAG_SUPPRESS_3288 # undef CM_LCC_DIAG_SUPPRESS_3288 # pragma diag_default 3288 diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6195d1f..321122a 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -5532,7 +5532,7 @@ cmGeneratorTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const } else if (cmHasLiteralPrefix(*location, "Resources/")) { flags.Type = cmGeneratorTarget::SourceFileTypeDeepResource; if (stripResources) { - flags.MacFolder += strlen("Resources/"); + flags.MacFolder += cmStrLen("Resources/"); } } else { flags.Type = cmGeneratorTarget::SourceFileTypeMacContent; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 67b6e92..11520b4 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -4407,12 +4407,20 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( buildSettings->AddAttribute("CODE_SIGNING_ALLOWED", this->CreateString("NO")); } + auto debugConfigs = this->GetCMakeInstance()->GetDebugConfigs(); + std::set<std::string> debugConfigSet(debugConfigs.begin(), + debugConfigs.end()); for (auto& config : configs) { CreateGlobalXCConfigSettings(root, config.second, config.first); cmXCodeObject* buildSettingsForCfg = this->CreateFlatClone(buildSettings); + if (debugConfigSet.count(cmSystemTools::UpperCase(config.first)) == 0) { + buildSettingsForCfg->AddAttribute("SWIFT_COMPILATION_MODE", + this->CreateString("wholemodule")); + } + // Put this last so it can override existing settings // Convert "CMAKE_XCODE_ATTRIBUTE_*" variables directly. for (const auto& var : this->CurrentMakefile->GetDefinitions()) { diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 6e0d704..2091f27 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -375,19 +375,15 @@ public: ++this->Makefile->RecursionDepth; this->Makefile->ExecutionStatusStack.push_back(&status); #if !defined(CMAKE_BOOTSTRAP) - if (this->Makefile->GetCMakeInstance()->IsProfilingEnabled()) { - this->Makefile->GetCMakeInstance()->GetProfilingOutput().StartEntry(lff, - lfc); - } + this->ProfilingDataRAII = + this->Makefile->GetCMakeInstance()->CreateProfilingEntry(lff, lfc); #endif } ~cmMakefileCall() { #if !defined(CMAKE_BOOTSTRAP) - if (this->Makefile->GetCMakeInstance()->IsProfilingEnabled()) { - this->Makefile->GetCMakeInstance()->GetProfilingOutput().StopEntry(); - } + this->ProfilingDataRAII.reset(); #endif this->Makefile->ExecutionStatusStack.pop_back(); --this->Makefile->RecursionDepth; @@ -399,6 +395,9 @@ public: private: cmMakefile* Makefile; +#if !defined(CMAKE_BOOTSTRAP) + cm::optional<cmMakefileProfilingData::RAII> ProfilingDataRAII; +#endif }; void cmMakefile::OnExecuteCommand(std::function<void()> callback) @@ -3584,6 +3583,9 @@ int cmMakefile::TryCompile(const std::string& srcdir, gg->RecursionDepth = this->RecursionDepth; cm.SetGlobalGenerator(std::move(gg)); + // copy trace state + cm.SetTraceRedirect(this->GetCMakeInstance()); + // do a configure cm.SetHomeDirectory(srcdir); cm.SetHomeOutputDirectory(bindir); @@ -4470,12 +4472,12 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id, } // Deprecate old policies. - if (status == cmPolicies::OLD && id <= cmPolicies::CMP0102 && + if (status == cmPolicies::OLD && id <= cmPolicies::CMP0108 && !(this->GetCMakeInstance()->GetIsInTryCompile() && ( // Policies set by cmCoreTryCompile::TryCompileCode. id == cmPolicies::CMP0065 || id == cmPolicies::CMP0083 || - id == cmPolicies::CMP0091)) && + id == cmPolicies::CMP0091 || id == cmPolicies::CMP0104)) && (!this->IsSet("CMAKE_WARN_DEPRECATED") || this->IsOn("CMAKE_WARN_DEPRECATED"))) { this->IssueMessage(MessageType::DEPRECATION_WARNING, diff --git a/Source/cmMakefileProfilingData.cxx b/Source/cmMakefileProfilingData.cxx index 1cd97c9..e4844f3 100644 --- a/Source/cmMakefileProfilingData.cxx +++ b/Source/cmMakefileProfilingData.cxx @@ -4,8 +4,12 @@ #include <chrono> #include <stdexcept> +#include <type_traits> +#include <utility> #include <vector> +#include <cm/utility> + #include <cm3p/json/value.h> #include <cm3p/json/writer.h> @@ -46,6 +50,23 @@ cmMakefileProfilingData::~cmMakefileProfilingData() noexcept void cmMakefileProfilingData::StartEntry(const cmListFileFunction& lff, cmListFileContext const& lfc) { + cm::optional<Json::Value> argsValue(cm::in_place, Json::objectValue); + if (!lff.Arguments().empty()) { + std::string args; + for (auto const& a : lff.Arguments()) { + args = cmStrCat(args, args.empty() ? "" : " ", a.Value); + } + (*argsValue)["functionArgs"] = args; + } + (*argsValue)["location"] = + cmStrCat(lfc.FilePath, ':', std::to_string(lfc.Line)); + this->StartEntry("script", lff.LowerCaseName(), std::move(argsValue)); +} + +void cmMakefileProfilingData::StartEntry(const std::string& category, + const std::string& name, + cm::optional<Json::Value> args) +{ /* Do not try again if we previously failed to write to output. */ if (!this->ProfileStream.good()) { return; @@ -58,24 +79,17 @@ void cmMakefileProfilingData::StartEntry(const cmListFileFunction& lff, cmsys::SystemInformation info; Json::Value v; v["ph"] = "B"; - v["name"] = lff.LowerCaseName(); - v["cat"] = "cmake"; + v["name"] = name; + v["cat"] = category; v["ts"] = static_cast<Json::Value::UInt64>( std::chrono::duration_cast<std::chrono::microseconds>( std::chrono::steady_clock::now().time_since_epoch()) .count()); v["pid"] = static_cast<int>(info.GetProcessId()); v["tid"] = 0; - Json::Value argsValue; - if (!lff.Arguments().empty()) { - std::string args; - for (auto const& a : lff.Arguments()) { - args += (args.empty() ? "" : " ") + a.Value; - } - argsValue["functionArgs"] = args; + if (args) { + v["args"] = *std::move(args); } - argsValue["location"] = lfc.FilePath + ":" + std::to_string(lfc.Line); - v["args"] = argsValue; this->JsonWriter->write(v, &this->ProfileStream); } catch (std::ios_base::failure& fail) { @@ -112,3 +126,27 @@ void cmMakefileProfilingData::StopEntry() cmSystemTools::Error("Error writing profiling output!"); } } + +cmMakefileProfilingData::RAII::RAII(RAII&& other) noexcept + : Data(other.Data) +{ + other.Data = nullptr; +} + +cmMakefileProfilingData::RAII::~RAII() +{ + if (this->Data) { + this->Data->StopEntry(); + } +} + +cmMakefileProfilingData::RAII& cmMakefileProfilingData::RAII::operator=( + RAII&& other) noexcept +{ + if (this->Data) { + this->Data->StopEntry(); + } + this->Data = other.Data; + other.Data = nullptr; + return *this; +} diff --git a/Source/cmMakefileProfilingData.h b/Source/cmMakefileProfilingData.h index a86764a..e8d7dfa 100644 --- a/Source/cmMakefileProfilingData.h +++ b/Source/cmMakefileProfilingData.h @@ -3,6 +3,11 @@ #pragma once #include <memory> #include <string> +#include <utility> + +#include <cm/optional> + +#include <cm3p/json/value.h> // IWYU pragma: keep #include "cmsys/FStream.hxx" @@ -19,8 +24,33 @@ public: cmMakefileProfilingData(const std::string&); ~cmMakefileProfilingData() noexcept; void StartEntry(const cmListFileFunction& lff, cmListFileContext const& lfc); + void StartEntry(const std::string& category, const std::string& name, + cm::optional<Json::Value> args = cm::nullopt); void StopEntry(); + class RAII + { + public: + RAII() = delete; + RAII(const RAII&) = delete; + RAII(RAII&&) noexcept; + + template <typename... Args> + RAII(cmMakefileProfilingData& data, Args&&... args) + : Data(&data) + { + this->Data->StartEntry(std::forward<Args>(args)...); + } + + ~RAII(); + + RAII& operator=(const RAII&) = delete; + RAII& operator=(RAII&&) noexcept; + + private: + cmMakefileProfilingData* Data = nullptr; + }; + private: cmsys::ofstream ProfileStream; std::unique_ptr<Json::StreamWriter> JsonWriter; diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 3d38e73..17ee7f3 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -786,6 +786,8 @@ std::string cmState::ModeToString(cmState::Mode mode) return "CTEST"; case CPack: return "CPACK"; + case Help: + return "HELP"; case Unknown: return "UNKNOWN"; } diff --git a/Source/cmState.h b/Source/cmState.h index 2d0c521..9a17b22 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -53,6 +53,7 @@ public: FindPackage, CTest, CPack, + Help }; enum class ProjectKind diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx index 677fdb6..7e47b4e 100644 --- a/Source/cmTimestamp.cxx +++ b/Source/cmTimestamp.cxx @@ -128,8 +128,8 @@ std::string cmTimestamp::CreateTimestampFromTimeT(time_t timeT, : static_cast<char>(0); if (c1 == '%' && c2 != 0) { - result += - this->AddTimestampComponent(c2, timeStruct, timeT, microseconds); + result += this->AddTimestampComponent(c2, timeStruct, timeT, utcFlag, + microseconds); ++i; } else { result += c1; @@ -179,7 +179,7 @@ time_t cmTimestamp::CreateUtcTimeTFromTm(struct tm& tm) const } std::string cmTimestamp::AddTimestampComponent( - char flag, struct tm& timeStruct, const time_t timeT, + char flag, struct tm& timeStruct, const time_t timeT, const bool utcFlag, const uint32_t microseconds) const { std::string formatString = cmStrCat('%', flag); @@ -203,6 +203,63 @@ std::string cmTimestamp::AddTimestampComponent( case 'Y': case '%': break; + case 'Z': +#if defined(__GLIBC__) + // 'struct tm' has the time zone, so strftime can honor UTC. + static_cast<void>(utcFlag); +#else + // 'struct tm' may not have the time zone, so strftime may + // use local time. Hard-code the UTC result. + if (utcFlag) { + return std::string("GMT"); + } +#endif + break; + case 'z': { +#if defined(__GLIBC__) + // 'struct tm' has the time zone, so strftime can honor UTC. + static_cast<void>(utcFlag); +#else + // 'struct tm' may not have the time zone, so strftime may + // use local time. Hard-code the UTC result. + if (utcFlag) { + return std::string("+0000"); + } +#endif +#ifndef _AIX + break; +#else + std::string xpg_sus_old; + bool const xpg_sus_was_set = + cmSystemTools::GetEnv("XPG_SUS_ENV", xpg_sus_old); + if (xpg_sus_was_set && xpg_sus_old == "ON") { + break; + } + xpg_sus_old = "XPG_SUS_ENV=" + xpg_sus_old; + + // On AIX systems, %z requires XPG_SUS_ENV=ON to work as desired. + cmSystemTools::PutEnv("XPG_SUS_ENV=ON"); + tzset(); + + char buffer[16]; + size_t size = strftime(buffer, sizeof(buffer), "%z", &timeStruct); + +# ifndef CMAKE_BOOTSTRAP + if (xpg_sus_was_set) { + cmSystemTools::PutEnv(xpg_sus_old); + } else { + cmSystemTools::UnsetEnv("XPG_SUS_ENV"); + } +# else + // No UnsetEnv during bootstrap. This is good enough for CMake itself. + cmSystemTools::PutEnv(xpg_sus_old); + static_cast<void>(xpg_sus_was_set); +# endif + tzset(); + + return std::string(buffer, size); +#endif + } case 's': // Seconds since UNIX epoch (midnight 1-jan-1970) { // Build a time_t for UNIX epoch and subtract from the input "timeT": diff --git a/Source/cmTimestamp.h b/Source/cmTimestamp.h index ada5006..05c6342 100644 --- a/Source/cmTimestamp.h +++ b/Source/cmTimestamp.h @@ -32,6 +32,6 @@ private: time_t CreateUtcTimeTFromTm(struct tm& timeStruct) const; std::string AddTimestampComponent(char flag, struct tm& timeStruct, - time_t timeT, - uint32_t microseconds = 0) const; + time_t timeT, bool utcFlag, + uint32_t microseconds) const; }; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 013a87b..36c0089 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -196,7 +196,7 @@ cmake::cmake(Role role, cmState::Mode mode, cmState::ProjectKind projectKind) this->AddProjectCommands(); } - if (mode == cmState::Project) { + if (mode == cmState::Project || mode == cmState::Help) { this->LoadEnvironmentPresets(); } @@ -1542,6 +1542,16 @@ void cmake::PrintTraceFormatVersion() } } +void cmake::SetTraceRedirect(cmake* other) +{ + this->Trace = other->Trace; + this->TraceExpand = other->TraceExpand; + this->TraceFormatVar = other->TraceFormatVar; + this->TraceOnlyThisSources = other->TraceOnlyThisSources; + + this->TraceRedirect = other; +} + bool cmake::SetDirectoriesFromFile(const std::string& arg) { // Check if the argument refers to a CMakeCache.txt or @@ -2060,6 +2070,10 @@ int cmake::HandleDeleteCacheVariables(const std::string& var) int cmake::Configure() { +#if !defined(CMAKE_BOOTSTRAP) + auto profilingRAII = this->CreateProfilingEntry("project", "configure"); +#endif + DiagLevel diagLevel; if (this->DiagLevels.count("deprecated") == 1) { @@ -2572,6 +2586,11 @@ int cmake::Generate() if (!this->GlobalGenerator) { return -1; } + +#if !defined(CMAKE_BOOTSTRAP) + auto profilingRAII = this->CreateProfilingEntry("project", "generate"); +#endif + if (!this->GlobalGenerator->Compute()) { return -1; } diff --git a/Source/cmake.h b/Source/cmake.h index 3183577..2f7f7bd 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -33,6 +33,7 @@ # include <cm3p/json/value.h> # include "cmCMakePresetsGraph.h" +# include "cmMakefileProfilingData.h" #endif class cmExternalMakefileProjectGeneratorFactory; @@ -41,9 +42,6 @@ class cmFileTimeCache; class cmGlobalGenerator; class cmGlobalGeneratorFactory; class cmMakefile; -#if !defined(CMAKE_BOOTSTRAP) -class cmMakefileProfilingData; -#endif class cmMessenger; class cmVariableWatch; struct cmBuildOptions; @@ -513,10 +511,19 @@ public: { return this->TraceOnlyThisSources; } - cmGeneratedFileStream& GetTraceFile() { return this->TraceFile; } + cmGeneratedFileStream& GetTraceFile() + { + if (this->TraceRedirect) { + return this->TraceRedirect->GetTraceFile(); + } + return this->TraceFile; + } void SetTraceFile(std::string const& file); void PrintTraceFormatVersion(); + //! Use trace from another ::cmake instance. + void SetTraceRedirect(cmake* other); + bool GetWarnUninitialized() const { return this->WarnUninitialized; } void SetWarnUninitialized(bool b) { this->WarnUninitialized = b; } bool GetWarnUnusedCli() const { return this->WarnUnusedCli; } @@ -630,6 +637,17 @@ public: #if !defined(CMAKE_BOOTSTRAP) cmMakefileProfilingData& GetProfilingOutput(); bool IsProfilingEnabled() const; + + template <typename... Args> + cm::optional<cmMakefileProfilingData::RAII> CreateProfilingEntry( + Args&&... args) + { + if (this->IsProfilingEnabled()) { + return cm::make_optional<cmMakefileProfilingData::RAII>( + this->GetProfilingOutput(), std::forward<Args>(args)...); + } + return cm::nullopt; + } #endif protected: @@ -688,6 +706,7 @@ private: bool TraceExpand = false; TraceFormat TraceFormatVar = TRACE_HUMAN; cmGeneratedFileStream TraceFile; + cmake* TraceRedirect = nullptr; bool WarnUninitialized = false; bool WarnUnusedCli = true; bool CheckSystemVars = false; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 723932e..43bebc1 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -208,7 +208,7 @@ int do_cmake(int ac, char const* const* av) doc.addCMakeStandardDocSections(); if (doc.CheckOptions(ac, av, "--")) { // Construct and print requested documentation. - cmake hcm(cmake::RoleInternal, cmState::Unknown); + cmake hcm(cmake::RoleInternal, cmState::Help); hcm.SetHomeDirectory(""); hcm.SetHomeOutputDirectory(""); hcm.AddCMakePaths(); |