[Cmake-commits] CMake branch, next, updated. v2.8.11.2-4196-g6126772

Stephen Kelly steveire at gmail.com
Sun Sep 15 13:23:12 EDT 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  6126772e2d57be94db1f67b0f614b68ed31598ce (commit)
       via  625f9deb860675fbf943ef99c0ae4dc919341891 (commit)
       via  06b34fa48832e9393572548402a7bdd7809a3807 (commit)
       via  81813a01726cfdf4f86be6e21ea32cbbf40eac5a (commit)
      from  700965ad521cb912c36fd3c505ece55d9857e81a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6126772e2d57be94db1f67b0f614b68ed31598ce
commit 6126772e2d57be94db1f67b0f614b68ed31598ce
Merge: 700965a 625f9de
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Sep 15 13:23:09 2013 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Sun Sep 15 13:23:09 2013 -0400

    Merge topic 'INTERFACE_LIBRARY-target-type' into next
    
    625f9de VS: Do not generate INTERFACE_LIBRARY targets at all
    06b34fa Make it possible to install(EXPORT) INTERFACE_LIBRARY targets.
    81813a0 Make it possible to export() INTERFACE_LIBRARY targets.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=625f9deb860675fbf943ef99c0ae4dc919341891
commit 625f9deb860675fbf943ef99c0ae4dc919341891
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Fri Sep 13 11:05:12 2013 -0400
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Sep 15 19:22:54 2013 +0200

    VS: Do not generate INTERFACE_LIBRARY targets at all
    
    Do not generate project files for INTERFACE_LIBRARY targets.  Do not
    generate dependencies on these targets; this is safe because transitive
    dependencies on real targets have already been hooked up.

diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx
index b3fabda..5296248 100644
--- a/Source/cmGlobalVisualStudio6Generator.cxx
+++ b/Source/cmGlobalVisualStudio6Generator.cxx
@@ -200,6 +200,10 @@ void cmGlobalVisualStudio6Generator
       tt != orderedProjectTargets.end(); ++tt)
     {
     cmTarget* target = *tt;
+    if(target->GetType() == cmTarget::INTERFACE_LIBRARY)
+      {
+      continue;
+      }
     // Write the project into the DSW file
     const char* expath = target->GetProperty("EXTERNAL_MSPROJECT");
     if(expath)
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index b475665..65eb3a9 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -392,6 +392,10 @@ void cmGlobalVisualStudio7Generator::WriteTargetDepends(
         projectTargets.begin(); tt != projectTargets.end(); ++tt)
     {
     cmTarget* target = *tt;
+    if(target->GetType() == cmTarget::INTERFACE_LIBRARY)
+      {
+      continue;
+      }
     cmMakefile* mf = target->GetMakefile();
     const char *vcprojName =
       target->GetProperty("GENERATOR_FILE_NAME");
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index e4244e0..b6deed2 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -406,6 +406,10 @@ void cmGlobalVisualStudio8Generator::WriteProjectDepends(
   for(OrderedTargetDependSet::const_iterator i = depends.begin();
       i != depends.end(); ++i)
     {
+    if((*i)->GetType() == cmTarget::INTERFACE_LIBRARY)
+      {
+      continue;
+      }
     std::string guid = this->GetGUID((*i)->GetName());
     fout << "\t\t{" << guid << "} = {" << guid << "}\n";
     }
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index 5931016..af80070 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -349,6 +349,10 @@ cmGlobalVisualStudioGenerator::GetTargetLinkClosure(cmTarget* target)
 void cmGlobalVisualStudioGenerator::FollowLinkDepends(
   cmTarget* target, std::set<cmTarget*>& linked)
 {
+  if(target->GetType() == cmTarget::INTERFACE_LIBRARY)
+    {
+    return;
+    }
   if(linked.insert(target).second &&
      target->GetType() == cmTarget::STATIC_LIBRARY)
     {
diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx
index c3789a0..aedd6ed 100644
--- a/Source/cmLocalVisualStudio10Generator.cxx
+++ b/Source/cmLocalVisualStudio10Generator.cxx
@@ -76,6 +76,10 @@ void cmLocalVisualStudio10Generator::Generate()
   cmTargets &tgts = this->Makefile->GetTargets();
   for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l)
     {
+    if(l->second.GetType() == cmTarget::INTERFACE_LIBRARY)
+      {
+      continue;
+      }
     if(static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
        ->TargetIsFortranOnly(l->second))
       {
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index cb30fa2..f0f47cb 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -152,7 +152,7 @@ void cmLocalVisualStudio6Generator::OutputDSPFile()
         this->SetBuildType(UTILITY, l->first.c_str(), l->second);
         break;
       case cmTarget::INTERFACE_LIBRARY:
-        break;
+        continue;
       default:
         cmSystemTools::Error("Bad target type", l->first.c_str());
         break;
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index bfbe138..84452c5 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -78,6 +78,10 @@ void cmLocalVisualStudio7Generator::AddHelperCommands()
     static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
   for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++)
     {
+    if(l->second.GetType() == cmTarget::INTERFACE_LIBRARY)
+      {
+      continue;
+      }
     const char* path = l->second.GetProperty("EXTERNAL_MSPROJECT");
     if(path)
       {
@@ -181,6 +185,10 @@ void cmLocalVisualStudio7Generator::WriteProjectFiles()
   for(cmTargets::iterator l = tgts.begin();
       l != tgts.end(); l++)
     {
+    if(l->second.GetType() == cmTarget::INTERFACE_LIBRARY)
+      {
+      continue;
+      }
     // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace
     // so don't build a projectfile for it
     if(!l->second.GetProperty("EXTERNAL_MSPROJECT"))
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index be18ceb..0dbb5eb 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -1838,6 +1838,10 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences()
        i != depends.end(); ++i)
     {
     cmTarget* dt = *i;
+    if(dt->GetType() == cmTarget::INTERFACE_LIBRARY)
+      {
+      continue;
+      }
     // skip fortran targets as they can not be processed by MSBuild
     // the only reference will be in the .sln file
     if(static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=06b34fa48832e9393572548402a7bdd7809a3807
commit 06b34fa48832e9393572548402a7bdd7809a3807
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Nov 20 11:06:29 2012 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Sep 15 19:22:54 2013 +0200

    Make it possible to install(EXPORT) INTERFACE_LIBRARY targets.

diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index c97d4ff..af40159 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,9 +165,13 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
     this->GenerateInterfaceProperties(te, os, properties);
     }
 
-  if (require2_8_12)
+  if (require2_8_13)
     {
-    this->GenerateRequiredCMakeVersion(os, "2.8.11.20130626");
+    this->GenerateRequiredCMakeVersion(os, "2.8.11.20130815");
+    }
+  else if (require2_8_12)
+    {
+    this->GenerateRequiredCMakeVersion(os, "2.8.11");
     }
 
   // Now load per-configuration properties for them.
@@ -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_)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=81813a01726cfdf4f86be6e21ea32cbbf40eac5a
commit 81813a01726cfdf4f86be6e21ea32cbbf40eac5a
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Nov 20 10:58:15 2012 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun Sep 15 19:22:53 2013 +0200

    Make it possible to export() INTERFACE_LIBRARY targets.

diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx
index 130a033..0e61c99 100644
--- a/Source/cmAddLibraryCommand.cxx
+++ b/Source/cmAddLibraryCommand.cxx
@@ -220,6 +220,16 @@ bool cmAddLibraryCommand
         );
       return true;
       }
+    if(type == cmTarget::INTERFACE_LIBRARY)
+      {
+      if (!cmGeneratorExpression::IsValidTargetName(libName))
+        {
+        cmOStringStream e;
+        e << "Invalid name for IMPORTED INTERFACE library target: " << libName;
+        this->SetError(e.str().c_str());
+        return false;
+        }
+      }
 
     // Make sure the target does not already exist.
     if(this->Makefile->FindTargetToUse(libName.c_str()))
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 086f27a..6f3274e 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -99,6 +99,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
           {
           case cmTarget::SHARED_LIBRARY:
           case cmTarget::STATIC_LIBRARY:
+          case cmTarget::INTERFACE_LIBRARY:
           case cmTarget::UNKNOWN_LIBRARY:
             break;
           case cmTarget::EXECUTABLE:
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index cdc3316..caee9b9 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -47,6 +47,11 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
         }
       return false;
       }
+    if (te->GetType() == cmTarget::INTERFACE_LIBRARY)
+      {
+      // 2.8.13
+      this->GenerateRequiredCMakeVersion(os, "2.8.11.20130815");
+      }
     }
 
   this->GenerateExpectedTargetsCode(os, expectedTargets);
@@ -118,16 +123,22 @@ cmExportBuildFileGenerator
     // Collect import properties for this target.
     cmTarget* target = *tei;
     ImportPropertyMap properties;
-    this->SetImportLocationProperty(config, suffix, target, properties);
+
+    if (target->GetType() != cmTarget::INTERFACE_LIBRARY)
+      {
+      this->SetImportLocationProperty(config, suffix, target, properties);
+      }
     if(!properties.empty())
       {
       // Get the rest of the target details.
-      this->SetImportDetailProperties(config, suffix,
-                                      target, properties, missingTargets);
-      this->SetImportLinkInterface(config, suffix,
-                                   cmGeneratorExpression::BuildInterface,
-                                   target, properties, missingTargets);
-
+      if (target->GetType() != cmTarget::INTERFACE_LIBRARY)
+        {
+        this->SetImportDetailProperties(config, suffix,
+                                        target, properties, missingTargets);
+        this->SetImportLinkInterface(config, suffix,
+                                    cmGeneratorExpression::BuildInterface,
+                                    target, properties, missingTargets);
+        }
 
       // TOOD: PUBLIC_HEADER_LOCATION
       // This should wait until the build feature propagation stuff
diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx
index f059ceb..be2ee31 100644
--- a/Source/cmExportCommand.cxx
+++ b/Source/cmExportCommand.cxx
@@ -130,7 +130,8 @@ bool cmExportCommand
       if((target->GetType() == cmTarget::EXECUTABLE) ||
          (target->GetType() == cmTarget::STATIC_LIBRARY) ||
          (target->GetType() == cmTarget::SHARED_LIBRARY) ||
-         (target->GetType() == cmTarget::MODULE_LIBRARY))
+         (target->GetType() == cmTarget::MODULE_LIBRARY) ||
+         (target->GetType() == cmTarget::INTERFACE_LIBRARY))
         {
         targets.push_back(target);
         }
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index ef336ea..8c841cb 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -378,11 +378,14 @@ void getCompatibleInterfaceProperties(cmTarget *target,
 
   if (!info)
     {
-    cmMakefile* mf = target->GetMakefile();
-    cmOStringStream e;
-    e << "Exporting the target \"" << target->GetName() << "\" is not "
-         "allowed since its linker language cannot be determined";
-    mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+    if (target->GetType() != cmTarget::INTERFACE_LIBRARY)
+      {
+      cmMakefile* mf = target->GetMakefile();
+      cmOStringStream e;
+      e << "Exporting the target \"" << target->GetName() << "\" is not "
+          "allowed since its linker language cannot be determined";
+      mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+      }
     return;
     }
 
@@ -887,6 +890,9 @@ cmExportFileGenerator
     case cmTarget::UNKNOWN_LIBRARY:
       os << "add_library(" << targetName << " UNKNOWN IMPORTED)\n";
       break;
+    case cmTarget::INTERFACE_LIBRARY:
+      os << "add_library(" << targetName << " INTERFACE IMPORTED)\n";
+      break;
     default:  // should never happen
       break;
     }
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 050ba9f..264c761 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -6164,7 +6164,8 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config,
   const char* loc = 0;
   const char* imp = 0;
   std::string suffix;
-  if (!this->GetMappedConfig(desired_config, &loc, &imp, suffix))
+  if (this->GetType() != INTERFACE_LIBRARY &&
+      !this->GetMappedConfig(desired_config, &loc, &imp, suffix))
     {
     return;
     }
diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt
index 1f23b2a..e4f3de8 100644
--- a/Tests/ExportImport/Export/CMakeLists.txt
+++ b/Tests/ExportImport/Export/CMakeLists.txt
@@ -426,3 +426,5 @@ export(TARGETS testExe2 testLib4 testLib5 testLib6 testExe3 testExe2lib
   NAMESPACE bld_
   APPEND FILE ExportBuildTree.cmake
   )
+
+add_subdirectory(Interface)
diff --git a/Tests/ExportImport/Export/Interface/CMakeLists.txt b/Tests/ExportImport/Export/Interface/CMakeLists.txt
new file mode 100644
index 0000000..01e89ef
--- /dev/null
+++ b/Tests/ExportImport/Export/Interface/CMakeLists.txt
@@ -0,0 +1,29 @@
+
+add_library(headeronly INTERFACE)
+set_property(TARGET headeronly PROPERTY INTERFACE_INCLUDE_DIRECTORIES
+  "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/headeronly>"
+  "$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/headeronly>"
+)
+set_property(TARGET headeronly PROPERTY INTERFACE_COMPILE_DEFINITIONS "HEADERONLY_DEFINE")
+
+include(GenerateExportHeader)
+add_library(sharedlib SHARED sharedlib.cpp)
+generate_export_header(sharedlib)
+set_property(TARGET sharedlib PROPERTY INCLUDE_DIRECTORIES
+  "${CMAKE_CURRENT_SOURCE_DIR}/sharedlib"
+  "${CMAKE_CURRENT_BINARY_DIR}"
+)
+set_property(TARGET sharedlib PROPERTY INTERFACE_INCLUDE_DIRECTORIES
+  "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/sharedlib;${CMAKE_CURRENT_BINARY_DIR}>"
+  "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/sharedlib>"
+)
+
+set_property(TARGET sharedlib PROPERTY INTERFACE_COMPILE_DEFINITIONS "SHAREDLIB_DEFINE")
+
+add_library(sharediface INTERFACE)
+target_link_libraries(sharediface INTERFACE sharedlib)
+
+export(TARGETS sharediface sharedlib headeronly
+  NAMESPACE bld_
+  FILE ../ExportInterfaceBuildTree.cmake
+)
diff --git a/Tests/ExportImport/Export/Interface/headeronly/headeronly.h b/Tests/ExportImport/Export/Interface/headeronly/headeronly.h
new file mode 100644
index 0000000..3673c21
--- /dev/null
+++ b/Tests/ExportImport/Export/Interface/headeronly/headeronly.h
@@ -0,0 +1,7 @@
+
+enum { one };
+
+struct HeaderOnly
+{
+  int foo() const { return 0; }
+};
diff --git a/Tests/ExportImport/Export/Interface/sharedlib.cpp b/Tests/ExportImport/Export/Interface/sharedlib.cpp
new file mode 100644
index 0000000..88ca713
--- /dev/null
+++ b/Tests/ExportImport/Export/Interface/sharedlib.cpp
@@ -0,0 +1,7 @@
+
+#include "sharedlib.h"
+
+int SharedLibObject::foo() const
+{
+  return 0;
+}
diff --git a/Tests/ExportImport/Export/Interface/sharedlib/sharedlib.h b/Tests/ExportImport/Export/Interface/sharedlib/sharedlib.h
new file mode 100644
index 0000000..aad9ef3
--- /dev/null
+++ b/Tests/ExportImport/Export/Interface/sharedlib/sharedlib.h
@@ -0,0 +1,7 @@
+
+#include "sharedlib_export.h"
+
+struct SHAREDLIB_EXPORT SharedLibObject
+{
+  int foo() const;
+};
diff --git a/Tests/ExportImport/Import/CMakeLists.txt b/Tests/ExportImport/Import/CMakeLists.txt
index 9c2d597..5e809a2 100644
--- a/Tests/ExportImport/Import/CMakeLists.txt
+++ b/Tests/ExportImport/Import/CMakeLists.txt
@@ -19,3 +19,6 @@ add_executable(imp_testTransExe1b imp_testTransExe1.c)
 target_link_libraries(imp_testTransExe1b imp_lib1b)
 
 add_subdirectory(try_compile)
+
+# Test package INTERFACE controls
+add_subdirectory(Interface)
diff --git a/Tests/ExportImport/Import/Interface/CMakeLists.txt b/Tests/ExportImport/Import/Interface/CMakeLists.txt
new file mode 100644
index 0000000..c8c8401
--- /dev/null
+++ b/Tests/ExportImport/Import/Interface/CMakeLists.txt
@@ -0,0 +1,42 @@
+
+# Import targets from the exported build tree.
+include(${Import_BINARY_DIR}/../Export/ExportInterfaceBuildTree.cmake)
+
+add_library(define_iface INTERFACE)
+set_property(TARGET define_iface PROPERTY
+  INTERFACE_COMPILE_DEFINITIONS DEFINE_IFACE_DEFINE)
+
+add_executable(headeronlytest_bld headeronlytest.cpp)
+target_link_libraries(headeronlytest_bld bld_headeronly)
+
+set_property(TARGET bld_sharediface APPEND PROPERTY INTERFACE_LINK_LIBRARIES define_iface)
+
+add_executable(interfacetest_bld interfacetest.cpp)
+target_link_libraries(interfacetest_bld bld_sharediface)
+
+include(CheckCXXSourceCompiles)
+
+macro(do_try_compile prefix)
+
+  set(CMAKE_REQUIRED_LIBRARIES ${prefix}headeronly)
+  check_cxx_source_compiles(
+    "
+  #include \"headeronly.h\"
+
+  #ifndef HEADERONLY_DEFINE
+  #error Expected HEADERONLY_DEFINE
+  #endif
+
+  int main(int,char**)
+  {
+    HeaderOnly ho;
+    return ho.foo();
+  }
+  " ${prefix}IFACE_TRY_COMPILE)
+
+  if(NOT ${prefix}IFACE_TRY_COMPILE)
+    message(SEND_ERROR "${prefix} try_compile with IMPORTED INTERFACE target failed!\n\n${OUTPUT}")
+  endif()
+endmacro()
+
+do_try_compile(bld_)
diff --git a/Tests/ExportImport/Import/Interface/headeronlytest.cpp b/Tests/ExportImport/Import/Interface/headeronlytest.cpp
new file mode 100644
index 0000000..20674a7
--- /dev/null
+++ b/Tests/ExportImport/Import/Interface/headeronlytest.cpp
@@ -0,0 +1,17 @@
+
+#include "headeronly.h"
+
+#ifndef HEADERONLY_DEFINE
+#error Expected HEADERONLY_DEFINE
+#endif
+
+#ifdef SHAREDLIB_DEFINE
+#error Unexpected SHAREDLIB_DEFINE
+#endif
+
+
+int main(int,char**)
+{
+  HeaderOnly ho;
+  return ho.foo();
+}
diff --git a/Tests/ExportImport/Import/Interface/interfacetest.cpp b/Tests/ExportImport/Import/Interface/interfacetest.cpp
new file mode 100644
index 0000000..786458d
--- /dev/null
+++ b/Tests/ExportImport/Import/Interface/interfacetest.cpp
@@ -0,0 +1,20 @@
+
+#include "sharedlib.h"
+
+#ifndef SHAREDLIB_DEFINE
+#error Expected SHAREDLIB_DEFINE
+#endif
+
+#ifdef HEADERONLY_DEFINE
+#error Unexpected HEADERONLY_DEFINE
+#endif
+
+#ifndef DEFINE_IFACE_DEFINE
+#error Expected DEFINE_IFACE_DEFINE
+#endif
+
+int main(int,char**)
+{
+  SharedLibObject slo;
+  return slo.foo();
+}
diff --git a/Tests/RunCMake/interface_library/invalid_name-stderr.txt b/Tests/RunCMake/interface_library/invalid_name-stderr.txt
index c66e080..e14fcde 100644
--- a/Tests/RunCMake/interface_library/invalid_name-stderr.txt
+++ b/Tests/RunCMake/interface_library/invalid_name-stderr.txt
@@ -7,3 +7,9 @@ CMake Error at invalid_name.cmake:4 \(add_library\):
   add_library Invalid name for INTERFACE library target: iface::target
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)
++
+CMake Error at invalid_name.cmake:6 \(add_library\):
+  add_library Invalid name for IMPORTED INTERFACE library target:
+  if\$target_imported
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/interface_library/invalid_name.cmake b/Tests/RunCMake/interface_library/invalid_name.cmake
index 51a109d..9a965aa 100644
--- a/Tests/RunCMake/interface_library/invalid_name.cmake
+++ b/Tests/RunCMake/interface_library/invalid_name.cmake
@@ -2,3 +2,5 @@
 add_library(if$ace INTERFACE)
 
 add_library(iface::target INTERFACE)
+
+add_library(if$target_imported INTERFACE IMPORTED)

-----------------------------------------------------------------------

Summary of changes:


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list