summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
authorNicolas BUNEL <nbunel@purples-dev-thx11.1>2016-05-27 14:03:43 (GMT)
committerBrad King <brad.king@kitware.com>2016-06-01 15:12:36 (GMT)
commit18bfbc972fd3daf3e973f80072c4de09ec7e852b (patch)
tree092bba580eac1fcf3977a56adbdb2c3f18223f04 /Source/cmSystemTools.cxx
parentd6754d37d593a0189809dcf98bc4fdf3a609f0a3 (diff)
downloadCMake-18bfbc972fd3daf3e973f80072c4de09ec7e852b.zip
CMake-18bfbc972fd3daf3e973f80072c4de09ec7e852b.tar.gz
CMake-18bfbc972fd3daf3e973f80072c4de09ec7e852b.tar.bz2
Add option to control 'bin' directory of CMake's own installation (#16076)
Add a `CMAKE_BIN_DIR` cache entry to CMake's own build configuration. Add a `--bindir` option to the `bootstrap` script to set it.
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r--Source/cmSystemTools.cxx21
1 files changed, 14 insertions, 7 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 7dece47..99d8569 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1930,11 +1930,11 @@ void cmSystemTools::FindCMakeResources(const char* argv0)
}
if (cmSystemTools::GetFilenameName(exe_dir) == "MacOS") {
// The executable is inside an application bundle.
- // Look for ../bin (install tree) and then fall back to
+ // Look for ..<CMAKE_BIN_DIR> (install tree) and then fall back to
// ../../../bin (build tree).
exe_dir = cmSystemTools::GetFilenamePath(exe_dir);
- if (cmSystemTools::FileExists((exe_dir + "/bin/cmake").c_str())) {
- exe_dir += "/bin";
+ if (cmSystemTools::FileExists(exe_dir + CMAKE_BIN_DIR "/cmake")) {
+ exe_dir += CMAKE_BIN_DIR;
} else {
exe_dir = cmSystemTools::GetFilenamePath(exe_dir);
exe_dir = cmSystemTools::GetFilenamePath(exe_dir);
@@ -1985,13 +1985,20 @@ void cmSystemTools::FindCMakeResources(const char* argv0)
}
#ifdef CMAKE_BUILD_WITH_CMAKE
- // Install tree has "<prefix>/bin/cmake" and "<prefix><CMAKE_DATA_DIR>".
- std::string dir = cmSystemTools::GetFilenamePath(exe_dir);
- cmSystemToolsCMakeRoot = dir + CMAKE_DATA_DIR;
- if (!cmSystemTools::FileExists(
+ // Install tree has
+ // - "<prefix><CMAKE_BIN_DIR>/cmake"
+ // - "<prefix><CMAKE_DATA_DIR>"
+ if (cmHasSuffix(exe_dir, CMAKE_BIN_DIR)) {
+ std::string const prefix =
+ exe_dir.substr(0, exe_dir.size() - strlen(CMAKE_BIN_DIR));
+ cmSystemToolsCMakeRoot = prefix + CMAKE_DATA_DIR;
+ }
+ if (cmSystemToolsCMakeRoot.empty() ||
+ !cmSystemTools::FileExists(
(cmSystemToolsCMakeRoot + "/Modules/CMake.cmake").c_str())) {
// Build tree has "<build>/bin[/<config>]/cmake" and
// "<build>/CMakeFiles/CMakeSourceDir.txt".
+ std::string dir = cmSystemTools::GetFilenamePath(exe_dir);
std::string src_dir_txt = dir + "/CMakeFiles/CMakeSourceDir.txt";
cmsys::ifstream fin(src_dir_txt.c_str());
std::string src_dir;