From ce0c303d62941d2b10098b1ec00de3ced8556919 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 20 Nov 2012 11:06:29 +0100 Subject: install: Teach EXPORT option to handle INTERFACE_LIBRARY targets --- Source/cmExportInstallFileGenerator.cxx | 19 ++++++++++++++++++- Source/cmInstallCommand.cxx | 8 +++++++- Tests/ExportImport/Export/Interface/CMakeLists.txt | 20 ++++++++++++++++++++ Tests/ExportImport/Import/Interface/CMakeLists.txt | 13 +++++++++++++ 4 files changed, 58 insertions(+), 2 deletions(-) diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index c8b4a79..c71008e 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -114,6 +114,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) std::vector missingTargets; bool require2_8_12 = false; + bool require2_8_13 = false; // Create all the imported targets. for(std::vector::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 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, diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 3c76bd6..d309a2a 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -379,7 +379,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector 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 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. diff --git a/Tests/ExportImport/Export/Interface/CMakeLists.txt b/Tests/ExportImport/Export/Interface/CMakeLists.txt index 01e89ef..fc9c0c7 100644 --- a/Tests/ExportImport/Export/Interface/CMakeLists.txt +++ b/Tests/ExportImport/Export/Interface/CMakeLists.txt @@ -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) diff --git a/Tests/ExportImport/Import/Interface/CMakeLists.txt b/Tests/ExportImport/Import/Interface/CMakeLists.txt index c8c8401..c7bd13e 100644 --- a/Tests/ExportImport/Import/Interface/CMakeLists.txt +++ b/Tests/ExportImport/Import/Interface/CMakeLists.txt @@ -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_) -- cgit v0.12