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.
This commit is contained in:
Nicolas BUNEL 2016-05-27 16:03:43 +02:00 committed by Brad King
parent d6754d37d5
commit 18bfbc972f
7 changed files with 31 additions and 10 deletions

View File

@ -166,7 +166,7 @@ if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
set(CPACK_PACKAGE_CONTACT "cmake@cmake.org") set(CPACK_PACKAGE_CONTACT "cmake@cmake.org")
if(UNIX) if(UNIX)
set(CPACK_STRIP_FILES "bin/ccmake;bin/cmake;bin/cpack;bin/ctest") set(CPACK_STRIP_FILES "${CMAKE_BIN_DIR}/ccmake;${CMAKE_BIN_DIR}/cmake;${CMAKE_BIN_DIR}/cpack;${CMAKE_BIN_DIR}/ctest")
set(CPACK_SOURCE_STRIP_FILES "") set(CPACK_SOURCE_STRIP_FILES "")
set(CPACK_PACKAGE_EXECUTABLES "ccmake" "CMake") set(CPACK_PACKAGE_EXECUTABLES "ccmake" "CMake")
endif() endif()

View File

@ -1,27 +1,32 @@
# Keep formatting here consistent with bootstrap script expectations. # Keep formatting here consistent with bootstrap script expectations.
if(BEOS) if(BEOS)
set(CMAKE_BIN_DIR_DEFAULT "bin") # HAIKU
set(CMAKE_DATA_DIR_DEFAULT "share/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}") # HAIKU set(CMAKE_DATA_DIR_DEFAULT "share/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}") # HAIKU
set(CMAKE_MAN_DIR_DEFAULT "documentation/man") # HAIKU set(CMAKE_MAN_DIR_DEFAULT "documentation/man") # HAIKU
set(CMAKE_DOC_DIR_DEFAULT "documentation/doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}") # HAIKU set(CMAKE_DOC_DIR_DEFAULT "documentation/doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}") # HAIKU
set(CMAKE_XDGDATA_DIR_DEFAULT "share") # HAIKU set(CMAKE_XDGDATA_DIR_DEFAULT "share") # HAIKU
elseif(CYGWIN) elseif(CYGWIN)
set(CMAKE_BIN_DIR_DEFAULT "bin") # CYGWIN
set(CMAKE_DATA_DIR_DEFAULT "share/cmake-${CMake_VERSION}") # CYGWIN set(CMAKE_DATA_DIR_DEFAULT "share/cmake-${CMake_VERSION}") # CYGWIN
set(CMAKE_DOC_DIR_DEFAULT "share/doc/cmake-${CMake_VERSION}") # CYGWIN set(CMAKE_DOC_DIR_DEFAULT "share/doc/cmake-${CMake_VERSION}") # CYGWIN
set(CMAKE_MAN_DIR_DEFAULT "share/man") # CYGWIN set(CMAKE_MAN_DIR_DEFAULT "share/man") # CYGWIN
set(CMAKE_XDGDATA_DIR_DEFAULT "share") # CYGWIN set(CMAKE_XDGDATA_DIR_DEFAULT "share") # CYGWIN
else() else()
set(CMAKE_BIN_DIR_DEFAULT "bin") # OTHER
set(CMAKE_DATA_DIR_DEFAULT "share/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}") # OTHER set(CMAKE_DATA_DIR_DEFAULT "share/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}") # OTHER
set(CMAKE_DOC_DIR_DEFAULT "doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}") # OTHER set(CMAKE_DOC_DIR_DEFAULT "doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}") # OTHER
set(CMAKE_MAN_DIR_DEFAULT "man") # OTHER set(CMAKE_MAN_DIR_DEFAULT "man") # OTHER
set(CMAKE_XDGDATA_DIR_DEFAULT "share") # OTHER set(CMAKE_XDGDATA_DIR_DEFAULT "share") # OTHER
endif() endif()
set(CMAKE_BIN_DIR_DESC "bin")
set(CMAKE_DATA_DIR_DESC "data") set(CMAKE_DATA_DIR_DESC "data")
set(CMAKE_DOC_DIR_DESC "docs") set(CMAKE_DOC_DIR_DESC "docs")
set(CMAKE_MAN_DIR_DESC "man pages") set(CMAKE_MAN_DIR_DESC "man pages")
set(CMAKE_XDGDATA_DIR_DESC "XDG specific files") set(CMAKE_XDGDATA_DIR_DESC "XDG specific files")
foreach(v foreach(v
CMAKE_BIN_DIR
CMAKE_DATA_DIR CMAKE_DATA_DIR
CMAKE_DOC_DIR CMAKE_DOC_DIR
CMAKE_MAN_DIR CMAKE_MAN_DIR

View File

@ -786,7 +786,7 @@ endif()
foreach(_tool ${_tools}) foreach(_tool ${_tools})
CMake_OPTIONAL_COMPONENT(${_tool}) CMake_OPTIONAL_COMPONENT(${_tool})
install(TARGETS ${_tool} DESTINATION bin ${COMPONENT}) install(TARGETS ${_tool} DESTINATION ${CMAKE_BIN_DIR} ${COMPONENT})
endforeach() endforeach()
install(FILES cmCPluginAPI.h DESTINATION ${CMAKE_DATA_DIR}/include) install(FILES cmCPluginAPI.h DESTINATION ${CMAKE_DATA_DIR}/include)

View File

@ -48,4 +48,4 @@ else()
endif() endif()
CMake_OPTIONAL_COMPONENT(ccmake) CMake_OPTIONAL_COMPONENT(ccmake)
install(TARGETS ccmake DESTINATION bin ${COMPONENT}) install(TARGETS ccmake DESTINATION ${CMAKE_BIN_DIR} ${COMPONENT})

View File

@ -15,4 +15,5 @@
#cmakedefine CMAKE_USE_MACH_PARSER #cmakedefine CMAKE_USE_MACH_PARSER
#cmakedefine CMAKE_ENCODING_UTF8 #cmakedefine CMAKE_ENCODING_UTF8
#cmakedefine CMake_HAVE_CXX11_UNORDERED_MAP #cmakedefine CMake_HAVE_CXX11_UNORDERED_MAP
#define CMAKE_BIN_DIR "/@CMAKE_BIN_DIR@"
#define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@" #define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@"

View File

@ -1930,11 +1930,11 @@ void cmSystemTools::FindCMakeResources(const char* argv0)
} }
if (cmSystemTools::GetFilenameName(exe_dir) == "MacOS") { if (cmSystemTools::GetFilenameName(exe_dir) == "MacOS") {
// The executable is inside an application bundle. // 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). // ../../../bin (build tree).
exe_dir = cmSystemTools::GetFilenamePath(exe_dir); exe_dir = cmSystemTools::GetFilenamePath(exe_dir);
if (cmSystemTools::FileExists((exe_dir + "/bin/cmake").c_str())) { if (cmSystemTools::FileExists(exe_dir + CMAKE_BIN_DIR "/cmake")) {
exe_dir += "/bin"; exe_dir += CMAKE_BIN_DIR;
} else { } else {
exe_dir = cmSystemTools::GetFilenamePath(exe_dir); exe_dir = cmSystemTools::GetFilenamePath(exe_dir);
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 #ifdef CMAKE_BUILD_WITH_CMAKE
// Install tree has "<prefix>/bin/cmake" and "<prefix><CMAKE_DATA_DIR>". // Install tree has
std::string dir = cmSystemTools::GetFilenamePath(exe_dir); // - "<prefix><CMAKE_BIN_DIR>/cmake"
cmSystemToolsCMakeRoot = dir + CMAKE_DATA_DIR; // - "<prefix><CMAKE_DATA_DIR>"
if (!cmSystemTools::FileExists( 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())) { (cmSystemToolsCMakeRoot + "/Modules/CMake.cmake").c_str())) {
// Build tree has "<build>/bin[/<config>]/cmake" and // Build tree has "<build>/bin[/<config>]/cmake" and
// "<build>/CMakeFiles/CMakeSourceDir.txt". // "<build>/CMakeFiles/CMakeSourceDir.txt".
std::string dir = cmSystemTools::GetFilenamePath(exe_dir);
std::string src_dir_txt = dir + "/CMakeFiles/CMakeSourceDir.txt"; std::string src_dir_txt = dir + "/CMakeFiles/CMakeSourceDir.txt";
cmsys::ifstream fin(src_dir_txt.c_str()); cmsys::ifstream fin(src_dir_txt.c_str());
std::string src_dir; std::string src_dir;

View File

@ -60,10 +60,12 @@ fi
cmake_copyright="`grep '^Copyright .* Kitware' "${cmake_source_dir}/Copyright.txt"`" cmake_copyright="`grep '^Copyright .* Kitware' "${cmake_source_dir}/Copyright.txt"`"
cmake_bin_dir_keyword="OTHER"
cmake_data_dir_keyword="OTHER" cmake_data_dir_keyword="OTHER"
cmake_doc_dir_keyword="OTHER" cmake_doc_dir_keyword="OTHER"
cmake_man_dir_keyword="OTHER" cmake_man_dir_keyword="OTHER"
cmake_xdgdata_dir_keyword="OTHER" cmake_xdgdata_dir_keyword="OTHER"
cmake_bin_dir=""
cmake_data_dir="" cmake_data_dir=""
cmake_doc_dir="" cmake_doc_dir=""
cmake_man_dir="" cmake_man_dir=""
@ -213,6 +215,7 @@ else
fi fi
# Lookup default install destinations. # Lookup default install destinations.
cmake_bin_dir_default="`cmake_install_dest_default BIN ${cmake_bin_dir_keyword}`"
cmake_data_dir_default="`cmake_install_dest_default DATA ${cmake_data_dir_keyword}`" cmake_data_dir_default="`cmake_install_dest_default DATA ${cmake_data_dir_keyword}`"
cmake_doc_dir_default="`cmake_install_dest_default DOC ${cmake_doc_dir_keyword}`" cmake_doc_dir_default="`cmake_install_dest_default DOC ${cmake_doc_dir_keyword}`"
cmake_man_dir_default="`cmake_install_dest_default MAN ${cmake_man_dir_keyword}`" cmake_man_dir_default="`cmake_install_dest_default MAN ${cmake_man_dir_keyword}`"
@ -422,6 +425,8 @@ Configuration:
Directory and file names: Directory and file names:
--prefix=PREFIX install files in tree rooted at PREFIX --prefix=PREFIX install files in tree rooted at PREFIX
['"${cmake_default_prefix}"'] ['"${cmake_default_prefix}"']
--bindir=DIR install binaries in PREFIX/DIR
['"${cmake_bin_dir_default}"']
--datadir=DIR install data files in PREFIX/DIR --datadir=DIR install data files in PREFIX/DIR
['"${cmake_data_dir_default}"'] ['"${cmake_data_dir_default}"']
--docdir=DIR install documentation files in PREFIX/DIR --docdir=DIR install documentation files in PREFIX/DIR
@ -627,6 +632,7 @@ while test $# != 0; do
--prefix=*) dir=`cmake_arg "$1"` --prefix=*) dir=`cmake_arg "$1"`
cmake_prefix_dir=`cmake_fix_slashes "$dir"` ;; cmake_prefix_dir=`cmake_fix_slashes "$dir"` ;;
--parallel=*) cmake_parallel_make=`cmake_arg "$1"` ;; --parallel=*) cmake_parallel_make=`cmake_arg "$1"` ;;
--bindir=*) cmake_bin_dir=`cmake_arg "$1"` ;;
--datadir=*) cmake_data_dir=`cmake_arg "$1"` ;; --datadir=*) cmake_data_dir=`cmake_arg "$1"` ;;
--docdir=*) cmake_doc_dir=`cmake_arg "$1"` ;; --docdir=*) cmake_doc_dir=`cmake_arg "$1"` ;;
--mandir=*) cmake_man_dir=`cmake_arg "$1"` ;; --mandir=*) cmake_man_dir=`cmake_arg "$1"` ;;
@ -1263,6 +1269,7 @@ cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_PATCH ${cmake_versi
cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION \"${cmake_version}\"" cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION \"${cmake_version}\""
cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP_SOURCE_DIR \"${CMAKE_BOOTSTRAP_SOURCE_DIR}\"" cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP_SOURCE_DIR \"${CMAKE_BOOTSTRAP_SOURCE_DIR}\""
cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP_BINARY_DIR \"${CMAKE_BOOTSTRAP_BINARY_DIR}\"" cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP_BINARY_DIR \"${CMAKE_BOOTSTRAP_BINARY_DIR}\""
cmake_report cmConfigure.h${_tmp} "#define CMAKE_BIN_DIR \"/bootstrap-not-insalled\""
cmake_report cmConfigure.h${_tmp} "#define CMAKE_DATA_DIR \"/bootstrap-not-insalled\"" cmake_report cmConfigure.h${_tmp} "#define CMAKE_DATA_DIR \"/bootstrap-not-insalled\""
cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP" cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP"
@ -1374,6 +1381,7 @@ echo '
set (CMAKE_INSTALL_PREFIX "'"${cmake_prefix_dir}"'" CACHE PATH "Install path prefix, prepended onto install directories." FORCE) set (CMAKE_INSTALL_PREFIX "'"${cmake_prefix_dir}"'" CACHE PATH "Install path prefix, prepended onto install directories." FORCE)
set (CMAKE_DOC_DIR "'"${cmake_doc_dir}"'" CACHE PATH "Install location for documentation (relative to prefix)." FORCE) set (CMAKE_DOC_DIR "'"${cmake_doc_dir}"'" CACHE PATH "Install location for documentation (relative to prefix)." FORCE)
set (CMAKE_MAN_DIR "'"${cmake_man_dir}"'" CACHE PATH "Install location for man pages (relative to prefix)." FORCE) set (CMAKE_MAN_DIR "'"${cmake_man_dir}"'" CACHE PATH "Install location for man pages (relative to prefix)." FORCE)
set (CMAKE_BIN_DIR "'"${cmake_bin_dir}"'" CACHE PATH "Install location for binaries (relative to prefix)." FORCE)
set (CMAKE_DATA_DIR "'"${cmake_data_dir}"'" CACHE PATH "Install location for data (relative to prefix)." FORCE) set (CMAKE_DATA_DIR "'"${cmake_data_dir}"'" CACHE PATH "Install location for data (relative to prefix)." FORCE)
set (CMAKE_XDGDATA_DIR "'"${cmake_xdgdata_dir}"'" CACHE PATH "Install location for XDG specific files (relative to prefix)." FORCE) set (CMAKE_XDGDATA_DIR "'"${cmake_xdgdata_dir}"'" CACHE PATH "Install location for XDG specific files (relative to prefix)." FORCE)
' > "${cmake_bootstrap_dir}/InitialCacheFlags.cmake" ' > "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"