mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 02:39:48 -06:00
file: GetRuntimeDependencies use CMAKE_OBJDUMP when applicable
On machines where the gnu bin utils are prefixed, or suffixed the file(GET_RUNTIME_DEPENDENCIES ) command would fail without explicitly setting the location of objdump. Now we pre-populate the variables used to find objdump based on the gnu bin utils, so that these use cases are better supported
This commit is contained in:
@@ -402,8 +402,8 @@ dependency resolution:
|
||||
Determines the path to the tool to use for dependency resolution. This is the
|
||||
actual path to ``objdump``, ``dumpbin``, or ``otool``.
|
||||
|
||||
If this variable is not specified, it is determined automatically by system
|
||||
introspection.
|
||||
If this variable is not specified, it is determined by the value of
|
||||
``CMAKE_OBJDUMP`` if set, else by system introspection.
|
||||
|
||||
Writing
|
||||
^^^^^^^
|
||||
|
||||
@@ -553,6 +553,71 @@ void cmLocalGenerator::GenerateInstallRules()
|
||||
/* clang-format on */
|
||||
}
|
||||
|
||||
// Write out CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM so that
|
||||
// installed code that uses `file(GET_RUNTIME_DEPENDENCIES)`
|
||||
// has same platform variable as when running cmake
|
||||
if (const char* platform = this->Makefile->GetDefinition(
|
||||
"CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM")) {
|
||||
/* clang-format off */
|
||||
fout <<
|
||||
"# Set default install directory permissions.\n"
|
||||
"if(NOT DEFINED CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM)\n"
|
||||
" set(CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM \""
|
||||
<< platform << "\")\n"
|
||||
"endif()\n"
|
||||
"\n";
|
||||
/* clang-format on */
|
||||
}
|
||||
|
||||
// Write out CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL so that
|
||||
// installed code that uses `file(GET_RUNTIME_DEPENDENCIES)`
|
||||
// has same tool selected as when running cmake
|
||||
if (const char* command =
|
||||
this->Makefile->GetDefinition("CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL")) {
|
||||
/* clang-format off */
|
||||
fout <<
|
||||
"# Set default install directory permissions.\n"
|
||||
"if(NOT DEFINED CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL)\n"
|
||||
" set(CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL \""
|
||||
<< command << "\")\n"
|
||||
"endif()\n"
|
||||
"\n";
|
||||
/* clang-format on */
|
||||
}
|
||||
|
||||
// Write out CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND so that
|
||||
// installed code that uses `file(GET_RUNTIME_DEPENDENCIES)`
|
||||
// has same path to the tool as when running cmake
|
||||
if (const char* command = this->Makefile->GetDefinition(
|
||||
"CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND")) {
|
||||
/* clang-format off */
|
||||
fout <<
|
||||
"# Set default install directory permissions.\n"
|
||||
"if(NOT DEFINED CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND)\n"
|
||||
" set(CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND \""
|
||||
<< command << "\")\n"
|
||||
"endif()\n"
|
||||
"\n";
|
||||
/* clang-format on */
|
||||
}
|
||||
|
||||
// Write out CMAKE_OBJDUMP so that installed code that uses
|
||||
// `file(GET_RUNTIME_DEPENDENCIES)` and hasn't specified
|
||||
// CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND has consistent
|
||||
// logic to fallback to CMAKE_OBJDUMP when `objdump` is
|
||||
// not on the path
|
||||
if (const char* command = this->Makefile->GetDefinition("CMAKE_OBJDUMP")) {
|
||||
/* clang-format off */
|
||||
fout <<
|
||||
"# Set default install directory permissions.\n"
|
||||
"if(NOT DEFINED CMAKE_OBJDUMP)\n"
|
||||
" set(CMAKE_OBJDUMP \""
|
||||
<< command << "\")\n"
|
||||
"endif()\n"
|
||||
"\n";
|
||||
/* clang-format on */
|
||||
}
|
||||
|
||||
// Ask each install generator to write its code.
|
||||
cmPolicies::PolicyStatus status = this->GetPolicyStatus(cmPolicies::CMP0082);
|
||||
auto const& installers = this->Makefile->GetInstallGenerators();
|
||||
|
||||
@@ -218,6 +218,9 @@ bool cmRuntimeDependencyArchive::GetGetRuntimeDependenciesCommand(
|
||||
// First see if it was supplied by the user
|
||||
std::string toolCommand = this->GetMakefile()->GetSafeDefinition(
|
||||
"CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND");
|
||||
if (toolCommand.empty() && search == "objdump") {
|
||||
toolCommand = this->GetMakefile()->GetSafeDefinition("CMAKE_OBJDUMP");
|
||||
}
|
||||
if (!toolCommand.empty()) {
|
||||
cmExpandList(toolCommand, command);
|
||||
return true;
|
||||
|
||||
@@ -188,6 +188,7 @@ else()
|
||||
endif()
|
||||
|
||||
set(run_install_test_components 1)
|
||||
run_install_test(file-GET_RUNTIME_DEPENDENCIES-variable-propagation)
|
||||
run_install_test(FILES-EXCLUDE_FROM_ALL)
|
||||
run_install_test(TARGETS-EXCLUDE_FROM_ALL)
|
||||
run_install_test(TARGETS-NAMELINK_COMPONENT)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,6 @@
|
||||
^CMake Error at cmake_install\.cmake:[0-9]+ \(message\):
|
||||
.*
|
||||
.*CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM: custom-platform.*
|
||||
.*CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL: custom-platform-objdump.*
|
||||
.*CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND: path/to/custom-objdump.*
|
||||
.*CMAKE_OBJDUMP: custom-objdump.*
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,6 @@
|
||||
^CMake Error at cmake_install\.cmake:[0-9]+ \(message\):
|
||||
.*
|
||||
.*CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM: custom-platform.*
|
||||
.*CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL: custom-platform-objdump.*
|
||||
.*CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND: path/to/custom-objdump.*
|
||||
.*CMAKE_OBJDUMP: custom-objdump.*
|
||||
@@ -0,0 +1,17 @@
|
||||
enable_language(C)
|
||||
|
||||
set(CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM "custom-platform")
|
||||
set(CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL "custom-platform-objdump")
|
||||
set(CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND "path/to/custom-objdump")
|
||||
set(CMAKE_OBJDUMP "custom-objdump")
|
||||
|
||||
install(CODE [[
|
||||
message(FATAL_ERROR "
|
||||
CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM: ${CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM}
|
||||
CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL: ${CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL}
|
||||
CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND: ${CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND}
|
||||
CMAKE_OBJDUMP: ${CMAKE_OBJDUMP}
|
||||
")
|
||||
]]
|
||||
COMPONENT dev
|
||||
)
|
||||
Reference in New Issue
Block a user