diff options
author | Brad King <brad.king@kitware.com> | 2022-09-07 13:48:41 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-09-07 13:49:12 (GMT) |
commit | c3dafa24b27dadd41d1b5d3fb9cf64c14a073b5a (patch) | |
tree | 24f1fe4ef729d28952737be9217cdf023eb1048d /Modules | |
parent | dae13c214fc034f7fe5125d95f8ddb69284d4c23 (diff) | |
parent | 0c638ab59782fd5210255674f3456d0400ee0223 (diff) | |
download | CMake-c3dafa24b27dadd41d1b5d3fb9cf64c14a073b5a.zip CMake-c3dafa24b27dadd41d1b5d3fb9cf64c14a073b5a.tar.gz CMake-c3dafa24b27dadd41d1b5d3fb9cf64c14a073b5a.tar.bz2 |
Merge topic 'cpack-reuse-cmake-tools'
0c638ab597 CPack: re-use paths of tools discovered by CMakeFindBinUtils
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !7635
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CPack.cmake | 37 | ||||
-rw-r--r-- | Modules/Internal/CPack/CPackDeb.cmake | 30 | ||||
-rw-r--r-- | Modules/Internal/CPack/CPackRPM.cmake | 6 |
3 files changed, 55 insertions, 18 deletions
diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index 07280e0..828d9ca 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -472,6 +472,33 @@ The following variables are for advanced uses of CPack: target or when running :manual:`cpack <cpack(1)>` without the :option:`-G <cpack -G>` option. +.. variable:: CPACK_READELF_EXECUTABLE + + .. versionadded:: 3.25 + + Specify the ``readelf`` executable path used by CPack. + The default value will be ``CMAKE_READELF`` when set. Otherwise, + the default value will be empty and CPack will use :command:`find_program` + to determine the ``readelf`` path when needed. + +.. variable:: CPACK_OBJCOPY_EXECUTABLE + + .. versionadded:: 3.25 + + Specify the ``objcopy`` executable path used by CPack. + The default value will be ``CMAKE_OBJCOPY`` when set. Otherwise, + the default value will be empty and CPack will use :command:`find_program` + to determine the ``objcopy`` path when needed. + +.. variable:: CPACK_OBJDUMP_EXECUTABLE + + .. versionadded:: 3.25 + + Specify the ``objdump`` executable path used by CPack. + The default value will be ``CMAKE_OBJDUMP`` when set. Otherwise, + the default value will be empty and CPack will use :command:`find_program` + to determine the ``objdump`` path when needed. + #]=======================================================================] # Define this var in order to avoid (or warn) concerning multiple inclusion @@ -591,6 +618,16 @@ _cpack_set_default(CPACK_RESOURCE_FILE_WELCOME _cpack_set_default(CPACK_MODULE_PATH "${CMAKE_MODULE_PATH}") +if(CMAKE_READELF) + _cpack_set_default(CPACK_READELF_EXECUTABLE "${CMAKE_READELF}") +endif() +if(CMAKE_OBJCOPY) + _cpack_set_default(CPACK_OBJCOPY_EXECUTABLE "${CMAKE_OBJCOPY}") +endif() +if(CMAKE_OBJDUMP) + _cpack_set_default(CPACK_OBJDUMP_EXECUTABLE "${CMAKE_OBJDUMP}") +endif() + # Set default directory creation permissions mode if(CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS) _cpack_set_default(CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS diff --git a/Modules/Internal/CPack/CPackDeb.cmake b/Modules/Internal/CPack/CPackDeb.cmake index 958a6db..38e32c2 100644 --- a/Modules/Internal/CPack/CPackDeb.cmake +++ b/Modules/Internal/CPack/CPackDeb.cmake @@ -37,8 +37,8 @@ endfunction() #extract library name and version for given shared object function(extract_so_info shared_object libname version) - if(READELF_EXECUTABLE) - execute_process(COMMAND "${READELF_EXECUTABLE}" -d "${shared_object}" + if(CPACK_READELF_EXECUTABLE) + execute_process(COMMAND "${CPACK_READELF_EXECUTABLE}" -d "${shared_object}" WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" RESULT_VARIABLE result OUTPUT_VARIABLE output @@ -197,15 +197,15 @@ function(cpack_deb_prepare_package_vars) endforeach() endif() - find_program(READELF_EXECUTABLE NAMES readelf) + find_program(CPACK_READELF_EXECUTABLE NAMES readelf) if(CPACK_DEBIAN_DEBUGINFO_PACKAGE AND CPACK_DEB_UNSTRIPPED_FILES) - find_program(OBJCOPY_EXECUTABLE NAMES objcopy) + find_program(CPACK_OBJCOPY_EXECUTABLE NAMES objcopy) - if(NOT OBJCOPY_EXECUTABLE) + if(NOT CPACK_OBJCOPY_EXECUTABLE) message(FATAL_ERROR "debuginfo packages require the objcopy tool") endif() - if(NOT READELF_EXECUTABLE) + if(NOT CPACK_READELF_EXECUTABLE) message(FATAL_ERROR "debuginfo packages require the readelf tool") endif() @@ -213,7 +213,7 @@ function(cpack_deb_prepare_package_vars) foreach(_FILE IN LISTS CPACK_DEB_UNSTRIPPED_FILES) # Get the file's Build ID - execute_process(COMMAND env LC_ALL=C ${READELF_EXECUTABLE} -n "${_FILE}" + execute_process(COMMAND env LC_ALL=C ${CPACK_READELF_EXECUTABLE} -n "${_FILE}" WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" OUTPUT_VARIABLE READELF_OUTPUT RESULT_VARIABLE READELF_RESULT @@ -221,7 +221,7 @@ function(cpack_deb_prepare_package_vars) OUTPUT_STRIP_TRAILING_WHITESPACE ) if(NOT READELF_RESULT EQUAL 0) message(FATAL_ERROR "CPackDeb: readelf: '${READELF_ERROR}';\n" - "executed command: '${READELF_EXECUTABLE} -n ${_FILE}'") + "executed command: '${CPACK_READELF_EXECUTABLE} -n ${_FILE}'") endif() if(READELF_OUTPUT MATCHES "Build ID: ([0-9a-zA-Z][0-9a-zA-Z])([0-9a-zA-Z]*)") set(_BUILD_ID_START ${CMAKE_MATCH_1}) @@ -235,7 +235,7 @@ function(cpack_deb_prepare_package_vars) set(_FILE_DBGSYM ${_DBGSYM_ROOT}/usr/lib/debug/.build-id/${_BUILD_ID_START}/${_BUILD_ID_REMAINING}.debug) get_filename_component(_OUT_DIR "${_FILE_DBGSYM}" DIRECTORY) file(MAKE_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}/${_OUT_DIR}") - execute_process(COMMAND ${OBJCOPY_EXECUTABLE} --only-keep-debug "${_FILE}" "${_FILE_DBGSYM}" + execute_process(COMMAND ${CPACK_OBJCOPY_EXECUTABLE} --only-keep-debug "${_FILE}" "${_FILE_DBGSYM}" WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" OUTPUT_VARIABLE OBJCOPY_OUTPUT RESULT_VARIABLE OBJCOPY_RESULT @@ -243,9 +243,9 @@ function(cpack_deb_prepare_package_vars) OUTPUT_STRIP_TRAILING_WHITESPACE ) if(NOT OBJCOPY_RESULT EQUAL 0) message(FATAL_ERROR "CPackDeb: objcopy: '${OBJCOPY_ERROR}';\n" - "executed command: '${OBJCOPY_EXECUTABLE} --only-keep-debug ${_FILE} ${_FILE_DBGSYM}'") + "executed command: '${CPACK_OBJCOPY_EXECUTABLE} --only-keep-debug ${_FILE} ${_FILE_DBGSYM}'") endif() - execute_process(COMMAND ${OBJCOPY_EXECUTABLE} --strip-unneeded ${_FILE} + execute_process(COMMAND ${CPACK_OBJCOPY_EXECUTABLE} --strip-unneeded ${_FILE} WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" OUTPUT_VARIABLE OBJCOPY_OUTPUT RESULT_VARIABLE OBJCOPY_RESULT @@ -253,9 +253,9 @@ function(cpack_deb_prepare_package_vars) OUTPUT_STRIP_TRAILING_WHITESPACE ) if(NOT OBJCOPY_RESULT EQUAL 0) message(FATAL_ERROR "CPackDeb: objcopy: '${OBJCOPY_ERROR}';\n" - "executed command: '${OBJCOPY_EXECUTABLE} --strip-debug ${_FILE}'") + "executed command: '${CPACK_OBJCOPY_EXECUTABLE} --strip-debug ${_FILE}'") endif() - execute_process(COMMAND ${OBJCOPY_EXECUTABLE} --add-gnu-debuglink=${_FILE_DBGSYM} ${_FILE} + execute_process(COMMAND ${CPACK_OBJCOPY_EXECUTABLE} --add-gnu-debuglink=${_FILE_DBGSYM} ${_FILE} WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" OUTPUT_VARIABLE OBJCOPY_OUTPUT RESULT_VARIABLE OBJCOPY_RESULT @@ -263,7 +263,7 @@ function(cpack_deb_prepare_package_vars) OUTPUT_STRIP_TRAILING_WHITESPACE ) if(NOT OBJCOPY_RESULT EQUAL 0) message(FATAL_ERROR "CPackDeb: objcopy: '${OBJCOPY_ERROR}';\n" - "executed command: '${OBJCOPY_EXECUTABLE} --add-gnu-debuglink=${_FILE_DBGSYM} ${_FILE}'") + "executed command: '${CPACK_OBJCOPY_EXECUTABLE} --add-gnu-debuglink=${_FILE_DBGSYM} ${_FILE}'") endif() endforeach() endif() @@ -652,7 +652,7 @@ function(cpack_deb_prepare_package_vars) unset(CPACK_DEBIAN_PACKAGE_SHLIBS_LIST) if(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS) - if(READELF_EXECUTABLE) + if(CPACK_READELF_EXECUTABLE) foreach(_FILE IN LISTS CPACK_DEB_SHARED_OBJECT_FILES) extract_so_info("${_FILE}" libname soversion) if(libname AND DEFINED soversion) diff --git a/Modules/Internal/CPack/CPackRPM.cmake b/Modules/Internal/CPack/CPackRPM.cmake index cd631b8..7c10280 100644 --- a/Modules/Internal/CPack/CPackRPM.cmake +++ b/Modules/Internal/CPack/CPackRPM.cmake @@ -625,8 +625,8 @@ function(cpack_rpm_debugsymbol_check INSTALL_FILES WORKING_DIR) endif() # With objdump we should check the debug symbols - find_program(OBJDUMP_EXECUTABLE objdump) - if(NOT OBJDUMP_EXECUTABLE) + find_program(CPACK_OBJDUMP_EXECUTABLE objdump) + if(NOT CPACK_OBJDUMP_EXECUTABLE) message(FATAL_ERROR "CPackRPM: objdump binary could not be found!" " Required for debuginfo packaging. See documentation of" " CPACK_RPM_DEBUGINFO_PACKAGE variable for details.") @@ -649,7 +649,7 @@ function(cpack_rpm_debugsymbol_check INSTALL_FILES WORKING_DIR) continue() endif() - execute_process(COMMAND "${OBJDUMP_EXECUTABLE}" -h ${WORKING_DIR}/${F} + execute_process(COMMAND "${CPACK_OBJDUMP_EXECUTABLE}" -h ${WORKING_DIR}/${F} WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}" RESULT_VARIABLE OBJDUMP_EXEC_RESULT OUTPUT_VARIABLE OBJDUMP_OUT |