install: Teach EXPORT option to handle INTERFACE_LIBRARY targets
This commit is contained in:
parent
435c912848
commit
ce0c303d62
|
@ -114,6 +114,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
|
|||
std::vector<std::string> missingTargets;
|
||||
|
||||
bool require2_8_12 = false;
|
||||
bool require2_8_13 = false;
|
||||
// Create all the imported targets.
|
||||
for(std::vector<cmTargetExport*>::const_iterator
|
||||
tei = allTargets.begin();
|
||||
|
@ -153,6 +154,10 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
|
|||
require2_8_12 = true;
|
||||
}
|
||||
}
|
||||
if (te->GetType() == cmTarget::INTERFACE_LIBRARY)
|
||||
{
|
||||
require2_8_13 = true;
|
||||
}
|
||||
this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE",
|
||||
te, properties);
|
||||
this->PopulateCompatibleInterfaceProperties(te, properties);
|
||||
|
@ -160,7 +165,11 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
|
|||
this->GenerateInterfaceProperties(te, os, properties);
|
||||
}
|
||||
|
||||
if (require2_8_12)
|
||||
if (require2_8_13)
|
||||
{
|
||||
this->GenerateRequiredCMakeVersion(os, "2.8.12.20131007");
|
||||
}
|
||||
else if (require2_8_12)
|
||||
{
|
||||
this->GenerateRequiredCMakeVersion(os, "2.8.12");
|
||||
}
|
||||
|
@ -286,6 +295,14 @@ cmExportInstallFileGenerator
|
|||
cmTargetExport const* te = *tei;
|
||||
ImportPropertyMap properties;
|
||||
std::set<std::string> importedLocations;
|
||||
if (!properties.empty()
|
||||
&& te->Target->GetType() == cmTarget::INTERFACE_LIBRARY)
|
||||
{
|
||||
this->GenerateImportPropertyCode(os, config, te->Target, properties);
|
||||
this->GenerateImportedFileChecksCode(os, te->Target, properties,
|
||||
importedLocations);
|
||||
continue;
|
||||
}
|
||||
this->SetImportLocationProperty(config, suffix, te->ArchiveGenerator,
|
||||
properties, importedLocations);
|
||||
this->SetImportLocationProperty(config, suffix, te->LibraryGenerator,
|
||||
|
|
|
@ -379,7 +379,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
|
|||
target->GetType() != cmTarget::STATIC_LIBRARY &&
|
||||
target->GetType() != cmTarget::SHARED_LIBRARY &&
|
||||
target->GetType() != cmTarget::MODULE_LIBRARY &&
|
||||
target->GetType() != cmTarget::OBJECT_LIBRARY)
|
||||
target->GetType() != cmTarget::OBJECT_LIBRARY &&
|
||||
target->GetType() != cmTarget::INTERFACE_LIBRARY)
|
||||
{
|
||||
cmOStringStream e;
|
||||
e << "TARGETS given target \"" << (*targetIt)
|
||||
|
@ -626,6 +627,11 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
|
|||
}
|
||||
}
|
||||
break;
|
||||
case cmTarget::INTERFACE_LIBRARY:
|
||||
// Nothing to do. An INTERFACE_LIBRARY can be installed, but the
|
||||
// only effect of that is to make it exportable. It installs no
|
||||
// other files itself.
|
||||
break;
|
||||
default:
|
||||
// This should never happen due to the above type check.
|
||||
// Ignore the case.
|
||||
|
|
|
@ -27,3 +27,23 @@ export(TARGETS sharediface sharedlib headeronly
|
|||
NAMESPACE bld_
|
||||
FILE ../ExportInterfaceBuildTree.cmake
|
||||
)
|
||||
|
||||
install(TARGETS headeronly sharediface sharedlib
|
||||
EXPORT expInterface
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib NAMELINK_SKIP
|
||||
ARCHIVE DESTINATION lib
|
||||
FRAMEWORK DESTINATION Frameworks
|
||||
BUNDLE DESTINATION Applications
|
||||
)
|
||||
install(FILES
|
||||
headeronly/headeronly.h
|
||||
DESTINATION include/headeronly
|
||||
)
|
||||
install(FILES
|
||||
sharedlib/sharedlib.h
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/sharedlib_export.h"
|
||||
DESTINATION include/sharedlib
|
||||
)
|
||||
|
||||
install(EXPORT expInterface NAMESPACE exp_ DESTINATION lib/exp)
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
# Import targets from the exported build tree.
|
||||
include(${Import_BINARY_DIR}/../Export/ExportInterfaceBuildTree.cmake)
|
||||
|
||||
# Import targets from the exported install tree.
|
||||
include(${CMAKE_INSTALL_PREFIX}/lib/exp/expInterface.cmake)
|
||||
|
||||
add_library(define_iface INTERFACE)
|
||||
set_property(TARGET define_iface PROPERTY
|
||||
INTERFACE_COMPILE_DEFINITIONS DEFINE_IFACE_DEFINE)
|
||||
|
@ -40,3 +43,13 @@ macro(do_try_compile prefix)
|
|||
endmacro()
|
||||
|
||||
do_try_compile(bld_)
|
||||
|
||||
add_executable(headeronlytest_exp headeronlytest.cpp)
|
||||
target_link_libraries(headeronlytest_exp exp_headeronly)
|
||||
|
||||
set_property(TARGET exp_sharediface APPEND PROPERTY INTERFACE_LINK_LIBRARIES define_iface)
|
||||
|
||||
add_executable(interfacetest_exp interfacetest.cpp)
|
||||
target_link_libraries(interfacetest_exp exp_sharediface)
|
||||
|
||||
do_try_compile(exp_)
|
||||
|
|
Loading…
Reference in New Issue