diff options
-rw-r--r-- | Source/cmCoreTryCompile.cxx | 6 | ||||
-rw-r--r-- | Source/cmFindPackageCommand.cxx | 4 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 16 | ||||
-rw-r--r-- | Source/cmGlobalGhsMultiGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudioGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmInstallCommand.cxx | 6 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 8 | ||||
-rw-r--r-- | Source/cmLocalNinjaGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 2 | ||||
-rw-r--r-- | Source/cmMakefileExecutableTargetGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmMakefileLibraryTargetGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 20 | ||||
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 19 | ||||
-rw-r--r-- | Source/cmQtAutoGenInitializer.cxx | 2 | ||||
-rw-r--r-- | Source/cmStandardLevelResolver.cxx | 2 | ||||
-rw-r--r-- | Source/cmStringAlgorithms.h | 14 | ||||
-rw-r--r-- | Source/cmTestGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 6 |
19 files changed, 69 insertions, 58 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 7fbe90e..8465c58 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -18,6 +18,7 @@ #include "cmMessageType.h" #include "cmOutputConverter.h" #include "cmPolicies.h" +#include "cmProperty.h" #include "cmState.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -235,9 +236,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, this->SrcFileSignature = true; cmStateEnums::TargetType targetType = cmStateEnums::EXECUTABLE; - const std::string* tt = - this->Makefile->GetDef("CMAKE_TRY_COMPILE_TARGET_TYPE"); - if (!isTryRun && tt && !tt->empty()) { + cmProp tt = this->Makefile->GetDef("CMAKE_TRY_COMPILE_TARGET_TYPE"); + if (!isTryRun && cmNonempty(tt)) { if (*tt == cmState::GetTargetTypeName(cmStateEnums::EXECUTABLE)) { targetType = cmStateEnums::EXECUTABLE; } else if (*tt == diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 8d5b177..ffc7cc4 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -1121,7 +1121,7 @@ void cmFindPackageCommand::AppendToFoundProperty(bool found) std::vector<std::string> foundContents; cmProp foundProp = this->Makefile->GetState()->GetGlobalProperty("PACKAGES_FOUND"); - if (foundProp && !foundProp->empty()) { + if (cmNonempty(foundProp)) { cmExpandList(*foundProp, foundContents, false); auto nameIt = std::find(foundContents.begin(), foundContents.end(), this->Name); @@ -1133,7 +1133,7 @@ void cmFindPackageCommand::AppendToFoundProperty(bool found) std::vector<std::string> notFoundContents; cmProp notFoundProp = this->Makefile->GetState()->GetGlobalProperty("PACKAGES_NOT_FOUND"); - if (notFoundProp && !notFoundProp->empty()) { + if (cmNonempty(notFoundProp)) { cmExpandList(*notFoundProp, notFoundContents, false); auto nameIt = std::find(notFoundContents.begin(), notFoundContents.end(), this->Name); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 9e6f995..742cf95 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -365,7 +365,7 @@ std::string cmGeneratorTarget::GetExportName() const { cmProp exportName = this->GetProperty("EXPORT_NAME"); - if (exportName && !exportName->empty()) { + if (cmNonempty(exportName)) { if (!cmGeneratorExpression::IsValidTargetName(*exportName)) { std::ostringstream e; e << "EXPORT_NAME property \"" << *exportName << "\" for \"" @@ -1194,7 +1194,7 @@ bool cmGeneratorTarget::MaybeHaveInterfaceProperty( // If this target itself has a non-empty property value, we are done. cmProp p = this->GetProperty(prop); - maybeInterfaceProp = p && !p->empty(); + maybeInterfaceProp = cmNonempty(p); // Otherwise, recurse to interface dependencies. if (!maybeInterfaceProp) { @@ -1841,12 +1841,12 @@ std::string cmGeneratorTarget::GetCompilePDBName( std::string configUpper = cmSystemTools::UpperCase(config); std::string configProp = cmStrCat("COMPILE_PDB_NAME_", configUpper); cmProp config_name = this->GetProperty(configProp); - if (config_name && !config_name->empty()) { + if (cmNonempty(config_name)) { return prefix + *config_name + ".pdb"; } cmProp name = this->GetProperty("COMPILE_PDB_NAME"); - if (name && !name->empty()) { + if (cmNonempty(name)) { return prefix + *name + ".pdb"; } @@ -2293,7 +2293,7 @@ std::string cmGeneratorTarget::GetInstallNameDirForInstallTree( cmProp install_name_dir = this->GetProperty("INSTALL_NAME_DIR"); if (this->CanGenerateInstallNameDir(INSTALL_NAME_FOR_INSTALL)) { - if (install_name_dir && !install_name_dir->empty()) { + if (cmNonempty(install_name_dir)) { dir = *install_name_dir; cmGeneratorExpression::ReplaceInstallPrefix(dir, installPrefix); dir = @@ -5840,7 +5840,7 @@ std::string cmGeneratorTarget::GetRuntimeLinkLibrary( // not it is overridden by a property. cmProp runtimeLibraryDefault = this->Makefile->GetDef( cmStrCat("CMAKE_", lang, "_RUNTIME_LIBRARY_DEFAULT")); - if (!runtimeLibraryDefault || runtimeLibraryDefault->empty()) { + if (!cmNonempty(runtimeLibraryDefault)) { return std::string(); } cmProp runtimeLibraryValue = @@ -6973,7 +6973,7 @@ std::string cmGeneratorTarget::CheckCMP0004(std::string const& item) const bool cmGeneratorTarget::IsDeprecated() const { cmProp deprecation = this->GetProperty("DEPRECATION"); - return deprecation && !deprecation->empty(); + return cmNonempty(deprecation); } std::string cmGeneratorTarget::GetDeprecation() const @@ -7038,7 +7038,7 @@ bool cmGeneratorTarget::IsCSharpOnly() const // Consider an explicit linker language property, but *not* the // computed linker language that may depend on linked targets. cmProp linkLang = this->GetProperty("LINKER_LANGUAGE"); - if (linkLang && !linkLang->empty()) { + if (cmNonempty(linkLang)) { languages.insert(*linkLang); } return languages.size() == 1 && languages.count("CSharp") > 0; diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index d36adfb..4715abe 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -635,7 +635,7 @@ void cmGlobalGhsMultiGenerator::WriteHighLevelDirectives( std::string tgt; const char* t = this->GetCMakeInstance()->GetCacheDefinition("GHS_PRIMARY_TARGET"); - if (t && *t != '\0') { + if (cmNonempty(t)) { tgt = t; this->GetCMakeInstance()->MarkCliAsUsed("GHS_PRIMARY_TARGET"); } else { diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index c688da2..b31d069 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -509,7 +509,7 @@ std::string cmGlobalVisualStudioGenerator::GetStartupProjectName( cmLocalGenerator const* root) const { cmProp n = root->GetMakefile()->GetProperty("VS_STARTUP_PROJECT"); - if (n && !n->empty()) { + if (cmNonempty(n)) { std::string startup = *n; if (this->FindTarget(startup)) { return startup; @@ -810,7 +810,7 @@ bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly( // a target with none of its own sources, e.g. when also using // object libraries. cmProp linkLang = gt->GetProperty("LINKER_LANGUAGE"); - if (linkLang && !linkLang->empty()) { + if (cmNonempty(linkLang)) { languages.insert(*linkLang); } diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 178af73..ddd6c22 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -680,7 +680,7 @@ bool HandleTargetsMode(std::vector<std::string> const& args, if (createInstallGeneratorsForTargetFileSets && !namelinkOnly) { cmProp files = target.GetProperty("PRIVATE_HEADER"); - if (files && !files->empty()) { + if (cmNonempty(files)) { std::vector<std::string> relFiles = cmExpandedList(*files); std::vector<std::string> absFiles; if (!helper.MakeFilesFullPath("PRIVATE_HEADER", relFiles, absFiles)) { @@ -702,7 +702,7 @@ bool HandleTargetsMode(std::vector<std::string> const& args, } files = target.GetProperty("PUBLIC_HEADER"); - if (files && !files->empty()) { + if (cmNonempty(files)) { std::vector<std::string> relFiles = cmExpandedList(*files); std::vector<std::string> absFiles; if (!helper.MakeFilesFullPath("PUBLIC_HEADER", relFiles, absFiles)) { @@ -724,7 +724,7 @@ bool HandleTargetsMode(std::vector<std::string> const& args, } files = target.GetProperty("RESOURCE"); - if (files && !files->empty()) { + if (cmNonempty(files)) { std::vector<std::string> relFiles = cmExpandedList(*files); std::vector<std::string> absFiles; if (!helper.MakeFilesFullPath("RESOURCE", relFiles, absFiles)) { diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index e7f2e64..961f349 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1972,7 +1972,7 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, // of a default selection whether or not it is overridden by a property. cmProp msvcRuntimeLibraryDefault = this->Makefile->GetDef("CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT"); - if (msvcRuntimeLibraryDefault && !msvcRuntimeLibraryDefault->empty()) { + if (cmNonempty(msvcRuntimeLibraryDefault)) { cmProp msvcRuntimeLibraryValue = target->GetProperty("MSVC_RUNTIME_LIBRARY"); if (!msvcRuntimeLibraryValue) { @@ -3807,8 +3807,7 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmGeneratorTarget* target, { // Find the Info.plist template. cmProp in = target->GetProperty("MACOSX_BUNDLE_INFO_PLIST"); - std::string inFile = - (in && !in->empty()) ? *in : "MacOSXBundleInfo.plist.in"; + std::string inFile = cmNonempty(in) ? *in : "MacOSXBundleInfo.plist.in"; if (!cmSystemTools::FileIsFullPath(inFile)) { std::string inMod = this->Makefile->GetModulesFile(inFile); if (!inMod.empty()) { @@ -3847,8 +3846,7 @@ void cmLocalGenerator::GenerateFrameworkInfoPList( { // Find the Info.plist template. cmProp in = target->GetProperty("MACOSX_FRAMEWORK_INFO_PLIST"); - std::string inFile = - (in && !in->empty()) ? *in : "MacOSXFrameworkInfo.plist.in"; + std::string inFile = cmNonempty(in) ? *in : "MacOSXFrameworkInfo.plist.in"; if (!cmSystemTools::FileIsFullPath(inFile)) { std::string inMod = this->Makefile->GetModulesFile(inFile); if (!inMod.empty()) { diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 87e8aa4..aee7f45 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -668,7 +668,7 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher( { cmProp property_value = this->Makefile->GetProperty("RULE_LAUNCH_CUSTOM"); - if (!property_value || property_value->empty()) { + if (!cmNonempty(property_value)) { return std::string(); } diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index de1461a..86a888a 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -950,7 +950,7 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand( std::string launcher; // Short-circuit if there is no launcher. const char* val = this->GetRuleLauncher(target, "RULE_LAUNCH_CUSTOM"); - if (val && *val) { + if (cmNonempty(val)) { // Expand rule variables referenced in the given launcher command. cmRulePlaceholderExpander::RuleVariables vars; vars.CMTargetName = target->GetName().c_str(); diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 446f225..bc288ac 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -218,7 +218,7 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule( const char* val = this->LocalGenerator->GetRuleLauncher( this->GeneratorTarget, "RULE_LAUNCH_LINK"); - if (val && *val) { + if (cmNonempty(val)) { launcher = cmStrCat(val, ' '); } @@ -583,7 +583,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) const char* val = this->LocalGenerator->GetRuleLauncher( this->GeneratorTarget, "RULE_LAUNCH_LINK"); - if (val && *val) { + if (cmNonempty(val)) { launcher = cmStrCat(val, ' '); } diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 5809b4a..1c25fc4 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -356,7 +356,7 @@ void cmMakefileLibraryTargetGenerator::WriteDeviceLibraryRules( std::string launcher; const char* val = this->LocalGenerator->GetRuleLauncher( this->GeneratorTarget, "RULE_LAUNCH_LINK"); - if (val && *val) { + if (cmNonempty(val)) { launcher = cmStrCat(val, ' '); } @@ -809,7 +809,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( std::string launcher; const char* val = this->LocalGenerator->GetRuleLauncher( this->GeneratorTarget, "RULE_LAUNCH_LINK"); - if (val && *val) { + if (cmNonempty(val)) { launcher = cmStrCat(val, ' '); } diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 6887569..657b7c5 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -807,7 +807,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( lang == "OBJC" || lang == "OBJCXX")) { std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER"; cmProp clauncher = this->GeneratorTarget->GetProperty(clauncher_prop); - if (clauncher && !clauncher->empty()) { + if (cmNonempty(clauncher)) { compilerLauncher = *clauncher; } } @@ -822,8 +822,8 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( cmProp cpplint = this->GeneratorTarget->GetProperty(cpplint_prop); std::string const cppcheck_prop = lang + "_CPPCHECK"; cmProp cppcheck = this->GeneratorTarget->GetProperty(cppcheck_prop); - if ((iwyu && !iwyu->empty()) || (tidy && !tidy->empty()) || - (cpplint && !cpplint->empty()) || (cppcheck && !cppcheck->empty())) { + if (cmNonempty(iwyu) || cmNonempty(tidy) || cmNonempty(cpplint) || + cmNonempty(cppcheck)) { std::string run_iwyu = "$(CMAKE_COMMAND) -E __run_co_compile"; if (!compilerLauncher.empty()) { // In __run_co_compile case the launcher command is supplied @@ -832,11 +832,11 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( run_iwyu += this->LocalGenerator->EscapeForShell(compilerLauncher); compilerLauncher.clear(); } - if (iwyu && !iwyu->empty()) { + if (cmNonempty(iwyu)) { run_iwyu += " --iwyu="; run_iwyu += this->LocalGenerator->EscapeForShell(*iwyu); } - if (tidy && !tidy->empty()) { + if (cmNonempty(tidy)) { run_iwyu += " --tidy="; const char* driverMode = this->Makefile->GetDefinition( "CMAKE_" + lang + "_CLANG_TIDY_DRIVER_MODE"); @@ -846,16 +846,16 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( run_iwyu += this->LocalGenerator->EscapeForShell( cmStrCat(*tidy, ";--extra-arg-before=--driver-mode=", driverMode)); } - if (cpplint && !cpplint->empty()) { + if (cmNonempty(cpplint)) { run_iwyu += " --cpplint="; run_iwyu += this->LocalGenerator->EscapeForShell(*cpplint); } - if (cppcheck && !cppcheck->empty()) { + if (cmNonempty(cppcheck)) { run_iwyu += " --cppcheck="; run_iwyu += this->LocalGenerator->EscapeForShell(*cppcheck); } - if ((tidy && !tidy->empty()) || (cpplint && !cpplint->empty()) || - (cppcheck && !cppcheck->empty())) { + if (cmNonempty(tidy) || (cmNonempty(cpplint)) || + (cmNonempty(cppcheck))) { run_iwyu += " --source="; run_iwyu += sourceFile; } @@ -882,7 +882,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( { const char* val = this->LocalGenerator->GetRuleLauncher( this->GeneratorTarget, "RULE_LAUNCH_COMPILE"); - if (val && *val) { + if (cmNonempty(val)) { launcher = cmStrCat(val, ' '); } } diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index b92548f..66e1e40 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -239,7 +239,7 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkRule( std::string launcher; const char* val = this->GetLocalGenerator()->GetRuleLauncher( this->GetGeneratorTarget(), "RULE_LAUNCH_LINK"); - if (val && *val) { + if (cmNonempty(val)) { launcher = cmStrCat(val, ' '); } @@ -376,7 +376,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile, std::string launcher; const char* val = this->GetLocalGenerator()->GetRuleLauncher( this->GetGeneratorTarget(), "RULE_LAUNCH_LINK"); - if (val && *val) { + if (cmNonempty(val)) { launcher = cmStrCat(val, ' '); } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 53a0cb7..de18536 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -662,7 +662,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, std::string launcher; const char* val = this->GetLocalGenerator()->GetRuleLauncher( this->GetGeneratorTarget(), "RULE_LAUNCH_COMPILE"); - if (val && *val) { + if (cmNonempty(val)) { launcher = cmStrCat(val, ' '); } @@ -813,7 +813,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, lang == "OBJC" || lang == "OBJCXX")) { std::string const clauncher_prop = cmStrCat(lang, "_COMPILER_LAUNCHER"); cmProp clauncher = this->GeneratorTarget->GetProperty(clauncher_prop); - if (clauncher && !clauncher->empty()) { + if (cmNonempty(clauncher)) { compilerLauncher = *clauncher; } } @@ -828,8 +828,8 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, cmProp cpplint = this->GeneratorTarget->GetProperty(cpplint_prop); std::string const cppcheck_prop = cmStrCat(lang, "_CPPCHECK"); cmProp cppcheck = this->GeneratorTarget->GetProperty(cppcheck_prop); - if ((iwyu && !iwyu->empty()) || (tidy && !tidy->empty()) || - (cpplint && !cpplint->empty()) || (cppcheck && !cppcheck->empty())) { + if (cmNonempty(iwyu) || cmNonempty(tidy) || cmNonempty(cpplint) || + cmNonempty(cppcheck)) { std::string run_iwyu = cmStrCat(cmakeCmd, " -E __run_co_compile"); if (!compilerLauncher.empty()) { // In __run_co_compile case the launcher command is supplied @@ -839,11 +839,11 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, this->LocalGenerator->EscapeForShell(compilerLauncher)); compilerLauncher.clear(); } - if (iwyu && !iwyu->empty()) { + if (cmNonempty(iwyu)) { run_iwyu += cmStrCat(" --iwyu=", this->GetLocalGenerator()->EscapeForShell(*iwyu)); } - if (tidy && !tidy->empty()) { + if (cmNonempty(tidy)) { run_iwyu += " --tidy="; const char* driverMode = this->Makefile->GetDefinition( cmStrCat("CMAKE_", lang, "_CLANG_TIDY_DRIVER_MODE")); @@ -853,17 +853,16 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, run_iwyu += this->GetLocalGenerator()->EscapeForShell( cmStrCat(*tidy, ";--extra-arg-before=--driver-mode=", driverMode)); } - if (cpplint && !cpplint->empty()) { + if (cmNonempty(cpplint)) { run_iwyu += cmStrCat( " --cpplint=", this->GetLocalGenerator()->EscapeForShell(*cpplint)); } - if (cppcheck && !cppcheck->empty()) { + if (cmNonempty(cppcheck)) { run_iwyu += cmStrCat(" --cppcheck=", this->GetLocalGenerator()->EscapeForShell(*cppcheck)); } - if ((tidy && !tidy->empty()) || (cpplint && !cpplint->empty()) || - (cppcheck && !cppcheck->empty())) { + if (cmNonempty(tidy) || cmNonempty(cpplint) || cmNonempty(cppcheck)) { run_iwyu += " --source=$in"; } run_iwyu += " -- "; diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 7e0bf96..6b7665a 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -1610,7 +1610,7 @@ void cmQtAutoGenInitializer::AddToSourceGroup(std::string const& fileName, }; for (std::string const& prop : props) { cmProp propName = this->Makefile->GetState()->GetGlobalProperty(prop); - if (propName && !propName->empty()) { + if (cmNonempty(propName)) { groupName = *propName; property = prop; break; diff --git a/Source/cmStandardLevelResolver.cxx b/Source/cmStandardLevelResolver.cxx index 5e30680..096ae9d 100644 --- a/Source/cmStandardLevelResolver.cxx +++ b/Source/cmStandardLevelResolver.cxx @@ -70,7 +70,7 @@ struct StanardLevelComputer if (existingStandard == nullptr) { cmProp defaultStandard = makefile->GetDef( cmStrCat("CMAKE_", this->Language, "_STANDARD_DEFAULT")); - if (defaultStandard && !defaultStandard->empty()) { + if (cmNonempty(defaultStandard)) { existingStandard = defaultStandard; } } diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h index a5ecca7..a1ff304 100644 --- a/Source/cmStringAlgorithms.h +++ b/Source/cmStringAlgorithms.h @@ -20,6 +20,20 @@ /** String range type. */ using cmStringRange = cmRange<std::vector<std::string>::const_iterator>; +/** Check for non-empty string. */ +inline bool cmNonempty(const char* str) +{ + return str && *str; +} +inline bool cmNonempty(cm::string_view str) +{ + return !str.empty(); +} +inline bool cmNonempty(std::string const* str) +{ + return str && !str->empty(); +} + /** Callable string comparison struct. */ struct cmStrCmp { diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index e10a8e2..7c0ce71 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -102,7 +102,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, // Prepend with the emulator when cross compiling if required. cmProp emulator = target->GetProperty("CROSSCOMPILING_EMULATOR"); - if (emulator != nullptr && !emulator->empty()) { + if (cmNonempty(emulator)) { std::vector<std::string> emulatorWithArgs = cmExpandedList(*emulator); std::string emulatorExe(emulatorWithArgs[0]); cmSystemTools::ConvertToUnixSlashes(emulatorExe); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 5f6b41d..5d9199b 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1976,7 +1976,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, } cmProp toolOverride = sf->GetProperty("VS_TOOL_OVERRIDE"); - if (toolOverride && !toolOverride->empty()) { + if (cmNonempty(toolOverride)) { tool = toolOverride->c_str(); } @@ -1985,12 +1985,12 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, if (this->GlobalGenerator->TargetsWindowsPhone() || this->GlobalGenerator->TargetsWindowsStore()) { cmProp content = sf->GetProperty("VS_DEPLOYMENT_CONTENT"); - if (content && !content->empty()) { + if (cmNonempty(content)) { toolHasSettings = true; deployContent = *content; cmProp location = sf->GetProperty("VS_DEPLOYMENT_LOCATION"); - if (location && !location->empty()) { + if (cmNonempty(location)) { deployLocation = *location; } } |