summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/command/file.rst4
-rw-r--r--Source/cmLocalGenerator.cxx65
-rw-r--r--Source/cmRuntimeDependencyArchive.cxx3
-rw-r--r--Tests/RunCMake/install/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-all-result.txt1
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-all-stderr.txt6
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-dev-result.txt1
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-dev-stderr.txt6
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-variable-propagation.cmake17
9 files changed, 102 insertions, 2 deletions
diff --git a/Help/command/file.rst b/Help/command/file.rst
index 92cb2ed..6105219 100644
--- a/Help/command/file.rst
+++ b/Help/command/file.rst
@@ -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
^^^^^^^
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 0fe0c40..a49a7f8 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -557,6 +557,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();
diff --git a/Source/cmRuntimeDependencyArchive.cxx b/Source/cmRuntimeDependencyArchive.cxx
index 34b3105..0781d29 100644
--- a/Source/cmRuntimeDependencyArchive.cxx
+++ b/Source/cmRuntimeDependencyArchive.cxx
@@ -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;
diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake
index 70570b7..bd0bbe3 100644
--- a/Tests/RunCMake/install/RunCMakeTest.cmake
+++ b/Tests/RunCMake/install/RunCMakeTest.cmake
@@ -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)
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-all-result.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-all-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-all-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-all-stderr.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-all-stderr.txt
new file mode 100644
index 0000000..591a5e7
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-all-stderr.txt
@@ -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.*
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-dev-result.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-dev-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-dev-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-dev-stderr.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-dev-stderr.txt
new file mode 100644
index 0000000..591a5e7
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-dev-stderr.txt
@@ -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.*
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-variable-propagation.cmake b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-variable-propagation.cmake
new file mode 100644
index 0000000..07bbc5e
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-variable-propagation.cmake
@@ -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
+)