diff options
-rw-r--r-- | Modules/CMakeDetermineCompilerId.cmake | 3 | ||||
-rw-r--r-- | Modules/FindBoost.cmake | 2 | ||||
-rw-r--r-- | Modules/FindDoxygen.cmake | 5 | ||||
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/CPack/cmCPackGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/CTest/cmCTestMultiProcessHandler.cxx | 49 | ||||
-rw-r--r-- | Source/CTest/cmCTestMultiProcessHandler.h | 5 | ||||
-rw-r--r-- | Source/CTest/cmCTestRunTest.cxx | 5 | ||||
-rw-r--r-- | Source/CTest/cmCTestRunTest.h | 3 | ||||
-rw-r--r-- | Source/QtDialog/QCMake.cxx | 4 | ||||
-rw-r--r-- | Source/cmCommandArgumentParserHelper.cxx | 7 | ||||
-rw-r--r-- | Source/cmExtraEclipseCDT4Generator.cxx | 6 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 14 | ||||
-rw-r--r-- | Source/cmLocalNinjaGenerator.cxx | 7 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 4 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 30 | ||||
-rw-r--r-- | Source/cmServerProtocol.cxx | 8 | ||||
-rw-r--r-- | Source/cmState.cxx | 6 | ||||
-rw-r--r-- | Source/cmState.h | 2 | ||||
-rw-r--r-- | Source/cmake.cxx | 54 | ||||
-rw-r--r-- | Tests/RunCMake/Ninja/RunCMakeTest.cmake | 9 |
21 files changed, 126 insertions, 103 deletions
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index dc4d9be..5e2df26a 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -525,6 +525,9 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) ${CMAKE_${lang}_COMPILER_ID_STRINGS_PARAMETERS} REGEX "INFO:[A-Za-z0-9_]+\\[[^]]*\\]") set(COMPILER_ID_TWICE) + # With the IAR Compiler, some strings are found twice, first time as incomplete + # list like "?<Constant "INFO:compiler[IAR]">". Remove the incomplete copies. + list(FILTER CMAKE_${lang}_COMPILER_ID_STRINGS EXCLUDE REGEX "\\?<Constant \\\"") # In C# binaries, some strings are found more than once. list(REMOVE_DUPLICATES CMAKE_${lang}_COMPILER_ID_STRINGS) foreach(info ${CMAKE_${lang}_COMPILER_ID_STRINGS}) diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 24ee1f2..37539ba 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -573,7 +573,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) endif() set(_Boost_IMPORTED_TARGETS TRUE) - if(Boost_VERSION VERSION_LESS 103300) + if(Boost_VERSION AND Boost_VERSION VERSION_LESS 103300) message(WARNING "Imported targets and dependency information not available for Boost version ${Boost_VERSION} (all versions older than 1.33)") set(_Boost_IMPORTED_TARGETS FALSE) elseif(NOT Boost_VERSION VERSION_LESS 103300 AND Boost_VERSION VERSION_LESS 103500) diff --git a/Modules/FindDoxygen.cmake b/Modules/FindDoxygen.cmake index 945ee0e..2ed9449 100644 --- a/Modules/FindDoxygen.cmake +++ b/Modules/FindDoxygen.cmake @@ -370,6 +370,9 @@ Deprecated Hint Variables #]=======================================================================] +cmake_policy(PUSH) +cmake_policy(SET CMP0057 NEW) # if IN_LIST + # For backwards compatibility support if(Doxygen_FIND_QUIETLY) set(DOXYGEN_FIND_QUIETLY TRUE) @@ -1108,3 +1111,5 @@ doxygen_add_docs() for target ${targetName}") ) endfunction() + +cmake_policy(POP) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 1e9f499..bd8ad4d 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 12) -set(CMake_VERSION_PATCH 20180911) +set(CMake_VERSION_PATCH 20180914) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 6347eed..acd6650 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -360,8 +360,6 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( return 0; } files = gl.GetFiles(); - std::vector<std::string>::iterator gfit; - std::vector<cmsys::RegularExpression>::iterator regIt; for (std::string const& gf : files) { bool skip = false; std::string inFile = gf; @@ -1499,7 +1497,6 @@ cmCPackComponent* cmCPackGenerator::GetComponent( if (installTypes && *installTypes) { std::vector<std::string> installTypesVector; cmSystemTools::ExpandListArgument(installTypes, installTypesVector); - std::vector<std::string>::iterator installTypesIt; for (std::string const& installType : installTypesVector) { component->InstallationTypes.push_back( this->GetInstallationType(projectName, installType)); @@ -1511,7 +1508,6 @@ cmCPackComponent* cmCPackGenerator::GetComponent( if (depends && *depends) { std::vector<std::string> dependsVector; cmSystemTools::ExpandListArgument(depends, dependsVector); - std::vector<std::string>::iterator dependIt; for (std::string const& depend : dependsVector) { cmCPackComponent* child = GetComponent(projectName, depend); component->Dependencies.push_back(child); diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 54b4be2..3e0c1ac 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -56,7 +56,6 @@ cmCTestMultiProcessHandler::cmCTestMultiProcessHandler() this->RunningCount = 0; this->ProcessorsAvailable = cmAffinity::GetProcessorsAvailable(); this->HaveAffinity = this->ProcessorsAvailable.size(); - this->StopTimePassed = false; this->HasCycles = false; this->SerialTestRunning = false; } @@ -130,17 +129,6 @@ void cmCTestMultiProcessHandler::RunTests() bool cmCTestMultiProcessHandler::StartTestProcess(int test) { - std::chrono::system_clock::time_point stop_time = this->CTest->GetStopTime(); - if (stop_time != std::chrono::system_clock::time_point() && - stop_time <= std::chrono::system_clock::now()) { - cmCTestLog(this->CTest, ERROR_MESSAGE, - "The stop time has been passed. " - "Stopping all tests." - << std::endl); - this->StopTimePassed = true; - return false; - } - if (this->HaveAffinity && this->Properties[test]->WantAffinity) { size_t needProcessors = this->GetProcessorsUsed(test); if (needProcessors > this->ProcessorsAvailable.size()) { @@ -199,6 +187,30 @@ bool cmCTestMultiProcessHandler::StartTestProcess(int test) return false; } +bool cmCTestMultiProcessHandler::CheckStopTimePassed() +{ + if (!this->StopTimePassed) { + std::chrono::system_clock::time_point stop_time = + this->CTest->GetStopTime(); + if (stop_time != std::chrono::system_clock::time_point() && + stop_time <= std::chrono::system_clock::now()) { + this->SetStopTimePassed(); + } + } + return this->StopTimePassed; +} + +void cmCTestMultiProcessHandler::SetStopTimePassed() +{ + if (!this->StopTimePassed) { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "The stop time has been passed. " + "Stopping all tests." + << std::endl); + this->StopTimePassed = true; + } +} + void cmCTestMultiProcessHandler::LockResources(int index) { this->LockedResources.insert( @@ -279,6 +291,10 @@ void cmCTestMultiProcessHandler::StartNextTests() return; } + if (this->CheckStopTimePassed()) { + return; + } + size_t numToStart = 0; if (this->RunningCount < this->ParallelLevel) { @@ -358,10 +374,6 @@ void cmCTestMultiProcessHandler::StartNextTests() } if (testLoadOk && processors <= numToStart && this->StartTest(test)) { - if (this->StopTimePassed) { - return; - } - numToStart -= processors; } else if (numToStart == 0) { break; @@ -424,8 +436,11 @@ void cmCTestMultiProcessHandler::FinishTestProcess(cmCTestRunTest* runner, auto properties = runner->GetTestProperties(); bool testResult = runner->EndTest(this->Completed, this->Total, started); + if (runner->TimedOutForStopTime()) { + this->SetStopTimePassed(); + } if (started) { - if (runner->StartAgain()) { + if (!this->StopTimePassed && runner->StartAgain()) { this->Completed--; // remove the completed test because run again return; } diff --git a/Source/CTest/cmCTestMultiProcessHandler.h b/Source/CTest/cmCTestMultiProcessHandler.h index 07a5fe7..3927a8a 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.h +++ b/Source/CTest/cmCTestMultiProcessHandler.h @@ -113,6 +113,9 @@ protected: inline size_t GetProcessorsUsed(int index); std::string GetName(int index); + bool CheckStopTimePassed(); + void SetStopTimePassed(); + void LockResources(int index); void UnlockResources(int index); // map from test number to set of depend tests @@ -125,7 +128,7 @@ protected: size_t RunningCount; std::set<size_t> ProcessorsAvailable; size_t HaveAffinity; - bool StopTimePassed; + bool StopTimePassed = false; // list of test properties (indices concurrent to the test map) PropertiesMap Properties; std::map<int, bool> TestRunningMap; diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index ef0a49d..23d4616 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -140,6 +140,9 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) bool passed = true; cmProcess::State res = started ? this->TestProcess->GetProcessStatus() : cmProcess::State::Error; + if (res != cmProcess::State::Expired) { + this->TimeoutIsForStopTime = false; + } int retVal = this->TestProcess->GetExitValue(); bool forceFail = false; bool skipped = false; @@ -537,6 +540,7 @@ bool cmCTestRunTest::StartTest(size_t total) auto timeout = this->TestProperties->Timeout; + this->TimeoutIsForStopTime = false; std::chrono::system_clock::time_point stop_time = this->CTest->GetStopTime(); if (stop_time != std::chrono::system_clock::time_point()) { std::chrono::duration<double> stop_timeout = @@ -547,6 +551,7 @@ bool cmCTestRunTest::StartTest(size_t total) } if (timeout == std::chrono::duration<double>::zero() || stop_timeout < timeout) { + this->TimeoutIsForStopTime = true; timeout = stop_timeout; } } diff --git a/Source/CTest/cmCTestRunTest.h b/Source/CTest/cmCTestRunTest.h index 3b1d674..7e80157 100644 --- a/Source/CTest/cmCTestRunTest.h +++ b/Source/CTest/cmCTestRunTest.h @@ -80,6 +80,8 @@ public: void FinalizeTest(); + bool TimedOutForStopTime() const { return this->TimeoutIsForStopTime; } + private: bool NeedsToRerun(); void DartProcessing(); @@ -92,6 +94,7 @@ private: void MemCheckPostProcess(); cmCTestTestHandler::cmCTestTestProperties* TestProperties; + bool TimeoutIsForStopTime = false; // Pointer back to the "parent"; the handler that invoked this test run cmCTestTestHandler* TestHandler; cmCTest* CTest; diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index 0e14a3f..0133b88 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -94,11 +94,11 @@ void QCMake::setBinaryDirectory(const QString& _dir) } const char* gen = state->GetCacheEntryValue("CMAKE_GENERATOR"); if (gen) { - const char* extraGen = + const std::string* extraGen = state->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR"); std::string curGen = cmExternalMakefileProjectGenerator::CreateFullGeneratorName( - gen, extraGen ? extraGen : ""); + gen, extraGen ? *extraGen : ""); this->setGenerator(QString::fromLocal8Bit(curGen.c_str())); } diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index c7210b4..2b4ceaa 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -68,12 +68,12 @@ const char* cmCommandArgumentParserHelper::ExpandSpecialVariable( return ""; } if (strcmp(key, "CACHE") == 0) { - if (const char* c = + if (const std::string* c = this->Makefile->GetState()->GetInitializedCacheValue(var)) { if (this->EscapeQuotes) { - return this->AddString(cmSystemTools::EscapeQuotes(c)); + return this->AddString(cmSystemTools::EscapeQuotes(*c)); } - return this->AddString(c); + return this->AddString(*c); } return ""; } @@ -253,7 +253,6 @@ int cmCommandArgumentParserHelper::ParseString(const char* str, int verb) void cmCommandArgumentParserHelper::CleanupParser() { - std::vector<char*>::iterator sit; for (char* var : this->Variables) { delete[] var; } diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 313d46b..34f58ad 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -215,7 +215,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(std::ostream& out, std::string cacheEntryName = "CMAKE_ECLIPSE_ENVVAR_"; cacheEntryName += envVar; - const char* cacheValue = + const std::string* cacheValue = lg->GetState()->GetInitializedCacheValue(cacheEntryName); // now we have both, decide which one to use @@ -232,14 +232,14 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(std::ostream& out, mf->GetCMakeInstance()->SaveCache(lg->GetBinaryDirectory()); } else if (!envVarSet && cacheValue != nullptr) { // It is already in the cache, but not in the env, so use it from the cache - valueToUse = cacheValue; + valueToUse = *cacheValue; } else { // It is both in the cache and in the env. // Use the version from the env. except if the value from the env is // completely contained in the value from the cache (for the case that we // now have a PATH without MSVC dirs in the env. but had the full PATH with // all MSVC dirs during the cmake run which stored the var in the cache: - valueToUse = cacheValue; + valueToUse = *cacheValue; if (valueToUse.find(envVarValue) == std::string::npos) { valueToUse = envVarValue; mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(), diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index b5212fc..99135c8 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -215,15 +215,15 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string& lang, if (!optional && (path.empty() || !cmSystemTools::FileExists(path))) { return; } - const char* cname = + const std::string* cname = this->GetCMakeInstance()->GetState()->GetInitializedCacheValue(langComp); std::string changeVars; if (cname && !optional) { std::string cnameString; - if (!cmSystemTools::FileIsFullPath(cname)) { - cnameString = cmSystemTools::FindProgram(cname); + if (!cmSystemTools::FileIsFullPath(*cname)) { + cnameString = cmSystemTools::FindProgram(*cname); } else { - cnameString = cname; + cnameString = *cname; } std::string pathString = path; // get rid of potentially multiple slashes: @@ -239,7 +239,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string& lang, } changeVars += langComp; changeVars += ";"; - changeVars += cname; + changeVars += *cname; this->GetCMakeInstance()->GetState()->SetGlobalProperty( "__CMAKE_DELETE_CACHE_CHANGE_VARS_", changeVars.c_str()); } @@ -1970,7 +1970,7 @@ void cmGlobalGenerator::AddMakefile(cmMakefile* mf) // update progress // estimate how many lg there will be - const char* numGenC = + const std::string* numGenC = this->CMakeInstance->GetState()->GetInitializedCacheValue( "CMAKE_NUMBER_OF_MAKEFILES"); @@ -1988,7 +1988,7 @@ void cmGlobalGenerator::AddMakefile(cmMakefile* mf) return; } - int numGen = atoi(numGenC); + int numGen = atoi(numGenC->c_str()); float prog = 0.9f * static_cast<float>(this->Makefiles.size()) / static_cast<float>(numGen); if (prog > 0.9f) { diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 360f73d..eb31478 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -564,8 +564,7 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher( return std::string(); } - // Expand rules in the empty string. It may insert the launcher and - // perform replacements. + // Expand rule variables referenced in the given launcher command. cmRulePlaceholderExpander::RuleVariables vars; std::string output; @@ -580,12 +579,10 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher( } vars.Output = output.c_str(); - std::string launcher = property_value; - launcher += " "; - std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander( this->CreateRulePlaceholderExpander()); + std::string launcher = property_value; rulePlaceholderExpander->ExpandRuleVariables(this, launcher, vars); if (!launcher.empty()) { launcher += " "; diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index bc83ce2..690b827 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -967,8 +967,7 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand( // Short-circuit if there is no launcher. const char* val = this->GetRuleLauncher(target, "RULE_LAUNCH_CUSTOM"); if (val && *val) { - // Expand rules in the empty string. It may insert the launcher and - // perform replacements. + // Expand rule variables referenced in the given launcher command. cmRulePlaceholderExpander::RuleVariables vars; vars.CMTargetName = target->GetName().c_str(); vars.CMTargetType = cmState::GetTargetTypeName(target->GetType()); @@ -986,7 +985,6 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand( vars.Output = output.c_str(); launcher = val; - launcher += " "; rulePlaceholderExpander->ExpandRuleVariables(this, launcher, vars); if (!launcher.empty()) { launcher += " "; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 5498ad2..dce7bd0 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1718,7 +1718,8 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, cmStateEnums::CacheEntryType type, bool force) { - const char* existingValue = this->GetState()->GetInitializedCacheValue(name); + const std::string* existingValue = + this->GetState()->GetInitializedCacheValue(name); // must be outside the following if() to keep it alive long enough std::string nvalue; @@ -1728,7 +1729,7 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, // if this is not a force, then use the value from the cache // if it is a force, then use the value being passed in if (!force) { - value = existingValue; + value = existingValue->c_str(); } if (type == cmStateEnums::PATH || type == cmStateEnums::FILEPATH) { std::vector<std::string>::size_type cc; @@ -1748,7 +1749,7 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, } this->GetCMakeInstance()->AddCacheEntry(name, nvalue.c_str(), doc, type); - nvalue = this->GetState()->GetInitializedCacheValue(name); + nvalue = *this->GetState()->GetInitializedCacheValue(name); value = nvalue.c_str(); } } @@ -2368,17 +2369,15 @@ std::string cmMakefile::GetRequiredDefinition(const std::string& name) const bool cmMakefile::IsDefinitionSet(const std::string& name) const { - const char* def; - if (const std::string* d = this->StateSnapshot.GetDefinition(name)) { - def = d->c_str(); - } else { + const std::string* def = this->StateSnapshot.GetDefinition(name); + if (!def) { def = this->GetState()->GetInitializedCacheValue(name); } #ifdef CMAKE_BUILD_WITH_CMAKE if (cmVariableWatch* vv = this->GetVariableWatch()) { if (!def) { vv->VariableAccessed( - name, cmVariableWatch::UNKNOWN_VARIABLE_DEFINED_ACCESS, def, this); + name, cmVariableWatch::UNKNOWN_VARIABLE_DEFINED_ACCESS, nullptr, this); } } #endif @@ -2387,10 +2386,8 @@ bool cmMakefile::IsDefinitionSet(const std::string& name) const const char* cmMakefile::GetDefinition(const std::string& name) const { - const char* def; - if (const std::string* d = this->StateSnapshot.GetDefinition(name)) { - def = d->c_str(); - } else { + const std::string* def = this->StateSnapshot.GetDefinition(name); + if (!def) { def = this->GetState()->GetInitializedCacheValue(name); } #ifdef CMAKE_BUILD_WITH_CMAKE @@ -2400,21 +2397,20 @@ const char* cmMakefile::GetDefinition(const std::string& name) const vv->VariableAccessed(name, def ? cmVariableWatch::VARIABLE_READ_ACCESS : cmVariableWatch::UNKNOWN_VARIABLE_READ_ACCESS, - def, this); + (def ? def->c_str() : nullptr), this); if (watch_function_executed) { // A callback was executed and may have caused re-allocation of the // variable storage. Look it up again for now. // FIXME: Refactor variable storage to avoid this problem. - if (const std::string* d = this->StateSnapshot.GetDefinition(name)) { - def = d->c_str(); - } else { + def = this->StateSnapshot.GetDefinition(name); + if (!def) { def = this->GetState()->GetInitializedCacheValue(name); } } } #endif - return def; + return (def ? def->c_str() : nullptr); } const char* cmMakefile::GetSafeDefinition(const std::string& def) const diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index 231cacb..2cad657 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -1339,20 +1339,20 @@ cmServerResponse cmServerProtocol1::ProcessConfigure( if (cm->LoadCache(buildDir)) { // build directory has been set up before - const char* cachedSourceDir = + const std::string* cachedSourceDir = cm->GetState()->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY"); if (!cachedSourceDir) { return request.ReportError("No CMAKE_HOME_DIRECTORY found in cache."); } if (sourceDir.empty()) { - sourceDir = std::string(cachedSourceDir); + sourceDir = *cachedSourceDir; cm->SetHomeDirectory(sourceDir); } - const char* cachedGenerator = + const std::string* cachedGenerator = cm->GetState()->GetInitializedCacheValue("CMAKE_GENERATOR"); if (cachedGenerator) { - if (gg && gg->GetName() != cachedGenerator) { + if (gg && gg->GetName() != *cachedGenerator) { return request.ReportError("Configured generator does not match with " "CMAKE_GENERATOR found in cache."); } diff --git a/Source/cmState.cxx b/Source/cmState.cxx index e01bf71..c8b8653 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -140,10 +140,10 @@ const char* cmState::GetCacheEntryValue(std::string const& key) const return e->Value.c_str(); } -const char* cmState::GetInitializedCacheValue(std::string const& key) const +const std::string* cmState::GetInitializedCacheValue( + std::string const& key) const { - const std::string* p = this->CacheManager->GetInitializedCacheValue(key); - return p ? p->c_str() : nullptr; + return this->CacheManager->GetInitializedCacheValue(key); } cmStateEnums::CacheEntryType cmState::GetCacheEntryType( diff --git a/Source/cmState.h b/Source/cmState.h index 38bdfec..ca7093a 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -68,7 +68,7 @@ public: std::vector<std::string> GetCacheEntryKeys() const; const char* GetCacheEntryValue(std::string const& key) const; - const char* GetInitializedCacheValue(std::string const& key) const; + const std::string* GetInitializedCacheValue(std::string const& key) const; cmStateEnums::CacheEntryType GetCacheEntryType(std::string const& key) const; void SetCacheEntryValue(std::string const& key, std::string const& value); void SetCacheValue(std::string const& key, std::string const& value); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 1bf8f7d..783dbf2 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -319,9 +319,10 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) bool haveValue = false; std::string cachedValue; if (this->WarnUnusedCli) { - if (const char* v = this->State->GetInitializedCacheValue(var)) { + if (const std::string* v = + this->State->GetInitializedCacheValue(var)) { haveValue = true; - cachedValue = v; + cachedValue = *v; } } @@ -331,7 +332,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) if (this->WarnUnusedCli) { if (!haveValue || - cachedValue != this->State->GetInitializedCacheValue(var)) { + cachedValue != *this->State->GetInitializedCacheValue(var)) { this->WatchUnusedCli(var); } } @@ -1107,7 +1108,7 @@ int cmake::DoPreConfigureChecks() // do a sanity check on some values if (this->State->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY")) { std::string cacheStart = - this->State->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY"); + *this->State->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY"); cacheStart += "/CMakeLists.txt"; std::string currentStart = this->GetHomeDirectory(); currentStart += "/CMakeLists.txt"; @@ -1276,14 +1277,14 @@ int cmake::ActualConfigure() // no generator specified on the command line if (!this->GlobalGenerator) { - const char* genName = + const std::string* genName = this->State->GetInitializedCacheValue("CMAKE_GENERATOR"); - const char* extraGenName = + const std::string* extraGenName = this->State->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR"); if (genName) { std::string fullName = cmExternalMakefileProjectGenerator::CreateFullGeneratorName( - genName, extraGenName ? extraGenName : ""); + *genName, extraGenName ? *extraGenName : ""); this->GlobalGenerator = this->CreateGlobalGenerator(fullName); } if (this->GlobalGenerator) { @@ -1301,14 +1302,14 @@ int cmake::ActualConfigure() } } - const char* genName = + const std::string* genName = this->State->GetInitializedCacheValue("CMAKE_GENERATOR"); if (genName) { - if (!this->GlobalGenerator->MatchesGeneratorName(genName)) { + if (!this->GlobalGenerator->MatchesGeneratorName(*genName)) { std::string message = "Error: generator : "; message += this->GlobalGenerator->GetName(); message += "\nDoes not match the generator used previously: "; - message += genName; + message += *genName; message += "\nEither remove the CMakeCache.txt file and CMakeFiles " "directory or choose a different binary directory."; cmSystemTools::Error(message.c_str()); @@ -1325,14 +1326,14 @@ int cmake::ActualConfigure() cmStateEnums::INTERNAL); } - if (const char* instance = + if (const std::string* instance = this->State->GetInitializedCacheValue("CMAKE_GENERATOR_INSTANCE")) { if (!this->GeneratorInstance.empty() && - this->GeneratorInstance != instance) { + this->GeneratorInstance != *instance) { std::string message = "Error: generator instance: "; message += this->GeneratorInstance; message += "\nDoes not match the instance used previously: "; - message += instance; + message += *instance; message += "\nEither remove the CMakeCache.txt file and CMakeFiles " "directory or choose a different binary directory."; cmSystemTools::Error(message.c_str()); @@ -1344,14 +1345,14 @@ int cmake::ActualConfigure() "Generator instance identifier.", cmStateEnums::INTERNAL); } - if (const char* platformName = + if (const std::string* platformName = this->State->GetInitializedCacheValue("CMAKE_GENERATOR_PLATFORM")) { if (!this->GeneratorPlatform.empty() && - this->GeneratorPlatform != platformName) { + this->GeneratorPlatform != *platformName) { std::string message = "Error: generator platform: "; message += this->GeneratorPlatform; message += "\nDoes not match the platform used previously: "; - message += platformName; + message += *platformName; message += "\nEither remove the CMakeCache.txt file and CMakeFiles " "directory or choose a different binary directory."; cmSystemTools::Error(message.c_str()); @@ -1363,13 +1364,13 @@ int cmake::ActualConfigure() "Name of generator platform.", cmStateEnums::INTERNAL); } - if (const char* tsName = + if (const std::string* tsName = this->State->GetInitializedCacheValue("CMAKE_GENERATOR_TOOLSET")) { - if (!this->GeneratorToolset.empty() && this->GeneratorToolset != tsName) { + if (!this->GeneratorToolset.empty() && this->GeneratorToolset != *tsName) { std::string message = "Error: generator toolset: "; message += this->GeneratorToolset; message += "\nDoes not match the toolset used previously: "; - message += tsName; + message += *tsName; message += "\nEither remove the CMakeCache.txt file and CMakeFiles " "directory or choose a different binary directory."; cmSystemTools::Error(message.c_str()); @@ -1685,7 +1686,8 @@ std::string cmake::StripExtension(const std::string& file) const const char* cmake::GetCacheDefinition(const std::string& name) const { - return this->State->GetInitializedCacheValue(name); + const std::string* p = this->State->GetInitializedCacheValue(name); + return p ? p->c_str() : nullptr; } void cmake::AddScriptingCommands() @@ -1868,14 +1870,14 @@ void cmake::PrintGeneratorList() void cmake::UpdateConversionPathTable() { // Update the path conversion table with any specified file: - const char* tablepath = + const std::string* tablepath = this->State->GetInitializedCacheValue("CMAKE_PATH_TRANSLATION_FILE"); if (tablepath) { - cmsys::ifstream table(tablepath); + cmsys::ifstream table(tablepath->c_str()); if (!table) { - cmSystemTools::Error("CMAKE_PATH_TRANSLATION_FILE set to ", tablepath, - ". CMake can not open file."); + cmSystemTools::Error("CMAKE_PATH_TRANSLATION_FILE set to ", + tablepath->c_str(), ". CMake can not open file."); cmSystemTools::ReportLastSystemError("CMake can not open file."); } else { std::string a, b; @@ -2527,11 +2529,11 @@ bool cmake::Open(const std::string& dir, bool dryRun) std::cerr << "Error: could not find CMAKE_GENERATOR in Cache\n"; return false; } - const char* extraGenName = + const std::string* extraGenName = this->State->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR"); std::string fullName = cmExternalMakefileProjectGenerator::CreateFullGeneratorName( - genName, extraGenName ? extraGenName : ""); + genName, extraGenName ? *extraGenName : ""); std::unique_ptr<cmGlobalGenerator> gen( this->CreateGlobalGenerator(fullName)); diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake index e0ddc9c..4b366a8 100644 --- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -205,15 +205,16 @@ function(run_sub_cmake test ninja_output_path_prefix) set(cmd_prefix "") set(cmd_suffix "") endif() + set(fs_delay 3) # We assume the system as 1 sec timestamp resolution. file(WRITE "${top_build_ninja}" "\ subninja ${escaped_ninja_output_path_prefix}/build.ninja default ${escaped_ninja_output_path_prefix}/all -# Sleep for 1 second before to regenerate to make sure the timestamp of +# Sleep for long enough before regenerating to make sure the timestamp of # the top build.ninja will be strictly greater than the timestamp of the -# sub/build.ninja file. We assume the system as 1 sec timestamp resolution. +# sub/build.ninja file. rule RERUN - command = ${cmd_prefix}\"${escaped_CMAKE_COMMAND}\" -E sleep 1 && \"${escaped_CMAKE_COMMAND}\" -E touch \"${escaped_top_build_ninja}\"${cmd_suffix} + command = ${cmd_prefix}\"${escaped_CMAKE_COMMAND}\" -E sleep ${fs_delay} && \"${escaped_CMAKE_COMMAND}\" -E touch \"${escaped_top_build_ninja}\"${cmd_suffix} description = Testing regeneration generator = 1 @@ -239,7 +240,7 @@ build build.ninja: RERUN ${escaped_build_ninja_dep} || ${escaped_ninja_output_pa # Test regeneration rules run in order. set(main_cmakelists "${RunCMake_SOURCE_DIR}/CMakeLists.txt") - sleep(1) # Assume the system as 1 sec timestamp resolution. + sleep(${fs_delay}) touch("${main_cmakelists}") touch("${build_ninja_dep}") run_ninja("${top_build_dir}") |