mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-15 12:16:40 +08:00
cmMakefile: Make GetSafeDefinition return std::string const&
This commit is contained in:

committed by
Brad King

parent
42212f7539
commit
f4ff60a803
@@ -151,9 +151,9 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
|
||||
cmSystemTools::CollapseFullPath(this->Values[ct_BUILD]).c_str(),
|
||||
this->Quiet);
|
||||
} else {
|
||||
const char* bdir =
|
||||
std::string const& bdir =
|
||||
this->Makefile->GetSafeDefinition("CTEST_BINARY_DIRECTORY");
|
||||
if (bdir) {
|
||||
if (!bdir.empty()) {
|
||||
this->CTest->SetCTestConfiguration(
|
||||
"BuildDirectory", cmSystemTools::CollapseFullPath(bdir).c_str(),
|
||||
this->Quiet);
|
||||
|
@@ -1725,7 +1725,7 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
|
||||
}
|
||||
const char* stagePath =
|
||||
this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX");
|
||||
const char* installPrefix =
|
||||
std::string const& installPrefix =
|
||||
this->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
|
||||
cmSystemTools::ConvertToUnixSlashes(rootPath);
|
||||
std::vector<std::string> const& rdirs = this->GetRuntimeSearchPath();
|
||||
|
@@ -36,7 +36,7 @@ bool cmDepends::Write(std::ostream& makeDepends, std::ostream& internalDepends)
|
||||
std::string srcLang = "CMAKE_DEPENDS_CHECK_";
|
||||
srcLang += this->Language;
|
||||
cmMakefile* mf = this->LocalGenerator->GetMakefile();
|
||||
const char* srcStr = mf->GetSafeDefinition(srcLang);
|
||||
std::string const& srcStr = mf->GetSafeDefinition(srcLang);
|
||||
std::vector<std::string> pairs;
|
||||
cmSystemTools::ExpandListArgument(srcStr, pairs);
|
||||
|
||||
|
@@ -195,7 +195,7 @@ static bool checkInterfaceDirs(const std::string& prepro,
|
||||
cmGeneratorTarget* target,
|
||||
const std::string& prop)
|
||||
{
|
||||
const char* installDir =
|
||||
std::string const& installDir =
|
||||
target->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
|
||||
std::string const& topSourceDir =
|
||||
target->GetLocalGenerator()->GetSourceDirectory();
|
||||
|
@@ -666,7 +666,7 @@ std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf)
|
||||
pureFortran = true;
|
||||
}
|
||||
|
||||
std::string compilerId = mf->GetSafeDefinition(compilerIdVar);
|
||||
std::string const& compilerId = mf->GetSafeDefinition(compilerIdVar);
|
||||
std::string compiler = "gcc"; // default to gcc
|
||||
if (compilerId == "MSVC") {
|
||||
if (mf->IsDefinitionSet("MSVC10")) {
|
||||
|
@@ -599,7 +599,7 @@ std::string cmExtraCodeLiteGenerator::GetCodeLiteCompilerName(
|
||||
compilerIdVar = "CMAKE_C_COMPILER_ID";
|
||||
}
|
||||
|
||||
std::string compilerId = mf->GetSafeDefinition(compilerIdVar);
|
||||
std::string const& compilerId = mf->GetSafeDefinition(compilerIdVar);
|
||||
std::string compiler = "gnu g++"; // default to g++
|
||||
|
||||
// Since we need the compiler for parsing purposes only
|
||||
|
@@ -580,10 +580,11 @@ struct CompilerIdNode : public cmGeneratorExpressionNode
|
||||
cmGeneratorExpressionDAGChecker* /*unused*/,
|
||||
const std::string& lang) const
|
||||
{
|
||||
const char* compilerId = context->LG->GetMakefile()->GetSafeDefinition(
|
||||
"CMAKE_" + lang + "_COMPILER_ID");
|
||||
std::string const& compilerId =
|
||||
context->LG->GetMakefile()->GetSafeDefinition("CMAKE_" + lang +
|
||||
"_COMPILER_ID");
|
||||
if (parameters.empty()) {
|
||||
return compilerId ? compilerId : "";
|
||||
return compilerId;
|
||||
}
|
||||
static cmsys::RegularExpression compilerIdValidator("^[A-Za-z0-9_]*$");
|
||||
if (!compilerIdValidator.find(*parameters.begin())) {
|
||||
@@ -591,15 +592,16 @@ struct CompilerIdNode : public cmGeneratorExpressionNode
|
||||
"Expression syntax not recognized.");
|
||||
return std::string();
|
||||
}
|
||||
if (!compilerId) {
|
||||
if (compilerId.empty()) {
|
||||
return parameters.front().empty() ? "1" : "0";
|
||||
}
|
||||
|
||||
if (strcmp(parameters.begin()->c_str(), compilerId) == 0) {
|
||||
if (strcmp(parameters.begin()->c_str(), compilerId.c_str()) == 0) {
|
||||
return "1";
|
||||
}
|
||||
|
||||
if (cmsysString_strcasecmp(parameters.begin()->c_str(), compilerId) == 0) {
|
||||
if (cmsysString_strcasecmp(parameters.begin()->c_str(),
|
||||
compilerId.c_str()) == 0) {
|
||||
switch (context->LG->GetPolicyStatus(cmPolicies::CMP0044)) {
|
||||
case cmPolicies::WARN: {
|
||||
std::ostringstream e;
|
||||
@@ -676,11 +678,11 @@ struct CompilerVersionNode : public cmGeneratorExpressionNode
|
||||
cmGeneratorExpressionDAGChecker* /*unused*/,
|
||||
const std::string& lang) const
|
||||
{
|
||||
const char* compilerVersion =
|
||||
std::string const& compilerVersion =
|
||||
context->LG->GetMakefile()->GetSafeDefinition("CMAKE_" + lang +
|
||||
"_COMPILER_VERSION");
|
||||
if (parameters.empty()) {
|
||||
return compilerVersion ? compilerVersion : "";
|
||||
return compilerVersion;
|
||||
}
|
||||
|
||||
static cmsys::RegularExpression compilerIdValidator("^[0-9\\.]*$");
|
||||
@@ -689,13 +691,13 @@ struct CompilerVersionNode : public cmGeneratorExpressionNode
|
||||
"Expression syntax not recognized.");
|
||||
return std::string();
|
||||
}
|
||||
if (!compilerVersion) {
|
||||
if (compilerVersion.empty()) {
|
||||
return parameters.front().empty() ? "1" : "0";
|
||||
}
|
||||
|
||||
return cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL,
|
||||
parameters.begin()->c_str(),
|
||||
compilerVersion)
|
||||
compilerVersion.c_str())
|
||||
? "1"
|
||||
: "0";
|
||||
}
|
||||
@@ -757,17 +759,17 @@ struct PlatformIdNode : public cmGeneratorExpressionNode
|
||||
const GeneratorExpressionContent* /*content*/,
|
||||
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
|
||||
{
|
||||
const char* platformId =
|
||||
std::string const& platformId =
|
||||
context->LG->GetMakefile()->GetSafeDefinition("CMAKE_SYSTEM_NAME");
|
||||
if (parameters.empty()) {
|
||||
return platformId ? platformId : "";
|
||||
return platformId;
|
||||
}
|
||||
|
||||
if (!platformId) {
|
||||
if (platformId.empty()) {
|
||||
return parameters.front().empty() ? "1" : "0";
|
||||
}
|
||||
|
||||
if (strcmp(parameters.begin()->c_str(), platformId) == 0) {
|
||||
if (*parameters.begin() == platformId) {
|
||||
return "1";
|
||||
}
|
||||
return "0";
|
||||
|
@@ -138,8 +138,7 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg)
|
||||
this->SourceEntries, true);
|
||||
|
||||
this->DLLPlatform =
|
||||
strcmp(this->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX"),
|
||||
"") != 0;
|
||||
!this->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX").empty();
|
||||
|
||||
this->PolicyMap = t->PolicyMap;
|
||||
}
|
||||
@@ -3489,12 +3488,13 @@ void cmGeneratorTarget::GetFullNameInternal(
|
||||
}
|
||||
|
||||
// if there is no prefix on the target use the cmake definition
|
||||
std::string targetPrefix2, targetSuffix2;
|
||||
if (!targetPrefix && prefixVar) {
|
||||
targetPrefix = this->Makefile->GetSafeDefinition(prefixVar);
|
||||
targetPrefix2 = this->Makefile->GetSafeDefinition(prefixVar);
|
||||
}
|
||||
// if there is no suffix on the target use the cmake definition
|
||||
if (!targetSuffix && suffixVar) {
|
||||
targetSuffix = this->Makefile->GetSafeDefinition(suffixVar);
|
||||
targetSuffix2 = this->Makefile->GetSafeDefinition(suffixVar);
|
||||
}
|
||||
|
||||
// frameworks have directory prefix but no suffix
|
||||
@@ -3502,19 +3502,19 @@ void cmGeneratorTarget::GetFullNameInternal(
|
||||
if (this->IsFrameworkOnApple()) {
|
||||
fw_prefix = this->GetFrameworkDirectory(config, ContentLevel);
|
||||
fw_prefix += "/";
|
||||
targetPrefix = fw_prefix.c_str();
|
||||
targetSuffix = nullptr;
|
||||
targetPrefix2 = fw_prefix;
|
||||
targetSuffix2.clear();
|
||||
}
|
||||
|
||||
if (this->IsCFBundleOnApple()) {
|
||||
fw_prefix = this->GetCFBundleDirectory(config, FullLevel);
|
||||
fw_prefix += "/";
|
||||
targetPrefix = fw_prefix.c_str();
|
||||
targetSuffix = nullptr;
|
||||
targetPrefix2 = fw_prefix;
|
||||
targetSuffix2.clear();
|
||||
}
|
||||
|
||||
// Begin the final name with the prefix.
|
||||
outPrefix = targetPrefix ? targetPrefix : "";
|
||||
outPrefix = targetPrefix2;
|
||||
|
||||
// Append the target name or property-specified name.
|
||||
outBase += this->GetOutputName(config, artifact);
|
||||
@@ -3533,7 +3533,7 @@ void cmGeneratorTarget::GetFullNameInternal(
|
||||
}
|
||||
|
||||
// Append the suffix.
|
||||
outSuffix = targetSuffix ? targetSuffix : "";
|
||||
outSuffix = targetSuffix2;
|
||||
}
|
||||
|
||||
std::string cmGeneratorTarget::GetLinkerLanguage(
|
||||
|
@@ -65,7 +65,7 @@ bool cmGetDirectoryPropertyCommand::InitialPass(
|
||||
"providing the name of the variable to get.");
|
||||
return false;
|
||||
}
|
||||
std::string output = dir->GetSafeDefinition(*i);
|
||||
std::string const& output = dir->GetSafeDefinition(*i);
|
||||
this->Makefile->AddDefinition(variable, output.c_str());
|
||||
return true;
|
||||
}
|
||||
|
@@ -828,8 +828,9 @@ void cmGlobalGenerator::EnableLanguage(
|
||||
std::string sharedLibFlagsVar = "CMAKE_SHARED_LIBRARY_";
|
||||
sharedLibFlagsVar += lang;
|
||||
sharedLibFlagsVar += "_FLAGS";
|
||||
const char* sharedLibFlags = mf->GetSafeDefinition(sharedLibFlagsVar);
|
||||
if (sharedLibFlags) {
|
||||
std::string const& sharedLibFlags =
|
||||
mf->GetSafeDefinition(sharedLibFlagsVar);
|
||||
if (!sharedLibFlags.empty()) {
|
||||
this->LanguageToOriginalSharedLibFlags[lang] = sharedLibFlags;
|
||||
}
|
||||
|
||||
@@ -1092,7 +1093,7 @@ void cmGlobalGenerator::FillExtensionToLanguageMap(const std::string& l,
|
||||
{
|
||||
std::string extensionsVar = std::string("CMAKE_") + std::string(l) +
|
||||
std::string("_SOURCE_FILE_EXTENSIONS");
|
||||
std::string exts = mf->GetSafeDefinition(extensionsVar);
|
||||
const std::string& exts = mf->GetSafeDefinition(extensionsVar);
|
||||
std::vector<std::string> extensionList;
|
||||
cmSystemTools::ExpandListArgument(exts, extensionList);
|
||||
for (std::string const& i : extensionList) {
|
||||
@@ -1112,7 +1113,7 @@ bool cmGlobalGenerator::GlobalSettingIsOn(std::string const& name) const
|
||||
return this->Makefiles[0]->IsOn(name);
|
||||
}
|
||||
|
||||
const char* cmGlobalGenerator::GetSafeGlobalSetting(
|
||||
std::string cmGlobalGenerator::GetSafeGlobalSetting(
|
||||
std::string const& name) const
|
||||
{
|
||||
assert(!this->Makefiles.empty());
|
||||
@@ -1593,7 +1594,7 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo()
|
||||
for (std::string const& li : langs) {
|
||||
std::string const standardIncludesVar =
|
||||
"CMAKE_" + li + "_STANDARD_INCLUDE_DIRECTORIES";
|
||||
std::string const standardIncludesStr =
|
||||
std::string const& standardIncludesStr =
|
||||
mf->GetSafeDefinition(standardIncludesVar);
|
||||
std::vector<std::string> standardIncludesVec;
|
||||
cmSystemTools::ExpandListArgument(standardIncludesStr,
|
||||
|
@@ -230,7 +230,7 @@ public:
|
||||
|
||||
const char* GetGlobalSetting(std::string const& name) const;
|
||||
bool GlobalSettingIsOn(std::string const& name) const;
|
||||
const char* GetSafeGlobalSetting(std::string const& name) const;
|
||||
std::string GetSafeGlobalSetting(std::string const& name) const;
|
||||
|
||||
/** Add a file to the manifest of generated targets for a configuration. */
|
||||
void AddToManifest(std::string const& f);
|
||||
|
@@ -651,13 +651,13 @@ void cmGlobalNinjaGenerator::EnableLanguage(
|
||||
this->ResolveLanguageCompiler(l, mf, optional);
|
||||
}
|
||||
#ifdef _WIN32
|
||||
if (strcmp(mf->GetSafeDefinition("CMAKE_C_SIMULATE_ID"), "MSVC") != 0 &&
|
||||
strcmp(mf->GetSafeDefinition("CMAKE_CXX_SIMULATE_ID"), "MSVC") != 0 &&
|
||||
if ((mf->GetSafeDefinition("CMAKE_C_SIMULATE_ID") != "MSVC") &&
|
||||
(mf->GetSafeDefinition("CMAKE_CXX_SIMULATE_ID") != "MSVC") &&
|
||||
(mf->IsOn("CMAKE_COMPILER_IS_MINGW") ||
|
||||
strcmp(mf->GetSafeDefinition("CMAKE_C_COMPILER_ID"), "GNU") == 0 ||
|
||||
strcmp(mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID"), "GNU") == 0 ||
|
||||
strcmp(mf->GetSafeDefinition("CMAKE_C_COMPILER_ID"), "Clang") == 0 ||
|
||||
strcmp(mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID"), "Clang") == 0)) {
|
||||
(mf->GetSafeDefinition("CMAKE_C_COMPILER_ID") == "GNU") ||
|
||||
(mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID") == "GNU") ||
|
||||
(mf->GetSafeDefinition("CMAKE_C_COMPILER_ID") == "Clang") ||
|
||||
(mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID") == "Clang"))) {
|
||||
this->UsingGCCOnWindows = true;
|
||||
}
|
||||
#endif
|
||||
|
@@ -5,7 +5,6 @@
|
||||
#include "cmsys/Glob.hxx"
|
||||
#include <sstream>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <utility>
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
@@ -350,8 +349,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
|
||||
|
||||
// Check whether this is a DLL platform.
|
||||
bool dll_platform =
|
||||
strcmp(this->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX"),
|
||||
"") != 0;
|
||||
!this->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX").empty();
|
||||
|
||||
for (std::string const& tgt : targetList.GetVector()) {
|
||||
|
||||
|
@@ -683,7 +683,7 @@ std::string cmLocalGenerator::GetIncludeFlags(
|
||||
|
||||
std::string flagVar = "CMAKE_INCLUDE_FLAG_";
|
||||
flagVar += lang;
|
||||
const char* includeFlag = this->Makefile->GetSafeDefinition(flagVar);
|
||||
std::string const& includeFlag = this->Makefile->GetSafeDefinition(flagVar);
|
||||
flagVar = "CMAKE_INCLUDE_FLAG_SEP_";
|
||||
flagVar += lang;
|
||||
const char* sep = this->Makefile->GetDefinition(flagVar);
|
||||
@@ -1824,9 +1824,9 @@ bool cmLocalGenerator::GetShouldUseOldFlags(bool shared,
|
||||
std::string flagsVar = "CMAKE_SHARED_LIBRARY_";
|
||||
flagsVar += lang;
|
||||
flagsVar += "_FLAGS";
|
||||
const char* flags = this->Makefile->GetSafeDefinition(flagsVar);
|
||||
std::string const& flags = this->Makefile->GetSafeDefinition(flagsVar);
|
||||
|
||||
if (flags && flags != originalFlags) {
|
||||
if (!flags.empty() && flags != originalFlags) {
|
||||
switch (this->GetPolicyStatus(cmPolicies::CMP0018)) {
|
||||
case cmPolicies::WARN: {
|
||||
std::ostringstream e;
|
||||
@@ -1859,7 +1859,7 @@ void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags,
|
||||
std::string const& lang,
|
||||
int targetType)
|
||||
{
|
||||
const char* picFlags = nullptr;
|
||||
std::string picFlags;
|
||||
|
||||
if (targetType == cmStateEnums::EXECUTABLE) {
|
||||
std::string flagsVar = "CMAKE_";
|
||||
@@ -1867,13 +1867,13 @@ void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags,
|
||||
flagsVar += "_COMPILE_OPTIONS_PIE";
|
||||
picFlags = this->Makefile->GetSafeDefinition(flagsVar);
|
||||
}
|
||||
if (!picFlags) {
|
||||
if (picFlags.empty()) {
|
||||
std::string flagsVar = "CMAKE_";
|
||||
flagsVar += lang;
|
||||
flagsVar += "_COMPILE_OPTIONS_PIC";
|
||||
picFlags = this->Makefile->GetSafeDefinition(flagsVar);
|
||||
}
|
||||
if (picFlags) {
|
||||
if (!picFlags.empty()) {
|
||||
std::vector<std::string> options;
|
||||
cmSystemTools::ExpandListArgument(picFlags, options);
|
||||
for (std::string const& o : options) {
|
||||
|
@@ -1422,7 +1422,8 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies(
|
||||
this->WriteDisclaimer(internalRuleFileStream);
|
||||
|
||||
// for each language we need to scan, scan it
|
||||
const char* langStr = mf->GetSafeDefinition("CMAKE_DEPENDS_LANGUAGES");
|
||||
std::string const& langStr =
|
||||
mf->GetSafeDefinition("CMAKE_DEPENDS_LANGUAGES");
|
||||
std::vector<std::string> langs;
|
||||
cmSystemTools::ExpandListArgument(langStr, langs);
|
||||
for (std::string const& lang : langs) {
|
||||
|
@@ -1082,7 +1082,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
|
||||
// Use the NOINHERIT macro to avoid getting VS project default
|
||||
// libraries which may be set by the user to something bad.
|
||||
fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) "
|
||||
<< this->Makefile->GetSafeDefinition(standardLibsVar.c_str());
|
||||
<< this->Makefile->GetSafeDefinition(standardLibsVar);
|
||||
if (this->FortranProject) {
|
||||
this->Internal->OutputObjects(fout, target, configName, " ");
|
||||
}
|
||||
@@ -1167,7 +1167,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
|
||||
// Use the NOINHERIT macro to avoid getting VS project default
|
||||
// libraries which may be set by the user to something bad.
|
||||
fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) "
|
||||
<< this->Makefile->GetSafeDefinition(standardLibsVar.c_str());
|
||||
<< this->Makefile->GetSafeDefinition(standardLibsVar);
|
||||
if (this->FortranProject) {
|
||||
this->Internal->OutputObjects(fout, target, configName, " ");
|
||||
}
|
||||
|
@@ -2384,7 +2384,7 @@ bool cmMakefile::IsDefinitionSet(const std::string& name) const
|
||||
return def != nullptr;
|
||||
}
|
||||
|
||||
const char* cmMakefile::GetDefinition(const std::string& name) const
|
||||
const std::string* cmMakefile::GetDef(const std::string& name) const
|
||||
{
|
||||
const std::string* def = this->StateSnapshot.GetDefinition(name);
|
||||
if (!def) {
|
||||
@@ -2410,16 +2410,26 @@ const char* cmMakefile::GetDefinition(const std::string& name) const
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return (def ? def->c_str() : nullptr);
|
||||
return def;
|
||||
}
|
||||
|
||||
const char* cmMakefile::GetSafeDefinition(const std::string& def) const
|
||||
const char* cmMakefile::GetDefinition(const std::string& name) const
|
||||
{
|
||||
const char* ret = this->GetDefinition(def);
|
||||
if (!ret) {
|
||||
return "";
|
||||
const std::string* def = GetDef(name);
|
||||
if (!def) {
|
||||
return nullptr;
|
||||
}
|
||||
return ret;
|
||||
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);
|
||||
if (!def) {
|
||||
return empty;
|
||||
}
|
||||
return *def;
|
||||
}
|
||||
|
||||
std::vector<std::string> cmMakefile::GetDefinitions() const
|
||||
|
@@ -422,7 +422,8 @@ public:
|
||||
* cache is then queried.
|
||||
*/
|
||||
const char* GetDefinition(const std::string&) const;
|
||||
const char* GetSafeDefinition(const std::string&) const;
|
||||
const std::string* GetDef(const std::string&) const;
|
||||
const std::string& GetSafeDefinition(const std::string&) const;
|
||||
std::string GetRequiredDefinition(const std::string& name) const;
|
||||
bool IsDefinitionSet(const std::string&) const;
|
||||
/**
|
||||
|
@@ -10,7 +10,6 @@
|
||||
#include <map>
|
||||
#include <memory> // IWYU pragma: keep
|
||||
#include <sstream>
|
||||
#include <string.h>
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmComputeLinkInformation.h"
|
||||
@@ -174,9 +173,8 @@ void cmNinjaTargetGenerator::AddIncludeFlags(std::string& languageFlags,
|
||||
|
||||
bool cmNinjaTargetGenerator::NeedDepTypeMSVC(const std::string& lang) const
|
||||
{
|
||||
return strcmp(this->GetMakefile()->GetSafeDefinition("CMAKE_NINJA_DEPTYPE_" +
|
||||
lang),
|
||||
"msvc") == 0;
|
||||
return (this->GetMakefile()->GetSafeDefinition("CMAKE_NINJA_DEPTYPE_" +
|
||||
lang) == "msvc");
|
||||
}
|
||||
|
||||
// TODO: Refactor with
|
||||
|
@@ -135,7 +135,7 @@ static bool GetPolicyDefault(cmMakefile* mf, std::string const& policy,
|
||||
cmPolicies::PolicyStatus* defaultSetting)
|
||||
{
|
||||
std::string defaultVar = "CMAKE_POLICY_DEFAULT_" + policy;
|
||||
std::string defaultValue = mf->GetSafeDefinition(defaultVar);
|
||||
std::string const& defaultValue = mf->GetSafeDefinition(defaultVar);
|
||||
if (defaultValue == "NEW") {
|
||||
*defaultSetting = cmPolicies::NEW;
|
||||
} else if (defaultValue == "OLD") {
|
||||
|
@@ -1126,7 +1126,7 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
|
||||
}
|
||||
};
|
||||
auto MfDef = [makefile](const char* key) {
|
||||
return std::string(makefile->GetSafeDefinition(key));
|
||||
return makefile->GetSafeDefinition(key);
|
||||
};
|
||||
|
||||
// Write
|
||||
|
@@ -1204,7 +1204,7 @@ bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile)
|
||||
valueConf = makefile->GetDefinition(keyConf);
|
||||
}
|
||||
if (valueConf == nullptr) {
|
||||
valueConf = makefile->GetSafeDefinition(key);
|
||||
return makefile->GetSafeDefinition(key);
|
||||
}
|
||||
return std::string(valueConf);
|
||||
};
|
||||
@@ -1226,7 +1226,7 @@ bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile)
|
||||
Base_.MultiConfig = InfoGetBool("AM_MULTI_CONFIG");
|
||||
{
|
||||
unsigned long num = Base_.NumThreads;
|
||||
if (cmSystemTools::StringToULong(InfoGet("AM_PARALLEL"), &num)) {
|
||||
if (cmSystemTools::StringToULong(InfoGet("AM_PARALLEL").c_str(), &num)) {
|
||||
num = std::max<unsigned long>(num, 1);
|
||||
num = std::min<unsigned long>(num, ParallelMax);
|
||||
Base_.NumThreads = static_cast<unsigned int>(num);
|
||||
@@ -1264,7 +1264,8 @@ bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile)
|
||||
// - Qt environment
|
||||
{
|
||||
unsigned long qtv = Base_.QtVersionMajor;
|
||||
if (cmSystemTools::StringToULong(InfoGet("AM_QT_VERSION_MAJOR"), &qtv)) {
|
||||
if (cmSystemTools::StringToULong(InfoGet("AM_QT_VERSION_MAJOR").c_str(),
|
||||
&qtv)) {
|
||||
Base_.QtVersionMajor = static_cast<unsigned int>(qtv);
|
||||
}
|
||||
}
|
||||
|
@@ -52,7 +52,7 @@ bool cmQtAutoGeneratorRcc::Init(cmMakefile* makefile)
|
||||
valueConf = makefile->GetDefinition(keyConf);
|
||||
}
|
||||
if (valueConf == nullptr) {
|
||||
valueConf = makefile->GetSafeDefinition(key);
|
||||
return makefile->GetSafeDefinition(key);
|
||||
}
|
||||
return std::string(valueConf);
|
||||
};
|
||||
|
@@ -190,13 +190,11 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
|
||||
|
||||
// Check whether this is a DLL platform.
|
||||
this->DLLPlatform =
|
||||
strcmp(this->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX"),
|
||||
"") != 0;
|
||||
!this->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX").empty();
|
||||
|
||||
// Check whether we are targeting an Android platform.
|
||||
this->IsAndroid =
|
||||
strcmp(this->Makefile->GetSafeDefinition("CMAKE_SYSTEM_NAME"),
|
||||
"Android") == 0;
|
||||
(this->Makefile->GetSafeDefinition("CMAKE_SYSTEM_NAME") == "Android");
|
||||
|
||||
// Setup default property values.
|
||||
if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
|
||||
|
@@ -2699,11 +2699,9 @@ bool cmVisualStudio10TargetGenerator::ComputeRcOptions(
|
||||
Options& rcOptions = *pOptions;
|
||||
|
||||
std::string CONFIG = cmSystemTools::UpperCase(configName);
|
||||
std::string rcConfigFlagsVar = std::string("CMAKE_RC_FLAGS_") + CONFIG;
|
||||
std::string flags =
|
||||
std::string(this->Makefile->GetSafeDefinition("CMAKE_RC_FLAGS")) +
|
||||
std::string(" ") +
|
||||
std::string(this->Makefile->GetSafeDefinition(rcConfigFlagsVar));
|
||||
std::string rcConfigFlagsVar = "CMAKE_RC_FLAGS_" + CONFIG;
|
||||
std::string flags = this->Makefile->GetSafeDefinition("CMAKE_RC_FLAGS") +
|
||||
" " + this->Makefile->GetSafeDefinition(rcConfigFlagsVar);
|
||||
|
||||
rcOptions.Parse(flags);
|
||||
|
||||
@@ -2757,10 +2755,8 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions(
|
||||
// Get compile flags for CUDA in this directory.
|
||||
std::string CONFIG = cmSystemTools::UpperCase(configName);
|
||||
std::string configFlagsVar = std::string("CMAKE_CUDA_FLAGS_") + CONFIG;
|
||||
std::string flags =
|
||||
std::string(this->Makefile->GetSafeDefinition("CMAKE_CUDA_FLAGS")) +
|
||||
std::string(" ") +
|
||||
std::string(this->Makefile->GetSafeDefinition(configFlagsVar));
|
||||
std::string flags = this->Makefile->GetSafeDefinition("CMAKE_CUDA_FLAGS") +
|
||||
" " + this->Makefile->GetSafeDefinition(configFlagsVar);
|
||||
this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, "CUDA",
|
||||
configName);
|
||||
|
||||
@@ -2971,9 +2967,8 @@ bool cmVisualStudio10TargetGenerator::ComputeMasmOptions(
|
||||
std::string CONFIG = cmSystemTools::UpperCase(configName);
|
||||
std::string configFlagsVar = std::string("CMAKE_ASM_MASM_FLAGS_") + CONFIG;
|
||||
std::string flags =
|
||||
std::string(this->Makefile->GetSafeDefinition("CMAKE_ASM_MASM_FLAGS")) +
|
||||
std::string(" ") +
|
||||
std::string(this->Makefile->GetSafeDefinition(configFlagsVar));
|
||||
this->Makefile->GetSafeDefinition("CMAKE_ASM_MASM_FLAGS") + " " +
|
||||
this->Makefile->GetSafeDefinition(configFlagsVar);
|
||||
|
||||
masmOptions.Parse(flags);
|
||||
|
||||
@@ -3024,14 +3019,11 @@ bool cmVisualStudio10TargetGenerator::ComputeNasmOptions(
|
||||
Options& nasmOptions = *pOptions;
|
||||
|
||||
std::string CONFIG = cmSystemTools::UpperCase(configName);
|
||||
std::string configFlagsVar = std::string("CMAKE_ASM_NASM_FLAGS_") + CONFIG;
|
||||
std::string configFlagsVar = "CMAKE_ASM_NASM_FLAGS_" + CONFIG;
|
||||
std::string flags =
|
||||
std::string(this->Makefile->GetSafeDefinition("CMAKE_ASM_NASM_FLAGS")) +
|
||||
std::string(" -f") +
|
||||
std::string(
|
||||
this->Makefile->GetSafeDefinition("CMAKE_ASM_NASM_OBJECT_FORMAT")) +
|
||||
std::string(" ") +
|
||||
std::string(this->Makefile->GetSafeDefinition(configFlagsVar));
|
||||
this->Makefile->GetSafeDefinition("CMAKE_ASM_NASM_FLAGS") + " -f" +
|
||||
this->Makefile->GetSafeDefinition("CMAKE_ASM_NASM_OBJECT_FORMAT") + " " +
|
||||
this->Makefile->GetSafeDefinition(configFlagsVar);
|
||||
nasmOptions.Parse(flags);
|
||||
|
||||
// Get includes for this target
|
||||
|
Reference in New Issue
Block a user