mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-04 12:49:36 -06:00
Merge topic 'normalize-input-paths' into release-4.0
5805461074cmSystemTools: Simplify call to FindProgram for our own executabledb0e2574cbcmSystemTools: Restore FindProgram look-up of on-disk case on Windows5d700abda4Source: Simplify FindProgram calls Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !10620
This commit is contained in:
@@ -27,8 +27,7 @@ int cmCPackBundleGenerator::InitializeInternal()
|
||||
}
|
||||
|
||||
if (this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP")) {
|
||||
std::string const codesign_path = cmSystemTools::FindProgram(
|
||||
"codesign", std::vector<std::string>(), false);
|
||||
std::string const codesign_path = cmSystemTools::FindProgram("codesign");
|
||||
|
||||
if (codesign_path.empty()) {
|
||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||
|
||||
@@ -75,8 +75,7 @@ int cmCPackDragNDropGenerator::InitializeInternal()
|
||||
paths.emplace_back("/Applications/Xcode.app/Contents/Developer/Tools");
|
||||
paths.emplace_back("/Developer/Tools");
|
||||
|
||||
std::string const hdiutil_path =
|
||||
cmSystemTools::FindProgram("hdiutil", std::vector<std::string>(), false);
|
||||
std::string const hdiutil_path = cmSystemTools::FindProgram("hdiutil");
|
||||
if (hdiutil_path.empty()) {
|
||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||
"Cannot locate hdiutil command" << std::endl);
|
||||
@@ -85,7 +84,7 @@ int cmCPackDragNDropGenerator::InitializeInternal()
|
||||
this->SetOptionIfNotSet("CPACK_COMMAND_HDIUTIL", hdiutil_path);
|
||||
|
||||
std::string const setfile_path =
|
||||
cmSystemTools::FindProgram("SetFile", paths, false);
|
||||
cmSystemTools::FindProgram("SetFile", paths);
|
||||
if (setfile_path.empty()) {
|
||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||
"Cannot locate SetFile command" << std::endl);
|
||||
@@ -93,7 +92,7 @@ int cmCPackDragNDropGenerator::InitializeInternal()
|
||||
}
|
||||
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()) {
|
||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||
"Cannot locate Rez command" << std::endl);
|
||||
|
||||
@@ -46,8 +46,8 @@ int cmCPackInnoSetupGenerator::InitializeInternal()
|
||||
#endif
|
||||
|
||||
SetOptionIfNotSet("CPACK_INNOSETUP_EXECUTABLE", "ISCC");
|
||||
std::string const& isccPath = cmSystemTools::FindProgram(
|
||||
GetOption("CPACK_INNOSETUP_EXECUTABLE"), path, false);
|
||||
std::string const& isccPath =
|
||||
cmSystemTools::FindProgram(GetOption("CPACK_INNOSETUP_EXECUTABLE"), path);
|
||||
|
||||
if (isccPath.empty()) {
|
||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||
|
||||
@@ -466,7 +466,7 @@ int cmCPackNSISGenerator::InitializeInternal()
|
||||
|
||||
this->SetOptionIfNotSet("CPACK_NSIS_EXECUTABLE", "makensis");
|
||||
nsisPath = cmSystemTools::FindProgram(
|
||||
*this->GetOption("CPACK_NSIS_EXECUTABLE"), path, false);
|
||||
*this->GetOption("CPACK_NSIS_EXECUTABLE"), path);
|
||||
|
||||
if (nsisPath.empty()) {
|
||||
cmCPackLogger(
|
||||
|
||||
@@ -127,9 +127,7 @@ int cmCPackProductBuildGenerator::InitializeInternal()
|
||||
{
|
||||
this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/Applications");
|
||||
|
||||
std::vector<std::string> no_paths;
|
||||
std::string program =
|
||||
cmSystemTools::FindProgram("pkgbuild", no_paths, false);
|
||||
std::string program = cmSystemTools::FindProgram("pkgbuild");
|
||||
if (program.empty()) {
|
||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||
"Cannot find pkgbuild executable" << std::endl);
|
||||
@@ -137,7 +135,7 @@ int cmCPackProductBuildGenerator::InitializeInternal()
|
||||
}
|
||||
this->SetOptionIfNotSet("CPACK_COMMAND_PKGBUILD", program);
|
||||
|
||||
program = cmSystemTools::FindProgram("productbuild", no_paths, false);
|
||||
program = cmSystemTools::FindProgram("productbuild");
|
||||
if (program.empty()) {
|
||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||
"Cannot find productbuild executable" << std::endl);
|
||||
|
||||
@@ -1708,7 +1708,7 @@ std::string cmCTestTestHandler::FindExecutable(
|
||||
// if everything else failed, check the users path, but only if a full path
|
||||
// wasn't specified
|
||||
if (fullPath.empty() && filepath.empty()) {
|
||||
std::string path = cmSystemTools::FindProgram(filename.c_str());
|
||||
std::string path = cmSystemTools::FindProgram(filename);
|
||||
if (!path.empty()) {
|
||||
resultingConfig.clear();
|
||||
return path;
|
||||
|
||||
@@ -2992,6 +2992,16 @@ unsigned int cmSystemTools::RandomNumber()
|
||||
return static_cast<unsigned int>(gen());
|
||||
}
|
||||
|
||||
std::string cmSystemTools::FindProgram(std::string const& name,
|
||||
std::vector<std::string> const& path)
|
||||
{
|
||||
std::string exe = cmsys::SystemTools::FindProgram(name, path);
|
||||
if (!exe.empty()) {
|
||||
exe = cmSystemTools::ToNormalizedPathOnDisk(std::move(exe));
|
||||
}
|
||||
return exe;
|
||||
}
|
||||
|
||||
namespace {
|
||||
std::string InitLogicalWorkingDirectory()
|
||||
{
|
||||
@@ -3065,11 +3075,7 @@ std::string FindOwnExecutable(char const* argv0)
|
||||
}
|
||||
}
|
||||
#else
|
||||
std::string errorMsg;
|
||||
std::string exe;
|
||||
if (!cmSystemTools::FindProgramPath(argv0, exe, errorMsg)) {
|
||||
// ???
|
||||
}
|
||||
std::string exe = cmsys::SystemTools::FindProgram(argv0);
|
||||
#endif
|
||||
exe = cmSystemTools::ToNormalizedPathOnDisk(std::move(exe));
|
||||
return exe;
|
||||
|
||||
@@ -560,6 +560,14 @@ public:
|
||||
static unsigned int RandomSeed();
|
||||
static unsigned int RandomNumber();
|
||||
|
||||
/**
|
||||
* Find an executable in the system PATH, with optional extra paths.
|
||||
* This wraps KWSys's FindProgram to add ToNormalizedPathOnDisk.
|
||||
*/
|
||||
static std::string FindProgram(
|
||||
std::string const& name,
|
||||
std::vector<std::string> const& path = std::vector<std::string>());
|
||||
|
||||
/** Find the directory containing CMake executables. */
|
||||
static void FindCMakeResources(char const* argv0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user