Clean up install rules of CMake itself (#14371)

Ensure CMAKE_DATA_DIR, CMAKE_DOC_DIR, and CMAKE_MAN_DIR are always
relative paths in CMake code, and set defaults accordingly.  Use the
install() command instead of install_files() and install_targets().
This is more modern and also avoids stripping of the first character
from user-specified destinations.

While at it, fix the default destinations reported in the bootstrap
help.
This commit is contained in:
Brad King 2013-08-26 11:50:08 -04:00
parent 8da09f6ee1
commit df62f64db7
13 changed files with 41 additions and 42 deletions

View File

@ -231,7 +231,7 @@ macro (CMAKE_BUILD_UTILITIES)
set(KWSYS_USE_Process 1) set(KWSYS_USE_Process 1)
set(KWSYS_USE_CommandLineArguments 1) set(KWSYS_USE_CommandLineArguments 1)
set(KWSYS_HEADER_ROOT ${CMake_BINARY_DIR}/Source) set(KWSYS_HEADER_ROOT ${CMake_BINARY_DIR}/Source)
set(KWSYS_INSTALL_DOC_DIR "${CMake_DOC_DEST}") set(KWSYS_INSTALL_DOC_DIR "${CMAKE_DOC_DIR}")
add_subdirectory(Source/kwsys) add_subdirectory(Source/kwsys)
set(kwsys_folder "Utilities/KWSys") set(kwsys_folder "Utilities/KWSys")
CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE} "${kwsys_folder}") CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE} "${kwsys_folder}")
@ -460,26 +460,27 @@ set(LIBRARY_OUTPUT_PATH "" CACHE INTERNAL
# install tree. # install tree.
set(CMAKE_SKIP_RPATH ON CACHE INTERNAL "CMake does not need RPATHs.") set(CMAKE_SKIP_RPATH ON CACHE INTERNAL "CMake does not need RPATHs.")
set(CMAKE_DATA_DIR "/share/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}" CACHE STRING set(CMAKE_DATA_DIR "share/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}" CACHE STRING
"Install location for data (relative to prefix).") "Install location for data (relative to prefix).")
set(CMAKE_DOC_DIR "/doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}" CACHE STRING set(CMAKE_DOC_DIR "doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}" CACHE STRING
"Install location for documentation (relative to prefix).") "Install location for documentation (relative to prefix).")
set(CMAKE_MAN_DIR "/man" CACHE STRING set(CMAKE_MAN_DIR "man" CACHE STRING
"Install location for man pages (relative to prefix).") "Install location for man pages (relative to prefix).")
mark_as_advanced(CMAKE_DATA_DIR CMAKE_DOC_DIR CMAKE_MAN_DIR) mark_as_advanced(CMAKE_DATA_DIR CMAKE_DOC_DIR CMAKE_MAN_DIR)
if(CYGWIN AND EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") if(CYGWIN AND EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
# Force doc, data and man dirs to conform to cygwin layout. # Force doc, data and man dirs to conform to cygwin layout.
set(CMAKE_DOC_DIR "/share/doc/cmake-${CMake_VERSION}") set(CMAKE_DOC_DIR "share/doc/cmake-${CMake_VERSION}")
set(CMAKE_DATA_DIR "/share/cmake-${CMake_VERSION}") set(CMAKE_DATA_DIR "share/cmake-${CMake_VERSION}")
set(CMAKE_MAN_DIR "/share/man") set(CMAKE_MAN_DIR "share/man")
# let the user know we just forced these values # let the user know we just forced these values
message(STATUS "Setup for Cygwin packaging") message(STATUS "Setup for Cygwin packaging")
message(STATUS "Override cache CMAKE_DOC_DIR = ${CMAKE_DOC_DIR}") message(STATUS "Override cache CMAKE_DOC_DIR = ${CMAKE_DOC_DIR}")
message(STATUS "Override cache CMAKE_DATA_DIR = ${CMAKE_DATA_DIR}") message(STATUS "Override cache CMAKE_DATA_DIR = ${CMAKE_DATA_DIR}")
message(STATUS "Override cache CMAKE_MAN_DIR = ${CMAKE_MAN_DIR}") message(STATUS "Override cache CMAKE_MAN_DIR = ${CMAKE_MAN_DIR}")
endif() endif()
string(REGEX REPLACE "^/" "" CMake_DATA_DEST "${CMAKE_DATA_DIR}") string(REGEX REPLACE "^/" "" CMAKE_DATA_DIR "${CMAKE_DATA_DIR}")
string(REGEX REPLACE "^/" "" CMake_DOC_DEST "${CMAKE_DOC_DIR}") string(REGEX REPLACE "^/" "" CMAKE_DOC_DIR "${CMAKE_DOC_DIR}")
string(REGEX REPLACE "^/" "" CMAKE_MAN_DIR "${CMAKE_MAN_DIR}")
if(BUILD_TESTING) if(BUILD_TESTING)
include(${CMake_SOURCE_DIR}/Tests/CMakeInstall.cmake) include(${CMake_SOURCE_DIR}/Tests/CMakeInstall.cmake)
@ -625,12 +626,12 @@ add_test(SystemInformationNew "${CMAKE_CMAKE_COMMAND}"
--system-information -G "${CMAKE_TEST_GENERATOR}" ) --system-information -G "${CMAKE_TEST_GENERATOR}" )
# Install license file as it requires. # Install license file as it requires.
install(FILES Copyright.txt DESTINATION ${CMake_DOC_DEST}) install(FILES Copyright.txt DESTINATION ${CMAKE_DOC_DIR})
# Install script directories. # Install script directories.
install( install(
DIRECTORY Modules Templates DIRECTORY Modules Templates
DESTINATION "${CMake_DATA_DEST}" DESTINATION ${CMAKE_DATA_DIR}
FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
DIRECTORY_PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE DIRECTORY_PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE
GROUP_READ GROUP_EXECUTE GROUP_READ GROUP_EXECUTE

View File

@ -1,4 +1,3 @@
string(REGEX REPLACE "^/(.*)" "\\1" REL_CMAKE_DATA_DIR "${CMAKE_DATA_DIR}") install(FILES cmake-help.vim cmake-indent.vim cmake-syntax.vim DESTINATION ${CMAKE_DATA_DIR}/editors/vim)
install(FILES cmake-help.vim cmake-indent.vim cmake-syntax.vim DESTINATION ${REL_CMAKE_DATA_DIR}/editors/vim) install(FILES cmake-mode.el DESTINATION ${CMAKE_DATA_DIR}/editors/emacs)
install(FILES cmake-mode.el DESTINATION ${REL_CMAKE_DATA_DIR}/editors/emacs)
add_subdirectory (bash-completion) add_subdirectory (bash-completion)

View File

@ -5,4 +5,4 @@
# add symlinks to the files in appropriate places # add symlinks to the files in appropriate places
# /etc/bash_completion.d/ # /etc/bash_completion.d/
# DATADIR/completions (may be /usr/share/<package>/completions # DATADIR/completions (may be /usr/share/<package>/completions
install(FILES cmake cpack ctest DESTINATION ${REL_CMAKE_DATA_DIR}/completions) install(FILES cmake cpack ctest DESTINATION ${CMAKE_DATA_DIR}/completions)

View File

@ -394,7 +394,7 @@ if(WIN32 AND NOT CYGWIN AND NOT BORLAND)
set_source_files_properties(cmcldeps.cxx PROPERTIES COMPILE_DEFINITIONS _WIN32_WINNT=0x0501) set_source_files_properties(cmcldeps.cxx PROPERTIES COMPILE_DEFINITIONS _WIN32_WINNT=0x0501)
add_executable(cmcldeps cmcldeps.cxx) add_executable(cmcldeps cmcldeps.cxx)
target_link_libraries(cmcldeps CMakeLib) target_link_libraries(cmcldeps CMakeLib)
install_targets(/bin cmcldeps) install(TARGETS cmcldeps DESTINATION bin)
endif() endif()
# create a library used by the command line and the GUI # create a library used by the command line and the GUI
@ -554,7 +554,7 @@ if(WIN32)
if(NOT UNIX) if(NOT UNIX)
add_executable(cmw9xcom cmw9xcom.cxx) add_executable(cmw9xcom cmw9xcom.cxx)
target_link_libraries(cmw9xcom CMakeLib) target_link_libraries(cmw9xcom CMakeLib)
install_targets(/bin cmw9xcom) install(TARGETS cmw9xcom DESTINATION bin)
endif() endif()
endif() endif()
@ -580,11 +580,9 @@ endif()
include (${CMake_BINARY_DIR}/Source/LocalUserOptions.cmake OPTIONAL) include (${CMake_BINARY_DIR}/Source/LocalUserOptions.cmake OPTIONAL)
include (${CMake_SOURCE_DIR}/Source/LocalUserOptions.cmake OPTIONAL) include (${CMake_SOURCE_DIR}/Source/LocalUserOptions.cmake OPTIONAL)
install_targets(/bin cmake) install(TARGETS cmake ctest cpack DESTINATION bin)
install_targets(/bin ctest)
install_targets(/bin cpack)
if(APPLE) if(APPLE)
install_targets(/bin cmakexbuild) install(TARGETS cmakexbuild DESTINATION bin)
endif() endif()
install_files(${CMAKE_DATA_DIR}/include cmCPluginAPI.h) install(FILES cmCPluginAPI.h DESTINATION ${CMAKE_DATA_DIR}/include)

View File

@ -34,4 +34,4 @@ add_executable(ccmake ${CURSES_SRCS} )
target_link_libraries(ccmake CMakeLib) target_link_libraries(ccmake CMakeLib)
target_link_libraries(ccmake cmForm) target_link_libraries(ccmake cmForm)
install_targets(/bin ccmake) install(TARGETS ccmake DESTINATION bin)

View File

@ -19,4 +19,4 @@
#cmakedefine CMAKE_STRICT #cmakedefine CMAKE_STRICT
#define CMAKE_ROOT_DIR "${CMake_SOURCE_DIR}" #define CMAKE_ROOT_DIR "${CMake_SOURCE_DIR}"
#define CMAKE_BUILD_DIR "${CMake_BINARY_DIR}" #define CMAKE_BUILD_DIR "${CMake_BINARY_DIR}"
#define CMAKE_DATA_DIR "@CMAKE_DATA_DIR@" #define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@"

View File

@ -123,11 +123,12 @@ add_custom_command(
MAIN_DEPENDENCY ${CMake_SOURCE_DIR}/Utilities/Doxygen/authors.txt MAIN_DEPENDENCY ${CMake_SOURCE_DIR}/Utilities/Doxygen/authors.txt
) )
install_files(${CMAKE_MAN_DIR}/man1 FILES ${MAN_FILES}) install(FILES ${MAN_FILES} DESTINATION ${CMAKE_MAN_DIR}/man1)
install_files(${CMAKE_DOC_DIR} FILES install(FILES
${TEXT_FILES} ${TEXT_FILES}
${HTML_FILES} ${HTML_FILES}
${DOCBOOK_FILES} ${DOCBOOK_FILES}
DESTINATION ${CMAKE_DOC_DIR}
) )
install(FILES cmake.m4 DESTINATION share/aclocal) install(FILES cmake.m4 DESTINATION share/aclocal)

View File

@ -2,4 +2,4 @@ PROJECT(CMCompress)
ADD_LIBRARY(cmcompress cmcompress.c) ADD_LIBRARY(cmcompress cmcompress.c)
INSTALL(FILES Copyright.txt DESTINATION ${CMake_DOC_DEST}/cmcompress) INSTALL(FILES Copyright.txt DESTINATION ${CMAKE_DOC_DIR}/cmcompress)

View File

@ -716,7 +716,7 @@ TARGET_LINK_LIBRARIES(cmcurl ${CURL_LIBS})
IF(CMAKE_BUILD_CURL_SHARED) IF(CMAKE_BUILD_CURL_SHARED)
SET_TARGET_PROPERTIES(cmcurl PROPERTIES DEFINE_SYMBOL BUILDING_LIBCURL SET_TARGET_PROPERTIES(cmcurl PROPERTIES DEFINE_SYMBOL BUILDING_LIBCURL
RUNTIME_OUTPUT_DIRECTORY ${CMake_BIN_DIR}) RUNTIME_OUTPUT_DIRECTORY ${CMake_BIN_DIR})
INSTALL_TARGETS(/bin cmcurl) INSTALL(TARGETS cmcurl RUNTIME DESTINATION bin)
ENDIF(CMAKE_BUILD_CURL_SHARED) ENDIF(CMAKE_BUILD_CURL_SHARED)
OPTION(CURL_TESTING "Do libCurl testing" OFF) OPTION(CURL_TESTING "Do libCurl testing" OFF)
@ -731,4 +731,4 @@ IF(CMAKE_CURL_TEST_URL)
ADD_TEST(curl LIBCURL ${CMAKE_CURL_TEST_URL}) ADD_TEST(curl LIBCURL ${CMAKE_CURL_TEST_URL})
ENDIF(CMAKE_CURL_TEST_URL) ENDIF(CMAKE_CURL_TEST_URL)
INSTALL(FILES COPYING DESTINATION ${CMake_DOC_DEST}/cmcurl) INSTALL(FILES COPYING DESTINATION ${CMAKE_DOC_DIR}/cmcurl)

View File

@ -31,4 +31,4 @@ CONFIGURE_FILE(${CMEXPAT_SOURCE_DIR}/expat.h
${CMEXPAT_BINARY_DIR}/expat.h) ${CMEXPAT_BINARY_DIR}/expat.h)
ADD_LIBRARY(cmexpat ${expat_SRCS}) ADD_LIBRARY(cmexpat ${expat_SRCS})
INSTALL(FILES COPYING DESTINATION ${CMake_DOC_DEST}/cmexpat) INSTALL(FILES COPYING DESTINATION ${CMAKE_DOC_DIR}/cmexpat)

View File

@ -1311,4 +1311,4 @@ ENDIF(APPLE)
add_subdirectory(libarchive) add_subdirectory(libarchive)
install(FILES COPYING DESTINATION ${CMake_DOC_DEST}/cmlibarchive) install(FILES COPYING DESTINATION ${CMAKE_DOC_DIR}/cmlibarchive)

View File

@ -40,4 +40,4 @@ ENDFOREACH(name)
ADD_LIBRARY(cmzlib ${ZLIB_SRCS}) ADD_LIBRARY(cmzlib ${ZLIB_SRCS})
INSTALL(FILES Copyright.txt DESTINATION ${CMake_DOC_DEST}/cmzlib) INSTALL(FILES Copyright.txt DESTINATION ${CMAKE_DOC_DIR}/cmzlib)

View File

@ -43,9 +43,9 @@ if [ "$cmake_version_tweak" != "0" ]; then
cmake_version="${cmake_version}.${cmake_version_tweak}" cmake_version="${cmake_version}.${cmake_version_tweak}"
fi fi
cmake_data_dir="/share/cmake-${cmake_version_major}.${cmake_version_minor}" cmake_data_dir="share/cmake-${cmake_version_major}.${cmake_version_minor}"
cmake_doc_dir="/doc/cmake-${cmake_version_major}.${cmake_version_minor}" cmake_doc_dir="doc/cmake-${cmake_version_major}.${cmake_version_minor}"
cmake_man_dir="/man" cmake_man_dir="man"
cmake_init_file="" cmake_init_file=""
cmake_bootstrap_system_libs="" cmake_bootstrap_system_libs=""
cmake_bootstrap_qt_gui="" cmake_bootstrap_qt_gui=""
@ -160,8 +160,8 @@ if ${cmake_system_mingw}; then
fi fi
elif ${cmake_system_haiku}; then elif ${cmake_system_haiku}; then
cmake_default_prefix=`finddir B_COMMON_DIRECTORY` cmake_default_prefix=`finddir B_COMMON_DIRECTORY`
cmake_man_dir="/documentation/man" cmake_man_dir="documentation/man"
cmake_doc_dir="/documentation/doc/cmake-${cmake_version}" cmake_doc_dir="documentation/doc/cmake-${cmake_version}"
else else
cmake_default_prefix="/usr/local" cmake_default_prefix="/usr/local"
fi fi
@ -353,13 +353,13 @@ 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}"']
--datadir=DIR install data files in PREFIX/DIR --datadir=DIR install data files in PREFIX/DIR
[/share/CMake] ['"${cmake_data_dir}"']
--docdir=DIR install documentation files in PREFIX/DIR --docdir=DIR install documentation files in PREFIX/DIR
[/doc/CMake] ['"${cmake_doc_dir}"']
--mandir=DIR install man pages files in PREFIX/DIR/manN --mandir=DIR install man pages files in PREFIX/DIR/manN
[/man] ['"${cmake_man_dir}"']
' '
exit 10 exit 10
} }
@ -1400,7 +1400,7 @@ cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_PATCH ${cmake_versi
cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_TWEAK ${cmake_version_tweak}" cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_TWEAK ${cmake_version_tweak}"
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_ROOT_DIR \"${cmake_root_dir}\"" cmake_report cmConfigure.h${_tmp} "#define CMAKE_ROOT_DIR \"${cmake_root_dir}\""
cmake_report cmConfigure.h${_tmp} "#define CMAKE_DATA_DIR \"${cmake_data_dir}\"" cmake_report cmConfigure.h${_tmp} "#define CMAKE_DATA_DIR \"/${cmake_data_dir}\""
cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP" cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP"
# Regenerate configured headers # Regenerate configured headers