summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalUnixMakefileGenerator3.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-08-21 20:00:48 (GMT)
committerBrad King <brad.king@kitware.com>2013-10-21 13:46:27 (GMT)
commitb04f3b9a2a116b1956d5342637cda1348a5ee07b (patch)
treeb7235edeb963d70d50711210172a7f3612711142 /Source/cmGlobalUnixMakefileGenerator3.cxx
parentdba4962b868c3baa7886dcd3f8b597e971a479a2 (diff)
downloadCMake-b04f3b9a2a116b1956d5342637cda1348a5ee07b.zip
CMake-b04f3b9a2a116b1956d5342637cda1348a5ee07b.tar.gz
CMake-b04f3b9a2a116b1956d5342637cda1348a5ee07b.tar.bz2
Create make rules for INTERFACE_LIBRARY targets.
The result is that the depends of the target are created. So, add_library(somelib foo.cpp) add_library(anotherlib EXCLUDE_FROM_ALL foo.cpp) add_library(extra EXCLUDE_FROM_ALL foo.cpp) target_link_libraries(anotherlib extra) add_library(iface INTERFACE) target_link_libraries(iface INTERFACE anotherlib) Executing 'make iface' will result in the anotherlib and extra targets being made. Adding a regular executable to the INTERFACE of an INTERFACE_LIBRARY will not result in the executable being built with 'make iface' because of the logic in cmComputeTargetDepends::AddTargetDepend. So far, this is implemented only for the Makefile generator. Other generators will follow if this feature is possible for them. Make INTERFACE_LIBRARY targets part of the all target by default. Test this by building the all target and making the expected library EXCLUDE_FROM_ALL.
Diffstat (limited to 'Source/cmGlobalUnixMakefileGenerator3.cxx')
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.cxx92
1 files changed, 55 insertions, 37 deletions
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index 7ab107f..ce95c08 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -435,6 +435,7 @@ cmGlobalUnixMakefileGenerator3
(l->second.GetType() == cmTarget::SHARED_LIBRARY) ||
(l->second.GetType() == cmTarget::MODULE_LIBRARY) ||
(l->second.GetType() == cmTarget::OBJECT_LIBRARY) ||
+ (l->second.GetType() == cmTarget::INTERFACE_LIBRARY) ||
(l->second.GetType() == cmTarget::UTILITY))
{
// Add this to the list of depends rules in this directory.
@@ -612,6 +613,7 @@ cmGlobalUnixMakefileGenerator3
(t->second.GetType() == cmTarget::SHARED_LIBRARY) ||
(t->second.GetType() == cmTarget::MODULE_LIBRARY) ||
(t->second.GetType() == cmTarget::OBJECT_LIBRARY) ||
+ (t->second.GetType() == cmTarget::INTERFACE_LIBRARY) ||
(t->second.GetType() == cmTarget::UTILITY)))
{
// Add a rule to build the target by name.
@@ -633,6 +635,10 @@ cmGlobalUnixMakefileGenerator3
t->second.GetName(), depends, commands,
true);
+ if (t->second.GetType() == cmTarget::INTERFACE_LIBRARY)
+ {
+ continue;
+ }
// Add a fast rule to build the target
std::string localName = lg->GetRelativeTargetDirectory(t->second);
std::string makefileName;
@@ -699,6 +705,7 @@ cmGlobalUnixMakefileGenerator3
|| (t->second.GetType() == cmTarget::SHARED_LIBRARY)
|| (t->second.GetType() == cmTarget::MODULE_LIBRARY)
|| (t->second.GetType() == cmTarget::OBJECT_LIBRARY)
+ || (t->second.GetType() == cmTarget::INTERFACE_LIBRARY)
|| (t->second.GetType() == cmTarget::UTILITY)))
{
std::string makefileName;
@@ -715,53 +722,64 @@ cmGlobalUnixMakefileGenerator3
<< localName << "\n\n";
commands.clear();
- makeTargetName = localName;
- makeTargetName += "/depend";
- commands.push_back(lg->GetRecursiveMakeCall
- (makefileName.c_str(),makeTargetName.c_str()));
- // add requires if we need it for this generator
- if (needRequiresStep)
+ if(t->second.GetType() != cmTarget::INTERFACE_LIBRARY)
{
makeTargetName = localName;
- makeTargetName += "/requires";
+ makeTargetName += "/depend";
commands.push_back(lg->GetRecursiveMakeCall
- (makefileName.c_str(),makeTargetName.c_str()));
- }
- makeTargetName = localName;
- makeTargetName += "/build";
- commands.push_back(lg->GetRecursiveMakeCall
(makefileName.c_str(),makeTargetName.c_str()));
- // Write the rule.
- localName += "/all";
- depends.clear();
+ // add requires if we need it for this generator
+ if (needRequiresStep)
+ {
+ makeTargetName = localName;
+ makeTargetName += "/requires";
+ commands.push_back(lg->GetRecursiveMakeCall
+ (makefileName.c_str(),makeTargetName.c_str()));
+ }
+ makeTargetName = localName;
+ makeTargetName += "/build";
+ commands.push_back(lg->GetRecursiveMakeCall
+ (makefileName.c_str(),makeTargetName.c_str()));
- std::string progressDir =
- lg->GetMakefile()->GetHomeOutputDirectory();
- progressDir += cmake::GetCMakeFilesDirectory();
- {
- cmOStringStream progCmd;
- progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report ";
- // all target counts
- progCmd << lg->Convert(progressDir.c_str(),
- cmLocalGenerator::FULL,
- cmLocalGenerator::SHELL);
- progCmd << " ";
- std::vector<unsigned long>& progFiles =
- this->ProgressMap[&t->second].Marks;
- for (std::vector<unsigned long>::iterator i = progFiles.begin();
- i != progFiles.end(); ++i)
+ // Write the rule.
+ localName += "/all";
+ depends.clear();
+
+ std::string progressDir =
+ lg->GetMakefile()->GetHomeOutputDirectory();
+ progressDir += cmake::GetCMakeFilesDirectory();
{
- progCmd << " " << *i;
+ cmOStringStream progCmd;
+ progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report ";
+ // all target counts
+ progCmd << lg->Convert(progressDir.c_str(),
+ cmLocalGenerator::FULL,
+ cmLocalGenerator::SHELL);
+ progCmd << " ";
+ std::vector<unsigned long>& progFiles =
+ this->ProgressMap[&t->second].Marks;
+ for (std::vector<unsigned long>::iterator i = progFiles.begin();
+ i != progFiles.end(); ++i)
+ {
+ progCmd << " " << *i;
+ }
+ commands.push_back(progCmd.str());
}
- commands.push_back(progCmd.str());
+ progressDir = "Built target ";
+ progressDir += t->first;
+ lg->AppendEcho(commands,progressDir.c_str());
+ }
+ else
+ {
+ depends.clear();
}
- progressDir = "Built target ";
- progressDir += t->first;
- lg->AppendEcho(commands,progressDir.c_str());
-
this->AppendGlobalTargetDepends(depends,t->second);
+ if(depends.empty() && this->EmptyRuleHackDepends != "")
+ {
+ depends.push_back(this->EmptyRuleHackDepends);
+ }
lg->WriteMakeRule(ruleFileStream, "All Build rule for target.",
localName.c_str(), depends, commands, true);
@@ -777,7 +795,7 @@ cmGlobalUnixMakefileGenerator3
// Write the rule.
commands.clear();
- progressDir = lg->GetMakefile()->GetHomeOutputDirectory();
+ std::string progressDir = lg->GetMakefile()->GetHomeOutputDirectory();
progressDir += cmake::GetCMakeFilesDirectory();
{