summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-01-14 18:00:10 (GMT)
committerKitware Robot <kwrobot@kitware.com>2021-01-14 18:00:16 (GMT)
commit967d1f7dde05769056a6431b7686939ccaa6d86a (patch)
tree30bdc80fd13c2844c2a1b9fc63966d8ebbb706cf
parent7bdef757ab318a928d90cdc99350666cdaf9bfca (diff)
parentac3ccc393e359063f498a33696c1785672a28d40 (diff)
downloadCMake-967d1f7dde05769056a6431b7686939ccaa6d86a.zip
CMake-967d1f7dde05769056a6431b7686939ccaa6d86a.tar.gz
CMake-967d1f7dde05769056a6431b7686939ccaa6d86a.tar.bz2
Merge topic 'install-FILES-rename-genex'
ac3ccc393e install(files): Support genex in rename option Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5694
-rw-r--r--Help/command/install.rst5
-rw-r--r--Help/release/dev/install-files-rename-genex.rst5
-rw-r--r--Source/cmInstallFilesGenerator.cxx14
-rw-r--r--Source/cmInstallFilesGenerator.h1
-rw-r--r--Tests/RunCMake/install/FILES-RENAME-all-check.cmake1
-rw-r--r--Tests/RunCMake/install/FILES-RENAME-bad-result.txt1
-rw-r--r--Tests/RunCMake/install/FILES-RENAME-bad-stderr.txt6
-rw-r--r--Tests/RunCMake/install/FILES-RENAME-bad.cmake4
-rw-r--r--Tests/RunCMake/install/FILES-RENAME.cmake4
-rw-r--r--Tests/RunCMake/install/RunCMakeTest.cmake5
10 files changed, 44 insertions, 2 deletions
diff --git a/Help/command/install.rst b/Help/command/install.rst
index bd8da39..35207f4 100644
--- a/Help/command/install.rst
+++ b/Help/command/install.rst
@@ -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
^^^^^^^^^^^^^^^^^^^^^^
diff --git a/Help/release/dev/install-files-rename-genex.rst b/Help/release/dev/install-files-rename-genex.rst
new file mode 100644
index 0000000..f735e24
--- /dev/null
+++ b/Help/release/dev/install-files-rename-genex.rst
@@ -0,0 +1,5 @@
+install-files-rename-genex
+--------------------------
+
+* The :command:`install(FILES)` command ``RENAME`` option learned to
+ support :manual:`generator expressions <cmake-generator-expressions(7)>`.
diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx
index c45000d..0a353e4 100644
--- a/Source/cmInstallFilesGenerator.cxx
+++ b/Source/cmInstallFilesGenerator.cxx
@@ -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,
diff --git a/Source/cmInstallFilesGenerator.h b/Source/cmInstallFilesGenerator.h
index b5a1ef4..66145f4 100644
--- a/Source/cmInstallFilesGenerator.h
+++ b/Source/cmInstallFilesGenerator.h
@@ -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;
diff --git a/Tests/RunCMake/install/FILES-RENAME-all-check.cmake b/Tests/RunCMake/install/FILES-RENAME-all-check.cmake
new file mode 100644
index 0000000..7e9b103
--- /dev/null
+++ b/Tests/RunCMake/install/FILES-RENAME-all-check.cmake
@@ -0,0 +1 @@
+check_installed([[^src;src/script_Debug\.ps]])
diff --git a/Tests/RunCMake/install/FILES-RENAME-bad-result.txt b/Tests/RunCMake/install/FILES-RENAME-bad-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/install/FILES-RENAME-bad-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/install/FILES-RENAME-bad-stderr.txt b/Tests/RunCMake/install/FILES-RENAME-bad-stderr.txt
new file mode 100644
index 0000000..9844158
--- /dev/null
+++ b/Tests/RunCMake/install/FILES-RENAME-bad-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error:
+ Error evaluating generator expression:
+
+ \$<NOTAGENEX>
+
+ Expression did not evaluate to a known generator expression
diff --git a/Tests/RunCMake/install/FILES-RENAME-bad.cmake b/Tests/RunCMake/install/FILES-RENAME-bad.cmake
new file mode 100644
index 0000000..5be0bb2
--- /dev/null
+++ b/Tests/RunCMake/install/FILES-RENAME-bad.cmake
@@ -0,0 +1,4 @@
+install(FILES empty.c
+ DESTINATION mybin
+ RENAME $<NOTAGENEX>
+ )
diff --git a/Tests/RunCMake/install/FILES-RENAME.cmake b/Tests/RunCMake/install/FILES-RENAME.cmake
new file mode 100644
index 0000000..5896e64
--- /dev/null
+++ b/Tests/RunCMake/install/FILES-RENAME.cmake
@@ -0,0 +1,4 @@
+install(FILES script.bat
+ DESTINATION src
+ RENAME script_$<CONFIG>.ps
+ )
diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake
index d64d88b..b067b3a 100644
--- a/Tests/RunCMake/install/RunCMakeTest.cmake
+++ b/Tests/RunCMake/install/RunCMakeTest.cmake
@@ -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()