mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-04 12:49:36 -06:00
@@ -473,6 +473,11 @@ this advice while installing headers to a project-specific subdirectory:
|
|||||||
use "generator expressions" with the syntax ``$<...>``. See the
|
use "generator expressions" with the syntax ``$<...>``. See the
|
||||||
:manual:`cmake-generator-expressions(7)` manual for available expressions.
|
: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
|
Installing Directories
|
||||||
^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
|||||||
5
Help/release/dev/install-files-rename-genex.rst
Normal file
5
Help/release/dev/install-files-rename-genex.rst
Normal file
@@ -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)>`.
|
||||||
@@ -25,10 +25,14 @@ cmInstallFilesGenerator::cmInstallFilesGenerator(
|
|||||||
, Programs(programs)
|
, Programs(programs)
|
||||||
, Optional(optional)
|
, 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) {
|
if (cmGeneratorExpression::Find(this->Destination) != std::string::npos) {
|
||||||
this->ActionsPerConfig = true;
|
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.
|
// We need per-config actions if any directories have generator expressions.
|
||||||
if (!this->ActionsPerConfig) {
|
if (!this->ActionsPerConfig) {
|
||||||
@@ -56,6 +60,12 @@ std::string cmInstallFilesGenerator::GetDestination(
|
|||||||
this->LocalGenerator, config);
|
this->LocalGenerator, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string cmInstallFilesGenerator::GetRename(std::string const& config) const
|
||||||
|
{
|
||||||
|
return cmGeneratorExpression::Evaluate(this->Rename, this->LocalGenerator,
|
||||||
|
config);
|
||||||
|
}
|
||||||
|
|
||||||
void cmInstallFilesGenerator::AddFilesInstallRule(
|
void cmInstallFilesGenerator::AddFilesInstallRule(
|
||||||
std::ostream& os, std::string const& config, Indent indent,
|
std::ostream& os, std::string const& config, Indent indent,
|
||||||
std::vector<std::string> const& files)
|
std::vector<std::string> const& files)
|
||||||
@@ -66,7 +76,7 @@ void cmInstallFilesGenerator::AddFilesInstallRule(
|
|||||||
os, this->GetDestination(config),
|
os, this->GetDestination(config),
|
||||||
(this->Programs ? cmInstallType_PROGRAMS : cmInstallType_FILES), files,
|
(this->Programs ? cmInstallType_PROGRAMS : cmInstallType_FILES), files,
|
||||||
this->Optional, this->FilePermissions.c_str(), no_dir_permissions,
|
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,
|
void cmInstallFilesGenerator::GenerateScriptActions(std::ostream& os,
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ public:
|
|||||||
bool Compute(cmLocalGenerator* lg) override;
|
bool Compute(cmLocalGenerator* lg) override;
|
||||||
|
|
||||||
std::string GetDestination(std::string const& config) const;
|
std::string GetDestination(std::string const& config) const;
|
||||||
|
std::string GetRename(std::string const& config) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void GenerateScriptActions(std::ostream& os, Indent indent) override;
|
void GenerateScriptActions(std::ostream& os, Indent indent) override;
|
||||||
|
|||||||
1
Tests/RunCMake/install/FILES-RENAME-all-check.cmake
Normal file
1
Tests/RunCMake/install/FILES-RENAME-all-check.cmake
Normal file
@@ -0,0 +1 @@
|
|||||||
|
check_installed([[^src;src/script_Debug\.ps]])
|
||||||
1
Tests/RunCMake/install/FILES-RENAME-bad-result.txt
Normal file
1
Tests/RunCMake/install/FILES-RENAME-bad-result.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
1
|
||||||
6
Tests/RunCMake/install/FILES-RENAME-bad-stderr.txt
Normal file
6
Tests/RunCMake/install/FILES-RENAME-bad-stderr.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
CMake Error:
|
||||||
|
Error evaluating generator expression:
|
||||||
|
|
||||||
|
\$<NOTAGENEX>
|
||||||
|
|
||||||
|
Expression did not evaluate to a known generator expression
|
||||||
4
Tests/RunCMake/install/FILES-RENAME-bad.cmake
Normal file
4
Tests/RunCMake/install/FILES-RENAME-bad.cmake
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
install(FILES empty.c
|
||||||
|
DESTINATION mybin
|
||||||
|
RENAME $<NOTAGENEX>
|
||||||
|
)
|
||||||
4
Tests/RunCMake/install/FILES-RENAME.cmake
Normal file
4
Tests/RunCMake/install/FILES-RENAME.cmake
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
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-DIRECTORY-bad)
|
||||||
run_cmake(DIRECTORY-DESTINATION-bad)
|
run_cmake(DIRECTORY-DESTINATION-bad)
|
||||||
run_cmake(FILES-DESTINATION-bad)
|
run_cmake(FILES-DESTINATION-bad)
|
||||||
|
run_cmake(FILES-RENAME-bad)
|
||||||
run_cmake(TARGETS-DESTINATION-bad)
|
run_cmake(TARGETS-DESTINATION-bad)
|
||||||
run_cmake(EXPORT-OldIFace)
|
run_cmake(EXPORT-OldIFace)
|
||||||
run_cmake(EXPORT-UnknownExport)
|
run_cmake(EXPORT-UnknownExport)
|
||||||
@@ -91,6 +92,10 @@ run_cmake(TARGETS-NAMELINK_COMPONENT-bad-exc)
|
|||||||
run_cmake(FILES-DESTINATION-TYPE)
|
run_cmake(FILES-DESTINATION-TYPE)
|
||||||
run_cmake(DIRECTORY-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)
|
if(APPLE)
|
||||||
run_cmake(TARGETS-Apple-Defaults)
|
run_cmake(TARGETS-Apple-Defaults)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
Reference in New Issue
Block a user