cmIsOn: add overload accepting const std::string*

This commit is contained in:
Vitaly Stakhovsky
2020-07-13 21:00:00 -04:00
parent 2da778664d
commit 7156911242
23 changed files with 60 additions and 88 deletions
+1 -4
View File
@@ -578,10 +578,7 @@ cmProp cmCacheManager::CacheEntry::GetProperty(const std::string& prop) const
bool cmCacheManager::CacheEntry::GetPropertyAsBool(
const std::string& prop) const
{
if (cmProp value = this->GetProperty(prop)) {
return cmIsOn(*value);
}
return false;
return cmIsOn(this->GetProperty(prop));
}
void cmCacheManager::CacheEntry::SetProperty(const std::string& prop,
+2 -2
View File
@@ -515,7 +515,7 @@ bool cmComputeLinkInformation::Compute()
// Restore the target link type so the correct system runtime
// libraries are found.
cmProp lss = this->Target->GetProperty("LINK_SEARCH_END_STATIC");
if (lss && cmIsOn(*lss)) {
if (cmIsOn(lss)) {
this->SetCurrentLinkType(LinkStatic);
} else {
this->SetCurrentLinkType(this->StartLinkType);
@@ -841,7 +841,7 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo()
// Lookup the starting link type from the target (linked statically?).
cmProp lss = this->Target->GetProperty("LINK_SEARCH_START_STATIC");
this->StartLinkType = (lss && cmIsOn(*lss)) ? LinkStatic : LinkShared;
this->StartLinkType = cmIsOn(lss) ? LinkStatic : LinkShared;
this->CurrentLinkType = this->StartLinkType;
}
+4 -6
View File
@@ -236,9 +236,8 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
//
// Also we can disable external (outside the project) files by setting ON
// CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES variable.
const bool excludeExternal =
cmIsOn(it.second[0]->GetMakefile()->GetSafeDefinition(
"CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES"));
const bool excludeExternal = it.second[0]->GetMakefile()->IsOn(
"CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES");
if (!splitted.empty() &&
(!excludeExternal || (relative.find("..") == std::string::npos)) &&
relative.find("CMakeFiles") == std::string::npos) {
@@ -380,9 +379,8 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
cmSystemTools::RelativePath(lg->GetSourceDirectory(), fullPath);
// Do not add this file if it has ".." in relative path and
// if CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES variable is on.
const bool excludeExternal =
cmIsOn(lg->GetMakefile()->GetSafeDefinition(
"CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES"));
const bool excludeExternal = lg->GetMakefile()->IsOn(
"CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES");
if (excludeExternal &&
(relative.find("..") != std::string::npos)) {
continue;
+3 -3
View File
@@ -1166,9 +1166,9 @@ void cmFindPackageCommand::AppendSuccessInformation()
std::string found = cmStrCat(this->Name, "_FOUND");
std::string upperFound = cmSystemTools::UpperCase(found);
const char* upperResult = this->Makefile->GetDefinition(upperFound);
const char* result = this->Makefile->GetDefinition(found);
bool packageFound = ((cmIsOn(result)) || (cmIsOn(upperResult)));
bool upperResult = this->Makefile->IsOn(upperFound);
bool result = this->Makefile->IsOn(found);
bool packageFound = (result || upperResult);
this->AppendToFoundProperty(packageFound);
+2 -3
View File
@@ -854,9 +854,8 @@ bool cmGeneratorTarget::IsIPOEnabled(std::string const& lang,
std::string const& config) const
{
cmProp feature = this->GetFeature("INTERPROCEDURAL_OPTIMIZATION", config);
const bool result = feature && cmIsOn(*feature);
if (!result) {
if (!cmIsOn(feature)) {
// 'INTERPROCEDURAL_OPTIMIZATION' is off, no need to check policies
return false;
}
@@ -1001,7 +1000,7 @@ bool cmGeneratorTarget::GetLanguageStandardRequired(
{
cmProp p =
this->GetPropertyWithPairedLanguageSupport(lang, "_STANDARD_REQUIRED");
return p && cmIsOn(*p);
return cmIsOn(p);
}
void cmGeneratorTarget::GetModuleDefinitionSources(
+3 -3
View File
@@ -550,9 +550,9 @@ void cmGhsMultiTargetGenerator::WriteSources(std::ostream& fout_proj)
*/
for (auto& sg : groupFilesList) {
std::ostream* fout;
bool useProjectFile = cmIsOn(*this->GeneratorTarget->GetProperty(
"GHS_NO_SOURCE_GROUP_FILE")) ||
cmIsOn(this->Makefile->GetDefinition("CMAKE_GHS_NO_SOURCE_GROUP_FILE"));
bool useProjectFile =
cmIsOn(this->GeneratorTarget->GetProperty("GHS_NO_SOURCE_GROUP_FILE")) ||
this->Makefile->IsOn("CMAKE_GHS_NO_SOURCE_GROUP_FILE");
if (useProjectFile || sg.empty()) {
fout = &fout_proj;
} else {
+4 -12
View File
@@ -304,14 +304,10 @@ bool cmGlobalGenerator::CheckTargetsForMissingSources() const
for (const auto& target : localGen->GetGeneratorTargets()) {
if (target->GetType() == cmStateEnums::TargetType::GLOBAL_TARGET ||
target->GetType() == cmStateEnums::TargetType::INTERFACE_LIBRARY ||
target->GetType() == cmStateEnums::TargetType::UTILITY) {
target->GetType() == cmStateEnums::TargetType::UTILITY ||
cmIsOn(target->GetProperty("ghs_integrity_app"))) {
continue;
}
if (cmProp p = target->GetProperty("ghs_integrity_app")) {
if (cmIsOn(*p)) {
continue;
}
}
std::vector<std::string> configs =
target->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
@@ -374,14 +370,10 @@ bool cmGlobalGenerator::CheckTargetsForPchCompilePdb() const
for (const auto& target : generator->GetGeneratorTargets()) {
if (target->GetType() == cmStateEnums::TargetType::GLOBAL_TARGET ||
target->GetType() == cmStateEnums::TargetType::INTERFACE_LIBRARY ||
target->GetType() == cmStateEnums::TargetType::UTILITY) {
target->GetType() == cmStateEnums::TargetType::UTILITY ||
cmIsOn(target->GetProperty("ghs_integrity_app"))) {
continue;
}
if (cmProp p = target->GetProperty("ghs_integrity_app")) {
if (cmIsOn(*p)) {
continue;
}
}
std::string const& reuseFrom =
target->GetSafeProperty("PRECOMPILE_HEADERS_REUSE_FROM");
+1 -2
View File
@@ -470,8 +470,7 @@ void cmGlobalGhsMultiGenerator::WriteAllTarget(
if (t->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
cmProp p = t->GetProperty("EXCLUDE_FROM_ALL");
if (!(p && cmIsOn(*p))) {
if (!cmIsOn(t->GetProperty("EXCLUDE_FROM_ALL"))) {
defaultTargets.push_back(t);
}
}
+1 -2
View File
@@ -694,8 +694,7 @@ std::set<std::string> cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
}
// inspect EXCLUDE_FROM_DEFAULT_BUILD[_<CONFIG>] properties
for (std::string const& i : configs) {
cmProp propertyValue = target->GetFeature("EXCLUDE_FROM_DEFAULT_BUILD", i);
if (!propertyValue || cmIsOff(*propertyValue)) {
if (cmIsOff(target->GetFeature("EXCLUDE_FROM_DEFAULT_BUILD", i))) {
activeConfigs.insert(i);
}
}
+11 -14
View File
@@ -191,21 +191,18 @@ bool requireDeviceLinking(cmGeneratorTarget& target, cmLocalGenerator& lg,
target.GetLinkClosure(config);
if (cm::contains(closure->Languages, "CUDA")) {
if (cmProp separableCompilation =
target.GetProperty("CUDA_SEPARABLE_COMPILATION")) {
if (cmIsOn(*separableCompilation)) {
bool doDeviceLinking = false;
switch (target.GetType()) {
case cmStateEnums::SHARED_LIBRARY:
case cmStateEnums::MODULE_LIBRARY:
case cmStateEnums::EXECUTABLE:
doDeviceLinking = true;
break;
default:
break;
}
return doDeviceLinking;
if (cmIsOn(target.GetProperty("CUDA_SEPARABLE_COMPILATION"))) {
bool doDeviceLinking = false;
switch (target.GetType()) {
case cmStateEnums::SHARED_LIBRARY:
case cmStateEnums::MODULE_LIBRARY:
case cmStateEnums::EXECUTABLE:
doDeviceLinking = true;
break;
default:
break;
}
return doDeviceLinking;
}
cmComputeLinkInformation* pcli = target.GetLinkInformation(config);
+3 -4
View File
@@ -130,7 +130,7 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile)
this->LinkerSysroot = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT");
}
if (std::string const* appleArchSysroots =
if (cmProp appleArchSysroots =
this->Makefile->GetDef("CMAKE_APPLE_ARCH_SYSROOTS")) {
std::string const& appleArchs =
this->Makefile->GetSafeDefinition("CMAKE_OSX_ARCHITECTURES");
@@ -1543,9 +1543,8 @@ void cmLocalGenerator::GetTargetFlags(
frameworkPath, linkPath);
}
if (cmIsOn(this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) {
std::string sFlagVar = std::string("CMAKE_SHARED_BUILD_") +
linkLanguage + std::string("_FLAGS");
if (this->Makefile->IsOn("BUILD_SHARED_LIBS")) {
std::string sFlagVar = "CMAKE_SHARED_BUILD_" + linkLanguage + "_FLAGS";
exeFlags += this->Makefile->GetSafeDefinition(sFlagVar);
exeFlags += " ";
}
+2 -4
View File
@@ -2521,8 +2521,7 @@ void cmMakefile::ExpandVariablesCMP0019()
bool cmMakefile::IsOn(const std::string& name) const
{
const char* value = this->GetDefinition(name);
return cmIsOn(value);
return cmIsOn(this->GetDef(name));
}
bool cmMakefile::IsSet(const std::string& name) const
@@ -4116,8 +4115,7 @@ cmProp cmMakefile::GetProperty(const std::string& prop, bool chain) const
bool cmMakefile::GetPropertyAsBool(const std::string& prop) const
{
cmProp p = this->GetProperty(prop);
return p && cmIsOn(*p);
return cmIsOn(this->GetProperty(prop));
}
std::vector<std::string> cmMakefile::GetPropertyKeys() const
+1 -2
View File
@@ -197,8 +197,7 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
}
// add custom commands to the clean rules?
cmProp clean_no_custom = this->Makefile->GetProperty("CLEAN_NO_CUSTOM");
bool clean = clean_no_custom ? cmIsOff(*clean_no_custom) : true;
bool clean = cmIsOff(this->Makefile->GetProperty("CLEAN_NO_CUSTOM"));
// First generate the object rule files. Save a list of all object
// files for this target.
+2 -2
View File
@@ -50,7 +50,7 @@ cmQtAutoGenGlobalInitializer::cmQtAutoGenGlobalInitializer(
{
cmMakefile* makefile = localGen->GetMakefile();
// Detect global autogen target name
if (cmIsOn(makefile->GetSafeDefinition("CMAKE_GLOBAL_AUTOGEN_TARGET"))) {
if (makefile->IsOn("CMAKE_GLOBAL_AUTOGEN_TARGET")) {
std::string targetName =
makefile->GetSafeDefinition("CMAKE_GLOBAL_AUTOGEN_TARGET_NAME");
if (targetName.empty()) {
@@ -61,7 +61,7 @@ cmQtAutoGenGlobalInitializer::cmQtAutoGenGlobalInitializer(
}
// Detect global autorcc target name
if (cmIsOn(makefile->GetSafeDefinition("CMAKE_GLOBAL_AUTORCC_TARGET"))) {
if (makefile->IsOn("CMAKE_GLOBAL_AUTORCC_TARGET")) {
std::string targetName =
makefile->GetSafeDefinition("CMAKE_GLOBAL_AUTORCC_TARGET_NAME");
if (targetName.empty()) {
+1 -1
View File
@@ -489,7 +489,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
if (this->Moc.Enabled) {
// Path prefix
if (cmIsOn(this->GenTarget->GetSafeProperty("AUTOMOC_PATH_PREFIX"))) {
if (cmIsOn(this->GenTarget->GetProperty("AUTOMOC_PATH_PREFIX"))) {
this->Moc.PathPrefix = true;
}
+1 -2
View File
@@ -380,8 +380,7 @@ const char* cmSourceFile::GetSafeProperty(const std::string& prop) const
bool cmSourceFile::GetPropertyAsBool(const std::string& prop) const
{
cmProp p = this->GetProperty(prop);
return p && cmIsOn(*p);
return cmIsOn(this->GetProperty(prop));
}
void cmSourceFile::SetProperties(cmPropertyMap properties)
+1 -2
View File
@@ -623,8 +623,7 @@ cmProp cmState::GetGlobalProperty(const std::string& prop)
bool cmState::GetGlobalPropertyAsBool(const std::string& prop)
{
cmProp p = this->GetGlobalProperty(prop);
return p && cmIsOn(*p);
return cmIsOn(this->GetGlobalProperty(prop));
}
void cmState::SetSourceDirectory(std::string const& sourceDirectory)
+1 -2
View File
@@ -648,8 +648,7 @@ cmProp cmStateDirectory::GetProperty(const std::string& prop, bool chain) const
bool cmStateDirectory::GetPropertyAsBool(const std::string& prop) const
{
cmProp p = this->GetProperty(prop);
return p && cmIsOn(*p);
return cmIsOn(this->GetProperty(prop));
}
std::vector<std::string> cmStateDirectory::GetPropertyKeys() const
+1 -1
View File
@@ -323,7 +323,7 @@ void cmStateSnapshot::SetDefaultDefinitions()
#if defined(__CYGWIN__)
std::string legacy;
if (cmSystemTools::GetEnv("CMAKE_LEGACY_CYGWIN_WIN32", legacy) &&
cmIsOn(legacy.c_str())) {
cmIsOn(legacy)) {
this->SetDefinition("WIN32", "1");
this->SetDefinition("CMAKE_HOST_WIN32", "1");
}
+10 -8
View File
@@ -205,10 +205,11 @@ bool cmIsNOTFOUND(cm::string_view val);
bool cmIsOn(cm::string_view val);
inline bool cmIsOn(const char* val)
{
if (!val) {
return false;
}
return cmIsOn(cm::string_view(val));
return val && cmIsOn(cm::string_view(val));
}
inline bool cmIsOn(std::string const* val)
{
return val && cmIsOn(*val);
}
/**
@@ -221,10 +222,11 @@ inline bool cmIsOn(const char* val)
bool cmIsOff(cm::string_view val);
inline bool cmIsOff(const char* val)
{
if (!val) {
return true;
}
return cmIsOff(cm::string_view(val));
return !val || cmIsOff(cm::string_view(val));
}
inline bool cmIsOff(std::string const* val)
{
return !val || cmIsOff(*val);
}
/** Returns true if string @a str starts with the character @a prefix. */
+1 -2
View File
@@ -1884,8 +1884,7 @@ std::string const& cmTarget::GetSafeProperty(std::string const& prop) const
bool cmTarget::GetPropertyAsBool(const std::string& prop) const
{
cmProp p = this->GetProperty(prop);
return p && cmIsOn(*p);
return cmIsOn(this->GetProperty(prop));
}
cmPropertyMap const& cmTarget::GetProperties() const
+1 -2
View File
@@ -324,8 +324,7 @@ bool cmXCodeScheme::WriteLaunchActionBooleanAttribute(
bool defaultValue)
{
cmProp property = Target->GetTarget()->GetProperty(varName);
bool isOn =
(property == nullptr && defaultValue) || (property && cmIsOn(*property));
bool isOn = (property == nullptr && defaultValue) || cmIsOn(property);
if (isOn) {
xout.Attribute(attrName.c_str(), "YES");
+3 -5
View File
@@ -1487,10 +1487,10 @@ int cmake::Configure()
this->Messenger->SetSuppressDeprecatedWarnings(value && cmIsOff(*value));
value = this->State->GetCacheEntryValue("CMAKE_ERROR_DEPRECATED");
this->Messenger->SetDeprecatedWarningsAsErrors(value && cmIsOn(*value));
this->Messenger->SetDeprecatedWarningsAsErrors(cmIsOn(value));
value = this->State->GetCacheEntryValue("CMAKE_SUPPRESS_DEVELOPER_WARNINGS");
this->Messenger->SetSuppressDevWarnings(value && cmIsOn(*value));
this->Messenger->SetSuppressDevWarnings(cmIsOn(value));
value = this->State->GetCacheEntryValue("CMAKE_SUPPRESS_DEVELOPER_ERRORS");
this->Messenger->SetDevWarningsAsErrors(value && cmIsOff(*value));
@@ -2742,9 +2742,7 @@ int cmake::Build(int jobs, const std::string& dir,
}
projName = *cachedProjectName;
cmProp cachedVerbose =
this->State->GetCacheEntryValue("CMAKE_VERBOSE_MAKEFILE");
if (cachedVerbose && cmIsOn(*cachedVerbose)) {
if (cmIsOn(this->State->GetCacheEntryValue("CMAKE_VERBOSE_MAKEFILE"))) {
verbose = true;
}