Commit ac3ccc39 authored by Asit Dhal's avatar Asit Dhal
Browse files

install(files): Support genex in rename option

Fixes: #19903
parent 20a7d448
Pipeline #208880 passed with stages
in 56 minutes and 8 seconds
......@@ -473,6 +473,11 @@ this advice while installing headers to a project-specific subdirectory:
use "generator expressions" with the syntax ``$<...>``. See the
:manual:`cmake-generator-expressions(7)` manual for available expressions.
.. versionadded:: 3.20
An install rename given as a ``RENAME`` argument may
use "generator expressions" with the syntax ``$<...>``. See the
:manual:`cmake-generator-expressions(7)` manual for available expressions.
Installing Directories
^^^^^^^^^^^^^^^^^^^^^^
......
install-files-rename-genex
--------------------------
* The :command:`install(FILES)` command ``RENAME`` option learned to
support :manual:`generator expressions <cmake-generator-expressions(7)>`.
......@@ -25,10 +25,14 @@ cmInstallFilesGenerator::cmInstallFilesGenerator(
, Programs(programs)
, Optional(optional)
{
// We need per-config actions if the destination has generator expressions.
// We need per-config actions if the destination and rename have generator
// expressions.
if (cmGeneratorExpression::Find(this->Destination) != std::string::npos) {
this->ActionsPerConfig = true;
}
if (cmGeneratorExpression::Find(this->Rename) != std::string::npos) {
this->ActionsPerConfig = true;
}
// We need per-config actions if any directories have generator expressions.
if (!this->ActionsPerConfig) {
......@@ -56,6 +60,12 @@ std::string cmInstallFilesGenerator::GetDestination(
this->LocalGenerator, config);
}
std::string cmInstallFilesGenerator::GetRename(std::string const& config) const
{
return cmGeneratorExpression::Evaluate(this->Rename, this->LocalGenerator,
config);
}
void cmInstallFilesGenerator::AddFilesInstallRule(
std::ostream& os, std::string const& config, Indent indent,
std::vector<std::string> const& files)
......@@ -66,7 +76,7 @@ void cmInstallFilesGenerator::AddFilesInstallRule(
os, this->GetDestination(config),
(this->Programs ? cmInstallType_PROGRAMS : cmInstallType_FILES), files,
this->Optional, this->FilePermissions.c_str(), no_dir_permissions,
this->Rename.c_str(), nullptr, indent);
this->GetRename(config).c_str(), nullptr, indent);
}
void cmInstallFilesGenerator::GenerateScriptActions(std::ostream& os,
......
......@@ -31,6 +31,7 @@ public:
bool Compute(cmLocalGenerator* lg) override;
std::string GetDestination(std::string const& config) const;
std::string GetRename(std::string const& config) const;
protected:
void GenerateScriptActions(std::ostream& os, Indent indent) override;
......
check_installed([[^src;src/script_Debug\.ps]])
CMake Error:
Error evaluating generator expression:
\$<NOTAGENEX>
Expression did not evaluate to a known generator expression
install(FILES empty.c
DESTINATION mybin
RENAME $<NOTAGENEX>
)
install(FILES script.bat
DESTINATION src
RENAME script_$<CONFIG>.ps
)
......@@ -74,6 +74,7 @@ run_cmake(SkipInstallRulesNoWarning2)
run_cmake(DIRECTORY-DIRECTORY-bad)
run_cmake(DIRECTORY-DESTINATION-bad)
run_cmake(FILES-DESTINATION-bad)
run_cmake(FILES-RENAME-bad)
run_cmake(TARGETS-DESTINATION-bad)
run_cmake(EXPORT-OldIFace)
run_cmake(EXPORT-UnknownExport)
......@@ -91,6 +92,10 @@ run_cmake(TARGETS-NAMELINK_COMPONENT-bad-exc)
run_cmake(FILES-DESTINATION-TYPE)
run_cmake(DIRECTORY-DESTINATION-TYPE)
set(RunCMake_TEST_OPTIONS "-DCMAKE_BUILD_TYPE:STRING=Debug")
run_install_test(FILES-RENAME)
unset(RunCMake_TEST_OPTIONS)
if(APPLE)
run_cmake(TARGETS-Apple-Defaults)
endif()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment