diff options
author | Stephen Kelly <steveire@gmail.com> | 2012-11-20 10:06:29 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-10-08 00:07:27 (GMT) |
commit | ce0c303d62941d2b10098b1ec00de3ced8556919 (patch) | |
tree | 46e32f12cb91c4172aebf3fe7004640382644408 | |
parent | 435c912848b08333e03c74439f725c9b96890d80 (diff) | |
download | CMake-ce0c303d62941d2b10098b1ec00de3ced8556919.zip CMake-ce0c303d62941d2b10098b1ec00de3ced8556919.tar.gz CMake-ce0c303d62941d2b10098b1ec00de3ced8556919.tar.bz2 |
install: Teach EXPORT option to handle INTERFACE_LIBRARY targets
-rw-r--r-- | Source/cmExportInstallFileGenerator.cxx | 19 | ||||
-rw-r--r-- | Source/cmInstallCommand.cxx | 8 | ||||
-rw-r--r-- | Tests/ExportImport/Export/Interface/CMakeLists.txt | 20 | ||||
-rw-r--r-- | 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<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, 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<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. 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_) |