Merge topic 'remove-INTERFACE-build-targets'

97fae68 Remove INTERFACE build targets.
This commit is contained in:
Brad King 2013-12-19 10:12:57 -05:00 committed by CMake Topic Stage
commit d42e0d552c
12 changed files with 67 additions and 121 deletions

View File

@ -199,6 +199,10 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
{ {
// Get the depender. // Get the depender.
cmTarget* depender = this->Targets[depender_index]; cmTarget* depender = this->Targets[depender_index];
if (depender->GetType() == cmTarget::INTERFACE_LIBRARY)
{
return;
}
// Loop over all targets linked directly in all configs. // Loop over all targets linked directly in all configs.
// We need to make targets depend on the union of all config-specific // We need to make targets depend on the union of all config-specific
@ -208,15 +212,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
std::set<cmStdString> emitted; std::set<cmStdString> emitted;
{ {
std::vector<std::string> tlibs; std::vector<std::string> tlibs;
if (depender->GetType() == cmTarget::INTERFACE_LIBRARY)
{
// For INTERFACE_LIBRARY depend on the interface instead.
depender->GetInterfaceLinkLibraries(0, tlibs, depender);
}
else
{
depender->GetDirectLinkLibraries(0, tlibs, depender); depender->GetDirectLinkLibraries(0, tlibs, depender);
}
// A target should not depend on itself. // A target should not depend on itself.
emitted.insert(depender->GetName()); emitted.insert(depender->GetName());
for(std::vector<std::string>::const_iterator lib = tlibs.begin(); for(std::vector<std::string>::const_iterator lib = tlibs.begin();
@ -237,15 +233,8 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
it != configs.end(); ++it) it != configs.end(); ++it)
{ {
std::vector<std::string> tlibs; std::vector<std::string> tlibs;
if (depender->GetType() == cmTarget::INTERFACE_LIBRARY)
{
// For INTERFACE_LIBRARY depend on the interface instead.
depender->GetInterfaceLinkLibraries(it->c_str(), tlibs, depender);
}
else
{
depender->GetDirectLinkLibraries(it->c_str(), tlibs, depender); depender->GetDirectLinkLibraries(it->c_str(), tlibs, depender);
}
// A target should not depend on itself. // A target should not depend on itself.
emitted.insert(depender->GetName()); emitted.insert(depender->GetName());
for(std::vector<std::string>::const_iterator lib = tlibs.begin(); for(std::vector<std::string>::const_iterator lib = tlibs.begin();

View File

@ -480,7 +480,6 @@ cmGlobalUnixMakefileGenerator3
(l->second->GetType() == cmTarget::SHARED_LIBRARY) || (l->second->GetType() == cmTarget::SHARED_LIBRARY) ||
(l->second->GetType() == cmTarget::MODULE_LIBRARY) || (l->second->GetType() == cmTarget::MODULE_LIBRARY) ||
(l->second->GetType() == cmTarget::OBJECT_LIBRARY) || (l->second->GetType() == cmTarget::OBJECT_LIBRARY) ||
(l->second->GetType() == cmTarget::INTERFACE_LIBRARY) ||
(l->second->GetType() == cmTarget::UTILITY)) (l->second->GetType() == cmTarget::UTILITY))
{ {
if(l->second->Target->IsImported()) if(l->second->Target->IsImported())
@ -658,7 +657,6 @@ cmGlobalUnixMakefileGenerator3
(t->second->GetType() == cmTarget::SHARED_LIBRARY) || (t->second->GetType() == cmTarget::SHARED_LIBRARY) ||
(t->second->GetType() == cmTarget::MODULE_LIBRARY) || (t->second->GetType() == cmTarget::MODULE_LIBRARY) ||
(t->second->GetType() == cmTarget::OBJECT_LIBRARY) || (t->second->GetType() == cmTarget::OBJECT_LIBRARY) ||
(t->second->GetType() == cmTarget::INTERFACE_LIBRARY) ||
(t->second->GetType() == cmTarget::UTILITY))) (t->second->GetType() == cmTarget::UTILITY)))
{ {
// Add a rule to build the target by name. // Add a rule to build the target by name.
@ -680,10 +678,6 @@ cmGlobalUnixMakefileGenerator3
t->second->GetName(), depends, commands, t->second->GetName(), depends, commands,
true); true);
if (t->second->GetType() == cmTarget::INTERFACE_LIBRARY)
{
continue;
}
// Add a fast rule to build the target // Add a fast rule to build the target
std::string localName = std::string localName =
lg->GetRelativeTargetDirectory(*t->second->Target); lg->GetRelativeTargetDirectory(*t->second->Target);
@ -757,7 +751,6 @@ cmGlobalUnixMakefileGenerator3
|| (t->second->GetType() == cmTarget::SHARED_LIBRARY) || (t->second->GetType() == cmTarget::SHARED_LIBRARY)
|| (t->second->GetType() == cmTarget::MODULE_LIBRARY) || (t->second->GetType() == cmTarget::MODULE_LIBRARY)
|| (t->second->GetType() == cmTarget::OBJECT_LIBRARY) || (t->second->GetType() == cmTarget::OBJECT_LIBRARY)
|| (t->second->GetType() == cmTarget::INTERFACE_LIBRARY)
|| (t->second->GetType() == cmTarget::UTILITY))) || (t->second->GetType() == cmTarget::UTILITY)))
{ {
std::string makefileName; std::string makefileName;
@ -774,9 +767,6 @@ cmGlobalUnixMakefileGenerator3
<< localName << "\n\n"; << localName << "\n\n";
commands.clear(); commands.clear();
if(t->second->GetType() != cmTarget::INTERFACE_LIBRARY)
{
makeTargetName = localName; makeTargetName = localName;
makeTargetName += "/depend"; makeTargetName += "/depend";
commands.push_back(lg->GetRecursiveMakeCall commands.push_back(lg->GetRecursiveMakeCall
@ -822,16 +812,8 @@ cmGlobalUnixMakefileGenerator3
progressDir = "Built target "; progressDir = "Built target ";
progressDir += t->second->GetName(); progressDir += t->second->GetName();
lg->AppendEcho(commands,progressDir.c_str()); lg->AppendEcho(commands,progressDir.c_str());
}
else
{
depends.clear();
}
this->AppendGlobalTargetDepends(depends,*t->second->Target); this->AppendGlobalTargetDepends(depends,*t->second->Target);
if(depends.empty() && this->EmptyRuleHackDepends != "")
{
depends.push_back(this->EmptyRuleHackDepends);
}
lg->WriteMakeRule(ruleFileStream, "All Build rule for target.", lg->WriteMakeRule(ruleFileStream, "All Build rule for target.",
localName.c_str(), depends, commands, true); localName.c_str(), depends, commands, true);
@ -847,7 +829,7 @@ cmGlobalUnixMakefileGenerator3
// Write the rule. // Write the rule.
commands.clear(); commands.clear();
std::string progressDir = lg->GetMakefile()->GetHomeOutputDirectory(); progressDir = lg->GetMakefile()->GetHomeOutputDirectory();
progressDir += cmake::GetCMakeFilesDirectory(); progressDir += cmake::GetCMakeFilesDirectory();
{ {

View File

@ -388,7 +388,6 @@ void cmLocalUnixMakefileGenerator3
(t->second->GetType() == cmTarget::SHARED_LIBRARY) || (t->second->GetType() == cmTarget::SHARED_LIBRARY) ||
(t->second->GetType() == cmTarget::MODULE_LIBRARY) || (t->second->GetType() == cmTarget::MODULE_LIBRARY) ||
(t->second->GetType() == cmTarget::OBJECT_LIBRARY) || (t->second->GetType() == cmTarget::OBJECT_LIBRARY) ||
(t->second->GetType() == cmTarget::INTERFACE_LIBRARY) ||
(t->second->GetType() == cmTarget::UTILITY)) (t->second->GetType() == cmTarget::UTILITY))
{ {
if (t->second->Target->IsImported()) if (t->second->Target->IsImported())

View File

@ -85,9 +85,6 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles()
case cmTarget::OBJECT_LIBRARY: case cmTarget::OBJECT_LIBRARY:
this->WriteObjectLibraryRules(); this->WriteObjectLibraryRules();
break; break;
case cmTarget::INTERFACE_LIBRARY:
// Nothing to do.
break;
default: default:
// If language is not known, this is an error. // If language is not known, this is an error.
cmSystemTools::Error("Unknown Library Type"); cmSystemTools::Error("Unknown Library Type");

View File

@ -76,7 +76,6 @@ cmMakefileTargetGenerator::New(cmGeneratorTarget *tgt)
case cmTarget::SHARED_LIBRARY: case cmTarget::SHARED_LIBRARY:
case cmTarget::MODULE_LIBRARY: case cmTarget::MODULE_LIBRARY:
case cmTarget::OBJECT_LIBRARY: case cmTarget::OBJECT_LIBRARY:
case cmTarget::INTERFACE_LIBRARY:
result = new cmMakefileLibraryTargetGenerator(tgt); result = new cmMakefileLibraryTargetGenerator(tgt);
break; break;
case cmTarget::UTILITY: case cmTarget::UTILITY:

View File

@ -285,24 +285,6 @@ if(BUILD_TESTING)
PASS_REGULAR_EXPRESSION "(file is not of required architecture|does not match cputype|not the architecture being linked)") PASS_REGULAR_EXPRESSION "(file is not of required architecture|does not match cputype|not the architecture being linked)")
endif() endif()
if(CMAKE_TEST_GENERATOR MATCHES Make)
set(InterfaceBuildTargets_libname testlib)
if (CMAKE_TEST_GENERATOR MATCHES "Borland|Watcom")
set(InterfaceBuildTargets_libname testlib.lib)
endif()
add_test(InterfaceBuildTargets ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/InterfaceBuildTargets"
"${CMake_BINARY_DIR}/Tests/InterfaceBuildTargets"
--build-two-config
${build_generator_args}
--build-project InterfaceBuildTargets
--build-options ${build_options}
--test-command ${CMAKE_CMAKE_COMMAND} -E touch_nocreate ${InterfaceBuildTargets_libname}
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/InterfaceBuildTargets")
endif()
list(APPEND TEST_BUILD_DIRS ${CMake_TEST_INSTALL_PREFIX}) list(APPEND TEST_BUILD_DIRS ${CMake_TEST_INSTALL_PREFIX})
if(NOT QT4_FOUND) if(NOT QT4_FOUND)

View File

@ -1,13 +0,0 @@
project(InterfaceBuildTargets)
add_library(testlib EXCLUDE_FROM_ALL testlib.cxx)
set_property(TARGET testlib PROPERTY PREFIX "")
if(CMAKE_GENERATOR MATCHES "Borland|Watcom")
# These librarians add the .lib suffix anyway.
set_property(TARGET testlib PROPERTY SUFFIX ".lib")
else()
set_property(TARGET testlib PROPERTY SUFFIX "")
endif()
add_library(iface INTERFACE)
target_link_libraries(iface INTERFACE testlib)

View File

@ -1,5 +0,0 @@
int main(int, char**)
{
return 0;
}

View File

@ -1,5 +0,0 @@
void testlib(void)
{
}

View File

@ -13,3 +13,17 @@ add_subdirectory(libsdir)
add_executable(sharedlibtestexe sharedlibtestexe.cpp) add_executable(sharedlibtestexe sharedlibtestexe.cpp)
target_link_libraries(sharedlibtestexe shared_iface) target_link_libraries(sharedlibtestexe shared_iface)
add_library(broken EXCLUDE_FROM_ALL broken.cpp)
add_library(iface_broken INTERFACE)
# This is not a dependency, so broken will not be built (and the error in
# it will not be hit)
target_link_libraries(iface_broken INTERFACE broken)
add_library(iface_whitelist INTERFACE)
# The target property CUSTOM will never be evaluated on the INTERFACE library.
target_link_libraries(iface_whitelist INTERFACE $<$<BOOL:$<TARGET_PROPERTY:CUSTOM>>:irrelevant>)
add_executable(exec_whitelist dummy.cpp)
target_link_libraries(exec_whitelist iface_whitelist)

View File

@ -0,0 +1,2 @@
#error Broken

View File

@ -0,0 +1,5 @@
int main(int, char **)
{
return 0;
}