1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-16 14:08:35 +08:00

Source: Simplify FindProgram calls

Remove defaulted arguments.  Remove unnecessary `.c_str()`.
This commit is contained in:
Brad King
2025-04-07 19:13:52 -04:00
parent d88b3e3ece
commit 5d700abda4
6 changed files with 10 additions and 14 deletions

View File

@@ -27,8 +27,7 @@ int cmCPackBundleGenerator::InitializeInternal()
} }
if (this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP")) { if (this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP")) {
std::string const codesign_path = cmSystemTools::FindProgram( std::string const codesign_path = cmSystemTools::FindProgram("codesign");
"codesign", std::vector<std::string>(), false);
if (codesign_path.empty()) { if (codesign_path.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,

View File

@@ -75,8 +75,7 @@ int cmCPackDragNDropGenerator::InitializeInternal()
paths.emplace_back("/Applications/Xcode.app/Contents/Developer/Tools"); paths.emplace_back("/Applications/Xcode.app/Contents/Developer/Tools");
paths.emplace_back("/Developer/Tools"); paths.emplace_back("/Developer/Tools");
std::string const hdiutil_path = std::string const hdiutil_path = cmSystemTools::FindProgram("hdiutil");
cmSystemTools::FindProgram("hdiutil", std::vector<std::string>(), false);
if (hdiutil_path.empty()) { if (hdiutil_path.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot locate hdiutil command" << std::endl); "Cannot locate hdiutil command" << std::endl);
@@ -85,7 +84,7 @@ int cmCPackDragNDropGenerator::InitializeInternal()
this->SetOptionIfNotSet("CPACK_COMMAND_HDIUTIL", hdiutil_path); this->SetOptionIfNotSet("CPACK_COMMAND_HDIUTIL", hdiutil_path);
std::string const setfile_path = std::string const setfile_path =
cmSystemTools::FindProgram("SetFile", paths, false); cmSystemTools::FindProgram("SetFile", paths);
if (setfile_path.empty()) { if (setfile_path.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot locate SetFile command" << std::endl); "Cannot locate SetFile command" << std::endl);
@@ -93,7 +92,7 @@ int cmCPackDragNDropGenerator::InitializeInternal()
} }
this->SetOptionIfNotSet("CPACK_COMMAND_SETFILE", setfile_path); this->SetOptionIfNotSet("CPACK_COMMAND_SETFILE", setfile_path);
std::string const rez_path = cmSystemTools::FindProgram("Rez", paths, false); std::string const rez_path = cmSystemTools::FindProgram("Rez", paths);
if (rez_path.empty()) { if (rez_path.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot locate Rez command" << std::endl); "Cannot locate Rez command" << std::endl);

View File

@@ -46,8 +46,8 @@ int cmCPackInnoSetupGenerator::InitializeInternal()
#endif #endif
SetOptionIfNotSet("CPACK_INNOSETUP_EXECUTABLE", "ISCC"); SetOptionIfNotSet("CPACK_INNOSETUP_EXECUTABLE", "ISCC");
std::string const& isccPath = cmSystemTools::FindProgram( std::string const& isccPath =
GetOption("CPACK_INNOSETUP_EXECUTABLE"), path, false); cmSystemTools::FindProgram(GetOption("CPACK_INNOSETUP_EXECUTABLE"), path);
if (isccPath.empty()) { if (isccPath.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,

View File

@@ -466,7 +466,7 @@ int cmCPackNSISGenerator::InitializeInternal()
this->SetOptionIfNotSet("CPACK_NSIS_EXECUTABLE", "makensis"); this->SetOptionIfNotSet("CPACK_NSIS_EXECUTABLE", "makensis");
nsisPath = cmSystemTools::FindProgram( nsisPath = cmSystemTools::FindProgram(
*this->GetOption("CPACK_NSIS_EXECUTABLE"), path, false); *this->GetOption("CPACK_NSIS_EXECUTABLE"), path);
if (nsisPath.empty()) { if (nsisPath.empty()) {
cmCPackLogger( cmCPackLogger(

View File

@@ -127,9 +127,7 @@ int cmCPackProductBuildGenerator::InitializeInternal()
{ {
this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/Applications"); this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/Applications");
std::vector<std::string> no_paths; std::string program = cmSystemTools::FindProgram("pkgbuild");
std::string program =
cmSystemTools::FindProgram("pkgbuild", no_paths, false);
if (program.empty()) { if (program.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot find pkgbuild executable" << std::endl); "Cannot find pkgbuild executable" << std::endl);
@@ -137,7 +135,7 @@ int cmCPackProductBuildGenerator::InitializeInternal()
} }
this->SetOptionIfNotSet("CPACK_COMMAND_PKGBUILD", program); this->SetOptionIfNotSet("CPACK_COMMAND_PKGBUILD", program);
program = cmSystemTools::FindProgram("productbuild", no_paths, false); program = cmSystemTools::FindProgram("productbuild");
if (program.empty()) { if (program.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot find productbuild executable" << std::endl); "Cannot find productbuild executable" << std::endl);

View File

@@ -1708,7 +1708,7 @@ std::string cmCTestTestHandler::FindExecutable(
// if everything else failed, check the users path, but only if a full path // if everything else failed, check the users path, but only if a full path
// wasn't specified // wasn't specified
if (fullPath.empty() && filepath.empty()) { if (fullPath.empty() && filepath.empty()) {
std::string path = cmSystemTools::FindProgram(filename.c_str()); std::string path = cmSystemTools::FindProgram(filename);
if (!path.empty()) { if (!path.empty()) {
resultingConfig.clear(); resultingConfig.clear();
return path; return path;