From df62f64db72b6f00657e9e739e1e117639dea9da Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 26 Aug 2013 11:50:08 -0400 Subject: 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. --- CMakeLists.txt | 23 ++++++++++++----------- Docs/CMakeLists.txt | 5 ++--- Docs/bash-completion/CMakeLists.txt | 2 +- Source/CMakeLists.txt | 12 +++++------- Source/CursesDialog/CMakeLists.txt | 2 +- Source/cmConfigure.cmake.h.in | 2 +- Utilities/CMakeLists.txt | 5 +++-- Utilities/cmcompress/CMakeLists.txt | 2 +- Utilities/cmcurl/CMakeLists.txt | 4 ++-- Utilities/cmexpat/CMakeLists.txt | 2 +- Utilities/cmlibarchive/CMakeLists.txt | 2 +- Utilities/cmzlib/CMakeLists.txt | 2 +- bootstrap | 20 ++++++++++---------- 13 files changed, 41 insertions(+), 42 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 75d372d..1fbbe08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/Docs/CMakeLists.txt b/Docs/CMakeLists.txt index a5e91c9..34090d2 100644 --- a/Docs/CMakeLists.txt +++ b/Docs/CMakeLists.txt @@ -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 ${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) diff --git a/Docs/bash-completion/CMakeLists.txt b/Docs/bash-completion/CMakeLists.txt index 592b71e..c0a8899 100644 --- a/Docs/bash-completion/CMakeLists.txt +++ b/Docs/bash-completion/CMakeLists.txt @@ -5,4 +5,4 @@ # add symlinks to the files in appropriate places # /etc/bash_completion.d/ # DATADIR/completions (may be /usr/share//completions -install(FILES cmake cpack ctest DESTINATION ${REL_CMAKE_DATA_DIR}/completions) +install(FILES cmake cpack ctest DESTINATION ${CMAKE_DATA_DIR}/completions) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 64fc53f..8412e3e 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -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) diff --git a/Source/CursesDialog/CMakeLists.txt b/Source/CursesDialog/CMakeLists.txt index 96e28b4..5efc2fb 100644 --- a/Source/CursesDialog/CMakeLists.txt +++ b/Source/CursesDialog/CMakeLists.txt @@ -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) diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in index 114afd7..ab53b1d 100644 --- a/Source/cmConfigure.cmake.h.in +++ b/Source/cmConfigure.cmake.h.in @@ -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@" diff --git a/Utilities/CMakeLists.txt b/Utilities/CMakeLists.txt index 91965e9..bad8d63 100644 --- a/Utilities/CMakeLists.txt +++ b/Utilities/CMakeLists.txt @@ -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) diff --git a/Utilities/cmcompress/CMakeLists.txt b/Utilities/cmcompress/CMakeLists.txt index 3323dcd..8063573 100644 --- a/Utilities/cmcompress/CMakeLists.txt +++ b/Utilities/cmcompress/CMakeLists.txt @@ -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) diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt index 320612c..74a713d 100644 --- a/Utilities/cmcurl/CMakeLists.txt +++ b/Utilities/cmcurl/CMakeLists.txt @@ -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) diff --git a/Utilities/cmexpat/CMakeLists.txt b/Utilities/cmexpat/CMakeLists.txt index b75c112..51ba413 100644 --- a/Utilities/cmexpat/CMakeLists.txt +++ b/Utilities/cmexpat/CMakeLists.txt @@ -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) diff --git a/Utilities/cmlibarchive/CMakeLists.txt b/Utilities/cmlibarchive/CMakeLists.txt index 621888c..8ef0e89 100644 --- a/Utilities/cmlibarchive/CMakeLists.txt +++ b/Utilities/cmlibarchive/CMakeLists.txt @@ -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) diff --git a/Utilities/cmzlib/CMakeLists.txt b/Utilities/cmzlib/CMakeLists.txt index c42a434..f161056 100644 --- a/Utilities/cmzlib/CMakeLists.txt +++ b/Utilities/cmzlib/CMakeLists.txt @@ -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) diff --git a/bootstrap b/bootstrap index afb66e5..fb4a0a0 100755 --- a/bootstrap +++ b/bootstrap @@ -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 -- cgit v0.12