diff options
author | Vitaly Stakhovsky <vvs31415@gitlab.org> | 2020-07-27 19:00:00 -0400 |
---|---|---|
committer | Vitaly Stakhovsky <vvs31415@gitlab.org> | 2020-07-28 08:31:31 -0400 |
commit | f37c14e93036fe01fca3539f539ff8821494e9d1 (patch) | |
tree | fc08ddab0c3e9b47f00cff9a287cc89a2afa13ca | |
parent | 261a2585d9df7113a5ba7c9beacb641754444523 (diff) | |
download | cmake-f37c14e93036fe01fca3539f539ff8821494e9d1.tar.gz |
Source: use cmNonempty()
26 files changed, 85 insertions, 86 deletions
diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 3d5fe6b9de..560e5c1dc5 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -696,57 +696,57 @@ int cmCPackDebGenerator::createDeb() const char* debian_pkg_source = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SOURCE"); - if (debian_pkg_source && *debian_pkg_source) { + if (cmNonempty(debian_pkg_source)) { controlValues["Source"] = debian_pkg_source; } const char* debian_pkg_dep = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_DEPENDS"); - if (debian_pkg_dep && *debian_pkg_dep) { + if (cmNonempty(debian_pkg_dep)) { controlValues["Depends"] = debian_pkg_dep; } const char* debian_pkg_rec = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_RECOMMENDS"); - if (debian_pkg_rec && *debian_pkg_rec) { + if (cmNonempty(debian_pkg_rec)) { controlValues["Recommends"] = debian_pkg_rec; } const char* debian_pkg_sug = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SUGGESTS"); - if (debian_pkg_sug && *debian_pkg_sug) { + if (cmNonempty(debian_pkg_sug)) { controlValues["Suggests"] = debian_pkg_sug; } const char* debian_pkg_url = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_HOMEPAGE"); - if (debian_pkg_url && *debian_pkg_url) { + if (cmNonempty(debian_pkg_url)) { controlValues["Homepage"] = debian_pkg_url; } const char* debian_pkg_predep = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PREDEPENDS"); - if (debian_pkg_predep && *debian_pkg_predep) { + if (cmNonempty(debian_pkg_predep)) { controlValues["Pre-Depends"] = debian_pkg_predep; } const char* debian_pkg_enhances = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_ENHANCES"); - if (debian_pkg_enhances && *debian_pkg_enhances) { + if (cmNonempty(debian_pkg_enhances)) { controlValues["Enhances"] = debian_pkg_enhances; } const char* debian_pkg_breaks = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_BREAKS"); - if (debian_pkg_breaks && *debian_pkg_breaks) { + if (cmNonempty(debian_pkg_breaks)) { controlValues["Breaks"] = debian_pkg_breaks; } const char* debian_pkg_conflicts = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_CONFLICTS"); - if (debian_pkg_conflicts && *debian_pkg_conflicts) { + if (cmNonempty(debian_pkg_conflicts)) { controlValues["Conflicts"] = debian_pkg_conflicts; } const char* debian_pkg_provides = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PROVIDES"); - if (debian_pkg_provides && *debian_pkg_provides) { + if (cmNonempty(debian_pkg_provides)) { controlValues["Provides"] = debian_pkg_provides; } const char* debian_pkg_replaces = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_REPLACES"); - if (debian_pkg_replaces && *debian_pkg_replaces) { + if (cmNonempty(debian_pkg_replaces)) { controlValues["Replaces"] = debian_pkg_replaces; } @@ -756,7 +756,7 @@ int cmCPackDebGenerator::createDeb() const char* debian_pkg_shlibs = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SHLIBS"); const bool gen_shibs = this->IsOn("CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS") && - debian_pkg_shlibs && *debian_pkg_shlibs; + cmNonempty(debian_pkg_shlibs); if (gen_shibs) { cmGeneratedFileStream out; out.Open(shlibsfilename, false, true); @@ -832,11 +832,11 @@ int cmCPackDebGenerator::createDbgsymDDeb() const char* debian_pkg_source = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SOURCE"); - if (debian_pkg_source && *debian_pkg_source) { + if (cmNonempty(debian_pkg_source)) { controlValues["Source"] = debian_pkg_source; } const char* debian_build_ids = this->GetOption("GEN_BUILD_IDS"); - if (debian_build_ids && *debian_build_ids) { + if (cmNonempty(debian_build_ids)) { controlValues["Build-Ids"] = debian_build_ids; } diff --git a/Source/CPack/cmCPackExternalGenerator.cxx b/Source/CPack/cmCPackExternalGenerator.cxx index 53be4fe56b..0bc8456710 100644 --- a/Source/CPack/cmCPackExternalGenerator.cxx +++ b/Source/CPack/cmCPackExternalGenerator.cxx @@ -61,7 +61,7 @@ int cmCPackExternalGenerator::PackageFiles() } const char* packageScript = this->GetOption("CPACK_EXTERNAL_PACKAGE_SCRIPT"); - if (packageScript && *packageScript) { + if (cmNonempty(packageScript)) { if (!cmSystemTools::FileIsFullPath(packageScript)) { cmCPackLogger( cmCPackLog::LOG_ERROR, @@ -211,7 +211,7 @@ int cmCPackExternalGenerator::cmCPackExternalVersionGenerator::WriteToJSON( const char* defaultDirectoryPermissions = this->Parent->GetOption("CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS"); - if (defaultDirectoryPermissions && *defaultDirectoryPermissions) { + if (cmNonempty(defaultDirectoryPermissions)) { root["defaultDirectoryPermissions"] = defaultDirectoryPermissions; } if (cmIsInternallyOn(this->Parent->GetOption("CPACK_SET_DESTDIR"))) { diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index c641175442..3880f6551d 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -216,7 +216,7 @@ int cmCPackGenerator::InstallProject() mode_t* default_dir_mode = nullptr; const char* default_dir_install_permissions = this->GetOption("CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS"); - if (default_dir_install_permissions && *default_dir_install_permissions) { + if (cmNonempty(default_dir_install_permissions)) { std::vector<std::string> items = cmExpandedList(default_dir_install_permissions); for (const auto& arg : items) { @@ -293,7 +293,7 @@ int cmCPackGenerator::InstallProjectViaInstallCommands( { (void)setDestDir; const char* installCommands = this->GetOption("CPACK_INSTALL_COMMANDS"); - if (installCommands && *installCommands) { + if (cmNonempty(installCommands)) { std::string tempInstallDirectoryEnv = cmStrCat("CMAKE_INSTALL_PREFIX=", tempInstallDirectory); cmSystemTools::PutEnv(tempInstallDirectoryEnv); @@ -344,7 +344,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( } const char* installDirectories = this->GetOption("CPACK_INSTALLED_DIRECTORIES"); - if (installDirectories && *installDirectories) { + if (cmNonempty(installDirectories)) { std::vector<std::string> installDirectoriesVector = cmExpandedList(installDirectories); if (installDirectoriesVector.size() % 2 != 0) { @@ -541,7 +541,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( const char* cmakeProjects = this->GetOption("CPACK_INSTALL_CMAKE_PROJECTS"); const char* cmakeGenerator = this->GetOption("CPACK_CMAKE_GENERATOR"); std::string absoluteDestFiles; - if (cmakeProjects && *cmakeProjects) { + if (cmNonempty(cmakeProjects)) { if (!cmakeGenerator) { cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_INSTALL_CMAKE_PROJECTS is specified, but " @@ -594,7 +594,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( std::string installTypesVar = "CPACK_" + cmSystemTools::UpperCase(project.Component) + "_INSTALL_TYPES"; const char* installTypes = this->GetOption(installTypesVar); - if (installTypes && *installTypes) { + if (cmNonempty(installTypes)) { std::vector<std::string> installTypesVector = cmExpandedList(installTypes); for (std::string const& installType : installTypesVector) { @@ -607,7 +607,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( std::string componentsVar = "CPACK_COMPONENTS_" + cmSystemTools::UpperCase(project.Component); const char* components = this->GetOption(componentsVar); - if (components && *components) { + if (cmNonempty(components)) { cmExpandList(components, componentsVector); for (std::string const& comp : componentsVector) { project.Components.push_back( @@ -771,7 +771,7 @@ int cmCPackGenerator::InstallCMakeProject( const char* default_dir_inst_permissions = this->GetOption("CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS"); - if (default_dir_inst_permissions && *default_dir_inst_permissions) { + if (cmNonempty(default_dir_inst_permissions)) { mf.AddDefinition("CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS", default_dir_inst_permissions); } @@ -983,7 +983,7 @@ void cmCPackGenerator::SetOptionIfNotSet(const std::string& op, const char* value) { const char* def = this->MakefileMap->GetDefinition(op); - if (def && *def) { + if (cmNonempty(def)) { return; } this->SetOption(op, value); @@ -1215,7 +1215,7 @@ bool cmCPackGenerator::IsOn(const std::string& name) const bool cmCPackGenerator::IsSetToOff(const std::string& op) const { const char* ret = this->MakefileMap->GetDefinition(op); - if (ret && *ret) { + if (cmNonempty(ret)) { return cmIsOff(ret); } return false; @@ -1509,7 +1509,7 @@ cmCPackInstallationType* cmCPackGenerator::GetInstallationType( installType->Name = name; const char* displayName = this->GetOption(macroPrefix + "_DISPLAY_NAME"); - if (displayName && *displayName) { + if (cmNonempty(displayName)) { installType->DisplayName = displayName; } else { installType->DisplayName = installType->Name; @@ -1531,7 +1531,7 @@ cmCPackComponent* cmCPackGenerator::GetComponent( "CPACK_COMPONENT_" + cmsys::SystemTools::UpperCase(name); component->Name = name; const char* displayName = this->GetOption(macroPrefix + "_DISPLAY_NAME"); - if (displayName && *displayName) { + if (cmNonempty(displayName)) { component->DisplayName = displayName; } else { component->DisplayName = component->Name; @@ -1543,17 +1543,17 @@ cmCPackComponent* cmCPackGenerator::GetComponent( cmIsOn(this->GetOption("CPACK_DOWNLOAD_ALL")); const char* archiveFile = this->GetOption(macroPrefix + "_ARCHIVE_FILE"); - if (archiveFile && *archiveFile) { + if (cmNonempty(archiveFile)) { component->ArchiveFile = archiveFile; } const char* plist = this->GetOption(macroPrefix + "_PLIST"); - if (plist && *plist) { + if (cmNonempty(plist)) { component->Plist = plist; } const char* groupName = this->GetOption(macroPrefix + "_GROUP"); - if (groupName && *groupName) { + if (cmNonempty(groupName)) { component->Group = GetComponentGroup(projectName, groupName); component->Group->Components.push_back(component); } else { @@ -1561,13 +1561,13 @@ cmCPackComponent* cmCPackGenerator::GetComponent( } const char* description = this->GetOption(macroPrefix + "_DESCRIPTION"); - if (description && *description) { + if (cmNonempty(description)) { component->Description = description; } // Determine the installation types. const char* installTypes = this->GetOption(macroPrefix + "_INSTALL_TYPES"); - if (installTypes && *installTypes) { + if (cmNonempty(installTypes)) { std::vector<std::string> installTypesVector = cmExpandedList(installTypes); for (std::string const& installType : installTypesVector) { @@ -1578,7 +1578,7 @@ cmCPackComponent* cmCPackGenerator::GetComponent( // Determine the component dependencies. const char* depends = this->GetOption(macroPrefix + "_DEPENDS"); - if (depends && *depends) { + if (cmNonempty(depends)) { std::vector<std::string> dependsVector = cmExpandedList(depends); for (std::string const& depend : dependsVector) { cmCPackComponent* child = GetComponent(projectName, depend); @@ -1602,21 +1602,21 @@ cmCPackComponentGroup* cmCPackGenerator::GetComponentGroup( // Define the group group->Name = name; const char* displayName = this->GetOption(macroPrefix + "_DISPLAY_NAME"); - if (displayName && *displayName) { + if (cmNonempty(displayName)) { group->DisplayName = displayName; } else { group->DisplayName = group->Name; } const char* description = this->GetOption(macroPrefix + "_DESCRIPTION"); - if (description && *description) { + if (cmNonempty(description)) { group->Description = description; } group->IsBold = this->IsOn(macroPrefix + "_BOLD_TITLE"); group->IsExpandedByDefault = this->IsOn(macroPrefix + "_EXPANDED"); const char* parentGroupName = this->GetOption(macroPrefix + "_PARENT_GROUP"); - if (parentGroupName && *parentGroupName) { + if (cmNonempty(parentGroupName)) { group->ParentGroup = GetComponentGroup(projectName, parentGroupName); group->ParentGroup->Subgroups.push_back(group); } else { diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 058b090e0c..2109b4e349 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -696,7 +696,7 @@ std::string cmCPackNSISGenerator::CreateComponentDescription( const char* userUploadDirectory = this->GetOption("CPACK_UPLOAD_DIRECTORY"); std::string uploadDirectory; - if (userUploadDirectory && *userUploadDirectory) { + if (cmNonempty(userUploadDirectory)) { uploadDirectory = userUploadDirectory; } else { uploadDirectory = diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx index f33bdc45ae..8aab167cf4 100644 --- a/Source/CTest/cmCTestBuildCommand.cxx +++ b/Source/CTest/cmCTestBuildCommand.cxx @@ -56,7 +56,7 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() this->Makefile->GetDefinition("CTEST_BUILD_CONFIGURATION"); const char* cmakeBuildConfiguration = !this->Configuration.empty() ? this->Configuration.c_str() - : ((ctestBuildConfiguration && *ctestBuildConfiguration) + : (cmNonempty(ctestBuildConfiguration) ? ctestBuildConfiguration : this->CTest->GetConfigType().c_str()); @@ -67,7 +67,7 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() ? this->Target.c_str() : this->Makefile->GetDefinition("CTEST_BUILD_TARGET"); - if (cmakeGeneratorName && *cmakeGeneratorName) { + if (cmNonempty(cmakeGeneratorName)) { if (!cmakeBuildConfiguration) { cmakeBuildConfiguration = "Release"; } diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx index 8716b313dc..ac57130c5b 100644 --- a/Source/CTest/cmCTestConfigureCommand.cxx +++ b/Source/CTest/cmCTestConfigureCommand.cxx @@ -48,7 +48,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() } else { const char* cmakeGeneratorName = this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR"); - if (cmakeGeneratorName && *cmakeGeneratorName) { + if (cmNonempty(cmakeGeneratorName)) { const std::string& source_dir = this->CTest->GetCTestConfiguration("SourceDirectory"); if (source_dir.empty()) { @@ -108,7 +108,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() const char* cmakeGeneratorPlatform = this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR_PLATFORM"); - if (cmakeGeneratorPlatform && *cmakeGeneratorPlatform) { + if (cmNonempty(cmakeGeneratorPlatform)) { cmakeConfigureCommand += " \"-A"; cmakeConfigureCommand += cmakeGeneratorPlatform; cmakeConfigureCommand += "\""; @@ -116,7 +116,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() const char* cmakeGeneratorToolset = this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR_TOOLSET"); - if (cmakeGeneratorToolset && *cmakeGeneratorToolset) { + if (cmNonempty(cmakeGeneratorToolset)) { cmakeConfigureCommand += " \"-T"; cmakeConfigureCommand += cmakeGeneratorToolset; cmakeConfigureCommand += "\""; diff --git a/Source/CTest/cmCTestTestCommand.cxx b/Source/CTest/cmCTestTestCommand.cxx index 07ea9120bf..cbc3c0c9f2 100644 --- a/Source/CTest/cmCTestTestCommand.cxx +++ b/Source/CTest/cmCTestTestCommand.cxx @@ -117,13 +117,13 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler() unsigned long testLoad; const char* ctestTestLoad = this->Makefile->GetDefinition("CTEST_TEST_LOAD"); if (!this->TestLoad.empty()) { - if (!cmStrToULong(this->TestLoad.c_str(), &testLoad)) { + if (!cmStrToULong(this->TestLoad, &testLoad)) { testLoad = 0; cmCTestLog(this->CTest, WARNING, "Invalid value for 'TEST_LOAD' : " << this->TestLoad << std::endl); } - } else if (ctestTestLoad && *ctestTestLoad) { + } else if (cmNonempty(ctestTestLoad)) { if (!cmStrToULong(ctestTestLoad, &testLoad)) { testLoad = 0; cmCTestLog(this->CTest, WARNING, diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index fbb95e14ed..43cceae187 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -832,8 +832,7 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() // We can support link type switching only if all needed flags are // known. - if (static_link_type_flag && *static_link_type_flag && - shared_link_type_flag && *shared_link_type_flag) { + 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; @@ -1768,7 +1767,7 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, std::string d = ri; if (!rootPath.empty() && cmHasPrefix(d, rootPath)) { d.erase(0, rootPath.size()); - } else if (stagePath && *stagePath && cmHasPrefix(d, stagePath)) { + } else if (cmNonempty(stagePath) && cmHasPrefix(d, stagePath)) { d.erase(0, strlen(stagePath)); d = cmStrCat(installPrefix, '/', d); cmSystemTools::ConvertToUnixSlashes(d); @@ -1799,7 +1798,7 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, std::string d = ri; if (!rootPath.empty() && cmHasPrefix(d, rootPath)) { d.erase(0, rootPath.size()); - } else if (stagePath && *stagePath && cmHasPrefix(d, stagePath)) { + } else if (cmNonempty(stagePath) && cmHasPrefix(d, stagePath)) { d.erase(0, strlen(stagePath)); d = cmStrCat(installPrefix, '/', d); cmSystemTools::ConvertToUnixSlashes(d); diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 8465c58bc5..63c14842a3 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -1045,14 +1045,14 @@ void cmCoreTryCompile::FindOutputFile(const std::string& targetName, const char* config = this->Makefile->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION"); // if a config was specified try that first - if (config && config[0]) { + if (cmNonempty(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 (config && config[0]) { + if (cmNonempty(config)) { std::string tmp = cmStrCat('/', config, app); searchDirs.push_back(std::move(tmp)); } diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index 8f02d95515..54418df2f9 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -395,7 +395,7 @@ bool cmDependsFortran::WriteDependenciesReal(std::string const& obj, << ' ' << stampFileForShell; cmMakefile* mf = this->LocalGenerator->GetMakefile(); const char* cid = mf->GetDefinition("CMAKE_Fortran_COMPILER_ID"); - if (cid && *cid) { + if (cmNonempty(cid)) { makeDepends << ' ' << cid; } makeDepends << '\n'; diff --git a/Source/cmFileCopier.cxx b/Source/cmFileCopier.cxx index 627e05b587..5d44a06816 100644 --- a/Source/cmFileCopier.cxx +++ b/Source/cmFileCopier.cxx @@ -173,7 +173,7 @@ bool cmFileCopier::GetDefaultDirectoryPermissions(mode_t** mode) // check if default dir creation permissions were set const char* default_dir_install_permissions = this->Makefile->GetDefinition( "CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS"); - if (default_dir_install_permissions && *default_dir_install_permissions) { + if (cmNonempty(default_dir_install_permissions)) { std::vector<std::string> items = cmExpandedList(default_dir_install_permissions); for (const auto& arg : items) { diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index 3e97150e79..3401effa7c 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -208,10 +208,10 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths) const char* sysrootLink = this->Makefile->GetDefinition("CMAKE_SYSROOT_LINK"); const char* rootPath = this->Makefile->GetDefinition("CMAKE_FIND_ROOT_PATH"); - const bool noSysroot = !sysroot || !*sysroot; - const bool noCompileSysroot = !sysrootCompile || !*sysrootCompile; - const bool noLinkSysroot = !sysrootLink || !*sysrootLink; - const bool noRootPath = !rootPath || !*rootPath; + const bool noSysroot = !cmNonempty(sysroot); + const bool noCompileSysroot = !cmNonempty(sysrootCompile); + const bool noLinkSysroot = !cmNonempty(sysrootLink); + const bool noRootPath = !cmNonempty(rootPath); if (noSysroot && noCompileSysroot && noLinkSysroot && noRootPath) { return; } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 64d4ec447a..41cff01368 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -2021,7 +2021,7 @@ bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const std::string sepVar = cmStrCat("CMAKE_SHARED_LIBRARY_RUNTIME_", ll, "_FLAG_SEP"); const char* sep = this->Makefile->GetDefinition(sepVar); - if (sep && *sep) { + if (cmNonempty(sep)) { // TODO: Add ELF check to ABI detection and get rid of // CMAKE_EXECUTABLE_FORMAT. if (const char* fmt = diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index eff6665131..3b160a8276 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -775,7 +775,7 @@ void cmGlobalGenerator::EnableLanguage( std::string compilerEnv = cmStrCat("CMAKE_", lang, "_COMPILER_ENV_VAR"); std::ostringstream noCompiler; const char* compilerFile = mf->GetDefinition(compilerName); - if (!compilerFile || !*compilerFile || cmIsNOTFOUND(compilerFile)) { + if (!cmNonempty(compilerFile) || cmIsNOTFOUND(compilerFile)) { /* clang-format off */ noCompiler << "No " << compilerName << " could be found.\n" @@ -2446,7 +2446,7 @@ void cmGlobalGenerator::AddGlobalTarget_Package( gti.WorkingDir = mf->GetCurrentBinaryDirectory(); cmCustomCommandLine singleLine; singleLine.push_back(cmSystemTools::GetCPackCommand()); - if (cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.') { + if (cmNonempty(cmakeCfgIntDir) && cmakeCfgIntDir[0] != '.') { singleLine.push_back("-C"); singleLine.push_back(cmakeCfgIntDir); } @@ -2531,7 +2531,7 @@ void cmGlobalGenerator::AddGlobalTarget_Test( singleLine.push_back(arg); } } - if (cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.') { + if (cmNonempty(cmakeCfgIntDir) && cmakeCfgIntDir[0] != '.') { singleLine.push_back("-C"); singleLine.push_back(cmakeCfgIntDir); } else // TODO: This is a hack. Should be something to do with the @@ -2612,7 +2612,7 @@ void cmGlobalGenerator::AddGlobalTarget_Install( "installation rules have been specified", mf->GetBacktrace()); } else if (this->InstallTargetEnabled && !skipInstallRules) { - if (!cmakeCfgIntDir || !*cmakeCfgIntDir || cmakeCfgIntDir[0] == '.') { + if (!(cmNonempty(cmakeCfgIntDir) && cmakeCfgIntDir[0] != '.')) { std::set<std::string>* componentsSet = &this->InstallComponents; std::ostringstream ostr; if (!componentsSet->empty()) { @@ -2651,7 +2651,7 @@ void cmGlobalGenerator::AddGlobalTarget_Install( cmd = "cmake"; } singleLine.push_back(cmd); - if (cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.') { + if (cmNonempty(cmakeCfgIntDir) && cmakeCfgIntDir[0] != '.') { std::string cfgArg = "-DBUILD_TYPE="; bool useEPN = this->UseEffectivePlatformName(mf.get()); if (useEPN) { diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 996946551d..7c8713141d 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -218,10 +218,11 @@ void cmGlobalGhsMultiGenerator::GetToolset(cmMakefile* mf, std::string& tsd, { const char* ghsRoot = mf->GetDefinition("GHS_TOOLSET_ROOT"); - if (!ghsRoot || ghsRoot[0] == '\0') { - ghsRoot = DEFAULT_TOOLSET_ROOT; + if (cmNonempty(ghsRoot)) { + tsd = ghsRoot; + } else { + tsd = DEFAULT_TOOLSET_ROOT; } - tsd = ghsRoot; if (ts.empty()) { std::vector<std::string> output; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 26f0becaf9..574e0f5856 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3381,7 +3381,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( buildSettings->AddAttribute("ONLY_ACTIVE_ARCH", this->CreateString("YES")); // When targeting macOS, use only the host architecture. if (this->SystemName == "Darwin"_s && - (!sysroot || !*sysroot || + (!cmNonempty(sysroot) || cmSystemTools::LowerCase(sysroot).find("macos") != std::string::npos)) { buildSettings->AddAttribute("ARCHS", @@ -3391,7 +3391,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( // Tell Xcode to use ARCHS (ONLY_ACTIVE_ARCH defaults to NO). buildSettings->AddAttribute("ARCHS", this->CreateString(archs)); } - if (deploymentTarget && *deploymentTarget) { + if (cmNonempty(deploymentTarget)) { buildSettings->AddAttribute(GetDeploymentPlatform(root->GetMakefile()), this->CreateString(deploymentTarget)); } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 646cf5e6fa..4c9744f05e 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -221,7 +221,7 @@ void cmLocalGenerator::ComputeObjectMaxPath() this->ObjectPathMax = 1000; #endif const char* plen = this->Makefile->GetDefinition("CMAKE_OBJECT_PATH_MAX"); - if (plen && *plen) { + if (cmNonempty(plen)) { unsigned int pmax; if (sscanf(plen, "%u", &pmax) == 1) { if (pmax >= 128) { @@ -434,7 +434,7 @@ void cmLocalGenerator::GenerateInstallRules() prefix_win32 = "C:"; } const char* project_name = this->Makefile->GetDefinition("PROJECT_NAME"); - if (project_name && project_name[0]) { + if (cmNonempty(project_name)) { prefix_win32 += "/Program Files/"; prefix_win32 += project_name; } else { @@ -893,7 +893,7 @@ std::string cmLocalGenerator::GetIncludeFlags( emitted.insert("/System/Library/Frameworks"); #endif for (std::string const& i : includes) { - if (fwSearchFlag && *fwSearchFlag && this->Makefile->IsOn("APPLE") && + if (cmNonempty(fwSearchFlag) && this->Makefile->IsOn("APPLE") && cmSystemTools::IsPathToFramework(i)) { std::string const frameworkDir = cmSystemTools::CollapseFullPath(cmStrCat(i, "/../")); @@ -1653,7 +1653,7 @@ static std::string GetFrameworkFlags(const std::string& lang, std::string fwSearchFlagVar = "CMAKE_" + lang + "_FRAMEWORK_SEARCH_FLAG"; const char* fwSearchFlag = mf->GetDefinition(fwSearchFlagVar); - if (!(fwSearchFlag && *fwSearchFlag)) { + if (!cmNonempty(fwSearchFlag)) { return std::string(); } @@ -1892,7 +1892,7 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags, std::string sysrootFlagVar = std::string("CMAKE_") + lang + "_SYSROOT_FLAG"; const char* sysrootFlag = this->Makefile->GetDefinition(sysrootFlagVar); - if (sysrootFlag && *sysrootFlag) { + if (cmNonempty(sysrootFlag)) { if (!this->AppleArchSysroots.empty() && !this->AllAppleArchSysrootsAreTheSame(archs, sysroot)) { for (std::string const& arch : archs) { @@ -1921,8 +1921,7 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags, std::string("CMAKE_") + lang + "_OSX_DEPLOYMENT_TARGET_FLAG"; const char* deploymentTargetFlag = this->Makefile->GetDefinition(deploymentTargetFlagVar); - if (deploymentTargetFlag && *deploymentTargetFlag && deploymentTarget && - *deploymentTarget) { + if (cmNonempty(deploymentTargetFlag) && cmNonempty(deploymentTarget)) { flags += " "; flags += deploymentTargetFlag; flags += deploymentTarget; @@ -3062,7 +3061,7 @@ void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines, if (!lang.empty()) { const char* df = this->Makefile->GetDefinition(cmStrCat("CMAKE_", lang, "_DEFINE_FLAG")); - if (df && *df) { + if (cmNonempty(df)) { dflag = df; } } diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 23e2a94668..8acd1e30a9 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1807,7 +1807,7 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo( std::string cidVar = cmStrCat("CMAKE_", implicitLang.first, "_COMPILER_ID"); const char* cid = this->Makefile->GetDefinition(cidVar); - if (cid && *cid) { + if (cmNonempty(cid)) { cmakefileStream << "set(CMAKE_" << implicitLang.first << "_COMPILER_ID \"" << cid << "\")\n"; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index aca40fabf1..5e1f0702bb 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -196,7 +196,7 @@ void cmMakefile::MaybeWarnCMP0074(std::string const& pkg) std::string env; cmSystemTools::GetEnv(varName, env); - bool const haveVar = var && *var; + bool const haveVar = cmNonempty(var); bool const haveEnv = !env.empty(); if ((haveVar || haveEnv) && this->WarnedCMP0074.insert(varName).second) { std::ostringstream w; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 286a3dcd88..13c2fe9299 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -839,7 +839,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( run_iwyu += " --tidy="; const char* driverMode = this->Makefile->GetDefinition( "CMAKE_" + lang + "_CLANG_TIDY_DRIVER_MODE"); - if (!(driverMode && *driverMode)) { + if (!cmNonempty(driverMode)) { driverMode = lang == "C" ? "gcc" : "g++"; } run_iwyu += this->LocalGenerator->EscapeForShell( @@ -1857,7 +1857,7 @@ void cmMakefileTargetGenerator::GenDefFile( this->LocalGenerator->GetCurrentBinaryDirectory(), objlist_file), cmOutputConverter::SHELL); const char* nm_executable = this->Makefile->GetDefinition("CMAKE_NM"); - if (nm_executable && *nm_executable) { + if (cmNonempty(nm_executable)) { cmd += " --nm="; cmd += this->LocalCommonGenerator->ConvertToOutputFormat( nm_executable, cmOutputConverter::SHELL); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 924a44e9a7..1775085aa5 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -1096,7 +1096,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement( obj_list_file, cmOutputConverter::SHELL); const char* nm_executable = GetMakefile()->GetDefinition("CMAKE_NM"); - if (nm_executable && *nm_executable) { + if (cmNonempty(nm_executable)) { cmd += " --nm="; cmd += this->LocalCommonGenerator->ConvertToOutputFormat( nm_executable, cmOutputConverter::SHELL); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index de18536e0f..048dbb678e 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -847,7 +847,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, run_iwyu += " --tidy="; const char* driverMode = this->Makefile->GetDefinition( cmStrCat("CMAKE_", lang, "_CLANG_TIDY_DRIVER_MODE")); - if (!(driverMode && *driverMode)) { + if (!cmNonempty(driverMode)) { driverMode = lang == "C" ? "gcc" : "g++"; } run_iwyu += this->GetLocalGenerator()->EscapeForShell( diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 2ec66d9f14..bb6db92c95 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -303,7 +303,7 @@ bool cmProjectCommand(std::vector<std::string> const& args, std::string vw; for (std::string const& i : vv) { const char* const v = mf.GetDefinition(i); - if (v && *v) { + if (cmNonempty(v)) { if (cmp0048 == cmPolicies::WARN) { if (!injectedProjectCommand) { vw += "\n "; diff --git a/Source/cmSearchPath.cxx b/Source/cmSearchPath.cxx index 766d3478b3..eb8fcaf3f5 100644 --- a/Source/cmSearchPath.cxx +++ b/Source/cmSearchPath.cxx @@ -180,7 +180,7 @@ void cmSearchPath::AddPrefixPaths(const std::vector<std::string>& paths, if (subdir == "include" || subdir == "lib") { const char* arch = this->FC->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE"); - if (arch && *arch) { + if (cmNonempty(arch)) { if (this->FC->Makefile->IsDefinitionSet("CMAKE_SYSROOT") && this->FC->Makefile->IsDefinitionSet( "CMAKE_PREFIX_LIBRARY_ARCHITECTURE")) { diff --git a/Source/cmStandardLevelResolver.cxx b/Source/cmStandardLevelResolver.cxx index 0eb869c416..6dbab98e8e 100644 --- a/Source/cmStandardLevelResolver.cxx +++ b/Source/cmStandardLevelResolver.cxx @@ -65,7 +65,7 @@ struct StanardLevelComputer const char* defaultStd = makefile->GetDefinition( cmStrCat("CMAKE_", this->Language, "_STANDARD_DEFAULT")); - if (!defaultStd || !*defaultStd) { + if (!cmNonempty(defaultStd)) { // this compiler has no notion of language standard levels return std::string{}; } @@ -472,7 +472,7 @@ const char* cmStandardLevelResolver::CompileFeaturesAvailable( const char* featuresKnown = this->Makefile->GetDefinition("CMAKE_" + lang + "_COMPILE_FEATURES"); - if (!featuresKnown || !*featuresKnown) { + if (!cmNonempty(featuresKnown)) { std::ostringstream e; if (error) { e << "no"; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 45fa44b895..1e688eded3 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2268,7 +2268,7 @@ int cmake::CheckBuildSystem() if (this->ClearBuildSystem) { // Get the generator used for this build system. const char* genName = mf.GetDefinition("CMAKE_DEPENDS_GENERATOR"); - if (!genName || genName[0] == '\0') { + if (!cmNonempty(genName)) { genName = "Unix Makefiles"; } |