diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2020-03-27 13:03:44 (GMT) |
---|---|---|
committer | Robert Maynard <robert.maynard@kitware.com> | 2020-04-06 16:12:14 (GMT) |
commit | f867423aa214e3145fe4e6775eb9634c340df02b (patch) | |
tree | 86ec75c2752ddcf02c12d36b6aef23271b6d3ab5 /Source | |
parent | 888b8a43d82e6f6157642c2bd84520920d8e2d11 (diff) | |
download | CMake-f867423aa214e3145fe4e6775eb9634c340df02b.zip CMake-f867423aa214e3145fe4e6775eb9634c340df02b.tar.gz CMake-f867423aa214e3145fe4e6775eb9634c340df02b.tar.bz2 |
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
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmLocalGenerator.cxx | 65 | ||||
-rw-r--r-- | Source/cmRuntimeDependencyArchive.cxx | 3 |
2 files changed, 68 insertions, 0 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 8484c58..e32a126 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -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(); 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; |