Merge topic 'install-files-dest-genex'

69ab5f55 Tests: Cover install(FILES) with a genex DESTINATION
17aa6fd3 install: Allow generator expressions in FILES DESTINATION
This commit is contained in:
Brad King 2015-09-24 10:28:54 -04:00 committed by CMake Topic Stage
commit cbfae8c3f2
11 changed files with 50 additions and 11 deletions

View File

@ -192,6 +192,10 @@ The list of ``files...`` given to ``FILES`` or ``PROGRAMS`` may use
However, if any item begins in a generator expression it must evaluate
to a full path.
The install destination given to the files install ``DESTINATION`` may
use "generator expressions" with the syntax ``$<...>``. See the
:manual:`cmake-generator-expressions(7)` manual for available expressions.
Installing Directories
^^^^^^^^^^^^^^^^^^^^^^

View File

@ -0,0 +1,5 @@
install-files-dest-genex
------------------------
* The :command:`install(FILES)` command ``DESTINATION`` option learned to
support :manual:`generator expressions <cmake-generator-expressions(7)>`.

View File

@ -34,6 +34,12 @@ cmInstallFilesGenerator
Programs(programs),
Optional(optional)
{
// We need per-config actions if the destination has generator expressions.
if(cmGeneratorExpression::Find(Destination) != std::string::npos)
{
this->ActionsPerConfig = true;
}
// We need per-config actions if any files have generator expressions.
for(std::vector<std::string>::const_iterator i = files.begin();
!this->ActionsPerConfig && i != files.end(); ++i)
@ -56,15 +62,26 @@ void cmInstallFilesGenerator::Compute(cmLocalGenerator* lg)
this->LocalGenerator = lg;
}
//----------------------------------------------------------------------------
std::string
cmInstallFilesGenerator::GetDestination(std::string const& config) const
{
cmGeneratorExpression ge;
return ge.Parse(this->Destination)
->Evaluate(this->LocalGenerator->GetMakefile(), config);
}
//----------------------------------------------------------------------------
void cmInstallFilesGenerator::AddFilesInstallRule(
std::ostream& os, Indent const& indent,
std::ostream& os,
const std::string config,
Indent const& indent,
std::vector<std::string> const& files)
{
// Write code to install the files.
const char* no_dir_permissions = 0;
this->AddInstallRule(os,
this->Destination,
this->GetDestination(config),
(this->Programs
? cmInstallType_PROGRAMS
: cmInstallType_FILES),
@ -84,7 +101,7 @@ void cmInstallFilesGenerator::GenerateScriptActions(std::ostream& os,
}
else
{
this->AddFilesInstallRule(os, indent, this->Files);
this->AddFilesInstallRule(os, "", indent, this->Files);
}
}
@ -102,5 +119,5 @@ void cmInstallFilesGenerator::GenerateScriptForConfig(std::ostream& os,
cmSystemTools::ExpandListArgument(cge->Evaluate(
this->LocalGenerator->GetMakefile(), config), files);
}
this->AddFilesInstallRule(os, indent, files);
this->AddFilesInstallRule(os, config, indent, files);
}

View File

@ -32,12 +32,16 @@ public:
void Compute(cmLocalGenerator* lg);
std::string GetDestination(std::string const& config) const;
protected:
virtual void GenerateScriptActions(std::ostream& os, Indent const& indent);
virtual void GenerateScriptForConfig(std::ostream& os,
const std::string& config,
Indent const& indent);
void AddFilesInstallRule(std::ostream& os, Indent const& indent,
void AddFilesInstallRule(std::ostream& os,
const std::string config,
Indent const& indent,
std::vector<std::string> const& files);
cmLocalGenerator* LocalGenerator;

View File

@ -29,14 +29,14 @@ add_custom_command(TARGET testLib1 POST_BUILD
$<TARGET_FILE:testLib1>.genex
)
install(FILES $<TARGET_FILE:testLib1>.genex
DESTINATION lib
DESTINATION $<1:lib>$<0:/wrong>
)
set_property(TARGET testLib1 PROPERTY MY_FILES
${CMAKE_CURRENT_SOURCE_DIR}/testLib1file1.txt
${CMAKE_CURRENT_SOURCE_DIR}/testLib1file2.txt
)
install(FILES $<TARGET_PROPERTY:testLib1,MY_FILES>
DESTINATION doc
DESTINATION $<1:doc>$<0:/wrong>
)
# Test library with empty link interface. Link it to an implementation

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,6 @@
CMake Error:
Error evaluating generator expression:
\$<NOTAGENEX>
Expression did not evaluate to a known generator expression

View File

@ -0,0 +1 @@
install(FILES empty.c DESTINATION $<NOTAGENEX>)

View File

@ -6,6 +6,7 @@ run_cmake(DIRECTORY-message-lazy)
run_cmake(SkipInstallRulesWarning)
run_cmake(SkipInstallRulesNoWarning1)
run_cmake(SkipInstallRulesNoWarning2)
run_cmake(FILES-DESTINATION-bad)
run_cmake(TARGETS-DESTINATION-bad)
run_cmake(CMP0062-OLD)
run_cmake(CMP0062-NEW)

View File

@ -209,9 +209,9 @@ else()
ARCHIVE DESTINATION MyTest/lib/static
OPTIONAL # for coverage...target should always exist
)
install(FILES lib1.h DESTINATION MyTest/include/foo)
install(FILES lib1.h DESTINATION MyTest/include/$<1:foo>$<0:/wrong>)
install(FILES lib2.h
DESTINATION MyTest/include/foo
DESTINATION $<1:MyTest/include/foo>$<0:/wrong>
COMPONENT Development
PERMISSIONS OWNER_READ OWNER_WRITE
RENAME lib2renamed.h

View File

@ -209,9 +209,9 @@ else()
ARCHIVE DESTINATION MyTest/lib/static
OPTIONAL # for coverage...target should always exist
)
install(FILES lib1.h DESTINATION MyTest/include/foo)
install(FILES lib1.h DESTINATION MyTest/include/$<1:foo>$<0:/wrong>)
install(FILES lib2.h
DESTINATION MyTest/include/foo
DESTINATION $<1:MyTest/include/foo>$<0:/wrong>
COMPONENT Development
PERMISSIONS OWNER_READ OWNER_WRITE
RENAME lib2renamed.h