summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/release/dev/cpack-reuse-cmake-tools.rst7
-rw-r--r--Modules/CPack.cmake37
-rw-r--r--Modules/Internal/CPack/CPackDeb.cmake30
-rw-r--r--Modules/Internal/CPack/CPackRPM.cmake6
-rw-r--r--Tests/RunCMake/CPack/DEB/Helpers.cmake4
-rw-r--r--Tests/RunCMake/CPack/DEB/Prerequirements.cmake6
-rw-r--r--Tests/RunCMake/CPack/RPM/Prerequirements.cmake6
-rw-r--r--Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/DEB-Prerequirements.cmake2
-rw-r--r--Tests/RunCMake/CPack/tests/GENERATE_SHLIBS_LDCONFIG/DEB-Prerequirements.cmake2
-rw-r--r--Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/RPM-Prerequirements.cmake2
10 files changed, 73 insertions, 29 deletions
diff --git a/Help/release/dev/cpack-reuse-cmake-tools.rst b/Help/release/dev/cpack-reuse-cmake-tools.rst
new file mode 100644
index 0000000..144a6b3
--- /dev/null
+++ b/Help/release/dev/cpack-reuse-cmake-tools.rst
@@ -0,0 +1,7 @@
+cpack-reuse-cmake-tools
+-----------------------
+
+* The :module:`CPack` module gained the :variable:`CPACK_READELF_EXECUTABLE`,
+ :variable:`CPACK_OBJCOPY_EXECUTABLE`, and
+ :variable:`CPACK_OBJDUMP_EXECUTABLE` variables to control the locations
+ of binutils used by :manual:`cpack(1)`.
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
diff --git a/Tests/RunCMake/CPack/DEB/Helpers.cmake b/Tests/RunCMake/CPack/DEB/Helpers.cmake
index 9b98ed4..8904c69 100644
--- a/Tests/RunCMake/CPack/DEB/Helpers.cmake
+++ b/Tests/RunCMake/CPack/DEB/Helpers.cmake
@@ -97,7 +97,7 @@ function(getMissingShlibsErrorExtra FILE RESULT_VAR)
string(APPEND error_extra "; errors \"${deb_install_files_errors}\"")
endif()
- if(READELF_EXECUTABLE)
+ if(CPACK_READELF_EXECUTABLE)
string(APPEND error_extra "; readelf \"\n")
# Only dynamically linked ELF files are included
@@ -106,7 +106,7 @@ function(getMissingShlibsErrorExtra FILE RESULT_VAR)
if(_FILE MATCHES "ELF.*shared object")
string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}")
- execute_process(COMMAND ${READELF_EXECUTABLE} -d "${CMAKE_MATCH_1}"
+ execute_process(COMMAND ${CPACK_READELF_EXECUTABLE} -d "${CMAKE_MATCH_1}"
WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
RESULT_VARIABLE result
OUTPUT_VARIABLE output
diff --git a/Tests/RunCMake/CPack/DEB/Prerequirements.cmake b/Tests/RunCMake/CPack/DEB/Prerequirements.cmake
index 60d02e7..3b02579 100644
--- a/Tests/RunCMake/CPack/DEB/Prerequirements.cmake
+++ b/Tests/RunCMake/CPack/DEB/Prerequirements.cmake
@@ -14,9 +14,9 @@ function(get_test_prerequirements found_var config_file)
endif()
# optional tool for some tests
- find_program(READELF_EXECUTABLE NAMES readelf)
- if(READELF_EXECUTABLE)
+ find_program(CPACK_READELF_EXECUTABLE NAMES readelf)
+ if(CPACK_READELF_EXECUTABLE)
file(APPEND "${config_file}"
- "\nset(READELF_EXECUTABLE \"${READELF_EXECUTABLE}\")")
+ "\nset(CPACK_READELF_EXECUTABLE \"${CPACK_READELF_EXECUTABLE}\")")
endif()
endfunction()
diff --git a/Tests/RunCMake/CPack/RPM/Prerequirements.cmake b/Tests/RunCMake/CPack/RPM/Prerequirements.cmake
index e95cd15..a4741ba 100644
--- a/Tests/RunCMake/CPack/RPM/Prerequirements.cmake
+++ b/Tests/RunCMake/CPack/RPM/Prerequirements.cmake
@@ -15,9 +15,9 @@ function(get_test_prerequirements found_var config_file)
endif()
# optional tool for some tests
- find_program(OBJDUMP_EXECUTABLE objdump)
- if(OBJDUMP_EXECUTABLE)
+ find_program(CPACK_OBJDUMP_EXECUTABLE objdump)
+ if(CPACK_OBJDUMP_EXECUTABLE)
file(APPEND "${config_file}"
- "\nset(OBJDUMP_EXECUTABLE \"${OBJDUMP_EXECUTABLE}\")")
+ "\nset(CPACK_OBJDUMP_EXECUTABLE \"${CPACK_OBJDUMP_EXECUTABLE}\")")
endif()
endfunction()
diff --git a/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/DEB-Prerequirements.cmake b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/DEB-Prerequirements.cmake
index be44b2e..b0bfc9d 100644
--- a/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/DEB-Prerequirements.cmake
+++ b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/DEB-Prerequirements.cmake
@@ -1,7 +1,7 @@
function(get_test_prerequirements found_var config_file)
include(${config_file})
- if(READELF_EXECUTABLE)
+ if(CPACK_READELF_EXECUTABLE)
set(${found_var} true PARENT_SCOPE)
endif()
endfunction()
diff --git a/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS_LDCONFIG/DEB-Prerequirements.cmake b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS_LDCONFIG/DEB-Prerequirements.cmake
index be44b2e..b0bfc9d 100644
--- a/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS_LDCONFIG/DEB-Prerequirements.cmake
+++ b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS_LDCONFIG/DEB-Prerequirements.cmake
@@ -1,7 +1,7 @@
function(get_test_prerequirements found_var config_file)
include(${config_file})
- if(READELF_EXECUTABLE)
+ if(CPACK_READELF_EXECUTABLE)
set(${found_var} true PARENT_SCOPE)
endif()
endfunction()
diff --git a/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/RPM-Prerequirements.cmake b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/RPM-Prerequirements.cmake
index 90cfe44..f5df8a2 100644
--- a/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/RPM-Prerequirements.cmake
+++ b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/RPM-Prerequirements.cmake
@@ -2,7 +2,7 @@ function(get_test_prerequirements found_var config_file)
if(SUBTEST_SUFFIX MATCHES ".*single_debug_info")
include(${config_file})
- if(OBJDUMP_EXECUTABLE)
+ if(CPACK_OBJDUMP_EXECUTABLE)
set(${found_var} true PARENT_SCOPE)
endif()
else()