From 11425041f04fd0945480b8f9e9933d1549b93981 Mon Sep 17 00:00:00 2001 From: Vitaly Stakhovsky Date: Sat, 1 Aug 2020 15:00:00 -0400 Subject: cmMakefile::GetDefinition: return cmProp --- Source/CPack/cmCPackGenerator.cxx | 31 ++--- Source/CPack/cpack.cxx | 31 ++--- Source/CTest/cmCTestBuildCommand.cxx | 55 ++++----- Source/CTest/cmCTestBuildHandler.cxx | 10 +- Source/CTest/cmCTestConfigureCommand.cxx | 18 +-- Source/CTest/cmCTestHandlerCommand.cxx | 5 +- Source/CTest/cmCTestScriptHandler.cxx | 17 +-- Source/CTest/cmCTestStartCommand.cxx | 29 ++--- Source/CTest/cmCTestSubmitCommand.cxx | 11 +- Source/CTest/cmCTestTestCommand.cxx | 17 ++- Source/CTest/cmCTestTestHandler.cxx | 5 +- Source/CTest/cmCTestUpdateCommand.cxx | 3 +- Source/cmAuxSourceDirectoryCommand.cxx | 5 +- Source/cmBuildCommand.cxx | 3 +- Source/cmBuildNameCommand.cxx | 7 +- Source/cmCPluginAPI.cxx | 2 +- Source/cmCTest.cxx | 10 +- Source/cmCommandArgumentParserHelper.cxx | 6 +- Source/cmCommonTargetGenerator.cxx | 8 +- Source/cmComputeLinkDepends.cxx | 12 +- Source/cmComputeLinkInformation.cxx | 66 +++++------ Source/cmConditionEvaluator.cxx | 7 +- Source/cmCoreTryCompile.cxx | 61 +++++----- Source/cmDepends.cxx | 7 +- Source/cmDependsC.cxx | 9 +- Source/cmDependsFortran.cxx | 5 +- Source/cmExtraCodeBlocksGenerator.cxx | 13 ++- Source/cmExtraEclipseCDT4Generator.cxx | 12 +- Source/cmExtraKateGenerator.cxx | 5 +- Source/cmFileAPICodemodel.cxx | 16 +-- Source/cmFileCommand.cxx | 13 ++- Source/cmFileCopier.cxx | 5 +- Source/cmFindBase.cxx | 5 +- Source/cmFindCommon.cxx | 27 +++-- Source/cmFindLibraryCommand.cxx | 5 +- Source/cmFindPackageCommand.cxx | 34 +++--- Source/cmForEachCommand.cxx | 9 +- Source/cmGeneratorExpressionNode.cxx | 2 +- Source/cmGeneratorTarget.cxx | 34 +++--- Source/cmGetFilenameComponentCommand.cxx | 5 +- Source/cmGetPropertyCommand.cxx | 5 +- Source/cmGhsMultiTargetGenerator.cxx | 4 +- Source/cmGlobalGenerator.cxx | 54 +++++---- Source/cmGlobalGhsMultiGenerator.cxx | 13 ++- Source/cmGlobalNinjaGenerator.cxx | 5 +- Source/cmGlobalVisualStudio14Generator.cxx | 4 +- Source/cmGlobalVisualStudio7Generator.cxx | 4 +- Source/cmGlobalXCodeGenerator.cxx | 27 +++-- Source/cmGraphVizWriter.cxx | 9 +- Source/cmIncludeGuardCommand.cxx | 2 +- Source/cmInstallTargetGenerator.cxx | 6 +- Source/cmJsonObjects.cxx | 4 +- Source/cmListCommand.cxx | 5 +- Source/cmLocalCommonGenerator.cxx | 5 +- Source/cmLocalGenerator.cxx | 182 ++++++++++++++--------------- Source/cmLocalNinjaGenerator.cxx | 5 +- Source/cmLocalUnixMakefileGenerator3.cxx | 35 +++--- Source/cmLocalVisualStudio7Generator.cxx | 14 ++- Source/cmLocalVisualStudioGenerator.cxx | 5 +- Source/cmMakefile.cxx | 109 ++++++++--------- Source/cmMakefile.h | 3 +- Source/cmMakefileTargetGenerator.cxx | 74 ++++++------ Source/cmNinjaNormalTargetGenerator.cxx | 22 ++-- Source/cmNinjaTargetGenerator.cxx | 29 +++-- Source/cmParseArgumentsCommand.cxx | 5 +- Source/cmProjectCommand.cxx | 9 +- Source/cmProperty.h | 10 ++ Source/cmQtAutoGenInitializer.cxx | 4 +- Source/cmRemoveCommand.cxx | 5 +- Source/cmSearchPath.cxx | 15 +-- Source/cmSeparateArgumentsCommand.cxx | 5 +- Source/cmSiteNameCommand.cxx | 7 +- Source/cmStandardLevelResolver.cxx | 26 ++--- Source/cmState.cxx | 5 +- Source/cmStringCommand.cxx | 11 +- Source/cmTarget.cxx | 16 +-- Source/cmTargetLinkLibrariesCommand.cxx | 8 +- Source/cmTryRunCommand.cxx | 10 +- Source/cmUtilitySourceCommand.cxx | 12 +- Source/cmVariableRequiresCommand.cxx | 5 +- Source/cmVariableWatchCommand.cxx | 5 +- Source/cmVisualStudio10TargetGenerator.cxx | 36 +++--- Source/cmake.cxx | 3 +- 83 files changed, 745 insertions(+), 702 deletions(-) diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 3880f65..a9fe91c 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -20,6 +20,7 @@ #include "cmGeneratedFileStream.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" +#include "cmProperty.h" #include "cmState.h" #include "cmStateSnapshot.h" #include "cmStringAlgorithms.h" @@ -905,8 +906,8 @@ int cmCPackGenerator::InstallCMakeProject( // forward definition of CMAKE_ABSOLUTE_DESTINATION_FILES // to CPack (may be used by generators like CPack RPM or DEB) // in order to transparently handle ABSOLUTE PATH - if (const char* def = mf.GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES")) { - mf.AddDefinition("CPACK_ABSOLUTE_DESTINATION_FILES", def); + if (cmProp def = mf.GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES")) { + mf.AddDefinition("CPACK_ABSOLUTE_DESTINATION_FILES", *def); } // Now rebuild the list of files after installation @@ -939,11 +940,11 @@ int cmCPackGenerator::InstallCMakeProject( } } - if (auto d = mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")) { + if (cmProp d = mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")) { if (!absoluteDestFiles.empty()) { absoluteDestFiles += ";"; } - absoluteDestFiles += d; + absoluteDestFiles += *d; cmCPackLogger(cmCPackLog::LOG_DEBUG, "Got some ABSOLUTE DESTINATION FILES: " << absoluteDestFiles << std::endl); @@ -954,12 +955,13 @@ int cmCPackGenerator::InstallCMakeProject( GetComponentInstallDirNameSuffix(component); if (nullptr != this->GetOption(absoluteDestFileComponent)) { std::string absoluteDestFilesListComponent = - cmStrCat(this->GetOption(absoluteDestFileComponent), ';', d); + cmStrCat(this->GetOption(absoluteDestFileComponent), ';', *d); this->SetOption(absoluteDestFileComponent, absoluteDestFilesListComponent.c_str()); } else { - this->SetOption(absoluteDestFileComponent, - mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")); + this->SetOption( + absoluteDestFileComponent, + cmToCStr(mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"))); } } } @@ -982,7 +984,7 @@ bool cmCPackGenerator::ReadListFile(const char* moduleName) void cmCPackGenerator::SetOptionIfNotSet(const std::string& op, const char* value) { - const char* def = this->MakefileMap->GetDefinition(op); + cmProp def = this->MakefileMap->GetDefinition(op); if (cmNonempty(def)) { return; } @@ -1214,30 +1216,31 @@ bool cmCPackGenerator::IsOn(const std::string& name) const bool cmCPackGenerator::IsSetToOff(const std::string& op) const { - const char* ret = this->MakefileMap->GetDefinition(op); + cmProp ret = this->MakefileMap->GetDefinition(op); if (cmNonempty(ret)) { - return cmIsOff(ret); + return cmIsOff(*ret); } return false; } bool cmCPackGenerator::IsSetToEmpty(const std::string& op) const { - const char* ret = this->MakefileMap->GetDefinition(op); + cmProp ret = this->MakefileMap->GetDefinition(op); if (ret) { - return !*ret; + return ret->empty(); } return false; } const char* cmCPackGenerator::GetOption(const std::string& op) const { - const char* ret = this->MakefileMap->GetDefinition(op); + cmProp ret = this->MakefileMap->GetDefinition(op); if (!ret) { cmCPackLogger(cmCPackLog::LOG_DEBUG, "Warning, GetOption return NULL for: " << op << std::endl); + return nullptr; } - return ret; + return ret->c_str(); } std::vector cmCPackGenerator::GetOptions() const diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 3a400b7..6c80753 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -12,6 +12,7 @@ #include "cmDocumentationFormatter.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" +#include "cmProperty.h" #include "cmState.h" #include "cmStateSnapshot.h" #include "cmStringAlgorithms.h" @@ -324,21 +325,22 @@ int main(int argc, char const* const* argv) } // Force CPACK_PACKAGE_DIRECTORY as absolute path - cpackProjectDirectory = globalMF.GetDefinition("CPACK_PACKAGE_DIRECTORY"); + cpackProjectDirectory = + globalMF.GetSafeDefinition("CPACK_PACKAGE_DIRECTORY"); cpackProjectDirectory = cmSystemTools::CollapseFullPath(cpackProjectDirectory); globalMF.AddDefinition("CPACK_PACKAGE_DIRECTORY", cpackProjectDirectory); - const char* cpackModulesPath = globalMF.GetDefinition("CPACK_MODULE_PATH"); + cmProp cpackModulesPath = globalMF.GetDefinition("CPACK_MODULE_PATH"); if (cpackModulesPath) { - globalMF.AddDefinition("CMAKE_MODULE_PATH", cpackModulesPath); + globalMF.AddDefinition("CMAKE_MODULE_PATH", *cpackModulesPath); } - const char* genList = globalMF.GetDefinition("CPACK_GENERATOR"); + cmProp genList = globalMF.GetDefinition("CPACK_GENERATOR"); if (!genList) { cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "CPack generator not specified" << std::endl); } else { - std::vector generatorsVector = cmExpandedList(genList); + std::vector generatorsVector = cmExpandedList(*genList); for (std::string const& gen : generatorsVector) { cmMakefile::ScopePushPop raii(&globalMF); cmMakefile* mf = &globalMF; @@ -411,32 +413,31 @@ int main(int argc, char const* const* argv) parsed = 0; } if (parsed) { - const char* projName = mf->GetDefinition("CPACK_PACKAGE_NAME"); + cmProp projName = mf->GetDefinition("CPACK_PACKAGE_NAME"); cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Use generator: " << cpackGenerator->GetNameOfClass() << std::endl); cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, - "For project: " << projName << std::endl); + "For project: " << *projName << std::endl); - const char* projVersion = - mf->GetDefinition("CPACK_PACKAGE_VERSION"); + cmProp projVersion = mf->GetDefinition("CPACK_PACKAGE_VERSION"); if (!projVersion) { - const char* projVersionMajor = + cmProp projVersionMajor = mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR"); - const char* projVersionMinor = + cmProp projVersionMinor = mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR"); - const char* projVersionPatch = + cmProp projVersionPatch = mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH"); std::ostringstream ostr; - ostr << projVersionMajor << "." << projVersionMinor << "." - << projVersionPatch; + ostr << *projVersionMajor << "." << *projVersionMinor << "." + << *projVersionPatch; mf->AddDefinition("CPACK_PACKAGE_VERSION", ostr.str()); } int res = cpackGenerator->DoPackage(); if (!res) { cmCPack_Log(&log, cmCPackLog::LOG_ERROR, - "Error when generating package: " << projName + "Error when generating package: " << *projName << std::endl); return 1; } diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx index 8aab167..1cc267e 100644 --- a/Source/CTest/cmCTestBuildCommand.cxx +++ b/Source/CTest/cmCTestBuildCommand.cxx @@ -2,7 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestBuildCommand.h" -#include #include #include @@ -39,12 +38,13 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() this->Handler = handler; - cmProp ctestBuildCommand = this->Makefile->GetDef("CTEST_BUILD_COMMAND"); + cmProp ctestBuildCommand = + this->Makefile->GetDefinition("CTEST_BUILD_COMMAND"); if (cmNonempty(ctestBuildCommand)) { this->CTest->SetCTestConfiguration("MakeCommand", *ctestBuildCommand, this->Quiet); } else { - const char* cmakeGeneratorName = + cmProp cmakeGeneratorName = this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR"); // Build configuration is determined by: CONFIGURATION argument, @@ -52,49 +52,51 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() // CTEST_CONFIGURATION_TYPE script variable, or ctest -C command // line argument... in that order. // - const char* ctestBuildConfiguration = + cmProp ctestBuildConfiguration = this->Makefile->GetDefinition("CTEST_BUILD_CONFIGURATION"); - const char* cmakeBuildConfiguration = !this->Configuration.empty() - ? this->Configuration.c_str() - : (cmNonempty(ctestBuildConfiguration) - ? ctestBuildConfiguration - : this->CTest->GetConfigType().c_str()); - - const char* cmakeBuildAdditionalFlags = !this->Flags.empty() - ? this->Flags.c_str() + const std::string* cmakeBuildConfiguration = !this->Configuration.empty() + ? &this->Configuration + : (cmNonempty(ctestBuildConfiguration) ? ctestBuildConfiguration + : &this->CTest->GetConfigType()); + + const std::string* cmakeBuildAdditionalFlags = !this->Flags.empty() + ? &this->Flags : this->Makefile->GetDefinition("CTEST_BUILD_FLAGS"); - const char* cmakeBuildTarget = !this->Target.empty() - ? this->Target.c_str() + const std::string* cmakeBuildTarget = !this->Target.empty() + ? &this->Target : this->Makefile->GetDefinition("CTEST_BUILD_TARGET"); if (cmNonempty(cmakeGeneratorName)) { if (!cmakeBuildConfiguration) { - cmakeBuildConfiguration = "Release"; + static const std::string sRelease = "Release"; + cmakeBuildConfiguration = &sRelease; } if (this->GlobalGenerator) { - if (this->GlobalGenerator->GetName() != cmakeGeneratorName) { + if (this->GlobalGenerator->GetName() != *cmakeGeneratorName) { this->GlobalGenerator.reset(); } } if (!this->GlobalGenerator) { this->GlobalGenerator = this->Makefile->GetCMakeInstance()->CreateGlobalGenerator( - cmakeGeneratorName); + *cmakeGeneratorName); if (!this->GlobalGenerator) { std::string e = cmStrCat("could not create generator named \"", - cmakeGeneratorName, '"'); + *cmakeGeneratorName, '"'); this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e); cmSystemTools::SetFatalErrorOccured(); return nullptr; } } - if (strlen(cmakeBuildConfiguration) == 0) { - const char* config = nullptr; + if (cmakeBuildConfiguration->empty()) { + const std::string* config = nullptr; #ifdef CMAKE_INTDIR - config = CMAKE_INTDIR; + static const std::string sIntDir = CMAKE_INTDIR; + config = &sIntDir; #endif if (!config) { - config = "Debug"; + static const std::string sDebug = "Debug"; + config = &sDebug; } cmakeBuildConfiguration = config; } @@ -102,8 +104,8 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() std::string dir = this->CTest->GetCTestConfiguration("BuildDirectory"); std::string buildCommand = this->GlobalGenerator->GenerateCMakeBuildCommand( - cmakeBuildTarget ? cmakeBuildTarget : "", cmakeBuildConfiguration, - cmakeBuildAdditionalFlags ? cmakeBuildAdditionalFlags : "", + cmakeBuildTarget ? *cmakeBuildTarget : "", *cmakeBuildConfiguration, + cmakeBuildAdditionalFlags ? *cmakeBuildAdditionalFlags : "", this->Makefile->IgnoreErrorsCMP0061()); cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "SetMakeCommand:" << buildCommand << "\n", @@ -123,13 +125,14 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() } } - if (cmProp useLaunchers = this->Makefile->GetDef("CTEST_USE_LAUNCHERS")) { + if (cmProp useLaunchers = + this->Makefile->GetDefinition("CTEST_USE_LAUNCHERS")) { this->CTest->SetCTestConfiguration("UseLaunchers", *useLaunchers, this->Quiet); } if (cmProp labelsForSubprojects = - this->Makefile->GetDef("CTEST_LABELS_FOR_SUBPROJECTS")) { + this->Makefile->GetDefinition("CTEST_LABELS_FOR_SUBPROJECTS")) { this->CTest->SetCTestConfiguration("LabelsForSubprojects", *labelsForSubprojects, this->Quiet); } diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 35c2b11..9997548 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -19,6 +19,7 @@ #include "cmGeneratedFileStream.h" #include "cmMakefile.h" #include "cmProcessOutput.h" +#include "cmProperty.h" #include "cmStringAlgorithms.h" #include "cmStringReplaceHelper.h" #include "cmSystemTools.h" @@ -248,13 +249,14 @@ void cmCTestBuildHandler::PopulateCustomVectors(cmMakefile* mf) } // Record the user-specified custom warning rules. - if (const char* customWarningMatchers = + if (cmProp customWarningMatchers = mf->GetDefinition("CTEST_CUSTOM_WARNING_MATCH")) { - cmExpandList(customWarningMatchers, this->ReallyCustomWarningMatches); + cmExpandList(*customWarningMatchers, this->ReallyCustomWarningMatches); } - if (const char* customWarningExceptions = + if (cmProp customWarningExceptions = mf->GetDefinition("CTEST_CUSTOM_WARNING_EXCEPTION")) { - cmExpandList(customWarningExceptions, this->ReallyCustomWarningExceptions); + cmExpandList(*customWarningExceptions, + this->ReallyCustomWarningExceptions); } } diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx index ac57130..db9923e 100644 --- a/Source/CTest/cmCTestConfigureCommand.cxx +++ b/Source/CTest/cmCTestConfigureCommand.cxx @@ -40,13 +40,13 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() } cmProp ctestConfigureCommand = - this->Makefile->GetDef("CTEST_CONFIGURE_COMMAND"); + this->Makefile->GetDefinition("CTEST_CONFIGURE_COMMAND"); if (cmNonempty(ctestConfigureCommand)) { this->CTest->SetCTestConfiguration("ConfigureCommand", *ctestConfigureCommand, this->Quiet); } else { - const char* cmakeGeneratorName = + cmProp cmakeGeneratorName = this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR"); if (cmNonempty(cmakeGeneratorName)) { const std::string& source_dir = @@ -71,7 +71,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() bool cmakeBuildTypeInOptions = false; auto gg = this->Makefile->GetCMakeInstance()->CreateGlobalGenerator( - cmakeGeneratorName); + *cmakeGeneratorName); if (gg) { multiConfig = gg->IsMultiConfig(); gg.reset(); @@ -103,22 +103,22 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() } cmakeConfigureCommand += " \"-G"; - cmakeConfigureCommand += cmakeGeneratorName; + cmakeConfigureCommand += *cmakeGeneratorName; cmakeConfigureCommand += "\""; - const char* cmakeGeneratorPlatform = + cmProp cmakeGeneratorPlatform = this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR_PLATFORM"); if (cmNonempty(cmakeGeneratorPlatform)) { cmakeConfigureCommand += " \"-A"; - cmakeConfigureCommand += cmakeGeneratorPlatform; + cmakeConfigureCommand += *cmakeGeneratorPlatform; cmakeConfigureCommand += "\""; } - const char* cmakeGeneratorToolset = + cmProp cmakeGeneratorToolset = this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR_TOOLSET"); if (cmNonempty(cmakeGeneratorToolset)) { cmakeConfigureCommand += " \"-T"; - cmakeConfigureCommand += cmakeGeneratorToolset; + cmakeConfigureCommand += *cmakeGeneratorToolset; cmakeConfigureCommand += "\""; } @@ -138,7 +138,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() } if (cmProp labelsForSubprojects = - this->Makefile->GetDef("CTEST_LABELS_FOR_SUBPROJECTS")) { + this->Makefile->GetDefinition("CTEST_LABELS_FOR_SUBPROJECTS")) { this->CTest->SetCTestConfiguration("LabelsForSubprojects", *labelsForSubprojects, this->Quiet); } diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx index 03b7173..731932e 100644 --- a/Source/CTest/cmCTestHandlerCommand.cxx +++ b/Source/CTest/cmCTestHandlerCommand.cxx @@ -126,7 +126,8 @@ bool cmCTestHandlerCommand::InitialPass(std::vector const& args, // CTEST_CONFIGURATION_TYPE script variable if it is defined. // The current script value trumps the -C argument on the command // line. - cmProp ctestConfigType = this->Makefile->GetDef("CTEST_CONFIGURATION_TYPE"); + cmProp ctestConfigType = + this->Makefile->GetDefinition("CTEST_CONFIGURATION_TYPE"); if (ctestConfigType) { this->CTest->SetConfigType(*ctestConfigType); } @@ -160,7 +161,7 @@ bool cmCTestHandlerCommand::InitialPass(std::vector const& args, this->Quiet); } - if (cmProp changeId = this->Makefile->GetDef("CTEST_CHANGE_ID")) { + if (cmProp changeId = this->Makefile->GetDefinition("CTEST_CHANGE_ID")) { this->CTest->SetCTestConfiguration("ChangeId", *changeId, this->Quiet); } diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 4fa4dc0..4808c36 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -35,6 +35,7 @@ #include "cmGeneratedFileStream.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" +#include "cmProperty.h" #include "cmState.h" #include "cmStateDirectory.h" #include "cmStateSnapshot.h" @@ -372,8 +373,8 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg) int cmCTestScriptHandler::ExtractVariables() { // Temporary variables - const char* minInterval; - const char* contDuration; + cmProp minInterval; + cmProp contDuration; this->SourceDir = this->Makefile->GetSafeDefinition("CTEST_SOURCE_DIRECTORY"); @@ -412,7 +413,7 @@ int cmCTestScriptHandler::ExtractVariables() int i; for (i = 1; i < 10; ++i) { sprintf(updateVar, "CTEST_EXTRA_UPDATES_%i", i); - const char* updateVal = this->Makefile->GetDefinition(updateVar); + cmProp updateVal = this->Makefile->GetDefinition(updateVar); if (updateVal) { if (this->UpdateCmd.empty()) { cmSystemTools::Error( @@ -420,7 +421,7 @@ int cmCTestScriptHandler::ExtractVariables() " specified without specifying CTEST_CVS_COMMAND."); return 12; } - this->ExtraUpdates.emplace_back(updateVal); + this->ExtraUpdates.emplace_back(*updateVal); } } @@ -455,10 +456,10 @@ int cmCTestScriptHandler::ExtractVariables() // the script may override the minimum continuous interval if (minInterval) { - this->MinimumInterval = 60 * atof(minInterval); + this->MinimumInterval = 60 * atof(minInterval->c_str()); } if (contDuration) { - this->ContinuousDuration = 60.0 * atof(contDuration); + this->ContinuousDuration = 60.0 * atof(contDuration->c_str()); } this->UpdateElapsedTime(); @@ -932,13 +933,13 @@ cmDuration cmCTestScriptHandler::GetRemainingTimeAllowed() return cmCTest::MaxDuration(); } - const char* timelimitS = this->Makefile->GetDefinition("CTEST_TIME_LIMIT"); + cmProp timelimitS = this->Makefile->GetDefinition("CTEST_TIME_LIMIT"); if (!timelimitS) { return cmCTest::MaxDuration(); } - auto timelimit = cmDuration(atof(timelimitS)); + auto timelimit = cmDuration(atof(timelimitS->c_str())); auto duration = std::chrono::duration_cast( std::chrono::steady_clock::now() - this->ScriptStartTime); diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx index 6398d66..53e1b2f 100644 --- a/Source/CTest/cmCTestStartCommand.cxx +++ b/Source/CTest/cmCTestStartCommand.cxx @@ -9,6 +9,7 @@ #include "cmCTestVC.h" #include "cmGeneratedFileStream.h" #include "cmMakefile.h" +#include "cmProperty.h" #include "cmSystemTools.h" class cmExecutionStatus; @@ -29,8 +30,8 @@ bool cmCTestStartCommand::InitialPass(std::vector const& args, size_t cnt = 0; const char* smodel = nullptr; - const char* src_dir = nullptr; - const char* bld_dir = nullptr; + const std::string* src_dir = nullptr; + const std::string* bld_dir = nullptr; while (cnt < args.size()) { if (args[cnt] == "GROUP" || args[cnt] == "TRACK") { @@ -54,10 +55,10 @@ bool cmCTestStartCommand::InitialPass(std::vector const& args, smodel = args[cnt].c_str(); cnt++; } else if (!src_dir) { - src_dir = args[cnt].c_str(); + src_dir = &args[cnt]; cnt++; } else if (!bld_dir) { - bld_dir = args[cnt].c_str(); + bld_dir = &args[cnt]; cnt++; } else { this->SetError("Too many arguments"); @@ -87,13 +88,13 @@ bool cmCTestStartCommand::InitialPass(std::vector const& args, return false; } - cmSystemTools::AddKeepPath(src_dir); - cmSystemTools::AddKeepPath(bld_dir); + cmSystemTools::AddKeepPath(*src_dir); + cmSystemTools::AddKeepPath(*bld_dir); this->CTest->EmptyCTestConfiguration(); - std::string sourceDir = cmSystemTools::CollapseFullPath(src_dir); - std::string binaryDir = cmSystemTools::CollapseFullPath(bld_dir); + std::string sourceDir = cmSystemTools::CollapseFullPath(*src_dir); + std::string binaryDir = cmSystemTools::CollapseFullPath(*bld_dir); this->CTest->SetCTestConfiguration("SourceDirectory", sourceDir, this->Quiet); this->CTest->SetCTestConfiguration("BuildDirectory", binaryDir, this->Quiet); @@ -102,16 +103,16 @@ bool cmCTestStartCommand::InitialPass(std::vector const& args, cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Run dashboard with model " << smodel << std::endl - << " Source directory: " << src_dir << std::endl - << " Build directory: " << bld_dir << std::endl, + << " Source directory: " << *src_dir << std::endl + << " Build directory: " << *bld_dir << std::endl, this->Quiet); } else { cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Run dashboard with " "to-be-determined model" << std::endl - << " Source directory: " << src_dir << std::endl - << " Build directory: " << bld_dir << std::endl, + << " Source directory: " << *src_dir << std::endl + << " Build directory: " << *bld_dir << std::endl, this->Quiet); } const char* group = this->CTest->GetSpecificGroup(); @@ -161,7 +162,7 @@ bool cmCTestStartCommand::InitialCheckout(std::ostream& ofs, std::string const& sourceDir) { // Use the user-provided command to create the source tree. - const char* initialCheckoutCommand = + cmProp initialCheckoutCommand = this->Makefile->GetDefinition("CTEST_CHECKOUT_COMMAND"); if (!initialCheckoutCommand) { initialCheckoutCommand = @@ -171,7 +172,7 @@ bool cmCTestStartCommand::InitialCheckout(std::ostream& ofs, // Use a generic VC object to run and log the command. cmCTestVC vc(this->CTest, ofs); vc.SetSourceDirectory(sourceDir); - if (!vc.InitialCheckout(initialCheckoutCommand)) { + if (!vc.InitialCheckout(*initialCheckoutCommand)) { return false; } } diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx index 026e98f..bdba0e5 100644 --- a/Source/CTest/cmCTestSubmitCommand.cxx +++ b/Source/CTest/cmCTestSubmitCommand.cxx @@ -16,6 +16,7 @@ #include "cmCommand.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmProperty.h" #include "cmRange.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -37,7 +38,7 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() { const std::string* submitURL = !this->SubmitURL.empty() ? &this->SubmitURL - : this->Makefile->GetDef("CTEST_SUBMIT_URL"); + : this->Makefile->GetDefinition("CTEST_SUBMIT_URL"); if (submitURL) { this->CTest->SetCTestConfiguration("SubmitURL", *submitURL, this->Quiet); @@ -58,17 +59,17 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() this->CTest->SetCTestConfigurationFromCMakeVariable( this->Makefile, "CurlOptions", "CTEST_CURL_OPTIONS", this->Quiet); - const char* notesFilesVariable = + cmProp notesFilesVariable = this->Makefile->GetDefinition("CTEST_NOTES_FILES"); if (notesFilesVariable) { - std::vector notesFiles = cmExpandedList(notesFilesVariable); + std::vector notesFiles = cmExpandedList(*notesFilesVariable); this->CTest->GenerateNotesFile(notesFiles); } - const char* extraFilesVariable = + cmProp extraFilesVariable = this->Makefile->GetDefinition("CTEST_EXTRA_SUBMIT_FILES"); if (extraFilesVariable) { - std::vector extraFiles = cmExpandedList(extraFilesVariable); + std::vector extraFiles = cmExpandedList(*extraFilesVariable); if (!this->CTest->SubmitExtraFiles(extraFiles)) { this->SetError("problem submitting extra files."); return nullptr; diff --git a/Source/CTest/cmCTestTestCommand.cxx b/Source/CTest/cmCTestTestCommand.cxx index cbc3c0c..4403733 100644 --- a/Source/CTest/cmCTestTestCommand.cxx +++ b/Source/CTest/cmCTestTestCommand.cxx @@ -40,12 +40,11 @@ void cmCTestTestCommand::BindArguments() cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler() { - const char* ctestTimeout = - this->Makefile->GetDefinition("CTEST_TEST_TIMEOUT"); + cmProp ctestTimeout = this->Makefile->GetDefinition("CTEST_TEST_TIMEOUT"); cmDuration timeout; if (ctestTimeout) { - timeout = cmDuration(atof(ctestTimeout)); + timeout = cmDuration(atof(ctestTimeout->c_str())); } else { timeout = this->CTest->GetTimeOut(); if (timeout <= cmDuration::zero()) { @@ -55,10 +54,10 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler() } this->CTest->SetTimeOut(timeout); - const char* resourceSpecFile = + cmProp resourceSpecFile = this->Makefile->GetDefinition("CTEST_RESOURCE_SPEC_FILE"); if (this->ResourceSpecFile.empty() && resourceSpecFile) { - this->ResourceSpecFile = resourceSpecFile; + this->ResourceSpecFile = *resourceSpecFile; } cmCTestGenericHandler* handler = this->InitializeActualHandler(); @@ -115,7 +114,7 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler() // or CTEST_TEST_LOAD script variable, or ctest --test-load // command line argument... in that order. unsigned long testLoad; - const char* ctestTestLoad = this->Makefile->GetDefinition("CTEST_TEST_LOAD"); + cmProp ctestTestLoad = this->Makefile->GetDefinition("CTEST_TEST_LOAD"); if (!this->TestLoad.empty()) { if (!cmStrToULong(this->TestLoad, &testLoad)) { testLoad = 0; @@ -124,10 +123,10 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler() << std::endl); } } else if (cmNonempty(ctestTestLoad)) { - if (!cmStrToULong(ctestTestLoad, &testLoad)) { + if (!cmStrToULong(*ctestTestLoad, &testLoad)) { testLoad = 0; cmCTestLog(this->CTest, WARNING, - "Invalid value for 'CTEST_TEST_LOAD' : " << ctestTestLoad + "Invalid value for 'CTEST_TEST_LOAD' : " << *ctestTestLoad << std::endl); } } else { @@ -136,7 +135,7 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler() handler->SetTestLoad(testLoad); if (cmProp labelsForSubprojects = - this->Makefile->GetDef("CTEST_LABELS_FOR_SUBPROJECTS")) { + this->Makefile->GetDefinition("CTEST_LABELS_FOR_SUBPROJECTS")) { this->CTest->SetCTestConfiguration("LabelsForSubprojects", *labelsForSubprojects, this->Quiet); } diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index abd1207..4d1a589 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -37,6 +37,7 @@ #include "cmGeneratedFileStream.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" +#include "cmProperty.h" #include "cmState.h" #include "cmStateSnapshot.h" #include "cmStringAlgorithms.h" @@ -1764,9 +1765,9 @@ bool cmCTestTestHandler::GetListOfTests() // SEND_ERROR or FATAL_ERROR in CTestTestfile or TEST_INCLUDE_FILES return false; } - const char* specFile = mf.GetDefinition("CTEST_RESOURCE_SPEC_FILE"); + cmProp specFile = mf.GetDefinition("CTEST_RESOURCE_SPEC_FILE"); if (this->ResourceSpecFile.empty() && specFile) { - this->ResourceSpecFile = specFile; + this->ResourceSpecFile = *specFile; } cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Done constructing a list of tests" << std::endl, diff --git a/Source/CTest/cmCTestUpdateCommand.cxx b/Source/CTest/cmCTestUpdateCommand.cxx index 95cae13..6fef90a 100644 --- a/Source/CTest/cmCTestUpdateCommand.cxx +++ b/Source/CTest/cmCTestUpdateCommand.cxx @@ -5,6 +5,7 @@ #include "cmCTest.h" #include "cmCTestUpdateHandler.h" #include "cmMakefile.h" +#include "cmProperty.h" #include "cmSystemTools.h" cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler() @@ -17,7 +18,7 @@ cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler() this->CTest->SetCTestConfiguration( "SourceDirectory", cmSystemTools::CollapseFullPath( - this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY")), + cmToCStrSafe(this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY"))), this->Quiet); } std::string source_dir = diff --git a/Source/cmAuxSourceDirectoryCommand.cxx b/Source/cmAuxSourceDirectoryCommand.cxx index 53d4cb4..15edcc5 100644 --- a/Source/cmAuxSourceDirectoryCommand.cxx +++ b/Source/cmAuxSourceDirectoryCommand.cxx @@ -36,10 +36,7 @@ bool cmAuxSourceDirectoryCommand(std::vector const& args, } // was the list already populated - const char* def = mf.GetDefinition(args[1]); - if (def) { - sourceListValue = def; - } + sourceListValue = mf.GetSafeDefinition(args[1]); std::vector files; diff --git a/Source/cmBuildCommand.cxx b/Source/cmBuildCommand.cxx index b82fb9a..2eaf315 100644 --- a/Source/cmBuildCommand.cxx +++ b/Source/cmBuildCommand.cxx @@ -6,6 +6,7 @@ #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmProperty.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -94,7 +95,7 @@ bool TwoArgsSignature(std::vector const& args, cmMakefile& mf = status.GetMakefile(); std::string const& define = args[0]; - const char* cacheValue = mf.GetDefinition(define); + cmProp cacheValue = mf.GetDefinition(define); std::string configType; if (!cmSystemTools::GetEnv("CMAKE_CONFIG_TYPE", configType) || diff --git a/Source/cmBuildNameCommand.cxx b/Source/cmBuildNameCommand.cxx index ad4d665..f9b8f8f 100644 --- a/Source/cmBuildNameCommand.cxx +++ b/Source/cmBuildNameCommand.cxx @@ -8,6 +8,7 @@ #include "cmExecutionStatus.h" #include "cmMakefile.h" +#include "cmProperty.h" #include "cmStateTypes.h" #include "cmSystemTools.h" @@ -19,12 +20,12 @@ bool cmBuildNameCommand(std::vector const& args, return false; } cmMakefile& mf = status.GetMakefile(); - const char* cacheValue = mf.GetDefinition(args[0]); + cmProp cacheValue = mf.GetDefinition(args[0]); if (cacheValue) { // do we need to correct the value? cmsys::RegularExpression reg("[()/]"); - if (reg.find(cacheValue)) { - std::string cv = cacheValue; + std::string cv = *cacheValue; + if (reg.find(cv)) { std::replace(cv.begin(), cv.end(), '/', '_'); std::replace(cv.begin(), cv.end(), '(', '_'); std::replace(cv.begin(), cv.end(), ')', '_'); diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index 697d435..1a1bbec 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -140,7 +140,7 @@ const char* CCONV cmGetCurrentOutputDirectory(void* arg) const char* CCONV cmGetDefinition(void* arg, const char* def) { cmMakefile* mf = static_cast(arg); - return mf->GetDefinition(def); + return cmToCStr(mf->GetDefinition(def)); } int CCONV cmIsOn(void* arg, const char* name) diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index f0ae8de..8cf5ae9 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -2620,14 +2620,14 @@ int cmCTest::ReadCustomConfigurationFileTree(const std::string& dir, void cmCTest::PopulateCustomVector(cmMakefile* mf, const std::string& def, std::vector& vec) { - const char* dval = mf->GetDefinition(def); + cmProp dval = mf->GetDefinition(def); if (!dval) { return; } cmCTestLog(this, DEBUG, "PopulateCustomVector: " << def << std::endl); vec.clear(); - cmExpandList(dval, vec); + cmExpandList(*dval, vec); for (std::string const& it : vec) { cmCTestLog(this, DEBUG, " -- " << it << std::endl); @@ -2637,11 +2637,11 @@ void cmCTest::PopulateCustomVector(cmMakefile* mf, const std::string& def, void cmCTest::PopulateCustomInteger(cmMakefile* mf, const std::string& def, int& val) { - const char* dval = mf->GetDefinition(def); + cmProp dval = mf->GetDefinition(def); if (!dval) { return; } - val = atoi(dval); + val = atoi(dval->c_str()); } std::string cmCTest::GetShortPathToFile(const std::string& cfname) @@ -2971,7 +2971,7 @@ bool cmCTest::SetCTestConfigurationFromCMakeVariable( cmMakefile* mf, const char* dconfig, const std::string& cmake_var, bool suppress) { - cmProp ctvar = mf->GetDef(cmake_var); + cmProp ctvar = mf->GetDefinition(cmake_var); if (!ctvar) { return false; } diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index 87eb91c..e07f7f1 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -93,7 +93,7 @@ const char* cmCommandArgumentParserHelper::ExpandVariable(const char* var) if (this->FileLine >= 0 && strcmp(var, "CMAKE_CURRENT_LIST_LINE") == 0) { return this->AddString(std::to_string(this->FileLine)); } - const char* value = this->Makefile->GetDefinition(var); + cmProp value = this->Makefile->GetDefinition(var); if (!value) { this->Makefile->MaybeWarnUninitialized(var, this->FileName); if (!this->RemoveEmpty) { @@ -101,9 +101,9 @@ const char* cmCommandArgumentParserHelper::ExpandVariable(const char* var) } } if (this->EscapeQuotes && value) { - return this->AddString(cmEscapeQuotes(value)); + return this->AddString(cmEscapeQuotes(*value)); } - return this->AddString(value ? value : ""); + return this->AddString(cmToCStrSafe(value)); } const char* cmCommandArgumentParserHelper::ExpandVariableForAt(const char* var) diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 8aee27c..2b7c9f6 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -55,7 +55,7 @@ void cmCommonTargetGenerator::AddModuleDefinitionFlag( } // TODO: Create a per-language flag variable. - const char* defFileFlag = + cmProp defFileFlag = this->Makefile->GetDefinition("CMAKE_LINK_DEF_FILE_FLAG"); if (!defFileFlag) { return; @@ -64,7 +64,7 @@ void cmCommonTargetGenerator::AddModuleDefinitionFlag( // Append the flag and value. Use ConvertToLinkReference to help // vs6's "cl -link" pass it to the linker. std::string flag = - cmStrCat(defFileFlag, + cmStrCat(*defFileFlag, this->LocalCommonGenerator->ConvertToOutputFormat( linkLineComputer->ConvertToLinkReference(mdi->DefFile), cmOutputConverter::SHELL)); @@ -270,7 +270,7 @@ void cmCommonTargetGenerator::AppendOSXVerFlag(std::string& flags, { // Lookup the flag to specify the version. std::string fvar = cmStrCat("CMAKE_", lang, "_OSX_", name, "_VERSION_FLAG"); - const char* flag = this->Makefile->GetDefinition(fvar); + cmProp flag = this->Makefile->GetDefinition(fvar); // Skip if no such flag. if (!flag) { @@ -288,7 +288,7 @@ void cmCommonTargetGenerator::AppendOSXVerFlag(std::string& flags, if (major > 0 || minor > 0 || patch > 0) { // Append the flag since a non-zero version is specified. std::ostringstream vflag; - vflag << flag << major << "." << minor << "." << patch; + vflag << *flag << major << "." << minor << "." << patch; this->LocalCommonGenerator->AppendFlags(flags, vflag.str()); } } diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 8ca2168..5341e8d 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include @@ -18,6 +17,7 @@ #include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" +#include "cmProperty.h" #include "cmRange.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" @@ -315,9 +315,9 @@ int cmComputeLinkDepends::AddLinkEntry(cmLinkItem const& item) } else { // Look for an old-style _LIB_DEPENDS variable. std::string var = cmStrCat(entry.Item.Value, "_LIB_DEPENDS"); - if (const char* val = this->Makefile->GetDefinition(var)) { + if (cmProp val = this->Makefile->GetDefinition(var)) { // The item dependencies are known. Follow them. - BFSEntry qe = { index, val }; + BFSEntry qe = { index, val->c_str() }; this->BFSQueue.push(qe); } else if (!entry.IsFlag) { // The item dependencies are not known. We need to infer them. @@ -454,10 +454,10 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index, // lower. if (!haveLLT) { std::string var = cmStrCat(d, "_LINK_TYPE"); - if (const char* val = this->Makefile->GetDefinition(var)) { - if (strcmp(val, "debug") == 0) { + if (cmProp val = this->Makefile->GetDefinition(var)) { + if (*val == "debug") { llt = DEBUG_LibraryType; - } else if (strcmp(val, "optimized") == 0) { + } else if (*val == "optimized") { llt = OPTIMIZED_LibraryType; } } diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 43cceae..4a331fb 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -4,7 +4,6 @@ #include #include -#include #include #include @@ -284,27 +283,28 @@ cmComputeLinkInformation::cmComputeLinkInformation( this->Target->GetType() == cmStateEnums::MODULE_LIBRARY) { std::string loader_flag_var = cmStrCat("CMAKE_SHARED_MODULE_LOADER_", this->LinkLanguage, "_FLAG"); - this->LoaderFlag = this->Makefile->GetDefinition(loader_flag_var); + this->LoaderFlag = + cmToCStr(this->Makefile->GetDefinition(loader_flag_var)); } // Get options needed to link libraries. - if (const char* flag = this->Makefile->GetDefinition( + if (cmProp flag = this->Makefile->GetDefinition( "CMAKE_" + this->LinkLanguage + "_LINK_LIBRARY_FLAG")) { - this->LibLinkFlag = flag; + this->LibLinkFlag = *flag; } else { this->LibLinkFlag = this->Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_FLAG"); } - if (const char* flag = this->Makefile->GetDefinition( + if (cmProp flag = this->Makefile->GetDefinition( "CMAKE_" + this->LinkLanguage + "_LINK_LIBRARY_FILE_FLAG")) { - this->LibLinkFileFlag = flag; + this->LibLinkFileFlag = *flag; } else { this->LibLinkFileFlag = this->Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_FILE_FLAG"); } - if (const char* suffix = this->Makefile->GetDefinition( + if (cmProp suffix = this->Makefile->GetDefinition( "CMAKE_" + this->LinkLanguage + "_LINK_LIBRARY_SUFFIX")) { - this->LibLinkSuffix = suffix; + this->LibLinkSuffix = *suffix; } else { this->LibLinkSuffix = this->Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_SUFFIX"); @@ -593,9 +593,9 @@ void cmComputeLinkInformation::AddRuntimeLinkLibrary(std::string const& lang) if (runtimeLibrary.empty()) { return; } - if (const char* runtimeLinkOptions = this->Makefile->GetDefinition( + if (cmProp runtimeLinkOptions = this->Makefile->GetDefinition( "CMAKE_" + lang + "_RUNTIME_LIBRARY_LINK_OPTIONS_" + runtimeLibrary)) { - std::vector libsVec = cmExpandedList(runtimeLinkOptions); + std::vector libsVec = cmExpandedList(*runtimeLinkOptions); for (std::string const& i : libsVec) { if (!cm::contains(this->ImplicitLinkLibs, i)) { this->AddItem(i, nullptr); @@ -609,8 +609,8 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang) // Add libraries for this language that are not implied by the // linker language. std::string libVar = cmStrCat("CMAKE_", lang, "_IMPLICIT_LINK_LIBRARIES"); - if (const char* libs = this->Makefile->GetDefinition(libVar)) { - std::vector libsVec = cmExpandedList(libs); + if (cmProp libs = this->Makefile->GetDefinition(libVar)) { + std::vector libsVec = cmExpandedList(*libs); for (std::string const& i : libsVec) { if (!cm::contains(this->ImplicitLinkLibs, i)) { this->AddItem(i, nullptr); @@ -621,8 +621,8 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang) // Add linker search paths for this language that are not // implied by the linker language. std::string dirVar = cmStrCat("CMAKE_", lang, "_IMPLICIT_LINK_DIRECTORIES"); - if (const char* dirs = this->Makefile->GetDefinition(dirVar)) { - std::vector dirsVec = cmExpandedList(dirs); + if (cmProp dirs = this->Makefile->GetDefinition(dirVar)) { + std::vector dirsVec = cmExpandedList(*dirs); this->OrderLinkerSearchPath->AddLanguageDirectories(dirsVec); } } @@ -800,8 +800,8 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() this->LinkTypeEnabled = false; // Lookup link type selection flags. - const char* static_link_type_flag = nullptr; - const char* shared_link_type_flag = nullptr; + cmProp static_link_type_flag = nullptr; + cmProp shared_link_type_flag = nullptr; const char* target_type_str = nullptr; switch (this->Target->GetType()) { case cmStateEnums::EXECUTABLE: @@ -834,8 +834,8 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() // known. if (cmNonempty(static_link_type_flag) && cmNonempty(shared_link_type_flag)) { this->LinkTypeEnabled = true; - this->StaticLinkTypeFlag = static_link_type_flag; - this->SharedLinkTypeFlag = shared_link_type_flag; + this->StaticLinkTypeFlag = *static_link_type_flag; + this->SharedLinkTypeFlag = *shared_link_type_flag; } // Lookup the starting link type from the target (linked statically?). @@ -861,16 +861,15 @@ void cmComputeLinkInformation::ComputeItemParserInfo() LinkShared); this->AddLinkExtension(mf->GetSafeDefinition("CMAKE_LINK_LIBRARY_SUFFIX"), LinkUnknown); - if (const char* linkSuffixes = - mf->GetDefinition("CMAKE_EXTRA_LINK_EXTENSIONS")) { - std::vector linkSuffixVec = cmExpandedList(linkSuffixes); + if (cmProp linkSuffixes = mf->GetDefinition("CMAKE_EXTRA_LINK_EXTENSIONS")) { + std::vector linkSuffixVec = cmExpandedList(*linkSuffixes); for (std::string const& i : linkSuffixVec) { this->AddLinkExtension(i, LinkUnknown); } } - if (const char* sharedSuffixes = + if (cmProp sharedSuffixes = mf->GetDefinition("CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES")) { - std::vector sharedSuffixVec = cmExpandedList(sharedSuffixes); + std::vector sharedSuffixVec = cmExpandedList(*sharedSuffixes); for (std::string const& i : sharedSuffixVec) { this->AddLinkExtension(i, LinkShared); } @@ -1553,10 +1552,10 @@ void cmComputeLinkInformation::LoadImplicitLinkInfo() // Append library architecture to all implicit platform directories // and add them to the set - if (const char* libraryArch = + if (cmProp libraryArch = this->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE")) { for (std::string const& i : implicitDirVec) { - this->ImplicitLinkDirs.insert(i + "/" + libraryArch); + this->ImplicitLinkDirs.insert(i + "/" + *libraryArch); } } @@ -1746,14 +1745,13 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, } if (use_build_rpath || use_link_rpath) { std::string rootPath; - if (const char* sysrootLink = + if (cmProp sysrootLink = this->Makefile->GetDefinition("CMAKE_SYSROOT_LINK")) { - rootPath = sysrootLink; + rootPath = *sysrootLink; } else { rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT"); } - const char* stagePath = - this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX"); + cmProp stagePath = this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX"); std::string const& installPrefix = this->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX"); cmSystemTools::ConvertToUnixSlashes(rootPath); @@ -1767,8 +1765,8 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, std::string d = ri; if (!rootPath.empty() && cmHasPrefix(d, rootPath)) { d.erase(0, rootPath.size()); - } else if (cmNonempty(stagePath) && cmHasPrefix(d, stagePath)) { - d.erase(0, strlen(stagePath)); + } else if (cmNonempty(stagePath) && cmHasPrefix(d, *stagePath)) { + d.erase(0, (*stagePath).size()); d = cmStrCat(installPrefix, '/', d); cmSystemTools::ConvertToUnixSlashes(d); } else if (use_relative_build_rpath) { @@ -1798,8 +1796,8 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, std::string d = ri; if (!rootPath.empty() && cmHasPrefix(d, rootPath)) { d.erase(0, rootPath.size()); - } else if (cmNonempty(stagePath) && cmHasPrefix(d, stagePath)) { - d.erase(0, strlen(stagePath)); + } else if (cmNonempty(stagePath) && cmHasPrefix(d, *stagePath)) { + d.erase(0, (*stagePath).size()); d = cmStrCat(installPrefix, '/', d); cmSystemTools::ConvertToUnixSlashes(d); } @@ -1821,7 +1819,7 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, "CMAKE_" + li + "_USE_IMPLICIT_LINK_DIRECTORIES_IN_RUNTIME_PATH"; if (this->Makefile->IsOn(useVar)) { std::string dirVar = "CMAKE_" + li + "_IMPLICIT_LINK_DIRECTORIES"; - if (cmProp dirs = this->Makefile->GetDef(dirVar)) { + if (cmProp dirs = this->Makefile->GetDefinition(dirVar)) { cmCLI_ExpandListUnique(*dirs, runtimeDirs, emitted); } } diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index 7a3a3e8..daa9f4c 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -15,6 +15,7 @@ #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmProperty.h" #include "cmState.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -143,7 +144,7 @@ const char* cmConditionEvaluator::GetDefinitionIfUnquoted( return nullptr; } - const char* def = this->Makefile.GetDefinition(argument.GetValue()); + cmProp def = this->Makefile.GetDefinition(argument.GetValue()); if (def && argument.WasQuoted() && this->Policy54Status == cmPolicies::WARN) { @@ -161,7 +162,7 @@ const char* cmConditionEvaluator::GetDefinitionIfUnquoted( } } - return def; + return cmToCStr(def); } //========================================================================= @@ -667,7 +668,7 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs, bool result = false; def = this->GetVariableOrString(*arg); - def2 = this->Makefile.GetDefinition(argP2->GetValue()); + def2 = cmToCStr(this->Makefile.GetDefinition(argP2->GetValue())); if (def2) { std::vector list = cmExpandedList(def2, true); diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index b9b91f6..6af3429 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -238,7 +238,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv, this->SrcFileSignature = true; cmStateEnums::TargetType targetType = cmStateEnums::EXECUTABLE; - cmProp tt = this->Makefile->GetDef("CMAKE_TRY_COMPILE_TARGET_TYPE"); + cmProp tt = this->Makefile->GetDefinition("CMAKE_TRY_COMPILE_TARGET_TYPE"); if (!isTryRun && cmNonempty(tt)) { if (*tt == cmState::GetTargetTypeName(cmStateEnums::EXECUTABLE)) { targetType = cmStateEnums::EXECUTABLE; @@ -527,19 +527,19 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv, return -1; } - const char* def = this->Makefile->GetDefinition("CMAKE_MODULE_PATH"); + cmProp def = this->Makefile->GetDefinition("CMAKE_MODULE_PATH"); fprintf(fout, "cmake_minimum_required(VERSION %u.%u.%u.%u)\n", cmVersion::GetMajorVersion(), cmVersion::GetMinorVersion(), cmVersion::GetPatchVersion(), cmVersion::GetTweakVersion()); if (def) { - fprintf(fout, "set(CMAKE_MODULE_PATH \"%s\")\n", def); + fprintf(fout, "set(CMAKE_MODULE_PATH \"%s\")\n", def->c_str()); } /* Set MSVC runtime library policy to match our selection. */ - if (const char* msvcRuntimeLibraryDefault = + if (cmProp msvcRuntimeLibraryDefault = this->Makefile->GetDefinition(kCMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT)) { fprintf(fout, "cmake_policy(SET CMP0091 %s)\n", - *msvcRuntimeLibraryDefault ? "NEW" : "OLD"); + !msvcRuntimeLibraryDefault->empty() ? "NEW" : "OLD"); } /* Set CUDA architectures policy to match outer project. */ @@ -555,14 +555,14 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv, projectLangs += " " + li; std::string rulesOverrideBase = "CMAKE_USER_MAKE_RULES_OVERRIDE"; std::string rulesOverrideLang = cmStrCat(rulesOverrideBase, "_", li); - if (const char* rulesOverridePath = + if (cmProp rulesOverridePath = this->Makefile->GetDefinition(rulesOverrideLang)) { fprintf(fout, "set(%s \"%s\")\n", rulesOverrideLang.c_str(), - rulesOverridePath); - } else if (const char* rulesOverridePath2 = + rulesOverridePath->c_str()); + } else if (cmProp rulesOverridePath2 = this->Makefile->GetDefinition(rulesOverrideBase)) { fprintf(fout, "set(%s \"%s\")\n", rulesOverrideBase.c_str(), - rulesOverridePath2); + rulesOverridePath2->c_str()); } } fprintf(fout, "project(CMAKE_TRY_COMPILE%s)\n", projectLangs.c_str()); @@ -577,9 +577,9 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv, fprintf(fout, "set(CMAKE_VERBOSE_MAKEFILE 1)\n"); for (std::string const& li : testLangs) { std::string langFlags = "CMAKE_" + li + "_FLAGS"; - const char* flags = this->Makefile->GetDefinition(langFlags); + cmProp flags = this->Makefile->GetDefinition(langFlags); fprintf(fout, "set(CMAKE_%s_FLAGS %s)\n", li.c_str(), - cmOutputConverter::EscapeForCMake(flags ? flags : "").c_str()); + cmOutputConverter::EscapeForCMake(cmToCStrSafe(flags)).c_str()); fprintf(fout, "set(CMAKE_%s_FLAGS \"${CMAKE_%s_FLAGS}" " ${COMPILE_DEFINITIONS}\")\n", @@ -616,10 +616,10 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv, for (std::string const& li : testLangs) { std::string const langFlagsCfg = cmStrCat("CMAKE_", li, "_FLAGS_", cfg); - const char* flagsCfg = this->Makefile->GetDefinition(langFlagsCfg); - fprintf(fout, "set(%s %s)\n", langFlagsCfg.c_str(), - cmOutputConverter::EscapeForCMake(flagsCfg ? flagsCfg : "") - .c_str()); + cmProp flagsCfg = this->Makefile->GetDefinition(langFlagsCfg); + fprintf( + fout, "set(%s %s)\n", langFlagsCfg.c_str(), + cmOutputConverter::EscapeForCMake(cmToCStrSafe(flagsCfg)).c_str()); } } break; } @@ -649,12 +649,11 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv, case cmPolicies::NEW: // NEW behavior is to pass linker flags. { - const char* exeLinkFlags = + cmProp exeLinkFlags = this->Makefile->GetDefinition("CMAKE_EXE_LINKER_FLAGS"); - fprintf( - fout, "set(CMAKE_EXE_LINKER_FLAGS %s)\n", - cmOutputConverter::EscapeForCMake(exeLinkFlags ? exeLinkFlags : "") - .c_str()); + fprintf(fout, "set(CMAKE_EXE_LINKER_FLAGS %s)\n", + cmOutputConverter::EscapeForCMake(cmToCStrSafe(exeLinkFlags)) + .c_str()); } break; } @@ -730,9 +729,9 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv, vars.insert(kCMAKE_WARN_DEPRECATED); vars.emplace("CMAKE_MSVC_RUNTIME_LIBRARY"_s); - if (const char* varListStr = this->Makefile->GetDefinition( + if (cmProp varListStr = this->Makefile->GetDefinition( kCMAKE_TRY_COMPILE_PLATFORM_VARIABLES)) { - std::vector varList = cmExpandedList(varListStr); + std::vector varList = cmExpandedList(*varListStr); vars.insert(varList.begin(), varList.end()); } @@ -767,16 +766,16 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv, cmLocalGenerator doesn't allow building for "the other" architecture only via CMAKE_OSX_ARCHITECTURES. */ - if (const char* tcArchs = this->Makefile->GetDefinition( + if (cmProp tcArchs = this->Makefile->GetDefinition( kCMAKE_TRY_COMPILE_OSX_ARCHITECTURES)) { vars.erase(kCMAKE_OSX_ARCHITECTURES); - std::string flag = "-DCMAKE_OSX_ARCHITECTURES=" + std::string(tcArchs); + std::string flag = "-DCMAKE_OSX_ARCHITECTURES=" + *tcArchs; cmakeFlags.push_back(std::move(flag)); } for (std::string const& var : vars) { - if (const char* val = this->Makefile->GetDefinition(var)) { - std::string flag = "-D" + var + "=" + val; + if (cmProp val = this->Makefile->GetDefinition(var)) { + std::string flag = "-D" + var + "=" + *val; cmakeFlags.push_back(std::move(flag)); } } @@ -916,8 +915,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv, if (this->Makefile->GetState()->UseGhsMultiIDE()) { // Forward the GHS variables to the inner project cache. for (std::string const& var : ghs_platform_vars) { - if (const char* val = this->Makefile->GetDefinition(var)) { - std::string flag = "-D" + var + "=" + "'" + val + "'"; + if (cmProp val = this->Makefile->GetDefinition(var)) { + std::string flag = "-D" + var + "=" + "'" + *val + "'"; cmakeFlags.push_back(std::move(flag)); } } @@ -1054,18 +1053,18 @@ void cmCoreTryCompile::FindOutputFile(const std::string& targetName, std::vector searchDirs; searchDirs.emplace_back(); - const char* config = + cmProp config = this->Makefile->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION"); // if a config was specified try that first if (cmNonempty(config)) { - std::string tmp = cmStrCat('/', config); + std::string tmp = cmStrCat('/', *config); searchDirs.push_back(std::move(tmp)); } searchDirs.emplace_back("/Debug"); #if defined(__APPLE__) std::string app = "/" + targetName + ".app"; if (cmNonempty(config)) { - std::string tmp = cmStrCat('/', config, app); + std::string tmp = cmStrCat('/', *config, app); searchDirs.push_back(std::move(tmp)); } std::string tmp = "/Debug" + app; diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx index d8aa730..d092f4f 100644 --- a/Source/cmDepends.cxx +++ b/Source/cmDepends.cxx @@ -11,6 +11,7 @@ #include "cmGeneratedFileStream.h" #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" +#include "cmProperty.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -228,19 +229,19 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends, void cmDepends::SetIncludePathFromLanguage(const std::string& lang) { // Look for the new per "TARGET_" variant first: - const char* includePath = nullptr; + cmProp includePath = nullptr; std::string includePathVar = cmStrCat("CMAKE_", lang, "_TARGET_INCLUDE_PATH"); cmMakefile* mf = this->LocalGenerator->GetMakefile(); includePath = mf->GetDefinition(includePathVar); if (includePath) { - cmExpandList(includePath, this->IncludePath); + cmExpandList(*includePath, this->IncludePath); } else { // Fallback to the old directory level variable if no per-target var: includePathVar = cmStrCat("CMAKE_", lang, "_INCLUDE_PATH"); includePath = mf->GetDefinition(includePathVar); if (includePath) { - cmExpandList(includePath, this->IncludePath); + cmExpandList(*includePath, this->IncludePath); } } } diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index e05c964..e6aef92 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -9,6 +9,7 @@ #include "cmFileTime.h" #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" +#include "cmProperty.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -38,13 +39,13 @@ cmDependsC::cmDependsC(cmLocalUnixMakefileGenerator3* lg, std::string complainRegex = "^$"; { std::string scanRegexVar = cmStrCat("CMAKE_", lang, "_INCLUDE_REGEX_SCAN"); - if (const char* sr = mf->GetDefinition(scanRegexVar)) { - scanRegex = sr; + if (cmProp sr = mf->GetDefinition(scanRegexVar)) { + scanRegex = *sr; } std::string complainRegexVar = cmStrCat("CMAKE_", lang, "_INCLUDE_REGEX_COMPLAIN"); - if (const char* cr = mf->GetDefinition(complainRegexVar)) { - complainRegex = cr; + if (cmProp cr = mf->GetDefinition(complainRegexVar)) { + complainRegex = *cr; } } diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index 54418df..a239418 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -15,6 +15,7 @@ #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" #include "cmOutputConverter.h" +#include "cmProperty.h" #include "cmStateDirectory.h" #include "cmStateSnapshot.h" #include "cmStringAlgorithms.h" @@ -394,9 +395,9 @@ bool cmDependsFortran::WriteDependenciesReal(std::string const& obj, makeDepends << "\t$(CMAKE_COMMAND) -E cmake_copy_f90_mod " << modFile << ' ' << stampFileForShell; cmMakefile* mf = this->LocalGenerator->GetMakefile(); - const char* cid = mf->GetDefinition("CMAKE_Fortran_COMPILER_ID"); + cmProp cid = mf->GetDefinition("CMAKE_Fortran_COMPILER_ID"); if (cmNonempty(cid)) { - makeDepends << ' ' << cid; + makeDepends << ' ' << *cid; } makeDepends << '\n'; } diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index df68033..87b8f9b 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -16,6 +16,7 @@ #include "cmGlobalGenerator.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" +#include "cmProperty.h" #include "cmRange.h" #include "cmSourceFile.h" #include "cmStateTypes.h" @@ -496,15 +497,15 @@ void cmExtraCodeBlocksGenerator::AppendTarget( if (target->GetType() == cmStateEnums::EXECUTABLE) { // Determine the directory where the executable target is created, and // set the working directory to this dir. - const char* runtimeOutputDir = + cmProp runtimeOutputDir = makefile->GetDefinition("CMAKE_RUNTIME_OUTPUT_DIRECTORY"); - if (runtimeOutputDir != nullptr) { - workingDir = runtimeOutputDir; + if (runtimeOutputDir) { + workingDir = *runtimeOutputDir; } else { - const char* executableOutputDir = + cmProp executableOutputDir = makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"); - if (executableOutputDir != nullptr) { - workingDir = executableOutputDir; + if (executableOutputDir) { + workingDir = *executableOutputDir; } } } diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index b6c0a7a..ccfd727 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -189,9 +189,9 @@ void cmExtraEclipseCDT4Generator::CreateSettingsResourcePrefsFile() } fout << "eclipse.preferences.version=1\n"; - const char* encoding = mf->GetDefinition("CMAKE_ECLIPSE_RESOURCE_ENCODING"); + cmProp encoding = mf->GetDefinition("CMAKE_ECLIPSE_RESOURCE_ENCODING"); if (encoding) { - fout << "encoding/=" << encoding << '\n'; + fout << "encoding/=" << *encoding << '\n'; } } @@ -793,11 +793,11 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const } } // add system defined c macros - const char* cDefs = + cmProp cDefs = mf->GetDefinition("CMAKE_EXTRA_GENERATOR_C_SYSTEM_DEFINED_MACROS"); if (this->CEnabled && cDefs) { // Expand the list. - std::vector defs = cmExpandedList(cDefs, true); + std::vector defs = cmExpandedList(*cDefs, true); // the list must contain only definition-value pairs: if ((defs.size() % 2) == 0) { @@ -825,11 +825,11 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const } } // add system defined c++ macros - const char* cxxDefs = + cmProp cxxDefs = mf->GetDefinition("CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS"); if (this->CXXEnabled && cxxDefs) { // Expand the list. - std::vector defs = cmExpandedList(cxxDefs, true); + std::vector defs = cmExpandedList(*cxxDefs, true); // the list must contain only definition-value pairs: if ((defs.size() % 2) == 0) { diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index 01fac5a..54c3114 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -13,6 +13,7 @@ #include "cmGlobalGenerator.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" +#include "cmProperty.h" #include "cmSourceFile.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" @@ -127,10 +128,10 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator& lg, // only add the "edit_cache" target if it's not ccmake, because // this will not work within the IDE if (targetName == "edit_cache") { - const char* editCommand = + cmProp editCommand = localGen->GetMakefile()->GetDefinition("CMAKE_EDIT_COMMAND"); if (editCommand == nullptr || - strstr(editCommand, "ccmake") != nullptr) { + strstr(editCommand->c_str(), "ccmake") != nullptr) { insertTarget = false; } } diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index 55fb115..4a53c8a 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -852,12 +852,12 @@ void Target::ProcessLanguage(std::string const& lang) { CompileData& cd = this->CompileDataMap[lang]; cd.Language = lang; - if (const char* sysrootCompile = + if (cmProp sysrootCompile = this->GT->Makefile->GetDefinition("CMAKE_SYSROOT_COMPILE")) { - cd.Sysroot = sysrootCompile; - } else if (const char* sysroot = + cd.Sysroot = *sysrootCompile; + } else if (cmProp sysroot = this->GT->Makefile->GetDefinition("CMAKE_SYSROOT")) { - cd.Sysroot = sysroot; + cd.Sysroot = *sysroot; } cmLocalGenerator* lg = this->GT->GetLocalGenerator(); { @@ -1404,12 +1404,12 @@ Json::Value Target::DumpLink() link["commandFragments"] = std::move(commandFragments); } } - if (const char* sysrootLink = + if (cmProp sysrootLink = this->GT->Makefile->GetDefinition("CMAKE_SYSROOT_LINK")) { - link["sysroot"] = this->DumpSysroot(sysrootLink); - } else if (const char* sysroot = + link["sysroot"] = this->DumpSysroot(*sysrootLink); + } else if (cmProp sysroot = this->GT->Makefile->GetDefinition("CMAKE_SYSROOT")) { - link["sysroot"] = this->DumpSysroot(sysroot); + link["sysroot"] = this->DumpSysroot(*sysroot); } if (this->GT->IsIPOEnabled(lang, this->Config)) { link["lto"] = true; diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index f1169cc..cdb1492 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -44,6 +44,7 @@ #include "cmMessageType.h" #include "cmNewLineStyle.h" #include "cmPolicies.h" +#include "cmProperty.h" #include "cmRange.h" #include "cmRuntimeDependencyArchive.h" #include "cmState.h" @@ -1568,7 +1569,7 @@ bool HandleDownloadCommand(std::vector const& args, std::string logVar; std::string statusVar; bool tls_verify = status.GetMakefile().IsOn("CMAKE_TLS_VERIFY"); - const char* cainfo = status.GetMakefile().GetDefinition("CMAKE_TLS_CAINFO"); + cmProp cainfo = status.GetMakefile().GetDefinition("CMAKE_TLS_CAINFO"); std::string netrc_level = status.GetMakefile().GetSafeDefinition("CMAKE_NETRC"); std::string netrc_file = @@ -1623,7 +1624,7 @@ bool HandleDownloadCommand(std::vector const& args, } else if (*i == "TLS_CAINFO") { ++i; if (i != args.end()) { - cainfo = i->c_str(); + cainfo = &(*i); } else { status.SetError("DOWNLOAD missing file value for TLS_CAINFO."); return false; @@ -1790,7 +1791,7 @@ bool HandleDownloadCommand(std::vector const& args, // check to see if a CAINFO file has been specified // command arg comes first - std::string const& cainfo_err = cmCurlSetCAInfo(curl, cainfo); + std::string const& cainfo_err = cmCurlSetCAInfo(curl, cmToCStr(cainfo)); if (!cainfo_err.empty()) { status.SetError(cainfo_err); return false; @@ -1956,7 +1957,7 @@ bool HandleUploadCommand(std::vector const& args, std::string statusVar; bool showProgress = false; bool tls_verify = status.GetMakefile().IsOn("CMAKE_TLS_VERIFY"); - const char* cainfo = status.GetMakefile().GetDefinition("CMAKE_TLS_CAINFO"); + cmProp cainfo = status.GetMakefile().GetDefinition("CMAKE_TLS_CAINFO"); std::string userpwd; std::string netrc_level = status.GetMakefile().GetSafeDefinition("CMAKE_NETRC"); @@ -2009,7 +2010,7 @@ bool HandleUploadCommand(std::vector const& args, } else if (*i == "TLS_CAINFO") { ++i; if (i != args.end()) { - cainfo = i->c_str(); + cainfo = &(*i); } else { status.SetError("UPLOAD missing file value for TLS_CAINFO."); return false; @@ -2110,7 +2111,7 @@ bool HandleUploadCommand(std::vector const& args, // check to see if a CAINFO file has been specified // command arg comes first - std::string const& cainfo_err = cmCurlSetCAInfo(curl, cainfo); + std::string const& cainfo_err = cmCurlSetCAInfo(curl, cmToCStr(cainfo)); if (!cainfo_err.empty()) { status.SetError(cainfo_err); return false; diff --git a/Source/cmFileCopier.cxx b/Source/cmFileCopier.cxx index 5d44a06..48fc286 100644 --- a/Source/cmFileCopier.cxx +++ b/Source/cmFileCopier.cxx @@ -10,6 +10,7 @@ #include "cmFSPermissions.h" #include "cmFileTimes.h" #include "cmMakefile.h" +#include "cmProperty.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -171,11 +172,11 @@ void cmFileCopier::DefaultDirectoryPermissions() bool cmFileCopier::GetDefaultDirectoryPermissions(mode_t** mode) { // check if default dir creation permissions were set - const char* default_dir_install_permissions = this->Makefile->GetDefinition( + cmProp default_dir_install_permissions = this->Makefile->GetDefinition( "CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS"); if (cmNonempty(default_dir_install_permissions)) { std::vector items = - cmExpandedList(default_dir_install_permissions); + cmExpandedList(*default_dir_install_permissions); for (const auto& arg : items) { if (!this->CheckPermissions(arg, **mode)) { this->Status.SetError( diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index 743ac75..bf52d75 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -294,11 +294,10 @@ void cmFindBase::FillUserGuessPath() bool cmFindBase::CheckForVariableInCache() { - if (const char* cacheValue = - this->Makefile->GetDefinition(this->VariableName)) { + if (cmProp cacheValue = this->Makefile->GetDefinition(this->VariableName)) { cmState* state = this->Makefile->GetState(); cmProp cacheEntry = state->GetCacheEntryValue(this->VariableName); - bool found = !cmIsNOTFOUND(cacheValue); + bool found = !cmIsNOTFOUND(*cacheValue); bool cached = cacheEntry != nullptr; if (found) { // If the user specifies the entry on the command line without a diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index 3401eff..dee91d7 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -11,6 +11,7 @@ #include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmProperty.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmake.h" @@ -182,9 +183,9 @@ void cmFindCommon::SelectDefaultSearchModes() }; for (auto& path : search_paths) { - const char* def = this->Makefile->GetDefinition(path.second); + cmProp def = this->Makefile->GetDefinition(path.second); if (def) { - path.first = !cmIsOn(def); + path.first = !cmIsOn(*def); } } } @@ -202,12 +203,11 @@ void cmFindCommon::RerootPaths(std::vector& paths) return; } - const char* sysroot = this->Makefile->GetDefinition("CMAKE_SYSROOT"); - const char* sysrootCompile = + cmProp sysroot = this->Makefile->GetDefinition("CMAKE_SYSROOT"); + cmProp sysrootCompile = this->Makefile->GetDefinition("CMAKE_SYSROOT_COMPILE"); - const char* sysrootLink = - this->Makefile->GetDefinition("CMAKE_SYSROOT_LINK"); - const char* rootPath = this->Makefile->GetDefinition("CMAKE_FIND_ROOT_PATH"); + cmProp sysrootLink = this->Makefile->GetDefinition("CMAKE_SYSROOT_LINK"); + cmProp rootPath = this->Makefile->GetDefinition("CMAKE_FIND_ROOT_PATH"); const bool noSysroot = !cmNonempty(sysroot); const bool noCompileSysroot = !cmNonempty(sysrootCompile); const bool noLinkSysroot = !cmNonempty(sysrootLink); @@ -219,23 +219,22 @@ void cmFindCommon::RerootPaths(std::vector& paths) // Construct the list of path roots with no trailing slashes. std::vector roots; if (rootPath) { - cmExpandList(rootPath, roots); + cmExpandList(*rootPath, roots); } if (sysrootCompile) { - roots.emplace_back(sysrootCompile); + roots.emplace_back(*sysrootCompile); } if (sysrootLink) { - roots.emplace_back(sysrootLink); + roots.emplace_back(*sysrootLink); } if (sysroot) { - roots.emplace_back(sysroot); + roots.emplace_back(*sysroot); } for (std::string& r : roots) { cmSystemTools::ConvertToUnixSlashes(r); } - const char* stagePrefix = - this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX"); + cmProp stagePrefix = this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX"); // Copy the original set of unrooted paths. std::vector unrootedPaths = paths; @@ -248,7 +247,7 @@ void cmFindCommon::RerootPaths(std::vector& paths) // a user home directory or is empty. std::string rootedDir; if (cmSystemTools::IsSubDirectory(up, r) || - (stagePrefix && cmSystemTools::IsSubDirectory(up, stagePrefix))) { + (stagePrefix && cmSystemTools::IsSubDirectory(up, *stagePrefix))) { rootedDir = up; } else if (!up.empty() && up[0] != '~') { // Start with the new root. diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index 3242b6d..b87dfe3 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -13,6 +13,7 @@ #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmProperty.h" #include "cmState.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" @@ -50,9 +51,9 @@ bool cmFindLibraryCommand::InitialPass(std::vector const& argsIn) // add custom lib paths instead of using fixed lib32, lib64 or // libx32 - if (const char* customLib = this->Makefile->GetDefinition( + if (cmProp customLib = this->Makefile->GetDefinition( "CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX")) { - this->AddArchitecturePaths(customLib); + this->AddArchitecturePaths(customLib->c_str()); } // add special 32 bit paths if this is a 32 bit compile. else if (this->Makefile->PlatformIs32Bit() && diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index ae06047..c462651 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -154,10 +154,10 @@ bool cmFindPackageCommand::InitialPass(std::vector const& args) } // Lookup required version of CMake. - if (const char* rv = + if (cmProp rv = this->Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION")) { unsigned int v[3] = { 0, 0, 0 }; - sscanf(rv, "%u.%u.%u", &v[0], &v[1], &v[2]); + sscanf(rv->c_str(), "%u.%u.%u", &v[0], &v[1], &v[2]); this->RequiredCMakeVersion = CMake_VERSION_ENCODE(v[0], v[1], v[2]); } @@ -165,9 +165,9 @@ bool cmFindPackageCommand::InitialPass(std::vector const& args) this->DebugBuffer.clear(); // Lookup target architecture, if any. - if (const char* arch = + if (cmProp arch = this->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE")) { - this->LibraryArchitecture = arch; + this->LibraryArchitecture = *arch; } // Lookup whether lib32 paths should be used. @@ -194,9 +194,9 @@ bool cmFindPackageCommand::InitialPass(std::vector const& args) // Check if User Package Registry should be disabled // The `CMAKE_FIND_USE_PACKAGE_REGISTRY` has // priority over the deprecated CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY - if (const char* def = + if (cmProp def = this->Makefile->GetDefinition("CMAKE_FIND_USE_PACKAGE_REGISTRY")) { - this->NoUserRegistry = !cmIsOn(def); + this->NoUserRegistry = !cmIsOn(*def); } else if (this->Makefile->IsOn("CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY")) { this->NoUserRegistry = true; } @@ -204,9 +204,9 @@ bool cmFindPackageCommand::InitialPass(std::vector const& args) // Check if System Package Registry should be disabled // The `CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY` has // priority over the deprecated CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY - if (const char* def = this->Makefile->GetDefinition( + if (cmProp def = this->Makefile->GetDefinition( "CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY")) { - this->NoSystemRegistry = !cmIsOn(def); + this->NoSystemRegistry = !cmIsOn(*def); } else if (this->Makefile->IsOn( "CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY")) { this->NoSystemRegistry = true; @@ -218,20 +218,20 @@ bool cmFindPackageCommand::InitialPass(std::vector const& args) } // Check if Sorting should be enabled - if (const char* so = + if (cmProp so = this->Makefile->GetDefinition("CMAKE_FIND_PACKAGE_SORT_ORDER")) { - if (strcmp(so, "NAME") == 0) { + if (*so == "NAME") { this->SortOrder = Name_order; - } else if (strcmp(so, "NATURAL") == 0) { + } else if (*so == "NATURAL") { this->SortOrder = Natural; } else { this->SortOrder = None; } } - if (const char* sd = + if (cmProp sd = this->Makefile->GetDefinition("CMAKE_FIND_PACKAGE_SORT_DIRECTION")) { - this->SortDirection = strcmp(sd, "ASC") == 0 ? Asc : Dec; + this->SortDirection = (*sd == "ASC") ? Asc : Dec; } // Find what search path locations have been enabled/disable @@ -675,9 +675,9 @@ void cmFindPackageCommand::SetModuleVariables(const std::string& components) void cmFindPackageCommand::AddFindDefinition(const std::string& var, const char* val) { - if (const char* old = this->Makefile->GetDefinition(var)) { + if (cmProp old = this->Makefile->GetDefinition(var)) { this->OriginalDefs[var].exists = true; - this->OriginalDefs[var].value = old; + this->OriginalDefs[var].value = *old; } else { this->OriginalDefs[var].exists = false; } @@ -759,14 +759,14 @@ bool cmFindPackageCommand::HandlePackageMode( this->ConsideredConfigs.clear(); // Try to find the config file. - const char* def = this->Makefile->GetDefinition(this->Variable); + cmProp def = this->Makefile->GetDefinition(this->Variable); // Try to load the config file if the directory is known bool fileFound = false; if (this->UseConfigFiles) { if (!cmIsOff(def)) { // Get the directory from the variable value. - std::string dir = def; + std::string dir = *def; cmSystemTools::ConvertToUnixSlashes(dir); // Treat relative paths with respect to the current source dir. diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index 3b82e0a..12fb55a 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -25,6 +25,7 @@ #include "cmListFileCache.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmProperty.h" #include "cmRange.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -113,8 +114,8 @@ bool cmForEachFunctionBlocker::ReplayItems( // At end of for each execute recorded commands // store the old value std::string oldDef; - if (auto d = mf.GetDefinition(this->Args.front())) { - oldDef = d; + if (cmProp d = mf.GetDefinition(this->Args.front())) { + oldDef = *d; } auto restore = false; @@ -186,8 +187,8 @@ bool cmForEachFunctionBlocker::ReplayZipLists( // Store old values for iteration variables std::map oldDefs; for (auto i = 0u; i < values.size(); ++i) { - if (auto d = mf.GetDefinition(iterationVars[i])) { - oldDefs.emplace(iterationVars[i], d); + if (cmProp d = mf.GetDefinition(iterationVars[i])) { + oldDefs.emplace(iterationVars[i], *d); } } diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 1cc1d18..d3308e2 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1741,7 +1741,7 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode for (auto const& lit : testedFeatures) { std::vector const& langAvailable = availableFeatures[lit.first]; - cmProp standardDefault = context->LG->GetMakefile()->GetDef( + cmProp standardDefault = context->LG->GetMakefile()->GetDefinition( "CMAKE_" + lit.first + "_STANDARD_DEFAULT"); for (std::string const& it : lit.second) { if (!cm::contains(langAvailable, it)) { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index dc5265f..05c8cc8 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -625,13 +625,13 @@ const char* cmGeneratorTarget::GetFilePrefixInternal( const char* prefixVar = this->Target->GetPrefixVariableInternal(artifact); if (!language.empty() && prefixVar && *prefixVar) { std::string langPrefix = prefixVar + std::string("_") + language; - targetPrefix = this->Makefile->GetDef(langPrefix); + targetPrefix = this->Makefile->GetDefinition(langPrefix); } // if there is no prefix on the target nor specific language // use the cmake definition. if (!targetPrefix && prefixVar) { - targetPrefix = this->Makefile->GetDef(prefixVar); + targetPrefix = this->Makefile->GetDefinition(prefixVar); } } @@ -675,13 +675,13 @@ const char* cmGeneratorTarget::GetFileSuffixInternal( const char* suffixVar = this->Target->GetSuffixVariableInternal(artifact); if (!language.empty() && suffixVar && *suffixVar) { std::string langSuffix = suffixVar + std::string("_") + language; - targetSuffix = this->Makefile->GetDef(langSuffix); + targetSuffix = this->Makefile->GetDefinition(langSuffix); } // if there is no suffix on the target nor specific language // use the cmake definition. if (!targetSuffix && suffixVar) { - targetSuffix = this->Makefile->GetDef(suffixVar); + targetSuffix = this->Makefile->GetDefinition(suffixVar); } } @@ -1167,10 +1167,10 @@ const std::string& cmGeneratorTarget::GetLocationForBuild() const // Now handle the deprecated build-time configuration location. std::string const noConfig; location = this->GetDirectory(noConfig); - const char* cfgid = this->Makefile->GetDefinition("CMAKE_CFG_INTDIR"); - if (cfgid && strcmp(cfgid, ".") != 0) { + cmProp cfgid = this->Makefile->GetDefinition("CMAKE_CFG_INTDIR"); + if (cfgid && (*cfgid != ".")) { location += "/"; - location += cfgid; + location += *cfgid; } if (this->IsAppBundleOnApple()) { @@ -2065,13 +2065,13 @@ bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const if (!ll.empty()) { std::string sepVar = cmStrCat("CMAKE_SHARED_LIBRARY_RUNTIME_", ll, "_FLAG_SEP"); - const char* sep = this->Makefile->GetDefinition(sepVar); + cmProp sep = this->Makefile->GetDefinition(sepVar); if (cmNonempty(sep)) { // TODO: Add ELF check to ABI detection and get rid of // CMAKE_EXECUTABLE_FORMAT. - if (const char* fmt = + if (cmProp fmt = this->Makefile->GetDefinition("CMAKE_EXECUTABLE_FORMAT")) { - return strcmp(fmt, "ELF") == 0; + return (*fmt == "ELF"); } } } @@ -3909,8 +3909,8 @@ std::string cmGeneratorTarget::GetPchHeader(const std::string& config, const std::string filename_tmp = cmStrCat(filename, ".tmp"); if (!pchReuseFrom) { - auto pchPrologue = this->Makefile->GetDefinition("CMAKE_PCH_PROLOGUE"); - auto pchEpilogue = this->Makefile->GetDefinition("CMAKE_PCH_EPILOGUE"); + cmProp pchPrologue = this->Makefile->GetDefinition("CMAKE_PCH_PROLOGUE"); + cmProp pchEpilogue = this->Makefile->GetDefinition("CMAKE_PCH_EPILOGUE"); std::string firstHeaderOnDisk; { @@ -3919,7 +3919,7 @@ std::string cmGeneratorTarget::GetPchHeader(const std::string& config, this->GetGlobalGenerator()->GetMakefileEncoding()); file << "/* generated by CMake */\n\n"; if (pchPrologue) { - file << pchPrologue << "\n"; + file << *pchPrologue << "\n"; } if (this->GetGlobalGenerator()->IsXcode()) { file << "#ifndef CMAKE_SKIP_PRECOMPILE_HEADERS\n"; @@ -3949,7 +3949,7 @@ std::string cmGeneratorTarget::GetPchHeader(const std::string& config, file << "#endif // CMAKE_SKIP_PRECOMPILE_HEADERS\n"; } if (pchEpilogue) { - file << pchEpilogue << "\n"; + file << *pchEpilogue << "\n"; } } @@ -4630,7 +4630,7 @@ bool cmGeneratorTarget::ComputeCompileFeatures( this->LanguageStandardMap[key] = *standardToCopy; generatorTargetLanguageStandard = &this->LanguageStandardMap[key]; } else { - cmProp defaultStandard = this->Makefile->GetDef( + cmProp defaultStandard = this->Makefile->GetDefinition( cmStrCat("CMAKE_", language.second, "_STANDARD_DEFAULT")); if (defaultStandard != nullptr) { this->LanguageStandardMap[key] = BTs(*defaultStandard); @@ -5952,7 +5952,7 @@ std::string cmGeneratorTarget::GetRuntimeLinkLibrary( { // This is activated by the presence of a default selection whether or // not it is overridden by a property. - cmProp runtimeLibraryDefault = this->Makefile->GetDef( + cmProp runtimeLibraryDefault = this->Makefile->GetDefinition( cmStrCat("CMAKE_", lang, "_RUNTIME_LIBRARY_DEFAULT")); if (!cmNonempty(runtimeLibraryDefault)) { return std::string(); @@ -5992,7 +5992,7 @@ std::string cmGeneratorTarget::CreateFortranModuleDirectory( target_mod_dir = default_mod_dir; } } - const char* moddir_flag = + cmProp moddir_flag = this->Makefile->GetDefinition("CMAKE_Fortran_MODDIR_FLAG"); if (!target_mod_dir.empty() && moddir_flag) { // Compute the full path to the module directory. diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx index 38bffbf..40e8a05 100644 --- a/Source/cmGetFilenameComponentCommand.cxx +++ b/Source/cmGetFilenameComponentCommand.cxx @@ -4,6 +4,7 @@ #include "cmExecutionStatus.h" #include "cmMakefile.h" +#include "cmProperty.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -21,8 +22,8 @@ bool cmGetFilenameComponentCommand(std::vector const& args, // Check and see if the value has been stored in the cache // already, if so use that value if (args.size() >= 4 && args.back() == "CACHE") { - const char* cacheValue = status.GetMakefile().GetDefinition(args.front()); - if (cacheValue && !cmIsNOTFOUND(cacheValue)) { + cmProp cacheValue = status.GetMakefile().GetDefinition(args.front()); + if (cacheValue && !cmIsNOTFOUND(*cacheValue)) { return true; } } diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx index cdfd8c8..7f60f85 100644 --- a/Source/cmGetPropertyCommand.cxx +++ b/Source/cmGetPropertyCommand.cxx @@ -430,8 +430,9 @@ bool HandleVariableMode(cmExecutionStatus& status, const std::string& name, return false; } - return StoreResult(infoType, status.GetMakefile(), variable, - status.GetMakefile().GetDefinition(propertyName)); + return StoreResult( + infoType, status.GetMakefile(), variable, + cmToCStr(status.GetMakefile().GetDefinition(propertyName))); } bool HandleCacheMode(cmExecutionStatus& status, const std::string& name, diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 1589c47..a8f8f57 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -43,9 +43,9 @@ cmGhsMultiTargetGenerator::cmGhsMultiTargetGenerator(cmGeneratorTarget* target) #endif { // Store the configuration name that is being used - if (const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE")) { + if (cmProp config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE")) { // Use the build type given by the user. - this->ConfigName = config; + this->ConfigName = *config; } else { // No configuration type given. this->ConfigName.clear(); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index a550b50..74360b8 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -780,27 +780,27 @@ void cmGlobalGenerator::EnableLanguage( std::string compilerName = cmStrCat("CMAKE_", lang, "_COMPILER"); std::string compilerEnv = cmStrCat("CMAKE_", lang, "_COMPILER_ENV_VAR"); std::ostringstream noCompiler; - const char* compilerFile = mf->GetDefinition(compilerName); - if (!cmNonempty(compilerFile) || cmIsNOTFOUND(compilerFile)) { + cmProp compilerFile = mf->GetDefinition(compilerName); + if (!cmNonempty(compilerFile) || cmIsNOTFOUND(*compilerFile)) { /* clang-format off */ noCompiler << "No " << compilerName << " could be found.\n" ; /* clang-format on */ } else if ((lang != "RC") && (lang != "ASM_MASM")) { - if (!cmSystemTools::FileIsFullPath(compilerFile)) { + if (!cmSystemTools::FileIsFullPath(*compilerFile)) { /* clang-format off */ noCompiler << "The " << compilerName << ":\n" - " " << compilerFile << "\n" + " " << *compilerFile << "\n" "is not a full path and was not found in the PATH.\n" ; /* clang-format on */ - } else if (!cmSystemTools::FileExists(compilerFile)) { + } else if (!cmSystemTools::FileExists(*compilerFile)) { /* clang-format off */ noCompiler << "The " << compilerName << ":\n" - " " << compilerFile << "\n" + " " << *compilerFile << "\n" "is not a full path to an existing compiler tool.\n" ; /* clang-format on */ @@ -817,7 +817,7 @@ void cmGlobalGenerator::EnableLanguage( cmSystemTools::RemoveFile(compilerLangFile); if (!this->CMakeInstance->GetIsInTryCompile()) { this->PrintCompilerAdvice(noCompiler, lang, - mf->GetDefinition(compilerEnv)); + cmToCStr(mf->GetDefinition(compilerEnv))); mf->IssueMessage(MessageType::FATAL_ERROR, noCompiler.str()); fatalError = true; } @@ -1095,17 +1095,16 @@ void cmGlobalGenerator::SetLanguageEnabledMaps(const std::string& l, return; } - std::string linkerPrefVar = - std::string("CMAKE_") + std::string(l) + std::string("_LINKER_PREFERENCE"); - const char* linkerPref = mf->GetDefinition(linkerPrefVar); + std::string linkerPrefVar = "CMAKE_" + l + "_LINKER_PREFERENCE"; + cmProp linkerPref = mf->GetDefinition(linkerPrefVar); int preference = 0; - if (linkerPref) { - if (sscanf(linkerPref, "%d", &preference) != 1) { + if (cmNonempty(linkerPref)) { + if (sscanf(linkerPref->c_str(), "%d", &preference) != 1) { // backward compatibility: before 2.6 LINKER_PREFERENCE // was either "None" or "Preferred", and only the first character was // tested. So if there is a custom language out there and it is // "Preferred", set its preference high - if (linkerPref[0] == 'P') { + if ((*linkerPref)[0] == 'P') { preference = 100; } else { preference = 0; @@ -1122,14 +1121,14 @@ void cmGlobalGenerator::SetLanguageEnabledMaps(const std::string& l, this->LanguageToLinkerPreference[l] = preference; - std::string outputExtensionVar = - std::string("CMAKE_") + std::string(l) + std::string("_OUTPUT_EXTENSION"); - const char* outputExtension = mf->GetDefinition(outputExtensionVar); - if (outputExtension) { + std::string outputExtensionVar = "CMAKE_" + l + "_OUTPUT_EXTENSION"; + if (cmProp p = mf->GetDefinition(outputExtensionVar)) { + std::string outputExtension = *p; this->LanguageToOutputExtension[l] = outputExtension; this->OutputExtensions[outputExtension] = outputExtension; - if (outputExtension[0] == '.') { - this->OutputExtensions[outputExtension + 1] = outputExtension + 1; + if (cmHasPrefix(outputExtension, ".")) { + outputExtension = outputExtension.substr(1); + this->OutputExtensions[outputExtension] = outputExtension; } } @@ -1162,7 +1161,7 @@ void cmGlobalGenerator::FillExtensionToLanguageMap(const std::string& l, const char* cmGlobalGenerator::GetGlobalSetting(std::string const& name) const { assert(!this->Makefiles.empty()); - return this->Makefiles[0]->GetDefinition(name); + return cmToCStr(this->Makefiles[0]->GetDefinition(name)); } bool cmGlobalGenerator::GlobalSettingIsOn(std::string const& name) const @@ -2463,9 +2462,9 @@ void cmGlobalGenerator::AddGlobalTarget_Package( if (this->GetPreinstallTargetName()) { gti.Depends.emplace_back(this->GetPreinstallTargetName()); } else { - const char* noPackageAll = + cmProp noPackageAll = mf->GetDefinition("CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY"); - if (!noPackageAll || cmIsOff(noPackageAll)) { + if (cmIsOff(noPackageAll)) { gti.Depends.emplace_back(this->GetAllTargetName()); } } @@ -2644,9 +2643,8 @@ void cmGlobalGenerator::AddGlobalTarget_Install( if (this->GetPreinstallTargetName()) { gti.Depends.emplace_back(this->GetPreinstallTargetName()); } else { - const char* noall = - mf->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY"); - if (!noall || cmIsOff(noall)) { + cmProp noall = mf->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY"); + if (cmIsOff(noall)) { gti.Depends.emplace_back(this->GetAllTargetName()); } } @@ -2666,7 +2664,7 @@ void cmGlobalGenerator::AddGlobalTarget_Install( singleLine.push_back(cfgArg); cfgArg = "-DEFFECTIVE_PLATFORM_NAME=$(EFFECTIVE_PLATFORM_NAME)"; } else { - cfgArg += mf->GetDefinition("CMAKE_CFG_INTDIR"); + cfgArg += cmToCStr(mf->GetDefinition("CMAKE_CFG_INTDIR")); } singleLine.push_back(cfgArg); } @@ -3074,7 +3072,7 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target) cmProp targetLabels = target->GetProperty("LABELS"); cmProp directoryLabels = target->Target->GetMakefile()->GetProperty("LABELS"); - const char* cmakeDirectoryLabels = + cmProp cmakeDirectoryLabels = target->Target->GetMakefile()->GetDefinition("CMAKE_DIRECTORY_LABELS"); if (targetLabels || directoryLabels || cmakeDirectoryLabels) { Json::Value lj_root(Json::objectValue); @@ -3110,7 +3108,7 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target) } if (cmakeDirectoryLabels) { - cmExpandList(cmakeDirectoryLabels, cmakeDirectoryLabelsList); + cmExpandList(*cmakeDirectoryLabels, cmakeDirectoryLabelsList); } if (!directoryLabelsList.empty() || !cmakeDirectoryLabelsList.empty()) { diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 7c87131..cbaf0ab 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -100,13 +100,13 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorToolset(std::string const& ts, /* set the build tool to use */ std::string gbuild(tsp + ((tsp.back() == '/') ? "" : "/") + DEFAULT_BUILD_PROGRAM); - const char* prevTool = mf->GetDefinition("CMAKE_MAKE_PROGRAM"); + cmProp prevTool = mf->GetDefinition("CMAKE_MAKE_PROGRAM"); /* check if the toolset changed from last generate */ - if (prevTool != nullptr && (gbuild != prevTool)) { + if (prevTool && (gbuild != *prevTool)) { std::string message = cmStrCat("toolset build tool: ", gbuild, - "\nDoes not match the previously used build tool: ", prevTool, + "\nDoes not match the previously used build tool: ", *prevTool, "\nEither remove the CMakeCache.txt file and CMakeFiles " "directory or choose a different binary directory."); cmSystemTools::Error(message); @@ -187,7 +187,8 @@ void cmGlobalGhsMultiGenerator::EnableLanguage( mf->AddDefinition("GHSMULTI", "1"); // identifier for user CMake files - const char* tgtPlatform = mf->GetDefinition("GHS_TARGET_PLATFORM"); + const char* tgtPlatform = + cmToCStrSafe(mf->GetDefinition("GHS_TARGET_PLATFORM")); if (!tgtPlatform) { cmSystemTools::Message("Green Hills MULTI: GHS_TARGET_PLATFORM not " "specified; defaulting to \"integrity\""); @@ -216,10 +217,10 @@ bool cmGlobalGhsMultiGenerator::FindMakeProgram(cmMakefile* /*mf*/) void cmGlobalGhsMultiGenerator::GetToolset(cmMakefile* mf, std::string& tsd, const std::string& ts) { - const char* ghsRoot = mf->GetDefinition("GHS_TOOLSET_ROOT"); + cmProp ghsRoot = mf->GetDefinition("GHS_TOOLSET_ROOT"); if (cmNonempty(ghsRoot)) { - tsd = ghsRoot; + tsd = *ghsRoot; } else { tsd = DEFAULT_TOOLSET_ROOT; } diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index ed61021..3cfdb8a 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -32,6 +32,7 @@ #include "cmMessageType.h" #include "cmNinjaLinkLineComputer.h" #include "cmOutputConverter.h" +#include "cmProperty.h" #include "cmRange.h" #include "cmState.h" #include "cmStateDirectory.h" @@ -614,8 +615,8 @@ bool cmGlobalNinjaGenerator::FindMakeProgram(cmMakefile* mf) if (!this->cmGlobalGenerator::FindMakeProgram(mf)) { return false; } - if (const char* ninjaCommand = mf->GetDefinition("CMAKE_MAKE_PROGRAM")) { - this->NinjaCommand = ninjaCommand; + if (cmProp ninjaCommand = mf->GetDefinition("CMAKE_MAKE_PROGRAM")) { + this->NinjaCommand = *ninjaCommand; std::vector command; command.push_back(this->NinjaCommand); command.emplace_back("--version"); diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index aa1b7ad..a12b7e1 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -239,8 +239,8 @@ std::string cmGlobalVisualStudio14Generator::GetWindows10SDKMaxVersion( { // if the given value is set, it can either be OFF/FALSE or a valid SDK // string - if (std::string const* value = - mf->GetDef("CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM")) { + if (cmProp value = mf->GetDefinition( + "CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM")) { // If the value is some off/false value, then there is NO maximum set. if (cmIsOff(value)) { diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index f8b438a..73a2caa 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -676,11 +676,11 @@ std::set cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild( "CMAKE_VS_INCLUDE_" + t + "_TO_DEFAULT_BUILD"; // inspect CMAKE_VS_INCLUDE__TO_DEFAULT_BUILD properties for (std::string const& i : configs) { - const char* propertyValue = + cmProp propertyValue = target->Target->GetMakefile()->GetDefinition(propertyName); if (propertyValue && cmIsOn(cmGeneratorExpression::Evaluate( - propertyValue, target->GetLocalGenerator(), i))) { + *propertyValue, target->GetLocalGenerator(), i))) { activeConfigs.insert(i); } } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 9f8e331..1cd73a0 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3539,12 +3539,11 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( this->CreateString(defaultConfigName)); cmXCodeObject* buildSettings = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); - const char* sysroot = - this->CurrentMakefile->GetDefinition("CMAKE_OSX_SYSROOT"); - const char* deploymentTarget = + cmProp sysroot = this->CurrentMakefile->GetDefinition("CMAKE_OSX_SYSROOT"); + cmProp deploymentTarget = this->CurrentMakefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET"); if (sysroot) { - buildSettings->AddAttribute("SDKROOT", this->CreateString(sysroot)); + buildSettings->AddAttribute("SDKROOT", this->CreateString(*sysroot)); } // recompute this as it may have been changed since enable language this->ComputeArchitectures(this->CurrentMakefile); @@ -3555,7 +3554,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( // When targeting macOS, use only the host architecture. if (this->SystemName == "Darwin"_s && (!cmNonempty(sysroot) || - cmSystemTools::LowerCase(sysroot).find("macos") != + cmSystemTools::LowerCase(*sysroot).find("macos") != std::string::npos)) { buildSettings->AddAttribute("ARCHS", this->CreateString("$(NATIVE_ARCH_ACTUAL)")); @@ -3566,7 +3565,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( } if (cmNonempty(deploymentTarget)) { buildSettings->AddAttribute(GetDeploymentPlatform(root->GetMakefile()), - this->CreateString(deploymentTarget)); + this->CreateString(*deploymentTarget)); } if (!this->GeneratorToolset.empty()) { buildSettings->AddAttribute("GCC_VERSION", @@ -3574,9 +3573,9 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( } if (this->GetLanguageEnabled("Swift")) { std::string swiftVersion; - if (const char* vers = this->CurrentMakefile->GetDefinition( + if (cmProp vers = this->CurrentMakefile->GetDefinition( "CMAKE_Swift_LANGUAGE_VERSION")) { - swiftVersion = vers; + swiftVersion = *vers; } else if (this->XcodeVersion >= 102) { swiftVersion = "4.0"; } else if (this->XcodeVersion >= 83) { @@ -3659,7 +3658,7 @@ std::string cmGlobalXCodeGenerator::GetObjectsDirectory( void cmGlobalXCodeGenerator::ComputeArchitectures(cmMakefile* mf) { this->Architectures.clear(); - const char* sysroot = mf->GetDefinition("CMAKE_OSX_SYSROOT"); + cmProp sysroot = mf->GetDefinition("CMAKE_OSX_SYSROOT"); if (sysroot) { mf->GetDefExpandList("CMAKE_OSX_ARCHITECTURES", this->Architectures); } @@ -3668,8 +3667,8 @@ void cmGlobalXCodeGenerator::ComputeArchitectures(cmMakefile* mf) // With no ARCHS we use ONLY_ACTIVE_ARCH and possibly a // platform-specific default ARCHS placeholder value. // Look up the arch that Xcode chooses in this case. - if (const char* arch = mf->GetDefinition("CMAKE_XCODE_ARCHS")) { - this->ObjectDirArchDefault = arch; + if (cmProp arch = mf->GetDefinition("CMAKE_XCODE_ARCHS")) { + this->ObjectDirArchDefault = *arch; // We expect only one arch but choose the first just in case. std::string::size_type pos = this->ObjectDirArchDefault.find(';'); if (pos != std::string::npos) { @@ -4035,9 +4034,9 @@ std::string cmGlobalXCodeGenerator::LookupFlags( { if (!varNameLang.empty()) { std::string varName = cmStrCat(varNamePrefix, varNameLang, varNameSuffix); - if (const char* varValue = this->CurrentMakefile->GetDefinition(varName)) { - if (*varValue) { - return varValue; + if (cmProp varValue = this->CurrentMakefile->GetDefinition(varName)) { + if (!varValue->empty()) { + return *varValue; } } } diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 8a7728e..cf4ba93 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -17,6 +17,7 @@ #include "cmLinkItem.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" +#include "cmProperty.h" #include "cmState.h" #include "cmStateSnapshot.h" #include "cmStringAlgorithms.h" @@ -229,9 +230,9 @@ void cmGraphVizWriter::ReadSettings( #define __set_if_set(var, cmakeDefinition) \ do { \ - const char* value = mf.GetDefinition(cmakeDefinition); \ + cmProp value = mf.GetDefinition(cmakeDefinition); \ if (value) { \ - (var) = value; \ + (var) = *value; \ } \ } while (false) @@ -241,9 +242,9 @@ void cmGraphVizWriter::ReadSettings( #define __set_bool_if_set(var, cmakeDefinition) \ do { \ - const char* value = mf.GetDefinition(cmakeDefinition); \ + cmProp value = mf.GetDefinition(cmakeDefinition); \ if (value) { \ - (var) = cmIsOn(value); \ + (var) = cmIsOn(*value); \ } \ } while (false) diff --git a/Source/cmIncludeGuardCommand.cxx b/Source/cmIncludeGuardCommand.cxx index ccb4496..aefd098 100644 --- a/Source/cmIncludeGuardCommand.cxx +++ b/Source/cmIncludeGuardCommand.cxx @@ -75,7 +75,7 @@ bool cmIncludeGuardCommand(std::vector const& args, } std::string includeGuardVar = GetIncludeGuardVariableName( - status.GetMakefile().GetDefinition("CMAKE_CURRENT_LIST_FILE")); + *status.GetMakefile().GetDefinition("CMAKE_CURRENT_LIST_FILE")); cmMakefile* const mf = &status.GetMakefile(); diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 178d5df..b3da202 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -820,7 +820,7 @@ void cmInstallTargetGenerator::AddStripRule(std::ostream& os, Indent indent, os << indent << "if(CMAKE_INSTALL_DO_STRIP)\n"; os << indent << " execute_process(COMMAND \"" - << this->Target->Target->GetMakefile()->GetDefinition("CMAKE_STRIP") + << this->Target->Target->GetMakefile()->GetSafeDefinition("CMAKE_STRIP") << "\" " << stripArgs << "\"" << toDestDirPath << "\")\n"; os << indent << "endif()\n"; } @@ -858,9 +858,9 @@ void cmInstallTargetGenerator::AddUniversalInstallRule( return; } - const char* xcodeVersion = mf->GetDefinition("XCODE_VERSION"); + cmProp xcodeVersion = mf->GetDefinition("XCODE_VERSION"); if (!xcodeVersion || - cmSystemTools::VersionCompareGreater("6", xcodeVersion)) { + cmSystemTools::VersionCompareGreater("6", *xcodeVersion)) { return; } diff --git a/Source/cmJsonObjects.cxx b/Source/cmJsonObjects.cxx index 3a2e3be..3a7ae0c 100644 --- a/Source/cmJsonObjects.cxx +++ b/Source/cmJsonObjects.cxx @@ -631,8 +631,8 @@ static Json::Value DumpProjectList(const cmake* cm, std::string const& config) // Project structure information: const cmMakefile* mf = lg->GetMakefile(); - auto minVersion = mf->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION"); - pObj[kMINIMUM_CMAKE_VERSION] = minVersion ? minVersion : ""; + auto minVersion = mf->GetSafeDefinition("CMAKE_MINIMUM_REQUIRED_VERSION"); + pObj[kMINIMUM_CMAKE_VERSION] = minVersion; pObj[kSOURCE_DIRECTORY_KEY] = mf->GetCurrentSourceDirectory(); pObj[kBUILD_DIRECTORY_KEY] = mf->GetCurrentBinaryDirectory(); pObj[kTARGETS_KEY] = DumpTargetsList(projectIt.second, config); diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index edec613..a2c14bd 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -27,6 +27,7 @@ #include "cmMakefile.h" #include "cmMessageType.h" #include "cmPolicies.h" +#include "cmProperty.h" #include "cmRange.h" #include "cmStringAlgorithms.h" #include "cmStringReplaceHelper.h" @@ -44,11 +45,11 @@ bool GetListString(std::string& listString, const std::string& var, const cmMakefile& makefile) { // get the old value - const char* cacheValue = makefile.GetDefinition(var); + cmProp cacheValue = makefile.GetDefinition(var); if (!cacheValue) { return false; } - listString = cacheValue; + listString = *cacheValue; return true; } diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx index 44db842..5daaeff 100644 --- a/Source/cmLocalCommonGenerator.cxx +++ b/Source/cmLocalCommonGenerator.cxx @@ -8,6 +8,7 @@ #include "cmGeneratorTarget.h" #include "cmMakefile.h" #include "cmOutputConverter.h" +#include "cmProperty.h" #include "cmStringAlgorithms.h" class cmGlobalGenerator; @@ -62,13 +63,13 @@ std::string cmLocalCommonGenerator::GetTargetFortranFlags( // If there is a separate module path flag then duplicate the // include path with it. This compiler does not search the include // path for modules. - if (const char* modpath_flag = + if (cmProp modpath_flag = this->Makefile->GetDefinition("CMAKE_Fortran_MODPATH_FLAG")) { std::vector includes; this->GetIncludeDirectories(includes, target, "C", config); for (std::string const& id : includes) { std::string flg = - cmStrCat(modpath_flag, + cmStrCat(*modpath_flag, this->ConvertToOutputFormat(id, cmOutputConverter::SHELL)); this->AppendFlags(flags, flg); } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 300bb26..f76770a 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -116,22 +116,22 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile) std::vector enabledLanguages = this->GetState()->GetEnabledLanguages(); - if (const char* sysrootCompile = + if (cmProp sysrootCompile = this->Makefile->GetDefinition("CMAKE_SYSROOT_COMPILE")) { - this->CompilerSysroot = sysrootCompile; + this->CompilerSysroot = *sysrootCompile; } else { this->CompilerSysroot = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT"); } - if (const char* sysrootLink = + if (cmProp sysrootLink = this->Makefile->GetDefinition("CMAKE_SYSROOT_LINK")) { - this->LinkerSysroot = sysrootLink; + this->LinkerSysroot = *sysrootLink; } else { this->LinkerSysroot = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT"); } if (cmProp appleArchSysroots = - this->Makefile->GetDef("CMAKE_APPLE_ARCH_SYSROOTS")) { + this->Makefile->GetDefinition("CMAKE_APPLE_ARCH_SYSROOTS")) { std::string const& appleArchs = this->Makefile->GetSafeDefinition("CMAKE_OSX_ARCHITECTURES"); std::vector archs; @@ -220,10 +220,10 @@ void cmLocalGenerator::ComputeObjectMaxPath() #else this->ObjectPathMax = 1000; #endif - const char* plen = this->Makefile->GetDefinition("CMAKE_OBJECT_PATH_MAX"); + cmProp plen = this->Makefile->GetDefinition("CMAKE_OBJECT_PATH_MAX"); if (cmNonempty(plen)) { unsigned int pmax; - if (sscanf(plen, "%u", &pmax) == 1) { + if (sscanf(plen->c_str(), "%u", &pmax) == 1) { if (pmax >= 128) { this->ObjectPathMax = pmax; } else { @@ -235,7 +235,7 @@ void cmLocalGenerator::ComputeObjectMaxPath() } } else { std::ostringstream w; - w << "CMAKE_OBJECT_PATH_MAX is set to \"" << plen + w << "CMAKE_OBJECT_PATH_MAX is set to \"" << *plen << "\", which fails to parse as a positive integer. " << "The value will be ignored."; this->IssueMessage(MessageType::AUTHOR_WARNING, w.str()); @@ -358,7 +358,7 @@ void cmLocalGenerator::GenerateTestFiles() } // Add directory labels property - const char* directoryLabels = + cmProp directoryLabels = this->Makefile->GetDefinition("CMAKE_DIRECTORY_LABELS"); cmProp labels = this->Makefile->GetProperty("LABELS"); @@ -371,7 +371,7 @@ void cmLocalGenerator::GenerateTestFiles() fout << ";"; } if (directoryLabels) { - fout << cmOutputConverter::EscapeForCMake(directoryLabels); + fout << cmOutputConverter::EscapeForCMake(*directoryLabels); } fout << ")\n"; } @@ -425,7 +425,8 @@ void cmLocalGenerator::ProcessEvaluationFiles( void cmLocalGenerator::GenerateInstallRules() { // Compute the install prefix. - const char* prefix = this->Makefile->GetDefinition("CMAKE_INSTALL_PREFIX"); + const char* prefix = + cmToCStr(this->Makefile->GetDefinition("CMAKE_INSTALL_PREFIX")); #if defined(_WIN32) && !defined(__CYGWIN__) std::string prefix_win32; @@ -433,10 +434,10 @@ void cmLocalGenerator::GenerateInstallRules() if (!cmSystemTools::GetEnv("SystemDrive", prefix_win32)) { prefix_win32 = "C:"; } - const char* project_name = this->Makefile->GetDefinition("PROJECT_NAME"); + cmProp project_name = this->Makefile->GetDefinition("PROJECT_NAME"); if (cmNonempty(project_name)) { prefix_win32 += "/Program Files/"; - prefix_win32 += project_name; + prefix_win32 += *project_name; } else { prefix_win32 += "/InstalledCMakeProject"; } @@ -457,9 +458,9 @@ void cmLocalGenerator::GenerateInstallRules() prefix = "/usr/local"; } #endif - if (const char* stagingPrefix = + if (cmProp stagingPrefix = this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX")) { - prefix = stagingPrefix; + prefix = stagingPrefix->c_str(); } // Compute the set of configurations. @@ -539,40 +540,40 @@ void cmLocalGenerator::GenerateInstallRules() /* clang-format on */ // Copy user-specified install options to the install code. - if (const char* so_no_exe = + if (cmProp so_no_exe = this->Makefile->GetDefinition("CMAKE_INSTALL_SO_NO_EXE")) { /* clang-format off */ fout << "# Install shared libraries without execute permission?\n" "if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)\n" - " set(CMAKE_INSTALL_SO_NO_EXE \"" << so_no_exe << "\")\n" + " set(CMAKE_INSTALL_SO_NO_EXE \"" << *so_no_exe << "\")\n" "endif()\n" "\n"; /* clang-format on */ } // Copy cmake cross compile state to install code. - if (const char* crosscompiling = + if (cmProp crosscompiling = this->Makefile->GetDefinition("CMAKE_CROSSCOMPILING")) { /* clang-format off */ fout << "# Is this installation the result of a crosscompile?\n" "if(NOT DEFINED CMAKE_CROSSCOMPILING)\n" - " set(CMAKE_CROSSCOMPILING \"" << crosscompiling << "\")\n" + " set(CMAKE_CROSSCOMPILING \"" << *crosscompiling << "\")\n" "endif()\n" "\n"; /* clang-format on */ } // Write default directory permissions. - if (const char* defaultDirPermissions = this->Makefile->GetDefinition( + if (cmProp defaultDirPermissions = this->Makefile->GetDefinition( "CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS")) { /* clang-format off */ fout << "# Set default install directory permissions.\n" "if(NOT DEFINED CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS)\n" " set(CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS \"" - << defaultDirPermissions << "\")\n" + << *defaultDirPermissions << "\")\n" "endif()\n" "\n"; /* clang-format on */ @@ -581,14 +582,14 @@ void cmLocalGenerator::GenerateInstallRules() // Write out CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM so that // installed code that uses `file(GET_RUNTIME_DEPENDENCIES)` // has same platform variable as when running cmake - if (const char* platform = this->Makefile->GetDefinition( + if (cmProp platform = this->Makefile->GetDefinition( "CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM")) { /* clang-format off */ fout << "# Set default install directory permissions.\n" "if(NOT DEFINED CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM)\n" " set(CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM \"" - << platform << "\")\n" + << *platform << "\")\n" "endif()\n" "\n"; /* clang-format on */ @@ -597,14 +598,14 @@ void cmLocalGenerator::GenerateInstallRules() // Write out CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL so that // installed code that uses `file(GET_RUNTIME_DEPENDENCIES)` // has same tool selected as when running cmake - if (const char* command = + if (cmProp command = this->Makefile->GetDefinition("CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL")) { /* clang-format off */ fout << "# Set default install directory permissions.\n" "if(NOT DEFINED CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL)\n" " set(CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL \"" - << command << "\")\n" + << *command << "\")\n" "endif()\n" "\n"; /* clang-format on */ @@ -613,14 +614,14 @@ void cmLocalGenerator::GenerateInstallRules() // Write out CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND so that // installed code that uses `file(GET_RUNTIME_DEPENDENCIES)` // has same path to the tool as when running cmake - if (const char* command = this->Makefile->GetDefinition( + if (cmProp command = this->Makefile->GetDefinition( "CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND")) { /* clang-format off */ fout << "# Set default install directory permissions.\n" "if(NOT DEFINED CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND)\n" " set(CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND \"" - << command << "\")\n" + << *command << "\")\n" "endif()\n" "\n"; /* clang-format on */ @@ -631,13 +632,13 @@ void cmLocalGenerator::GenerateInstallRules() // CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND has consistent // logic to fallback to CMAKE_OBJDUMP when `objdump` is // not on the path - if (const char* command = this->Makefile->GetDefinition("CMAKE_OBJDUMP")) { + if (cmProp command = this->Makefile->GetDefinition("CMAKE_OBJDUMP")) { /* clang-format off */ fout << "# Set default install directory permissions.\n" "if(NOT DEFINED CMAKE_OBJDUMP)\n" " set(CMAKE_OBJDUMP \"" - << command << "\")\n" + << *command << "\")\n" "endif()\n" "\n"; /* clang-format on */ @@ -858,8 +859,8 @@ std::string cmLocalGenerator::GetIncludeFlags( std::string const& includeFlag = this->Makefile->GetSafeDefinition(cmStrCat("CMAKE_INCLUDE_FLAG_", lang)); - const char* sep = - this->Makefile->GetDefinition(cmStrCat("CMAKE_INCLUDE_FLAG_SEP_", lang)); + const char* sep = cmToCStr( + this->Makefile->GetDefinition(cmStrCat("CMAKE_INCLUDE_FLAG_SEP_", lang))); bool quotePaths = false; if (this->Makefile->GetDefinition("CMAKE_QUOTE_INCLUDE_PATHS")) { quotePaths = true; @@ -876,15 +877,15 @@ std::string cmLocalGenerator::GetIncludeFlags( // Support special system include flag if it is available and the // normal flag is repeated for each directory. - const char* sysIncludeFlag = nullptr; + cmProp sysIncludeFlag = nullptr; if (repeatFlag) { sysIncludeFlag = this->Makefile->GetDefinition( cmStrCat("CMAKE_INCLUDE_SYSTEM_FLAG_", lang)); } - const char* fwSearchFlag = this->Makefile->GetDefinition( + cmProp fwSearchFlag = this->Makefile->GetDefinition( cmStrCat("CMAKE_", lang, "_FRAMEWORK_SEARCH_FLAG")); - const char* sysFwSearchFlag = this->Makefile->GetDefinition( + cmProp sysFwSearchFlag = this->Makefile->GetDefinition( cmStrCat("CMAKE_", lang, "_SYSTEM_FRAMEWORK_SEARCH_FLAG")); bool flagUsed = false; @@ -900,9 +901,9 @@ std::string cmLocalGenerator::GetIncludeFlags( if (emitted.insert(frameworkDir).second) { if (sysFwSearchFlag && target && target->IsSystemIncludeDirectory(i, config, lang)) { - includeFlags << sysFwSearchFlag; + includeFlags << *sysFwSearchFlag; } else { - includeFlags << fwSearchFlag; + includeFlags << *fwSearchFlag; } includeFlags << this->ConvertToOutputFormat(frameworkDir, shellFormat) << " "; @@ -913,7 +914,7 @@ std::string cmLocalGenerator::GetIncludeFlags( if (!flagUsed || repeatFlag) { if (sysIncludeFlag && target && target->IsSystemIncludeDirectory(i, config, lang)) { - includeFlags << sysIncludeFlag; + includeFlags << *sysIncludeFlag; } else { includeFlags << includeFlag; } @@ -953,9 +954,9 @@ void cmLocalGenerator::AddCompileOptions(std::vector>& flags, const std::string& lang, const std::string& config) { - std::string langFlagRegexVar = std::string("CMAKE_") + lang + "_FLAG_REGEX"; + std::string langFlagRegexVar = cmStrCat("CMAKE_", lang, "_FLAG_REGEX"); - if (const char* langFlagRegexStr = + if (cmProp langFlagRegexStr = this->Makefile->GetDefinition(langFlagRegexVar)) { // Filter flags acceptable to this language. if (cmProp targetFlags = target->GetProperty("COMPILE_FLAGS")) { @@ -964,7 +965,7 @@ void cmLocalGenerator::AddCompileOptions(std::vector>& flags, // Re-escape these flags since COMPILE_FLAGS were already parsed // as a command line above. std::string compileOpts; - this->AppendCompileOptions(compileOpts, opts, langFlagRegexStr); + this->AppendCompileOptions(compileOpts, opts, langFlagRegexStr->c_str()); if (!compileOpts.empty()) { flags.emplace_back(std::move(compileOpts)); } @@ -972,7 +973,8 @@ void cmLocalGenerator::AddCompileOptions(std::vector>& flags, std::vector> targetCompileOpts = target->GetCompileOptions(config, lang); // COMPILE_OPTIONS are escaped. - this->AppendCompileOptions(flags, targetCompileOpts, langFlagRegexStr); + this->AppendCompileOptions(flags, targetCompileOpts, + langFlagRegexStr->c_str()); } else { // Use all flags. if (cmProp targetFlags = target->GetProperty("COMPILE_FLAGS")) { @@ -1022,7 +1024,7 @@ void cmLocalGenerator::AddCompileOptions(std::vector>& flags, // Add compile flag for the MSVC compiler only. cmMakefile* mf = this->GetMakefile(); - if (const char* jmc = + if (cmProp jmc = mf->GetDefinition("CMAKE_" + lang + "_COMPILE_OPTIONS_JMC")) { // Handle Just My Code debugging flags, /JMC. @@ -1036,7 +1038,7 @@ void cmLocalGenerator::AddCompileOptions(std::vector>& flags, std::string isJMCEnabled = cmGeneratorExpression::Evaluate(*jmcExprGen, this, config); if (cmIsOn(isJMCEnabled)) { - std::vector optVec = cmExpandedList(jmc); + std::vector optVec = cmExpandedList(*jmc); std::string jmcFlags; this->AppendCompileOptions(jmcFlags, optVec); if (!jmcFlags.empty()) { @@ -1652,7 +1654,7 @@ static std::string GetFrameworkFlags(const std::string& lang, } std::string fwSearchFlagVar = "CMAKE_" + lang + "_FRAMEWORK_SEARCH_FLAG"; - const char* fwSearchFlag = mf->GetDefinition(fwSearchFlagVar); + cmProp fwSearchFlag = mf->GetDefinition(fwSearchFlagVar); if (!cmNonempty(fwSearchFlag)) { return std::string(); } @@ -1679,7 +1681,7 @@ static std::string GetFrameworkFlags(const std::string& lang, std::vector const& frameworks = cli->GetFrameworkPaths(); for (std::string const& framework : frameworks) { if (emitted.insert(framework).second) { - flags += fwSearchFlag; + flags += *fwSearchFlag; flags += lg->ConvertToOutputFormat(framework, cmOutputConverter::SHELL); flags += " "; @@ -1761,18 +1763,18 @@ void cmLocalGenerator::OutputLinkLibraries( std::string linkLanguage = cli.GetLinkLanguage(); std::string libPathFlag; - if (const char* value = this->Makefile->GetDefinition( + if (cmProp value = this->Makefile->GetDefinition( "CMAKE_" + cli.GetLinkLanguage() + "_LIBRARY_PATH_FLAG")) { - libPathFlag = value; + libPathFlag = *value; } else { libPathFlag = this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_FLAG"); } std::string libPathTerminator; - if (const char* value = this->Makefile->GetDefinition( + if (cmProp value = this->Makefile->GetDefinition( "CMAKE_" + cli.GetLinkLanguage() + "_LIBRARY_PATH_TERMINATOR")) { - libPathTerminator = value; + libPathTerminator = *value; } else { libPathTerminator = this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_TERMINATOR"); @@ -1886,16 +1888,15 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags, } } - const char* sysroot = this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT"); - if (sysroot && sysroot[0] == '/' && !sysroot[1]) { + cmProp sysroot = this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT"); + if (sysroot && *sysroot == "/") { sysroot = nullptr; } - std::string sysrootFlagVar = - std::string("CMAKE_") + lang + "_SYSROOT_FLAG"; - const char* sysrootFlag = this->Makefile->GetDefinition(sysrootFlagVar); + std::string sysrootFlagVar = "CMAKE_" + lang + "_SYSROOT_FLAG"; + cmProp sysrootFlag = this->Makefile->GetDefinition(sysrootFlagVar); if (cmNonempty(sysrootFlag)) { if (!this->AppleArchSysroots.empty() && - !this->AllAppleArchSysrootsAreTheSame(archs, sysroot)) { + !this->AllAppleArchSysrootsAreTheSame(archs, cmToCStr(sysroot))) { for (std::string const& arch : archs) { std::string const& archSysroot = this->AppleArchSysroots[arch]; if (cmIsOff(archSysroot)) { @@ -1904,28 +1905,28 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags, if (filterArch.empty() || filterArch == arch) { flags += " -Xarch_" + arch + " "; // Combine sysroot flag and path to work with -Xarch - std::string arch_sysroot = sysrootFlag + archSysroot; + std::string arch_sysroot = *sysrootFlag + archSysroot; flags += this->ConvertToOutputFormat(arch_sysroot, SHELL); } } - } else if (sysroot && *sysroot) { + } else if (cmNonempty(sysroot)) { flags += " "; - flags += sysrootFlag; + flags += *sysrootFlag; flags += " "; - flags += this->ConvertToOutputFormat(sysroot, SHELL); + flags += this->ConvertToOutputFormat(*sysroot, SHELL); } } - const char* deploymentTarget = + cmProp deploymentTarget = this->Makefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET"); std::string deploymentTargetFlagVar = - std::string("CMAKE_") + lang + "_OSX_DEPLOYMENT_TARGET_FLAG"; - const char* deploymentTargetFlag = + "CMAKE_" + lang + "_OSX_DEPLOYMENT_TARGET_FLAG"; + cmProp deploymentTargetFlag = this->Makefile->GetDefinition(deploymentTargetFlagVar); if (cmNonempty(deploymentTargetFlag) && cmNonempty(deploymentTarget)) { flags += " "; - flags += deploymentTargetFlag; - flags += deploymentTarget; + flags += *deploymentTargetFlag; + flags += *deploymentTarget; } } } @@ -1944,10 +1945,10 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, if (lang == "Swift") { if (cmProp v = target->GetProperty("Swift_LANGUAGE_VERSION")) { - if (cmSystemTools::VersionCompare( - cmSystemTools::OP_GREATER_EQUAL, - this->Makefile->GetDefinition("CMAKE_Swift_COMPILER_VERSION"), - "4.2")) { + if (cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER_EQUAL, + cmToCStr(this->Makefile->GetDefinition( + "CMAKE_Swift_COMPILER_VERSION")), + "4.2")) { this->AppendFlags(flags, "-swift-version " + *v); } } @@ -1968,7 +1969,7 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, } // Add VFS Overlay for Clang compiliers if (compiler == "Clang") { - if (const char* vfsOverlay = + if (cmProp vfsOverlay = this->Makefile->GetDefinition("CMAKE_CLANG_VFS_OVERLAY")) { std::string const& compilerSimulateId = this->Makefile->GetSafeDefinition( @@ -1977,17 +1978,17 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, this->AppendCompileOptions( flags, std::vector{ "-Xclang", "-ivfsoverlay", "-Xclang", - vfsOverlay }); + *vfsOverlay }); } else { this->AppendCompileOptions( - flags, std::vector{ "-ivfsoverlay", vfsOverlay }); + flags, std::vector{ "-ivfsoverlay", *vfsOverlay }); } } } // Add MSVC runtime library flags. This is activated by the presence // of a default selection whether or not it is overridden by a property. cmProp msvcRuntimeLibraryDefault = - this->Makefile->GetDef("CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT"); + this->Makefile->GetDefinition("CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT"); if (cmNonempty(msvcRuntimeLibraryDefault)) { cmProp msvcRuntimeLibraryValue = target->GetProperty("MSVC_RUNTIME_LIBRARY"); @@ -1997,11 +1998,10 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, std::string const msvcRuntimeLibrary = cmGeneratorExpression::Evaluate( *msvcRuntimeLibraryValue, this, config, target); if (!msvcRuntimeLibrary.empty()) { - if (const char* msvcRuntimeLibraryOptions = - this->Makefile->GetDefinition( - "CMAKE_" + lang + "_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_" + - msvcRuntimeLibrary)) { - this->AppendCompileOptions(flags, msvcRuntimeLibraryOptions); + if (cmProp msvcRuntimeLibraryOptions = this->Makefile->GetDefinition( + "CMAKE_" + lang + "_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_" + + msvcRuntimeLibrary)) { + this->AppendCompileOptions(flags, *msvcRuntimeLibraryOptions); } else if ((this->Makefile->GetSafeDefinition( "CMAKE_" + lang + "_COMPILER_ID") == "MSVC" || this->Makefile->GetSafeDefinition( @@ -2178,9 +2178,9 @@ void cmLocalGenerator::AddCompilerRequirementFlag( std::string const& optionFlagDef = standardResolver.GetCompileOptionDef(target, lang, config); if (!optionFlagDef.empty()) { - auto opt = target->Target->GetMakefile()->GetDefinition(optionFlagDef); + cmProp opt = target->Target->GetMakefile()->GetDefinition(optionFlagDef); if (opt) { - std::vector optVec = cmExpandedList(opt); + std::vector optVec = cmExpandedList(*opt); for (std::string const& i : optVec) { this->AppendFlagEscape(flags, i); } @@ -2195,7 +2195,7 @@ static void AddVisibilityCompileOption(std::string& flags, std::string* warnCMP0063) { std::string compileOption = "CMAKE_" + lang + "_COMPILE_OPTIONS_VISIBILITY"; - const char* opt = lg->GetMakefile()->GetDefinition(compileOption); + cmProp opt = lg->GetMakefile()->GetDefinition(compileOption); if (!opt) { return; } @@ -2219,7 +2219,7 @@ static void AddVisibilityCompileOption(std::string& flags, cmSystemTools::Error(e.str()); return; } - std::string option = opt + *prop; + std::string option = *opt + *prop; lg->AppendFlags(flags, option); } @@ -2231,7 +2231,7 @@ static void AddInlineVisibilityCompileOption(std::string& flags, { std::string compileOption = cmStrCat("CMAKE_", lang, "_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN"); - const char* opt = lg->GetMakefile()->GetDefinition(compileOption); + cmProp opt = lg->GetMakefile()->GetDefinition(compileOption); if (!opt) { return; } @@ -2244,7 +2244,7 @@ static void AddInlineVisibilityCompileOption(std::string& flags, *warnCMP0063 += " VISIBILITY_INLINES_HIDDEN\n"; return; } - lg->AppendFlags(flags, opt); + lg->AppendFlags(flags, *opt); } void cmLocalGenerator::AddVisibilityPresetFlags( @@ -2917,12 +2917,12 @@ void cmLocalGenerator::AppendIPOLinkerFlags(std::string& flags, } const std::string name = "CMAKE_" + lang + "_LINK_OPTIONS_IPO"; - const char* rawFlagsList = this->Makefile->GetDefinition(name); + cmProp rawFlagsList = this->Makefile->GetDefinition(name); if (rawFlagsList == nullptr) { return; } - std::vector flagsList = cmExpandedList(rawFlagsList); + std::vector flagsList = cmExpandedList(*rawFlagsList); for (std::string const& o : flagsList) { this->AppendFlagEscape(flags, o); } @@ -3108,10 +3108,10 @@ void cmLocalGenerator::JoinDefines(const std::set& defines, // Lookup the define flag for the current language. std::string dflag = "-D"; if (!lang.empty()) { - const char* df = + cmProp df = this->Makefile->GetDefinition(cmStrCat("CMAKE_", lang, "_DEFINE_FLAG")); if (cmNonempty(df)) { - dflag = df; + dflag = *df; } } const char* itemSeparator = definesString.empty() ? "" : " "; @@ -3155,10 +3155,10 @@ void cmLocalGenerator::AppendFeatureOptions(std::string& flags, const std::string& lang, const char* feature) { - const char* optionList = this->Makefile->GetDefinition( + cmProp optionList = this->Makefile->GetDefinition( cmStrCat("CMAKE_", lang, "_COMPILE_OPTIONS_", feature)); if (optionList != nullptr) { - std::vector options = cmExpandedList(optionList); + std::vector options = cmExpandedList(*optionList); for (std::string const& o : options) { this->AppendFlagEscape(flags, o); } @@ -3613,9 +3613,9 @@ KWIML_INT_uint64_t cmLocalGenerator::GetBackwardsCompatibility() unsigned int major = 0; unsigned int minor = 0; unsigned int patch = 0; - if (const char* value = + if (cmProp value = this->Makefile->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY")) { - switch (sscanf(value, "%u.%u.%u", &major, &minor, &patch)) { + switch (sscanf(value->c_str(), "%u.%u.%u", &major, &minor, &patch)) { case 2: patch = 0; break; diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index eb841d9..2188d7f 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -312,7 +312,7 @@ void cmLocalNinjaGenerator::WritePools(std::ostream& os) cmProp jobpools = this->GetCMakeInstance()->GetState()->GetGlobalProperty("JOB_POOLS"); if (!jobpools) { - jobpools = this->GetMakefile()->GetDef("CMAKE_JOB_POOLS"); + jobpools = this->GetMakefile()->GetDefinition("CMAKE_JOB_POOLS"); } if (jobpools) { cmGlobalNinjaGenerator::WriteComment( @@ -363,7 +363,8 @@ void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os) { cmGlobalNinjaGenerator::WriteDivider(os); os << "# Write statements declared in CMakeLists.txt:\n" - << "# " << this->Makefile->GetDefinition("CMAKE_CURRENT_LIST_FILE") + << "# " + << cmToCStr(this->Makefile->GetDefinition("CMAKE_CURRENT_LIST_FILE")) << '\n'; if (this->IsRootMakefile()) { os << "# Which is the root file.\n"; diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 26b0989..9825f1c 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -519,9 +519,9 @@ void cmLocalUnixMakefileGenerator3::WriteMakeRule( // Mark the rule as symbolic if requested. if (symbolic) { - if (const char* sym = + if (cmProp sym = this->Makefile->GetDefinition("CMAKE_MAKE_SYMBOLIC_RULE")) { - os << tgt << space << ": " << sym << "\n"; + os << tgt << space << ": " << *sym << "\n"; } } @@ -833,9 +833,8 @@ void cmLocalUnixMakefileGenerator3::AppendRuleDepend( { // Add a dependency on the rule file itself unless an option to skip // it is specifically enabled by the user or project. - const char* nodep = - this->Makefile->GetDefinition("CMAKE_SKIP_RULE_DEPENDENCY"); - if (!nodep || cmIsOff(nodep)) { + cmProp nodep = this->Makefile->GetDefinition("CMAKE_SKIP_RULE_DEPENDENCY"); + if (cmIsOff(nodep)) { depends.emplace_back(ruleFileName); } } @@ -1395,22 +1394,22 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies( // Lookup useful directory information. if (haveDirectoryInfo) { // Test whether we need to force Unix paths. - if (const char* force = mf->GetDefinition("CMAKE_FORCE_UNIX_PATHS")) { + if (cmProp force = mf->GetDefinition("CMAKE_FORCE_UNIX_PATHS")) { if (!cmIsOff(force)) { cmSystemTools::SetForceUnixPaths(true); } } // Setup relative path top directories. - if (const char* relativePathTopSource = + if (cmProp relativePathTopSource = mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_SOURCE")) { this->StateSnapshot.GetDirectory().SetRelativePathTopSource( - relativePathTopSource); + relativePathTopSource->c_str()); } - if (const char* relativePathTopBinary = + if (cmProp relativePathTopBinary = mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_BINARY")) { this->StateSnapshot.GetDirectory().SetRelativePathTopBinary( - relativePathTopBinary); + relativePathTopBinary->c_str()); } } else { cmSystemTools::Error("Directory Information file not found"); @@ -1478,13 +1477,13 @@ void cmLocalUnixMakefileGenerator3::CheckMultipleOutputs(bool verbose) cmMakefile* mf = this->Makefile; // Get the string listing the multiple output pairs. - const char* pairs_string = mf->GetDefinition("CMAKE_MULTIPLE_OUTPUT_PAIRS"); + cmProp pairs_string = mf->GetDefinition("CMAKE_MULTIPLE_OUTPUT_PAIRS"); if (!pairs_string) { return; } // Convert the string to a list and preserve empty entries. - std::vector pairs = cmExpandedList(pairs_string, true); + std::vector pairs = cmExpandedList(*pairs_string, true); for (auto i = pairs.begin(); i != pairs.end() && (i + 1) != pairs.end();) { const std::string& depender = *i++; const std::string& dependee = *i++; @@ -1650,9 +1649,9 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( recursiveTarget = cmStrCat(this->GetCurrentBinaryDirectory(), "/preinstall"); commands.clear(); depends.clear(); - const char* noall = + cmProp noall = this->Makefile->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY"); - if (!noall || cmIsOff(noall)) { + if (cmIsOff(noall)) { // Drive the build before installing. depends.emplace_back("all"); } else if (regenerate) { @@ -1700,11 +1699,11 @@ void cmLocalUnixMakefileGenerator3::ClearDependencies(cmMakefile* mf, bool verbose) { // Get the list of target files to check - const char* infoDef = mf->GetDefinition("CMAKE_DEPEND_INFO_FILES"); + cmProp infoDef = mf->GetDefinition("CMAKE_DEPEND_INFO_FILES"); if (!infoDef) { return; } - std::vector files = cmExpandedList(infoDef); + std::vector files = cmExpandedList(*infoDef); // Each depend information file corresponds to a target. Clear the // dependencies for that target. @@ -1808,10 +1807,10 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo( // Tell the dependency scanner what compiler is used. std::string cidVar = cmStrCat("CMAKE_", implicitLang.first, "_COMPILER_ID"); - const char* cid = this->Makefile->GetDefinition(cidVar); + cmProp cid = this->Makefile->GetDefinition(cidVar); if (cmNonempty(cid)) { cmakefileStream << "set(CMAKE_" << implicitLang.first - << "_COMPILER_ID \"" << cid << "\")\n"; + << "_COMPILER_ID \"" << *cid << "\")\n"; } if (implicitLang.first == "Fortran") { diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index ee7f74c..fb10022 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -593,8 +593,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( std::ostream& fout, const std::string& configName, const std::string& libName, cmGeneratorTarget* target) { - const char* mfcFlag = this->Makefile->GetDefinition("CMAKE_MFC_FLAG"); - if (!mfcFlag) { + std::string mfcFlag; + if (cmProp p = this->Makefile->GetDefinition("CMAKE_MFC_FLAG")) { + mfcFlag = *p; + } else { mfcFlag = "0"; } cmGlobalVisualStudio7Generator* gg = @@ -1087,9 +1089,9 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( } } std::string stackVar = cmStrCat("CMAKE_", linkLanguage, "_STACK_SIZE"); - const char* stackVal = this->Makefile->GetDefinition(stackVar); + cmProp stackVal = this->Makefile->GetDefinition(stackVar); if (stackVal) { - fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"\n"; + fout << "\t\t\t\tStackReserveSize=\"" << *stackVal << "\"\n"; } temp = cmStrCat( target->GetDirectory(configName, cmStateEnums::ImportLibraryArtifact), @@ -1176,9 +1178,9 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( << "\"\n"; } std::string stackVar = cmStrCat("CMAKE_", linkLanguage, "_STACK_SIZE"); - const char* stackVal = this->Makefile->GetDefinition(stackVar); + cmProp stackVal = this->Makefile->GetDefinition(stackVar); if (stackVal) { - fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\""; + fout << "\t\t\t\tStackReserveSize=\"" << *stackVal << "\""; } temp = cmStrCat( target->GetDirectory(configName, cmStateEnums::ImportLibraryArtifact), diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index ebd4f96..6d6ed9f 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -172,13 +172,12 @@ std::string cmLocalVisualStudioGenerator::ConstructScript( // for visual studio IDE add extra stuff to the PATH // if CMAKE_MSVCIDE_RUN_PATH is set. if (this->Makefile->GetDefinition("MSVC_IDE")) { - const char* extraPath = - this->Makefile->GetDefinition("CMAKE_MSVCIDE_RUN_PATH"); + cmProp extraPath = this->Makefile->GetDefinition("CMAKE_MSVCIDE_RUN_PATH"); if (extraPath) { script += newline; newline = newline_text; script += "set PATH="; - script += extraPath; + script += *extraPath; script += ";%PATH%"; } } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index d9d4ae8..f384e21 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -194,7 +194,7 @@ void cmMakefile::MaybeWarnCMP0074(std::string const& pkg) { // Warn if a _ROOT variable we may use is set. std::string const varName = pkg + "_ROOT"; - const char* var = this->GetDefinition(varName); + cmProp var = this->GetDefinition(varName); std::string env; cmSystemTools::GetEnv(varName, env); @@ -205,7 +205,7 @@ void cmMakefile::MaybeWarnCMP0074(std::string const& pkg) w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0074) << "\n"; if (haveVar) { w << "CMake variable " << varName << " is set to:\n" - << " " << var << "\n"; + << " " << *var << "\n"; } if (haveEnv) { w << "Environment variable " << varName << " is set to:\n" @@ -441,9 +441,9 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, // Check for maximum recursion depth. int depth = CMake_DEFAULT_RECURSION_LIMIT; - const char* depthStr = this->GetDefinition("CMAKE_MAXIMUM_RECURSION_DEPTH"); + cmProp depthStr = this->GetDefinition("CMAKE_MAXIMUM_RECURSION_DEPTH"); if (depthStr) { - std::istringstream s(depthStr); + std::istringstream s(*depthStr); int d; if (s >> d) { depth = d; @@ -627,8 +627,8 @@ void cmMakefile::IncludeScope::EnforceCMP0011() bool cmMakefile::ReadDependentFile(const std::string& filename, bool noPolicyScope) { - if (const char* def = this->GetDefinition("CMAKE_CURRENT_LIST_FILE")) { - this->AddDefinition("CMAKE_PARENT_LIST_FILE", def); + if (cmProp def = this->GetDefinition("CMAKE_CURRENT_LIST_FILE")) { + this->AddDefinition("CMAKE_PARENT_LIST_FILE", *def); } std::string filenametoread = cmSystemTools::CollapseFullPath( filename, this->GetCurrentSourceDirectory()); @@ -891,9 +891,10 @@ void cmMakefile::DoGenerate(cmLocalGenerator& lg) void cmMakefile::Generate(cmLocalGenerator& lg) { this->DoGenerate(lg); - const char* oldValue = this->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY"); + cmProp oldValue = this->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY"); if (oldValue && - cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, oldValue, "2.4")) { + cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, oldValue->c_str(), + "2.4")) { this->GetCMakeInstance()->IssueMessage( MessageType::FATAL_ERROR, "You have set CMAKE_BACKWARDS_COMPATIBILITY to a CMake version less " @@ -2378,8 +2379,10 @@ cmSourceGroup* cmMakefile::GetOrCreateSourceGroup( cmSourceGroup* cmMakefile::GetOrCreateSourceGroup(const std::string& name) { - const char* delimiters = this->GetDefinition("SOURCE_GROUP_DELIMITER"); - if (delimiters == nullptr) { + std::string delimiters; + if (cmProp p = this->GetDefinition("SOURCE_GROUP_DELIMITER")) { + delimiters = *p; + } else { delimiters = "/\\"; } return this->GetOrCreateSourceGroup(cmTokenize(name, delimiters)); @@ -2523,21 +2526,21 @@ void cmMakefile::ExpandVariablesCMP0019() bool cmMakefile::IsOn(const std::string& name) const { - return cmIsOn(this->GetDef(name)); + return cmIsOn(this->GetDefinition(name)); } bool cmMakefile::IsSet(const std::string& name) const { - const char* value = this->GetDefinition(name); + cmProp value = this->GetDefinition(name); if (!value) { return false; } - if (!*value) { + if (value->empty()) { return false; } - if (cmIsNOTFOUND(value)) { + if (cmIsNOTFOUND(*value)) { return false; } @@ -2546,31 +2549,29 @@ bool cmMakefile::IsSet(const std::string& name) const bool cmMakefile::PlatformIs32Bit() const { - if (const char* plat_abi = - this->GetDefinition("CMAKE_INTERNAL_PLATFORM_ABI")) { - if (strcmp(plat_abi, "ELF X32") == 0) { + if (cmProp plat_abi = this->GetDefinition("CMAKE_INTERNAL_PLATFORM_ABI")) { + if (*plat_abi == "ELF X32") { return false; } } - if (const char* sizeof_dptr = this->GetDefinition("CMAKE_SIZEOF_VOID_P")) { - return atoi(sizeof_dptr) == 4; + if (cmProp sizeof_dptr = this->GetDefinition("CMAKE_SIZEOF_VOID_P")) { + return atoi(sizeof_dptr->c_str()) == 4; } return false; } bool cmMakefile::PlatformIs64Bit() const { - if (const char* sizeof_dptr = this->GetDefinition("CMAKE_SIZEOF_VOID_P")) { - return atoi(sizeof_dptr) == 8; + if (cmProp sizeof_dptr = this->GetDefinition("CMAKE_SIZEOF_VOID_P")) { + return atoi(sizeof_dptr->c_str()) == 8; } return false; } bool cmMakefile::PlatformIsx32() const { - if (const char* plat_abi = - this->GetDefinition("CMAKE_INTERNAL_PLATFORM_ABI")) { - if (strcmp(plat_abi, "ELF X32") == 0) { + if (cmProp plat_abi = this->GetDefinition("CMAKE_INTERNAL_PLATFORM_ABI")) { + if (*plat_abi == "ELF X32") { return true; } } @@ -2619,7 +2620,7 @@ const char* cmMakefile::GetSONameFlag(const std::string& language) const name += language; } name += "_FLAG"; - return GetDefinition(name); + return cmToCStr(GetDefinition(name)); } bool cmMakefile::CanIWriteThisFile(std::string const& fileName) const @@ -2642,7 +2643,7 @@ const std::string& cmMakefile::GetRequiredDefinition( const std::string& name) const { static std::string const empty; - const std::string* def = GetDef(name); + const std::string* def = GetDefinition(name); if (!def) { cmSystemTools::Error("Error required internal CMake variable not " "set, cmake may not be built correctly.\n" @@ -2670,7 +2671,7 @@ bool cmMakefile::IsDefinitionSet(const std::string& name) const return def != nullptr; } -const std::string* cmMakefile::GetDef(const std::string& name) const +cmProp cmMakefile::GetDefinition(const std::string& name) const { cmProp def = this->StateSnapshot.GetDefinition(name); if (!def) { @@ -2699,19 +2700,10 @@ const std::string* cmMakefile::GetDef(const std::string& name) const return def; } -const char* cmMakefile::GetDefinition(const std::string& name) const -{ - const std::string* def = GetDef(name); - if (!def) { - return nullptr; - } - return def->c_str(); -} - const std::string& cmMakefile::GetSafeDefinition(const std::string& name) const { static std::string const empty; - const std::string* def = GetDef(name); + const std::string* def = GetDefinition(name); if (!def) { return empty; } @@ -2722,7 +2714,7 @@ bool cmMakefile::GetDefExpandList(const std::string& name, std::vector& out, bool emptyArgs) const { - cmProp def = this->GetDef(name); + cmProp def = this->GetDefinition(name); if (!def) { return false; } @@ -2875,12 +2867,12 @@ MessageType cmMakefile::ExpandVariablesInStringOld( // Lookup the definition of VAR. std::string var(first + 1, last - first - 2); - if (const char* val = this->GetDefinition(var)) { + if (cmProp val = this->GetDefinition(var)) { // Store the value in the output escaping as requested. if (escapeQuotes) { - source.append(cmEscapeQuotes(val)); + source.append(cmEscapeQuotes(*val)); } else { - source.append(val); + source.append(*val); } } @@ -3026,7 +3018,7 @@ MessageType cmMakefile::ExpandVariablesInStringNew( if (filename && lookup == lineVar) { varresult = std::to_string(line); } else { - value = this->GetDef(lookup); + value = this->GetDefinition(lookup); } break; case ENVIRONMENT: @@ -3158,7 +3150,7 @@ MessageType cmMakefile::ExpandVariablesInStringNew( if (filename && variable == lineVar) { varresult = std::to_string(line); } else { - const std::string* def = this->GetDef(variable); + const std::string* def = this->GetDefinition(variable); if (def) { varresult = *def; } else if (!this->SuppressSideEffects) { @@ -3676,19 +3668,18 @@ int cmMakefile::TryCompile(const std::string& srcdir, cm.SetGeneratorToolset(this->GetSafeDefinition("CMAKE_GENERATOR_TOOLSET")); cm.LoadCache(); if (!cm.GetGlobalGenerator()->IsMultiConfig()) { - if (const char* config = + if (cmProp config = this->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION")) { // Tell the single-configuration generator which one to use. // Add this before the user-provided CMake arguments in case // one of the arguments is -DCMAKE_BUILD_TYPE=... - cm.AddCacheEntry("CMAKE_BUILD_TYPE", config, "Build configuration", - cmStateEnums::STRING); + cm.AddCacheEntry("CMAKE_BUILD_TYPE", config->c_str(), + "Build configuration", cmStateEnums::STRING); } } - const char* recursionDepth = - this->GetDefinition("CMAKE_MAXIMUM_RECURSION_DEPTH"); + cmProp recursionDepth = this->GetDefinition("CMAKE_MAXIMUM_RECURSION_DEPTH"); if (recursionDepth) { - cm.AddCacheEntry("CMAKE_MAXIMUM_RECURSION_DEPTH", recursionDepth, + cm.AddCacheEntry("CMAKE_MAXIMUM_RECURSION_DEPTH", recursionDepth->c_str(), "Maximum recursion depth", cmStateEnums::STRING); } // if cmake args were provided then pass them in @@ -3821,9 +3812,9 @@ std::string cmMakefile::GetModulesFile(const std::string& filename, std::string moduleInCMakeModulePath; // Always search in CMAKE_MODULE_PATH: - const char* cmakeModulePath = this->GetDefinition("CMAKE_MODULE_PATH"); + cmProp cmakeModulePath = this->GetDefinition("CMAKE_MODULE_PATH"); if (cmakeModulePath) { - std::vector modulePath = cmExpandedList(cmakeModulePath); + std::vector modulePath = cmExpandedList(*cmakeModulePath); // Look through the possible module directories. for (std::string itempl : modulePath) { @@ -3862,14 +3853,14 @@ std::string cmMakefile::GetModulesFile(const std::string& filename, } if (!moduleInCMakeModulePath.empty() && !moduleInCMakeRoot.empty()) { - const char* currentFile = this->GetDefinition("CMAKE_CURRENT_LIST_FILE"); + cmProp currentFile = this->GetDefinition("CMAKE_CURRENT_LIST_FILE"); std::string mods = cmSystemTools::GetCMakeRoot() + "/Modules/"; - if (currentFile && cmSystemTools::IsSubDirectory(currentFile, mods)) { + if (currentFile && cmSystemTools::IsSubDirectory(*currentFile, mods)) { switch (this->GetPolicyStatus(cmPolicies::CMP0017)) { case cmPolicies::WARN: { std::ostringstream e; /* clang-format off */ - e << "File " << currentFile << " includes " + e << "File " << *currentFile << " includes " << moduleInCMakeModulePath << " (found via CMAKE_MODULE_PATH) which shadows " << moduleInCMakeRoot << ". This may cause errors later on .\n" @@ -3919,7 +3910,7 @@ void cmMakefile::ConfigureString(const std::string& input, std::string& output, // Replace #cmakedefine instances. if (this->cmDefineRegex.find(line)) { - const char* def = this->GetDefinition(this->cmDefineRegex.match(2)); + cmProp def = this->GetDefinition(this->cmDefineRegex.match(2)); if (!cmIsOff(def)) { const std::string indentation = this->cmDefineRegex.match(1); cmSystemTools::ReplaceString(line, "#" + indentation + "cmakedefine", @@ -3932,7 +3923,7 @@ void cmMakefile::ConfigureString(const std::string& input, std::string& output, } } else if (this->cmDefine01Regex.find(line)) { const std::string indentation = this->cmDefine01Regex.match(1); - const char* def = this->GetDefinition(this->cmDefine01Regex.match(2)); + cmProp def = this->GetDefinition(this->cmDefine01Regex.match(2)); cmSystemTools::ReplaceString(line, "#" + indentation + "cmakedefine01", "#" + indentation + "define"); output += line; @@ -4457,11 +4448,11 @@ static std::string const nMatchesVariable = "CMAKE_MATCH_COUNT"; void cmMakefile::ClearMatches() { - const char* nMatchesStr = this->GetDefinition(nMatchesVariable); + cmProp nMatchesStr = this->GetDefinition(nMatchesVariable); if (!nMatchesStr) { return; } - int nMatches = atoi(nMatchesStr); + int nMatches = atoi(nMatchesStr->c_str()); for (int i = 0; i <= nMatches; i++) { std::string const& var = matchVariables[i]; std::string const& s = this->GetSafeDefinition(var); @@ -4510,7 +4501,7 @@ cmPolicies::PolicyStatus cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id, bool cmMakefile::PolicyOptionalWarningEnabled(std::string const& var) { // Check for an explicit CMAKE_POLICY_WARNING_CMP setting. - if (const char* val = this->GetDefinition(var)) { + if (cmProp val = this->GetDefinition(var)) { return cmIsOn(val); } // Enable optional policy warnings with --debug-output, --trace, diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 69894b1..350f59d 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -515,8 +515,7 @@ public: * If the variable is not found in this makefile instance, the * cache is then queried. */ - const char* GetDefinition(const std::string&) const; - const std::string* GetDef(const std::string&) const; + cmProp GetDefinition(const std::string&) const; const std::string& GetSafeDefinition(const std::string&) const; const std::string& GetRequiredDefinition(const std::string& name) const; bool IsDefinitionSet(const std::string&) const; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index afbbbd4..8d62328 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -257,14 +257,14 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() this->GeneratorTarget->GetExtraSources(extraSources, this->GetConfigName()); this->OSXBundleGenerator->GenerateMacOSXContentStatements( extraSources, this->MacOSXContentGenerator.get(), this->GetConfigName()); - const char* pchExtension = - this->Makefile->GetDefinition("CMAKE_PCH_EXTENSION"); + cmProp pchExtension = this->Makefile->GetDefinition("CMAKE_PCH_EXTENSION"); std::vector externalObjects; this->GeneratorTarget->GetExternalObjects(externalObjects, this->GetConfigName()); for (cmSourceFile const* sf : externalObjects) { auto const& objectFileName = sf->GetFullPath(); - if (!cmSystemTools::StringEndsWith(objectFileName, pchExtension)) { + if (!cmSystemTools::StringEndsWith(objectFileName, + cmToCStr(pchExtension))) { this->ExternalObjects.push_back(objectFileName); } } @@ -814,13 +814,13 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( langIncludes.size(), this->GetIncludes(lang, this->GetConfigName())); - const char* eliminate[] = { + cmProp eliminate[] = { this->Makefile->GetDefinition("CMAKE_START_TEMP_FILE"), this->Makefile->GetDefinition("CMAKE_END_TEMP_FILE") }; - for (const char* el : eliminate) { + for (cmProp el : eliminate) { if (el) { - cmSystemTools::ReplaceString(compileCommand, el, ""); + cmSystemTools::ReplaceString(compileCommand, *el, ""); } } @@ -866,9 +866,12 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( } if (cmNonempty(tidy)) { run_iwyu += " --tidy="; - const char* driverMode = this->Makefile->GetDefinition( - "CMAKE_" + lang + "_CLANG_TIDY_DRIVER_MODE"); - if (!cmNonempty(driverMode)) { + cmProp p = this->Makefile->GetDefinition("CMAKE_" + lang + + "_CLANG_TIDY_DRIVER_MODE"); + std::string driverMode; + if (cmNonempty(p)) { + driverMode = *p; + } else { driverMode = lang == "C" ? "gcc" : "g++"; } run_iwyu += this->LocalGenerator->EscapeForShell( @@ -977,10 +980,10 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( std::string preprocessRuleVar = cmStrCat("CMAKE_", lang, "_CREATE_PREPROCESSED_SOURCE"); - if (const char* preprocessRule = + if (cmProp preprocessRule = this->Makefile->GetDefinition(preprocessRuleVar)) { std::vector preprocessCommands = - cmExpandedList(preprocessRule); + cmExpandedList(*preprocessRule); std::string shellObjI = this->LocalGenerator->ConvertToOutputFormat( objI, cmOutputConverter::SHELL); @@ -1022,10 +1025,10 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( std::string assemblyRuleVar = cmStrCat("CMAKE_", lang, "_CREATE_ASSEMBLY_SOURCE"); - if (const char* assemblyRule = + if (cmProp assemblyRule = this->Makefile->GetDefinition(assemblyRuleVar)) { std::vector assemblyCommands = - cmExpandedList(assemblyRule); + cmExpandedList(*assemblyRule); std::string shellObjS = this->LocalGenerator->ConvertToOutputFormat( objS, cmOutputConverter::SHELL); @@ -1372,17 +1375,17 @@ void cmMakefileTargetGenerator::WriteObjectsVariable( << this->GeneratorTarget->GetName() << "\n" << variableName << " ="; std::string object; - const char* lineContinue = - this->Makefile->GetDefinition("CMAKE_MAKE_LINE_CONTINUE"); - if (!lineContinue) { + std::string lineContinue; + if (cmProp p = this->Makefile->GetDefinition("CMAKE_MAKE_LINE_CONTINUE")) { + lineContinue = *p; + } else { lineContinue = "\\"; } - const char* pchExtension = - this->Makefile->GetDefinition("CMAKE_PCH_EXTENSION"); + cmProp pchExtension = this->Makefile->GetDefinition("CMAKE_PCH_EXTENSION"); for (std::string const& obj : this->Objects) { - if (cmSystemTools::StringEndsWith(obj, pchExtension)) { + if (cmSystemTools::StringEndsWith(obj, cmToCStr(pchExtension))) { continue; } *this->BuildFileStream << " " << lineContinue << "\n"; @@ -1477,14 +1480,13 @@ private: void cmMakefileTargetGenerator::WriteObjectsStrings( std::vector& objStrings, std::string::size_type limit) { - const char* pchExtension = - this->Makefile->GetDefinition("CMAKE_PCH_EXTENSION"); + cmProp pchExtension = this->Makefile->GetDefinition("CMAKE_PCH_EXTENSION"); cmMakefileTargetGeneratorObjectStrings helper( objStrings, this->LocalGenerator, this->LocalGenerator->GetStateSnapshot().GetDirectory(), limit); for (std::string const& obj : this->Objects) { - if (cmSystemTools::StringEndsWith(obj, pchExtension)) { + if (cmSystemTools::StringEndsWith(obj, cmToCStr(pchExtension))) { continue; } helper.Feed(obj); @@ -1607,8 +1609,8 @@ std::string cmMakefileTargetGenerator::GetLinkRule( cmStrCat("CMAKE_", this->GeneratorTarget->GetLinkerLanguage(this->GetConfigName()), "_GNUtoMS_RULE"); - if (const char* rule = this->Makefile->GetDefinition(ruleVar)) { - linkRule += rule; + if (cmProp rule = this->Makefile->GetDefinition(ruleVar)) { + linkRule += *rule; } } return linkRule; @@ -1657,8 +1659,8 @@ bool cmMakefileTargetGenerator::CheckUseResponseFileForObjects( // Check for an explicit setting one way or the other. std::string const responseVar = "CMAKE_" + l + "_USE_RESPONSE_FILE_FOR_OBJECTS"; - if (const char* val = this->Makefile->GetDefinition(responseVar)) { - if (*val) { + if (cmProp val = this->Makefile->GetDefinition(responseVar)) { + if (!val->empty()) { return cmIsOn(val); } } @@ -1696,8 +1698,8 @@ bool cmMakefileTargetGenerator::CheckUseResponseFileForLibraries( // Check for an explicit setting one way or the other. std::string const responseVar = "CMAKE_" + l + "_USE_RESPONSE_FILE_FOR_LIBRARIES"; - if (const char* val = this->Makefile->GetDefinition(responseVar)) { - if (*val) { + if (cmProp val = this->Makefile->GetDefinition(responseVar)) { + if (!val->empty()) { return cmIsOn(val); } } @@ -1758,8 +1760,10 @@ void cmMakefileTargetGenerator::CreateLinkLibs( cmStrCat("CMAKE_", this->GeneratorTarget->GetLinkerLanguage(this->GetConfigName()), "_RESPONSE_FILE_LINK_FLAG"); - const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar); - if (!responseFlag) { + std::string responseFlag; + if (cmProp p = this->Makefile->GetDefinition(responseFlagVar)) { + responseFlag = *p; + } else { responseFlag = "@"; } @@ -1796,8 +1800,10 @@ void cmMakefileTargetGenerator::CreateObjectLists( cmStrCat("CMAKE_", this->GeneratorTarget->GetLinkerLanguage(this->GetConfigName()), "_RESPONSE_FILE_LINK_FLAG"); - const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar); - if (!responseFlag) { + std::string responseFlag; + if (cmProp p = this->Makefile->GetDefinition(responseFlagVar)) { + responseFlag = *p; + } else { responseFlag = "@"; } @@ -1892,11 +1898,11 @@ void cmMakefileTargetGenerator::GenDefFile( this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), objlist_file), cmOutputConverter::SHELL); - const char* nm_executable = this->Makefile->GetDefinition("CMAKE_NM"); + cmProp nm_executable = this->Makefile->GetDefinition("CMAKE_NM"); if (cmNonempty(nm_executable)) { cmd += " --nm="; cmd += this->LocalCommonGenerator->ConvertToOutputFormat( - nm_executable, cmOutputConverter::SHELL); + *nm_executable, cmOutputConverter::SHELL); } real_link_commands.insert(real_link_commands.begin(), cmd); // create a list of obj files for the -E __create_def to read diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index bde5ee7..59f5e25 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -307,10 +307,10 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile, // build response file name std::string cmakeLinkVar = cmakeVarLang + "_RESPONSE_FILE_LINK_FLAG"; - const char* flag = GetMakefile()->GetDefinition(cmakeLinkVar); + cmProp flag = GetMakefile()->GetDefinition(cmakeLinkVar); if (flag) { - responseFlag = flag; + responseFlag = *flag; } else { responseFlag = "@"; } @@ -478,15 +478,15 @@ std::vector cmNinjaNormalTargetGenerator::ComputeLinkCmd( // CMAKE__CREATE_STATIC_LIBRARY_IPO define instead. std::string linkCmdVar = this->GetGeneratorTarget()->GetCreateRuleVariable( this->TargetLinkLanguage(config), config); - const char* linkCmd = mf->GetDefinition(linkCmdVar); + cmProp linkCmd = mf->GetDefinition(linkCmdVar); if (linkCmd) { - std::string linkCmdStr = linkCmd; + std::string linkCmdStr = *linkCmd; if (this->GetGeneratorTarget()->HasImplibGNUtoMS(config)) { std::string ruleVar = cmStrCat("CMAKE_", this->GeneratorTarget->GetLinkerLanguage(config), "_GNUtoMS_RULE"); - if (const char* rule = this->Makefile->GetDefinition(ruleVar)) { - linkCmdStr += rule; + if (cmProp rule = this->Makefile->GetDefinition(ruleVar)) { + linkCmdStr += *rule; } } cmExpandList(linkCmdStr, linkCmds); @@ -1027,8 +1027,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement( gt->GetFullNameComponents(prefix, base, suffix, config); std::string dbg_suffix = ".dbg"; // TODO: Where to document? - if (auto d = mf->GetDefinition("CMAKE_DEBUG_SYMBOL_SUFFIX")) { - dbg_suffix = d; + if (cmProp d = mf->GetDefinition("CMAKE_DEBUG_SYMBOL_SUFFIX")) { + dbg_suffix = *d; } vars["TARGET_PDB"] = base + suffix + dbg_suffix; } @@ -1091,11 +1091,11 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement( cmd += this->GetLocalGenerator()->ConvertToOutputFormat( obj_list_file, cmOutputConverter::SHELL); - const char* nm_executable = GetMakefile()->GetDefinition("CMAKE_NM"); + cmProp nm_executable = GetMakefile()->GetDefinition("CMAKE_NM"); if (cmNonempty(nm_executable)) { cmd += " --nm="; cmd += this->LocalCommonGenerator->ConvertToOutputFormat( - nm_executable, cmOutputConverter::SHELL); + *nm_executable, cmOutputConverter::SHELL); } preLinkCmdLines.push_back(std::move(cmd)); @@ -1144,7 +1144,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement( // build response file name std::string cmakeLinkVar = cmakeVarLang + "_RESPONSE_FILE_LINK_FLAG"; - const char* flag = GetMakefile()->GetDefinition(cmakeLinkVar); + cmProp flag = GetMakefile()->GetDefinition(cmakeLinkVar); bool const lang_supports_response = !(this->TargetLinkLanguage(config) == "RC" || diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 96e0c69..857333c 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -762,9 +762,9 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, if (!mf->GetIsSourceFileTryCompile()) { rule.DepType = "gcc"; rule.DepFile = "$DEP_FILE"; - auto d = mf->GetDefinition("CMAKE_C_COMPILER"); + cmProp d = mf->GetDefinition("CMAKE_C_COMPILER"); const std::string cl = - d ? d : mf->GetSafeDefinition("CMAKE_CXX_COMPILER"); + d ? *d : mf->GetSafeDefinition("CMAKE_CXX_COMPILER"); cldeps = cmStrCat('"', cmSystemTools::GetCMClDepsCommand(), "\" ", lang, ' ', vars.Source, " $DEP_FILE $out \"", mf->GetSafeDefinition("CMAKE_CL_SHOWINCLUDES_PREFIX"), @@ -778,8 +778,9 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, if (!depfileFlags.empty()) { cmSystemTools::ReplaceString(depfileFlags, "", "$DEP_FILE"); cmSystemTools::ReplaceString(depfileFlags, "", "$out"); - cmSystemTools::ReplaceString(depfileFlags, "", - mf->GetDefinition("CMAKE_C_COMPILER")); + cmSystemTools::ReplaceString( + depfileFlags, "", + cmToCStr(mf->GetDefinition("CMAKE_C_COMPILER"))); flags += cmStrCat(' ', depfileFlags); } } @@ -847,9 +848,12 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, } if (cmNonempty(tidy)) { run_iwyu += " --tidy="; - const char* driverMode = this->Makefile->GetDefinition( + cmProp p = this->Makefile->GetDefinition( cmStrCat("CMAKE_", lang, "_CLANG_TIDY_DRIVER_MODE")); - if (!cmNonempty(driverMode)) { + std::string driverMode; + if (cmNonempty(p)) { + driverMode = *p; + } else { driverMode = lang == "C" ? "gcc" : "g++"; } run_iwyu += this->GetLocalGenerator()->EscapeForShell( @@ -942,15 +946,15 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements( config); } if (firstForConfig) { - const char* pchExtension = - GetMakefile()->GetDefinition("CMAKE_PCH_EXTENSION"); + cmProp pchExtension = GetMakefile()->GetDefinition("CMAKE_PCH_EXTENSION"); std::vector externalObjects; this->GeneratorTarget->GetExternalObjects(externalObjects, config); for (cmSourceFile const* sf : externalObjects) { auto objectFileName = this->GetGlobalGenerator()->ExpandCFGIntDir( this->GetSourceFilePath(sf), config); - if (!cmSystemTools::StringEndsWith(objectFileName, pchExtension)) { + if (!cmSystemTools::StringEndsWith(objectFileName, + cmToCStr(pchExtension))) { this->Configs[config].Objects.push_back(objectFileName); } } @@ -1159,7 +1163,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( // build response file name std::string cmakeLinkVar = cmStrCat(cmakeVarLang, "_RESPONSE_FILE_FLAG"); - const char* flag = GetMakefile()->GetDefinition(cmakeLinkVar); + cmProp flag = GetMakefile()->GetDefinition(cmakeLinkVar); bool const lang_supports_response = !(language == "RC" || (language == "CUDA" && !flag)); @@ -1200,9 +1204,10 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( objBuild.Outputs.push_back(objectFileName); if (firstForConfig) { - const char* pchExtension = + cmProp pchExtension = this->GetMakefile()->GetDefinition("CMAKE_PCH_EXTENSION"); - if (!cmSystemTools::StringEndsWith(objectFileName, pchExtension)) { + if (!cmSystemTools::StringEndsWith(objectFileName, + cmToCStr(pchExtension))) { // Add this object to the list of object files. this->Configs[config].Objects.push_back(objectFileName); } diff --git a/Source/cmParseArgumentsCommand.cxx b/Source/cmParseArgumentsCommand.cxx index d712edb..2465069 100644 --- a/Source/cmParseArgumentsCommand.cxx +++ b/Source/cmParseArgumentsCommand.cxx @@ -13,6 +13,7 @@ #include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmProperty.h" #include "cmRange.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -195,7 +196,7 @@ bool cmParseArgumentsCommand(std::vector const& args, for (unsigned long i = argvStart; i < count; ++i) { std::ostringstream argName; argName << "ARGV" << i; - const char* arg = status.GetMakefile().GetDefinition(argName.str()); + cmProp arg = status.GetMakefile().GetDefinition(argName.str()); if (!arg) { status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, "PARSE_ARGV called with " + @@ -203,7 +204,7 @@ bool cmParseArgumentsCommand(std::vector const& args, cmSystemTools::SetFatalErrorOccured(); return true; } - list.emplace_back(arg); + list.emplace_back(*arg); } } diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index bb6db92..0cfba63 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -15,6 +15,7 @@ #include "cmMakefile.h" #include "cmMessageType.h" #include "cmPolicies.h" +#include "cmProperty.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -302,7 +303,7 @@ bool cmProjectCommand(std::vector const& args, } std::string vw; for (std::string const& i : vv) { - const char* const v = mf.GetDefinition(i); + cmProp v = mf.GetDefinition(i); if (cmNonempty(v)) { if (cmp0048 == cmPolicies::WARN) { if (!injectedProjectCommand) { @@ -352,12 +353,12 @@ static bool IncludeByVariable(cmExecutionStatus& status, const std::string& variable) { cmMakefile& mf = status.GetMakefile(); - const char* const include = mf.GetDefinition(variable); + cmProp include = mf.GetDefinition(variable); if (!include) { return true; } - const bool readit = mf.ReadDependentFile(include); + const bool readit = mf.ReadDependentFile(*include); if (readit) { return true; } @@ -366,7 +367,7 @@ static bool IncludeByVariable(cmExecutionStatus& status, return true; } - status.SetError(cmStrCat("could not find file:\n ", include)); + status.SetError(cmStrCat("could not find file:\n ", *include)); return false; } diff --git a/Source/cmProperty.h b/Source/cmProperty.h index b0fcce7..47eec93 100644 --- a/Source/cmProperty.h +++ b/Source/cmProperty.h @@ -26,4 +26,14 @@ public: using cmProp = const std::string*; +inline const char* cmToCStr(cmProp p) +{ + return p ? p->c_str() : nullptr; +} + +inline const char* cmToCStrSafe(cmProp p) +{ + return p ? p->c_str() : ""; +} + #endif diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 187b256..3b62e9c 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -1758,8 +1758,8 @@ cmQtAutoGenInitializer::GetQtVersion(cmGeneratorTarget const* target) // Read versions from variables for (auto const& keyPair : keys) { - addVersion(target->Makefile->GetDef(std::string(keyPair.first)), - target->Makefile->GetDef(std::string(keyPair.second))); + addVersion(target->Makefile->GetDefinition(std::string(keyPair.first)), + target->Makefile->GetDefinition(std::string(keyPair.second))); } // Read versions from directory properties diff --git a/Source/cmRemoveCommand.cxx b/Source/cmRemoveCommand.cxx index 457b708..1345588 100644 --- a/Source/cmRemoveCommand.cxx +++ b/Source/cmRemoveCommand.cxx @@ -4,6 +4,7 @@ #include "cmExecutionStatus.h" #include "cmMakefile.h" +#include "cmProperty.h" #include "cmStringAlgorithms.h" // cmRemoveCommand @@ -16,7 +17,7 @@ bool cmRemoveCommand(std::vector const& args, std::string const& variable = args[0]; // VAR is always first // get the old value - const char* cacheValue = status.GetMakefile().GetDefinition(variable); + cmProp cacheValue = status.GetMakefile().GetDefinition(variable); // if there is no old value then return if (!cacheValue) { @@ -24,7 +25,7 @@ bool cmRemoveCommand(std::vector const& args, } // expand the variable - std::vector const varArgsExpanded = cmExpandedList(cacheValue); + std::vector const varArgsExpanded = cmExpandedList(*cacheValue); // expand the args // check for REMOVE(VAR v1 v2 ... vn) diff --git a/Source/cmSearchPath.cxx b/Source/cmSearchPath.cxx index eb8fcaf..a58be62 100644 --- a/Source/cmSearchPath.cxx +++ b/Source/cmSearchPath.cxx @@ -8,6 +8,7 @@ #include "cmFindCommon.h" #include "cmMakefile.h" +#include "cmProperty.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -77,8 +78,8 @@ void cmSearchPath::AddCMakePath(const std::string& variable) assert(this->FC != nullptr); // Get a path from a CMake variable. - if (const char* value = this->FC->Makefile->GetDefinition(variable)) { - std::vector expanded = cmExpandedList(value); + if (cmProp value = this->FC->Makefile->GetDefinition(variable)) { + std::vector expanded = cmExpandedList(*value); for (std::string const& p : expanded) { this->AddPathInternal( @@ -101,8 +102,8 @@ void cmSearchPath::AddCMakePrefixPath(const std::string& variable) assert(this->FC != nullptr); // Get a path from a CMake variable. - if (const char* value = this->FC->Makefile->GetDefinition(variable)) { - std::vector expanded = cmExpandedList(value); + if (cmProp value = this->FC->Makefile->GetDefinition(variable)) { + std::vector expanded = cmExpandedList(*value); this->AddPrefixPaths( expanded, this->FC->Makefile->GetCurrentSourceDirectory().c_str()); @@ -178,15 +179,15 @@ void cmSearchPath::AddPrefixPaths(const std::vector& paths, dir += "/"; } if (subdir == "include" || subdir == "lib") { - const char* arch = + cmProp arch = this->FC->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE"); if (cmNonempty(arch)) { if (this->FC->Makefile->IsDefinitionSet("CMAKE_SYSROOT") && this->FC->Makefile->IsDefinitionSet( "CMAKE_PREFIX_LIBRARY_ARCHITECTURE")) { - this->AddPathInternal(cmStrCat('/', arch, dir, subdir), base); + this->AddPathInternal(cmStrCat('/', *arch, dir, subdir), base); } else { - this->AddPathInternal(cmStrCat(dir, subdir, '/', arch), base); + this->AddPathInternal(cmStrCat(dir, subdir, '/', *arch), base); } } } diff --git a/Source/cmSeparateArgumentsCommand.cxx b/Source/cmSeparateArgumentsCommand.cxx index cfe3087..e45f3b0 100644 --- a/Source/cmSeparateArgumentsCommand.cxx +++ b/Source/cmSeparateArgumentsCommand.cxx @@ -6,6 +6,7 @@ #include "cmExecutionStatus.h" #include "cmMakefile.h" +#include "cmProperty.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -65,8 +66,8 @@ bool cmSeparateArgumentsCommand(std::vector const& args, if (mode == ModeOld) { // Original space-replacement version of command. - if (const char* def = status.GetMakefile().GetDefinition(var)) { - std::string value = def; + if (cmProp def = status.GetMakefile().GetDefinition(var)) { + std::string value = *def; std::replace(value.begin(), value.end(), ' ', ';'); status.GetMakefile().AddDefinition(var, value); } diff --git a/Source/cmSiteNameCommand.cxx b/Source/cmSiteNameCommand.cxx index b2d905e..58af8f0 100644 --- a/Source/cmSiteNameCommand.cxx +++ b/Source/cmSiteNameCommand.cxx @@ -6,6 +6,7 @@ #include "cmExecutionStatus.h" #include "cmMakefile.h" +#include "cmProperty.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -26,15 +27,15 @@ bool cmSiteNameCommand(std::vector const& args, paths.emplace_back("/sbin"); paths.emplace_back("/usr/local/bin"); - const char* cacheValue = status.GetMakefile().GetDefinition(args[0]); + cmProp cacheValue = status.GetMakefile().GetDefinition(args[0]); if (cacheValue) { return true; } - const char* temp = status.GetMakefile().GetDefinition("HOSTNAME"); + cmProp temp = status.GetMakefile().GetDefinition("HOSTNAME"); std::string hostname_cmd; if (temp) { - hostname_cmd = temp; + hostname_cmd = *temp; } else { hostname_cmd = cmSystemTools::FindProgram("hostname", paths); } diff --git a/Source/cmStandardLevelResolver.cxx b/Source/cmStandardLevelResolver.cxx index 6dbab98..8672f61 100644 --- a/Source/cmStandardLevelResolver.cxx +++ b/Source/cmStandardLevelResolver.cxx @@ -63,7 +63,7 @@ struct StanardLevelComputer const auto& stds = this->Levels; const auto& stdsStrings = this->LevelsAsStrings; - const char* defaultStd = makefile->GetDefinition( + cmProp defaultStd = makefile->GetDefinition( cmStrCat("CMAKE_", this->Language, "_STANDARD_DEFAULT")); if (!cmNonempty(defaultStd)) { // this compiler has no notion of language standard levels @@ -93,8 +93,7 @@ struct StanardLevelComputer std::string option_flag = cmStrCat( "CMAKE_", this->Language, *standardProp, "_", type, "_COMPILE_OPTION"); - const char* opt = - target->Target->GetMakefile()->GetDefinition(option_flag); + cmProp opt = target->Target->GetMakefile()->GetDefinition(option_flag); if (!opt) { std::ostringstream e; e << "Target \"" << target->GetName() @@ -118,7 +117,7 @@ struct StanardLevelComputer int defaultValue = -1; try { standardValue = std::stoi(standardStr); - defaultValue = std::stoi(defaultStd); + defaultValue = std::stoi(*defaultStd); } catch (std::invalid_argument&) { // fall through as we want an error // when we can't find the bad value in the `stds` vector @@ -139,7 +138,7 @@ struct StanardLevelComputer if (defaultStdIt == cm::cend(stds)) { std::string e = cmStrCat("CMAKE_", this->Language, "_STANDARD_DEFAULT is set to invalid value '", - defaultStd, "'"); + *defaultStd, "'"); makefile->IssueMessage(MessageType::INTERNAL_ERROR, e); return std::string{}; } @@ -185,7 +184,7 @@ struct StanardLevelComputer cmProp existingStandard = currentLangStandardValue; if (existingStandard == nullptr) { - cmProp defaultStandard = makefile->GetDef( + cmProp defaultStandard = makefile->GetDefinition( cmStrCat("CMAKE_", this->Language, "_STANDARD_DEFAULT")); if (cmNonempty(defaultStandard)) { existingStandard = defaultStandard; @@ -228,7 +227,7 @@ struct StanardLevelComputer std::string const& config, std::string const& feature) const { - cmProp defaultStandard = makefile->GetDef( + cmProp defaultStandard = makefile->GetDefinition( cmStrCat("CMAKE_", this->Language, "_STANDARD_DEFAULT")); if (!defaultStandard) { makefile->IssueMessage( @@ -280,9 +279,9 @@ struct StanardLevelComputer std::string prefix = cmStrCat("CMAKE_", this->Language); StandardNeeded maxLevel = { -1, -1 }; for (size_t i = 0; i < this->Levels.size(); ++i) { - if (const char* prop = makefile->GetDefinition( + if (cmProp prop = makefile->GetDefinition( cmStrCat(prefix, this->LevelsAsStrings[i], "_COMPILE_FEATURES"))) { - std::vector props = cmExpandedList(prop); + std::vector props = cmExpandedList(*prop); if (cm::contains(props, feature)) { maxLevel = { static_cast(i), this->Levels[i] }; } @@ -390,9 +389,10 @@ bool cmStandardLevelResolver::CheckCompileFeaturesAvailable( std::ostringstream e; e << "The compiler feature \"" << feature << "\" is not known to " << lang << " compiler\n\"" - << this->Makefile->GetDefinition("CMAKE_" + lang + "_COMPILER_ID") + << this->Makefile->GetSafeDefinition("CMAKE_" + lang + "_COMPILER_ID") << "\"\nversion " - << this->Makefile->GetDefinition("CMAKE_" + lang + "_COMPILER_VERSION") + << this->Makefile->GetSafeDefinition("CMAKE_" + lang + + "_COMPILER_VERSION") << "."; if (error) { *error = e.str(); @@ -469,7 +469,7 @@ const char* cmStandardLevelResolver::CompileFeaturesAvailable( return nullptr; } - const char* featuresKnown = + cmProp featuresKnown = this->Makefile->GetDefinition("CMAKE_" + lang + "_COMPILE_FEATURES"); if (!cmNonempty(featuresKnown)) { @@ -492,7 +492,7 @@ const char* cmStandardLevelResolver::CompileFeaturesAvailable( } return nullptr; } - return featuresKnown; + return cmToCStr(featuresKnown); } bool cmStandardLevelResolver::GetNewRequiredStandard( diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 73f166c..e96c82f 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -469,9 +469,10 @@ void cmState::AddUnexpectedCommand(std::string const& name, const char* error) name, [name, error](std::vector const&, cmExecutionStatus& status) -> bool { - const char* versionValue = + cmProp versionValue = status.GetMakefile().GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION"); - if (name == "endif" && (!versionValue || atof(versionValue) <= 1.4)) { + if (name == "endif" && + (!versionValue || atof(versionValue->c_str()) <= 1.4)) { return true; } status.SetError(error); diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index a7c21cc..653b383 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -20,6 +20,7 @@ #include "cmGeneratorExpression.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmProperty.h" #include "cmRange.h" #include "cmStringAlgorithms.h" #include "cmStringReplaceHelper.h" @@ -535,11 +536,7 @@ bool HandleAppendCommand(std::vector const& args, const std::string& variable = args[1]; - std::string value; - const char* oldValue = status.GetMakefile().GetDefinition(variable); - if (oldValue) { - value = oldValue; - } + std::string value = status.GetMakefile().GetSafeDefinition(variable); value += cmJoin(cmMakeRange(args).advance(2), std::string()); status.GetMakefile().AddDefinition(variable, value); return true; @@ -561,9 +558,9 @@ bool HandlePrependCommand(std::vector const& args, const std::string& variable = args[1]; std::string value = cmJoin(cmMakeRange(args).advance(2), std::string()); - const char* oldValue = status.GetMakefile().GetDefinition(variable); + cmProp oldValue = status.GetMakefile().GetDefinition(variable); if (oldValue) { - value += oldValue; + value += *oldValue; } status.GetMakefile().AddDefinition(variable, value); return true; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 022a892..e0b8dff 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -265,16 +265,16 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, auto initProp = [this, mf, &defKey](const std::string& property) { // Replace everything after "CMAKE_" defKey.replace(defKey.begin() + 6, defKey.end(), property); - if (const char* value = mf->GetDefinition(defKey)) { - this->SetProperty(property, value); + if (cmProp value = mf->GetDefinition(defKey)) { + this->SetProperty(property, *value); } }; auto initPropValue = [this, mf, &defKey](const std::string& property, const char* default_value) { // Replace everything after "CMAKE_" defKey.replace(defKey.begin() + 6, defKey.end(), property); - if (const char* value = mf->GetDefinition(defKey)) { - this->SetProperty(property, value); + if (cmProp value = mf->GetDefinition(defKey)) { + this->SetProperty(property, *value); } else if (default_value) { this->SetProperty(property, default_value); } @@ -524,11 +524,11 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, // check for "CMAKE_VS_GLOBALS" variable and set up target properties // if any - const char* globals = mf->GetDefinition("CMAKE_VS_GLOBALS"); + cmProp globals = mf->GetDefinition("CMAKE_VS_GLOBALS"); if (globals) { const std::string genName = mf->GetGlobalGenerator()->GetName(); if (cmHasLiteralPrefix(genName, "Visual Studio")) { - std::vector props = cmExpandedList(globals); + std::vector props = cmExpandedList(*globals); const std::string vsGlobal = "VS_GLOBAL_"; for (const std::string& i : props) { // split NAME=VALUE @@ -1017,9 +1017,9 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, std::string const& lib, this->GetPolicyStatusCMP0073() == cmPolicies::WARN)) { std::string targetEntry = cmStrCat(impl->Name, "_LIB_DEPENDS"); std::string dependencies; - const char* old_val = mf.GetDefinition(targetEntry); + cmProp old_val = mf.GetDefinition(targetEntry); if (old_val) { - dependencies += old_val; + dependencies += *old_val; } switch (llt) { case GENERAL_LibraryType: diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index df751da..7db2c46 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -2,7 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmTargetLinkLibrariesCommand.h" -#include #include #include #include @@ -14,6 +13,7 @@ #include "cmMakefile.h" #include "cmMessageType.h" #include "cmPolicies.h" +#include "cmProperty.h" #include "cmState.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" @@ -277,12 +277,12 @@ bool cmTargetLinkLibrariesCommand(std::vector const& args, // with old versions of CMake and new) llt = GENERAL_LibraryType; std::string linkType = cmStrCat(args[0], "_LINK_TYPE"); - const char* linkTypeString = mf.GetDefinition(linkType); + cmProp linkTypeString = mf.GetDefinition(linkType); if (linkTypeString) { - if (strcmp(linkTypeString, "debug") == 0) { + if (*linkTypeString == "debug") { llt = DEBUG_LibraryType; } - if (strcmp(linkTypeString, "optimized") == 0) { + if (*linkTypeString == "optimized") { llt = OPTIMIZED_LibraryType; } } diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index 64d71bc..3f89641 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -146,10 +146,10 @@ bool cmTryRunCommand::InitialPass(std::vector const& argv, if (!this->OutputVariable.empty()) { // if the TryCompileCore saved output in this outputVariable then // prepend that output to this output - const char* compileOutput = + cmProp compileOutput = this->Makefile->GetDefinition(this->OutputVariable); if (compileOutput) { - runOutputContents = compileOutput + runOutputContents; + runOutputContents = *compileOutput + runOutputContents; } this->Makefile->AddDefinition(this->OutputVariable, runOutputContents); } @@ -328,12 +328,12 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, file << comment << "\n\n"; file << "set( " << this->RunResultVariable << " \n \"" - << this->Makefile->GetDefinition(this->RunResultVariable) + << this->Makefile->GetSafeDefinition(this->RunResultVariable) << "\"\n CACHE STRING \"Result from TRY_RUN\" FORCE)\n\n"; if (out) { file << "set( " << internalRunOutputName << " \n \"" - << this->Makefile->GetDefinition(internalRunOutputName) + << this->Makefile->GetSafeDefinition(internalRunOutputName) << "\"\n CACHE STRING \"Output from TRY_RUN\" FORCE)\n\n"; } file.close(); @@ -354,6 +354,6 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, } if (out) { - (*out) = this->Makefile->GetDefinition(internalRunOutputName); + (*out) = *this->Makefile->GetDefinition(internalRunOutputName); } } diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx index 6de78ff..d276c8a 100644 --- a/Source/cmUtilitySourceCommand.cxx +++ b/Source/cmUtilitySourceCommand.cxx @@ -6,6 +6,7 @@ #include "cmExecutionStatus.h" #include "cmMakefile.h" +#include "cmProperty.h" #include "cmState.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" @@ -24,7 +25,7 @@ bool cmUtilitySourceCommand(std::vector const& args, // The first argument is the cache entry name. std::string const& cacheEntry = *arg++; - const char* cacheValue = status.GetMakefile().GetDefinition(cacheEntry); + cmProp cacheValue = status.GetMakefile().GetDefinition(cacheEntry); // If it exists already and appears up to date then we are done. If // the string contains "(IntDir)" but that is not the // CMAKE_CFG_INTDIR setting then the value is out of date. @@ -45,7 +46,7 @@ bool cmUtilitySourceCommand(std::vector const& args, } else { cmState* state = status.GetMakefile().GetState(); haveCacheValue = (cacheValue && - (strstr(cacheValue, "(IntDir)") == nullptr || + (strstr(cacheValue->c_str(), "(IntDir)") == nullptr || (intDir == "$(IntDir)")) && (state->GetCacheMajorVersion() != 0 && state->GetCacheMinorVersion() != 0)); @@ -84,8 +85,9 @@ bool cmUtilitySourceCommand(std::vector const& args, std::string utilityDirectory = status.GetMakefile().GetCurrentBinaryDirectory(); std::string exePath; - if (auto d = status.GetMakefile().GetDefinition("EXECUTABLE_OUTPUT_PATH")) { - exePath = d; + if (cmProp d = + status.GetMakefile().GetDefinition("EXECUTABLE_OUTPUT_PATH")) { + exePath = *d; } if (!exePath.empty()) { utilityDirectory = exePath; @@ -96,7 +98,7 @@ bool cmUtilitySourceCommand(std::vector const& args, // Construct the cache entry for the executable's location. std::string utilityExecutable = utilityDirectory + "/" + cmakeCFGout + "/" + utilityName + - status.GetMakefile().GetDefinition("CMAKE_EXECUTABLE_SUFFIX"); + *status.GetMakefile().GetDefinition("CMAKE_EXECUTABLE_SUFFIX"); // make sure we remove any /./ in the name cmSystemTools::ReplaceString(utilityExecutable, "/./", "/"); diff --git a/Source/cmVariableRequiresCommand.cxx b/Source/cmVariableRequiresCommand.cxx index 6b93c63..1fe03ab 100644 --- a/Source/cmVariableRequiresCommand.cxx +++ b/Source/cmVariableRequiresCommand.cxx @@ -4,6 +4,7 @@ #include "cmExecutionStatus.h" #include "cmMakefile.h" +#include "cmProperty.h" #include "cmState.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -37,11 +38,11 @@ bool cmVariableRequiresCommand(std::vector const& args, } } } - const char* reqVar = status.GetMakefile().GetDefinition(resultVariable); + cmProp reqVar = status.GetMakefile().GetDefinition(resultVariable); // if reqVar is unset, then set it to requirementsMet // if reqVar is set to true, but requirementsMet is false , then // set reqVar to false. - if (!reqVar || (!requirementsMet && status.GetMakefile().IsOn(reqVar))) { + if (!reqVar || (!requirementsMet && status.GetMakefile().IsOn(*reqVar))) { status.GetMakefile().AddDefinitionBool(resultVariable, requirementsMet); } diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx index ecae16d..750b0b5 100644 --- a/Source/cmVariableWatchCommand.cxx +++ b/Source/cmVariableWatchCommand.cxx @@ -10,6 +10,7 @@ #include "cmListFileCache.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmProperty.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmVariableWatch.h" @@ -45,7 +46,7 @@ void cmVariableWatchCommandVariableAccessed(const std::string& variable, std::string stack = *mf->GetProperty("LISTFILE_STACK"); if (!data->Command.empty()) { cmListFileFunction newLFF; - const char* const currentListFile = + cmProp const currentListFile = mf->GetDefinition("CMAKE_CURRENT_LIST_FILE"); const auto fakeLineNo = std::numeric_limits::max(); @@ -53,7 +54,7 @@ void cmVariableWatchCommandVariableAccessed(const std::string& variable, { variable, cmListFileArgument::Quoted, fakeLineNo }, { accessString, cmListFileArgument::Quoted, fakeLineNo }, { newValue ? newValue : "", cmListFileArgument::Quoted, fakeLineNo }, - { currentListFile, cmListFileArgument::Quoted, fakeLineNo }, + { *currentListFile, cmListFileArgument::Quoted, fakeLineNo }, { stack, cmListFileArgument::Quoted, fakeLineNo } }; newLFF.Name = data->Command; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index fa6ad47..dc61def 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1226,9 +1226,9 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValues( Elem& e1, std::string const& config) { cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator; - const char* mfcFlag = this->Makefile->GetDefinition("CMAKE_MFC_FLAG"); + cmProp mfcFlag = this->Makefile->GetDefinition("CMAKE_MFC_FLAG"); if (mfcFlag) { - std::string const mfcFlagValue = mfcFlag; + std::string const mfcFlagValue = *mfcFlag; std::string useOfMfcValue = "false"; if (this->GeneratorTarget->GetType() <= cmStateEnums::OBJECT_LIBRARY) { @@ -2603,42 +2603,42 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions( e1.WritePlatformConfigTag("IntDir", cond, intermediateDir); - if (const char* sdkExecutableDirectories = this->Makefile->GetDefinition( + if (cmProp sdkExecutableDirectories = this->Makefile->GetDefinition( "CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES")) { e1.WritePlatformConfigTag("ExecutablePath", cond, - sdkExecutableDirectories); + *sdkExecutableDirectories); } - if (const char* sdkIncludeDirectories = this->Makefile->GetDefinition( + if (cmProp sdkIncludeDirectories = this->Makefile->GetDefinition( "CMAKE_VS_SDK_INCLUDE_DIRECTORIES")) { - e1.WritePlatformConfigTag("IncludePath", cond, sdkIncludeDirectories); + e1.WritePlatformConfigTag("IncludePath", cond, *sdkIncludeDirectories); } - if (const char* sdkReferenceDirectories = this->Makefile->GetDefinition( + if (cmProp sdkReferenceDirectories = this->Makefile->GetDefinition( "CMAKE_VS_SDK_REFERENCE_DIRECTORIES")) { e1.WritePlatformConfigTag("ReferencePath", cond, - sdkReferenceDirectories); + *sdkReferenceDirectories); } - if (const char* sdkLibraryDirectories = this->Makefile->GetDefinition( + if (cmProp sdkLibraryDirectories = this->Makefile->GetDefinition( "CMAKE_VS_SDK_LIBRARY_DIRECTORIES")) { - e1.WritePlatformConfigTag("LibraryPath", cond, sdkLibraryDirectories); + e1.WritePlatformConfigTag("LibraryPath", cond, *sdkLibraryDirectories); } - if (const char* sdkLibraryWDirectories = this->Makefile->GetDefinition( + if (cmProp sdkLibraryWDirectories = this->Makefile->GetDefinition( "CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES")) { e1.WritePlatformConfigTag("LibraryWPath", cond, - sdkLibraryWDirectories); + *sdkLibraryWDirectories); } - if (const char* sdkSourceDirectories = + if (cmProp sdkSourceDirectories = this->Makefile->GetDefinition("CMAKE_VS_SDK_SOURCE_DIRECTORIES")) { - e1.WritePlatformConfigTag("SourcePath", cond, sdkSourceDirectories); + e1.WritePlatformConfigTag("SourcePath", cond, *sdkSourceDirectories); } - if (const char* sdkExcludeDirectories = this->Makefile->GetDefinition( + if (cmProp sdkExcludeDirectories = this->Makefile->GetDefinition( "CMAKE_VS_SDK_EXCLUDE_DIRECTORIES")) { - e1.WritePlatformConfigTag("ExcludePath", cond, sdkExcludeDirectories); + e1.WritePlatformConfigTag("ExcludePath", cond, *sdkExcludeDirectories); } std::string name = @@ -3769,9 +3769,9 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( }; } - if (const char* stackVal = this->Makefile->GetDefinition( + if (cmProp stackVal = this->Makefile->GetDefinition( "CMAKE_" + linkLanguage + "_STACK_SIZE")) { - linkOptions.AddFlag("StackReserveSize", stackVal); + linkOptions.AddFlag("StackReserveSize", *stackVal); } linkOptions.AddFlag("GenerateDebugInformation", "false"); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 1bee728..bca938e 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2286,7 +2286,8 @@ int cmake::CheckBuildSystem() if (this->ClearBuildSystem) { // Get the generator used for this build system. - const char* genName = mf.GetDefinition("CMAKE_DEPENDS_GENERATOR"); + const char* genName = + cmToCStr(mf.GetDefinition("CMAKE_DEPENDS_GENERATOR")); if (!cmNonempty(genName)) { genName = "Unix Makefiles"; } -- cgit v0.12