Commit df62f64d authored by Brad King's avatar Brad King

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.
parent 8da09f6e
......@@ -231,7 +231,7 @@ macro (CMAKE_BUILD_UTILITIES)
set(KWSYS_USE_Process 1)
set(KWSYS_USE_CommandLineArguments 1)
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)
set(kwsys_folder "Utilities/KWSys")
CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE} "${kwsys_folder}")
......@@ -460,26 +460,27 @@ set(LIBRARY_OUTPUT_PATH "" CACHE INTERNAL
# install tree.
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).")
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).")
set(CMAKE_MAN_DIR "/man" CACHE STRING
set(CMAKE_MAN_DIR "man" CACHE STRING
"Install location for man pages (relative to prefix).")
mark_as_advanced(CMAKE_DATA_DIR CMAKE_DOC_DIR CMAKE_MAN_DIR)
if(CYGWIN AND EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
# Force doc, data and man dirs to conform to cygwin layout.
set(CMAKE_DOC_DIR "/share/doc/cmake-${CMake_VERSION}")
set(CMAKE_DATA_DIR "/share/cmake-${CMake_VERSION}")
set(CMAKE_MAN_DIR "/share/man")
set(CMAKE_DOC_DIR "share/doc/cmake-${CMake_VERSION}")
set(CMAKE_DATA_DIR "share/cmake-${CMake_VERSION}")
set(CMAKE_MAN_DIR "share/man")
# let the user know we just forced these values
message(STATUS "Setup for Cygwin packaging")
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_MAN_DIR = ${CMAKE_MAN_DIR}")
endif()
string(REGEX REPLACE "^/" "" CMake_DATA_DEST "${CMAKE_DATA_DIR}")
string(REGEX REPLACE "^/" "" CMake_DOC_DEST "${CMAKE_DOC_DIR}")
string(REGEX REPLACE "^/" "" CMAKE_DATA_DIR "${CMAKE_DATA_DIR}")
string(REGEX REPLACE "^/" "" CMAKE_DOC_DIR "${CMAKE_DOC_DIR}")
string(REGEX REPLACE "^/" "" CMAKE_MAN_DIR "${CMAKE_MAN_DIR}")
if(BUILD_TESTING)
include(${CMake_SOURCE_DIR}/Tests/CMakeInstall.cmake)
......@@ -625,12 +626,12 @@ add_test(SystemInformationNew "${CMAKE_CMAKE_COMMAND}"
--system-information -G "${CMAKE_TEST_GENERATOR}" )
# 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(
DIRECTORY Modules Templates
DESTINATION "${CMake_DATA_DEST}"
DESTINATION ${CMAKE_DATA_DIR}
FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
DIRECTORY_PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE
GROUP_READ GROUP_EXECUTE
......
string(REGEX REPLACE "^/(.*)" "\\1" REL_CMAKE_DATA_DIR "${CMAKE_DATA_DIR}")
install(FILES cmake-help.vim cmake-indent.vim cmake-syntax.vim DESTINATION ${REL_CMAKE_DATA_DIR}/editors/vim)
install(FILES cmake-mode.el DESTINATION ${REL_CMAKE_DATA_DIR}/editors/emacs)
install(FILES cmake-help.vim cmake-indent.vim cmake-syntax.vim DESTINATION ${CMAKE_DATA_DIR}/editors/vim)
install(FILES cmake-mode.el DESTINATION ${CMAKE_DATA_DIR}/editors/emacs)
add_subdirectory (bash-completion)
......@@ -5,4 +5,4 @@
# add symlinks to the files in appropriate places
# /etc/bash_completion.d/
# 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)
......@@ -394,7 +394,7 @@ if(WIN32 AND NOT CYGWIN AND NOT BORLAND)
set_source_files_properties(cmcldeps.cxx PROPERTIES COMPILE_DEFINITIONS _WIN32_WINNT=0x0501)
add_executable(cmcldeps cmcldeps.cxx)
target_link_libraries(cmcldeps CMakeLib)
install_targets(/bin cmcldeps)
install(TARGETS cmcldeps DESTINATION bin)
endif()
# create a library used by the command line and the GUI
......@@ -554,7 +554,7 @@ if(WIN32)
if(NOT UNIX)
add_executable(cmw9xcom cmw9xcom.cxx)
target_link_libraries(cmw9xcom CMakeLib)
install_targets(/bin cmw9xcom)
install(TARGETS cmw9xcom DESTINATION bin)
endif()
endif()
......@@ -580,11 +580,9 @@ endif()
include (${CMake_BINARY_DIR}/Source/LocalUserOptions.cmake OPTIONAL)
include (${CMake_SOURCE_DIR}/Source/LocalUserOptions.cmake OPTIONAL)
install_targets(/bin cmake)
install_targets(/bin ctest)
install_targets(/bin cpack)
install(TARGETS cmake ctest cpack DESTINATION bin)
if(APPLE)
install_targets(/bin cmakexbuild)
install(TARGETS cmakexbuild DESTINATION bin)
endif()
install_files(${CMAKE_DATA_DIR}/include cmCPluginAPI.h)
install(FILES cmCPluginAPI.h DESTINATION ${CMAKE_DATA_DIR}/include)
......@@ -34,4 +34,4 @@ add_executable(ccmake ${CURSES_SRCS} )
target_link_libraries(ccmake CMakeLib)
target_link_libraries(ccmake cmForm)
install_targets(/bin ccmake)
install(TARGETS ccmake DESTINATION bin)
......@@ -19,4 +19,4 @@
#cmakedefine CMAKE_STRICT
#define CMAKE_ROOT_DIR "${CMake_SOURCE_DIR}"
#define CMAKE_BUILD_DIR "${CMake_BINARY_DIR}"
#define CMAKE_DATA_DIR "@CMAKE_DATA_DIR@"
#define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@"
......@@ -123,11 +123,12 @@ add_custom_command(
MAIN_DEPENDENCY ${CMake_SOURCE_DIR}/Utilities/Doxygen/authors.txt
)
install_files(${CMAKE_MAN_DIR}/man1 FILES ${MAN_FILES})
install_files(${CMAKE_DOC_DIR} FILES
install(FILES ${MAN_FILES} DESTINATION ${CMAKE_MAN_DIR}/man1)
install(FILES
${TEXT_FILES}
${HTML_FILES}
${DOCBOOK_FILES}
DESTINATION ${CMAKE_DOC_DIR}
)
install(FILES cmake.m4 DESTINATION share/aclocal)
......
......@@ -2,4 +2,4 @@ PROJECT(CMCompress)
ADD_LIBRARY(cmcompress cmcompress.c)
INSTALL(FILES Copyright.txt DESTINATION ${CMake_DOC_DEST}/cmcompress)
INSTALL(FILES Copyright.txt DESTINATION ${CMAKE_DOC_DIR}/cmcompress)
......@@ -716,7 +716,7 @@ TARGET_LINK_LIBRARIES(cmcurl ${CURL_LIBS})
IF(CMAKE_BUILD_CURL_SHARED)
SET_TARGET_PROPERTIES(cmcurl PROPERTIES DEFINE_SYMBOL BUILDING_LIBCURL
RUNTIME_OUTPUT_DIRECTORY ${CMake_BIN_DIR})
INSTALL_TARGETS(/bin cmcurl)
INSTALL(TARGETS cmcurl RUNTIME DESTINATION bin)
ENDIF(CMAKE_BUILD_CURL_SHARED)
OPTION(CURL_TESTING "Do libCurl testing" OFF)
......@@ -731,4 +731,4 @@ IF(CMAKE_CURL_TEST_URL)
ADD_TEST(curl LIBCURL ${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)
......@@ -31,4 +31,4 @@ CONFIGURE_FILE(${CMEXPAT_SOURCE_DIR}/expat.h
${CMEXPAT_BINARY_DIR}/expat.h)
ADD_LIBRARY(cmexpat ${expat_SRCS})
INSTALL(FILES COPYING DESTINATION ${CMake_DOC_DEST}/cmexpat)
INSTALL(FILES COPYING DESTINATION ${CMAKE_DOC_DIR}/cmexpat)
......@@ -1311,4 +1311,4 @@ ENDIF(APPLE)
add_subdirectory(libarchive)
install(FILES COPYING DESTINATION ${CMake_DOC_DEST}/cmlibarchive)
install(FILES COPYING DESTINATION ${CMAKE_DOC_DIR}/cmlibarchive)
......@@ -40,4 +40,4 @@ ENDFOREACH(name)
ADD_LIBRARY(cmzlib ${ZLIB_SRCS})
INSTALL(FILES Copyright.txt DESTINATION ${CMake_DOC_DEST}/cmzlib)
INSTALL(FILES Copyright.txt DESTINATION ${CMAKE_DOC_DIR}/cmzlib)
......@@ -43,9 +43,9 @@ if [ "$cmake_version_tweak" != "0" ]; then
cmake_version="${cmake_version}.${cmake_version_tweak}"
fi
cmake_data_dir="/share/cmake-${cmake_version_major}.${cmake_version_minor}"
cmake_doc_dir="/doc/cmake-${cmake_version_major}.${cmake_version_minor}"
cmake_man_dir="/man"
cmake_data_dir="share/cmake-${cmake_version_major}.${cmake_version_minor}"
cmake_doc_dir="doc/cmake-${cmake_version_major}.${cmake_version_minor}"
cmake_man_dir="man"
cmake_init_file=""
cmake_bootstrap_system_libs=""
cmake_bootstrap_qt_gui=""
......@@ -160,8 +160,8 @@ if ${cmake_system_mingw}; then
fi
elif ${cmake_system_haiku}; then
cmake_default_prefix=`finddir B_COMMON_DIRECTORY`
cmake_man_dir="/documentation/man"
cmake_doc_dir="/documentation/doc/cmake-${cmake_version}"
cmake_man_dir="documentation/man"
cmake_doc_dir="documentation/doc/cmake-${cmake_version}"
else
cmake_default_prefix="/usr/local"
fi
......@@ -353,13 +353,13 @@ Configuration:
Directory and file names:
--prefix=PREFIX install files in tree rooted at PREFIX
[${cmake_default_prefix}]
['"${cmake_default_prefix}"']
--datadir=DIR install data files in PREFIX/DIR
[/share/CMake]
['"${cmake_data_dir}"']
--docdir=DIR install documentation files in PREFIX/DIR
[/doc/CMake]
['"${cmake_doc_dir}"']
--mandir=DIR install man pages files in PREFIX/DIR/manN
[/man]
['"${cmake_man_dir}"']
'
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 \"${cmake_version}\""
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"
# Regenerate configured headers
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment