[Cmake-commits] CMake branch, next, updated. v3.2.2-3060-g75e0711

Brad King brad.king at kitware.com
Thu May 21 09:58:00 EDT 2015


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  75e071117161e8e01a5fd3144279f276dcf8f1a1 (commit)
       via  65d0930ef5fffaf0538f4be23c8d6bc933964f82 (commit)
       via  a6edb953434166e3b539a020c31d825457eb4aa6 (commit)
       via  726bee71d6bffe8a878ebad4f7ae2c10716fe76a (commit)
       via  38d55c7ccbd0dddbf12592cc55730a854ea4d9a4 (commit)
      from  8070c4f252293e7dfe44fd2c53d5d7498b307c67 (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=75e071117161e8e01a5fd3144279f276dcf8f1a1
commit 75e071117161e8e01a5fd3144279f276dcf8f1a1
Merge: 8070c4f 65d0930
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu May 21 09:57:58 2015 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu May 21 09:57:58 2015 -0400

    Merge topic 'FindOpenGL-target' into next
    
    65d0930e FindOpenGL: Provide imported targets for GL and GLU (#15267)
    a6edb953 Allow imported INTERFACE libraries to specify a link item
    726bee71 cmTarget: Refactor GetMappedConfig to choose location property up front
    38d55c7c cmTarget: Clarify comments in GetMappedConfig


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=65d0930ef5fffaf0538f4be23c8d6bc933964f82
commit 65d0930ef5fffaf0538f4be23c8d6bc933964f82
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue May 19 15:40:55 2015 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu May 21 09:19:07 2015 -0400

    FindOpenGL: Provide imported targets for GL and GLU (#15267)
    
    Create OpenGL::GL and OpenGL::GLU imported targets using the locations
    found.  On Windows the MS opengl32 library is provided by the platform
    SDK so we do not know the full path to the library file.  In this case,
    provide the target as an interface library with IMPORTED_LINK_ITEM set
    so that we simply ask the linker to search for the library.
    
    This restores the change originally made by commit v3.1.0-rc1~420^2~2
    (FindOpenGL: Provide imported targets for GL and GLU, 2014-05-31) and
    later reverted by commit v3.1.0-rc3~10^2 (FindOpenGL: Revert support for
    imported targets, 2014-12-01) but resolves the reasons it was reverted.
    
    Add a test for the FindOpenGL module that always runs but skips actually
    building anything if OpenGL is not found.  Provide an option that a
    dashboard script can use to require that OpenGL be found on a machine
    where it is expected to work.
    
    Inspired-by: Philipp Möller <bootsarehax at googlemail.com>

diff --git a/Help/release/dev/FindOpenGL-target.rst b/Help/release/dev/FindOpenGL-target.rst
new file mode 100644
index 0000000..670507e
--- /dev/null
+++ b/Help/release/dev/FindOpenGL-target.rst
@@ -0,0 +1,5 @@
+FindOpenGL-target
+-----------------
+
+* The :module:`FindOpenGL` module now provides imported targets
+  ``OpenGL::GL`` and ``OpenGL::GLU`` when the libraries are found.
diff --git a/Modules/FindOpenGL.cmake b/Modules/FindOpenGL.cmake
index a7eefa7..f4cf6d7 100644
--- a/Modules/FindOpenGL.cmake
+++ b/Modules/FindOpenGL.cmake
@@ -4,6 +4,16 @@
 #
 # FindModule for OpenGL and GLU.
 #
+# IMPORTED Targets
+# ^^^^^^^^^^^^^^^^
+#
+# This module defines the :prop_tgt:`IMPORTED` targets:
+#
+# ``OpenGL::GL``
+#  Defined if the system has OpenGL.
+# ``OpenGL::GLU``
+#  Defined if the system has GLU.
+#
 # Result Variables
 # ^^^^^^^^^^^^^^^^
 #
@@ -168,6 +178,55 @@ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
 FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenGL REQUIRED_VARS ${_OpenGL_REQUIRED_VARS})
 unset(_OpenGL_REQUIRED_VARS)
 
+# OpenGL:: targets
+if(OPENGL_FOUND)
+  if(NOT TARGET OpenGL::GL)
+    if(IS_ABSOLUTE "${OPENGL_gl_LIBRARY}")
+      add_library(OpenGL::GL UNKNOWN IMPORTED)
+      if(OPENGL_gl_LIBRARY MATCHES "/([^/]+)\\.framework$")
+        set_property(TARGET OpenGL::GL PROPERTY
+          IMPORTED_LOCATION "${OPENGL_gl_LIBRARY}/${CMAKE_MATCH_1}"
+          )
+      else()
+        set_property(TARGET OpenGL::GL PROPERTY
+          IMPORTED_LOCATION "${OPENGL_gl_LIBRARY}"
+          )
+      endif()
+    else()
+      add_library(OpenGL::GL INTERFACE IMPORTED)
+      set_property(TARGET OpenGL::GL PROPERTY
+        IMPORTED_LINK_ITEM "${OPENGL_gl_LIBRARY}"
+        )
+    endif()
+    set_property(TARGET OpenGL::GL PROPERTY
+      INTERFACE_INCLUDE_DIRECTORIES "${OPENGL_INCLUDE_DIR}"
+      )
+  endif()
+
+  if(OPENGL_GLU_FOUND AND NOT TARGET OpenGL::GLU)
+    if(IS_ABSOLUTE "${OPENGL_glu_LIBRARY}")
+      add_library(OpenGL::GLU UNKNOWN IMPORTED)
+      if(OPENGL_glu_LIBRARY MATCHES "/([^/]+)\\.framework$")
+        set_property(TARGET OpenGL::GLU PROPERTY
+          IMPORTED_LOCATION "${OPENGL_glu_LIBRARY}/${CMAKE_MATCH_1}"
+          )
+      else()
+        set_property(TARGET OpenGL::GLU PROPERTY
+          IMPORTED_LOCATION "${OPENGL_glu_LIBRARY}"
+          )
+      endif()
+    else()
+      add_library(OpenGL::GLU INTERFACE IMPORTED)
+      set_property(TARGET OpenGL::GLU PROPERTY
+        IMPORTED_LINK_ITEM "${OPENGL_glu_LIBRARY}"
+        )
+    endif()
+    set_property(TARGET OpenGL::GLU PROPERTY
+      INTERFACE_LINK_LIBRARIES OpenGL::GL
+      )
+  endif()
+endif()
+
 mark_as_advanced(
   OPENGL_INCLUDE_DIR
   OPENGL_xmesa_INCLUDE_DIR
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index b61e3af..c7f1235 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1342,6 +1342,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
   if(CMake_TEST_FindJsonCpp)
     add_subdirectory(FindJsonCpp)
   endif()
+  add_subdirectory(FindOpenGL)
 
   # Matlab module
   if(CMake_TEST_FindMatlab)
diff --git a/Tests/FindOpenGL/CMakeLists.txt b/Tests/FindOpenGL/CMakeLists.txt
new file mode 100644
index 0000000..187fff5
--- /dev/null
+++ b/Tests/FindOpenGL/CMakeLists.txt
@@ -0,0 +1,11 @@
+add_test(NAME FindOpenGL.Test COMMAND
+  ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+  --build-and-test
+  "${CMake_SOURCE_DIR}/Tests/FindOpenGL/Test"
+  "${CMake_BINARY_DIR}/Tests/FindOpenGL/Test"
+  ${build_generator_args}
+  --build-project TestFindOpenGL
+  --build-options ${build_options}
+    -DCMake_TEST_FindOpenGL_REQUIRED=${CMake_TEST_FindOpenGL_REQUIRED}
+  --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+  )
diff --git a/Tests/FindOpenGL/Test/CMakeLists.txt b/Tests/FindOpenGL/Test/CMakeLists.txt
new file mode 100644
index 0000000..80a610f
--- /dev/null
+++ b/Tests/FindOpenGL/Test/CMakeLists.txt
@@ -0,0 +1,30 @@
+cmake_minimum_required(VERSION 3.2)
+project(TestFindOpenGL C)
+include(CTest)
+
+if(CMake_TEST_FindOpenGL_REQUIRED)
+  find_package(OpenGL REQUIRED)
+else()
+  find_package(OpenGL)
+  if(NOT OPENGL_FOUND)
+    message("OpenGL not found, skipping rest of test.")
+    return()
+  endif()
+endif()
+
+add_executable(test_opengl_tgt main.c)
+if(TARGET OpenGL::GLU)
+  target_link_libraries(test_opengl_tgt OpenGL::GLU)
+  target_compile_definitions(test_opengl_tgt PRIVATE HAVE_GLU)
+else()
+  target_link_libraries(test_opengl_tgt OpenGL::GL)
+endif()
+add_test(NAME test_opengl_tgt COMMAND test_opengl_tgt)
+
+add_executable(test_opengl_var main.c)
+if(OPENGL_glu_LIBRARY)
+  target_compile_definitions(test_opengl_var PRIVATE HAVE_GLU)
+endif()
+target_include_directories(test_opengl_var PRIVATE ${OPENGL_INCLUDE_DIR})
+target_link_libraries(test_opengl_var PRIVATE ${OPENGL_LIBRARIES})
+add_test(NAME test_opengl_var COMMAND test_opengl_var)
diff --git a/Tests/FindOpenGL/Test/main.c b/Tests/FindOpenGL/Test/main.c
new file mode 100644
index 0000000..37a5416
--- /dev/null
+++ b/Tests/FindOpenGL/Test/main.c
@@ -0,0 +1,30 @@
+#ifdef __APPLE__
+# pragma GCC diagnostic ignored "-Wdeprecated"
+# include <OpenGL/gl.h>
+# ifdef HAVE_GLU
+#  include <OpenGL/glu.h>
+# endif
+#else
+# ifdef _WIN32
+#  include <windows.h>
+# endif
+# include <GL/gl.h>
+# ifdef HAVE_GLU
+#  include <GL/glu.h>
+# endif
+#endif
+
+#ifdef __GNUC__
+# pragma GCC diagnostic ignored "-Wpointer-to-int-cast"
+#endif
+
+int main(int argc, char* argv[])
+{
+  (void)argv;
+#ifdef HAVE_GLU
+  /* Link to a GLU symbol that can be called without a context.  */
+  gluErrorString(GLU_INVALID_ENUM);
+#endif
+  /* Link to a GL symbol without calling it since we have no context.  */
+  return ((int)(&glGetError)) * (argc-1);
+}

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a6edb953434166e3b539a020c31d825457eb4aa6
commit a6edb953434166e3b539a020c31d825457eb4aa6
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue May 19 15:36:28 2015 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu May 21 09:19:07 2015 -0400

    Allow imported INTERFACE libraries to specify a link item
    
    Add an IMPORTED_LINK_ITEM[_<CONFIG>] target property to specify an item
    to be placed on the link line in place of an interface library since it
    has no library file of its own.  Restrict use of the property to
    imported INTERFACE libraries.
    
    This will be particularly useful for find modules that need to provide
    imported libraries from system SDKs where the full path to the library
    file is not known.  Now such find modules will be able to provide an
    imported interface library and set IMPORTED_LINK_ITEM to refer to the
    SDK library by name.  See issue 15267.
    
    The IMPORTED_LINK_ITEM[_<CONFIG>] property also allows us to implement
    MAP_IMPORTED_CONFIG_<CONFIG> for interface libraries.  Drop some of the
    special cases added by commit v3.0.0-rc1~301^2~1 (INTERFACE_LIBRARY:
    Avoid codepaths which set unneeded properties, 2013-11-20) and commit
    v3.0.0-rc1~237^2 (Don't search for IMPORTED_LOCATION of
    INTERFACE_LIBRARY, 2013-12-09).  Ensure the test added by commit
    v3.0.0-rc1~150^2 (InterfaceLibrary: Add test requiring
    MAP_IMPORTED_CONFIG whitelisting, 2014-01-09) still passes.

diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index 615254e..7c59895 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -150,6 +150,8 @@ Properties on Targets
    /prop_tgt/IMPORTED_LINK_INTERFACE_LIBRARIES
    /prop_tgt/IMPORTED_LINK_INTERFACE_MULTIPLICITY_CONFIG
    /prop_tgt/IMPORTED_LINK_INTERFACE_MULTIPLICITY
+   /prop_tgt/IMPORTED_LINK_ITEM_CONFIG
+   /prop_tgt/IMPORTED_LINK_ITEM
    /prop_tgt/IMPORTED_LOCATION_CONFIG
    /prop_tgt/IMPORTED_LOCATION
    /prop_tgt/IMPORTED_NO_SONAME_CONFIG
diff --git a/Help/prop_tgt/IMPORTED_LINK_ITEM.rst b/Help/prop_tgt/IMPORTED_LINK_ITEM.rst
new file mode 100644
index 0000000..d8ee91f
--- /dev/null
+++ b/Help/prop_tgt/IMPORTED_LINK_ITEM.rst
@@ -0,0 +1,27 @@
+IMPORTED_LINK_ITEM
+------------------
+
+Specify the link line item for an :ref:`imported <Imported Targets>`
+:ref:`Interface Library <Interface Libraries>`.
+
+An interface library has no library file so linking to it normally
+adds its usage requirements but does not link to an actual library.
+The ``IMPORTED_LINK_ITEM`` property specifies a single item to
+be placed on the link line in place of the interface library.
+The item may be:
+
+* A full path to a library file such as ``/usr/lib/libfoo.so``.
+* A plain library name such as ``foo``.
+* A link flag.
+
+See the :command:`target_link_libraries` command for details on
+how each type of item is treated, but note that the
+``IMPORTED_LINK_ITEM`` property does not recognize the keyword
+arguments of that command.  Furthermore, the item specified in
+this property is *not* treated as a library target name even if
+it happens to name one.
+
+The ``IMPORTED_LINK_ITEM`` property is allowed only on
+:ref:`imported <Imported Targets>` :ref:`Interface Libraries`
+and is rejected on targets of other types (for which
+the :prop_tgt:`IMPORTED_LOCATION` target property may be used).
diff --git a/Help/prop_tgt/IMPORTED_LINK_ITEM_CONFIG.rst b/Help/prop_tgt/IMPORTED_LINK_ITEM_CONFIG.rst
new file mode 100644
index 0000000..028b6d9
--- /dev/null
+++ b/Help/prop_tgt/IMPORTED_LINK_ITEM_CONFIG.rst
@@ -0,0 +1,7 @@
+IMPORTED_LINK_ITEM_<CONFIG>
+---------------------------
+
+<CONFIG>-specific version of :prop_tgt:`IMPORTED_LINK_ITEM` property.
+
+Configuration names correspond to those provided by the project from
+which the target is imported.
diff --git a/Help/release/dev/imported-link-item.rst b/Help/release/dev/imported-link-item.rst
new file mode 100644
index 0000000..17d6777
--- /dev/null
+++ b/Help/release/dev/imported-link-item.rst
@@ -0,0 +1,7 @@
+imported-link-item
+------------------
+
+* :ref:`Imported <Imported Targets>` :ref:`Interface Libraries` learned new
+  :prop_tgt:`IMPORTED_LINK_ITEM` and :prop_tgt:`IMPORTED_LINK_ITEM_<CONFIG>`
+  target properties to specify a link line item since interface libraries do
+  not have their own library files.
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index e6cbe60..153a2b4 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -658,6 +658,13 @@ void cmComputeLinkInformation::AddItem(std::string const& item,
       // of COMPATIBLE_INTERFACE_ enforcement.  The generators will ignore
       // this for the actual link line.
       this->Items.push_back(Item(std::string(), true, tgt));
+
+      // Also add the item the interface specifies to be used in its place.
+      std::string const& linkItem = tgt->GetImportedLinkItem(config);
+      if (!linkItem.empty())
+        {
+        this->AddItem(linkItem, 0);
+        }
       }
     else
       {
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 88ec61b..ada1488 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -77,6 +77,7 @@ struct cmTarget::ImportInfo
   std::string Location;
   std::string SOName;
   std::string ImportLibrary;
+  std::string LinkItem;
   std::string Languages;
   std::string Libraries;
   std::string LibrariesProp;
@@ -364,11 +365,6 @@ void cmTarget::SetMakefile(cmMakefile* mf)
       std::string configUpper = cmSystemTools::UpperCase(*ci);
       for(const char** p = configProps; *p; ++p)
         {
-        if (this->TargetTypeValue == INTERFACE_LIBRARY
-            && strcmp(*p, "MAP_IMPORTED_CONFIG_") != 0)
-          {
-          continue;
-          }
         std::string property = *p;
         property += configUpper;
         this->SetPropertyDefault(property, 0);
@@ -1675,7 +1671,10 @@ static bool whiteListedInterfaceProperty(const std::string& prop)
     return true;
     }
 
-  if (cmHasLiteralPrefix(prop, "MAP_IMPORTED_CONFIG_"))
+  if (prop == "IMPORTED_CONFIGURATIONS" ||
+      prop == "IMPORTED_LINK_ITEM" ||
+      cmHasLiteralPrefix(prop, "IMPORTED_LINK_ITEM_") ||
+      cmHasLiteralPrefix(prop, "MAP_IMPORTED_CONFIG_"))
     {
     return true;
     }
@@ -1745,6 +1744,15 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
           << this->Name << "\")\n";
     this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
     }
+  else if(cmHasLiteralPrefix(prop, "IMPORTED_LINK_ITEM") &&
+          (this->GetType() != cmTarget::INTERFACE_LIBRARY ||
+           !this->IsImported()))
+    {
+    std::ostringstream e;
+    e << prop << " property may be set only on "
+      << "imported INTERFACE library targets.\n";
+    this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+    }
   else if (prop == "LINK_LIBRARIES")
     {
     this->Internal->LinkImplementationPropertyEntries.clear();
@@ -1832,6 +1840,15 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
           << this->Name << "\")\n";
     this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
     }
+  else if(cmHasLiteralPrefix(prop, "IMPORTED_LINK_ITEM") &&
+          (this->GetType() != cmTarget::INTERFACE_LIBRARY ||
+           !this->IsImported()))
+    {
+    std::ostringstream e;
+    e << prop << " property may be set only on "
+      << "imported INTERFACE library targets.\n";
+    this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+    }
   else if (prop == "LINK_LIBRARIES")
     {
     cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
@@ -3837,6 +3854,16 @@ void cmTarget::GetFullNameComponents(std::string& prefix, std::string& base,
 }
 
 //----------------------------------------------------------------------------
+std::string cmTarget::GetImportedLinkItem(std::string const& config) const
+{
+  if (cmTarget::ImportInfo const* info = this->GetImportInfo(config))
+    {
+    return info->LinkItem;
+    }
+  return std::string();
+}
+
+//----------------------------------------------------------------------------
 std::string cmTarget::GetFullPath(const std::string& config, bool implib,
                                   bool realname) const
 {
@@ -5393,15 +5420,9 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
                                const char** imp,
                                std::string& suffix) const
 {
-  if (this->GetType() == INTERFACE_LIBRARY)
-    {
-    // This method attempts to find a config-specific LOCATION for the
-    // IMPORTED library. In the case of INTERFACE_LIBRARY, there is no
-    // LOCATION at all, so leaving *loc and *imp unchanged is the appropriate
-    // and valid response.
-    return true;
-    }
-  std::string const locPropBase = "IMPORTED_LOCATION";
+  std::string const locPropBase =
+    this->GetType() == INTERFACE_LIBRARY?
+    "IMPORTED_LINK_ITEM" : "IMPORTED_LOCATION";
 
   // Track the configuration-specific property suffix.
   suffix = "_";
@@ -5451,7 +5472,9 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
   // any other configuration.
   if(!mappedConfigs.empty() && !*loc && !*imp)
     {
-    return false;
+    // Interface libraries are always available because their
+    // link item is optional so it is okay to leave *loc empty.
+    return this->GetType() == cmTarget::INTERFACE_LIBRARY;
     }
 
   // If we have not yet found it then there are no mapped
@@ -5515,7 +5538,9 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
   // If we have not yet found it then the target location is not available.
   if(!*loc && !*imp)
     {
-    return false;
+    // Interface libraries are always available because their
+    // link item is optional so it is okay to leave *loc empty.
+    return this->GetType() == cmTarget::INTERFACE_LIBRARY;
     }
 
   return true;
@@ -5568,6 +5593,10 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config,
   }
   if(this->GetType() == INTERFACE_LIBRARY)
     {
+    if (loc)
+      {
+      info.LinkItem = loc;
+      }
     return;
     }
 
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 1a8b75a..f3b8d8d 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -434,6 +434,9 @@ public:
       no soname at all.  */
   bool IsImportedSharedLibWithoutSOName(const std::string& config) const;
 
+  /** Get the link item for an imported interface library.  */
+  std::string GetImportedLinkItem(std::string const& config) const;
+
   /** Get the full path to the target according to the settings in its
       makefile and the configuration type.  */
   std::string GetFullPath(const std::string& config="", bool implib = false,
diff --git a/Tests/InterfaceLibrary/CMakeLists.txt b/Tests/InterfaceLibrary/CMakeLists.txt
index ee81419..76d3176 100644
--- a/Tests/InterfaceLibrary/CMakeLists.txt
+++ b/Tests/InterfaceLibrary/CMakeLists.txt
@@ -25,8 +25,23 @@ target_sources(iface_objlib INTERFACE $<TARGET_OBJECTS:objlib>)
 add_library(intermediate INTERFACE)
 target_link_libraries(intermediate INTERFACE iface_objlib)
 
+add_library(item_fake STATIC item_fake.cpp)
+add_library(item_real STATIC item.cpp)
+add_library(item_iface INTERFACE IMPORTED)
+set_property(TARGET item_iface PROPERTY IMPORTED_LINK_ITEM item_real)
+add_dependencies(item_iface item_real)
+link_directories(${CMAKE_CURRENT_BINARY_DIR})
+
 add_executable(InterfaceLibrary definetestexe.cpp)
-target_link_libraries(InterfaceLibrary iface_nodepends headeriface subiface intermediate)
+target_link_libraries(InterfaceLibrary
+  iface_nodepends
+  headeriface
+  subiface
+  intermediate
+
+  item_iface
+  item_fake # ensure that 'item_real' is ordered in place of item_iface
+  )
 
 add_subdirectory(libsdir)
 
diff --git a/Tests/InterfaceLibrary/definetestexe.cpp b/Tests/InterfaceLibrary/definetestexe.cpp
index 9044076..e6b7f58 100644
--- a/Tests/InterfaceLibrary/definetestexe.cpp
+++ b/Tests/InterfaceLibrary/definetestexe.cpp
@@ -17,8 +17,9 @@
 
 extern int obj();
 extern int sub();
+extern int item();
 
 int main(int,char**)
 {
-  return obj() + sub();
+  return obj() + sub() + item();
 }
diff --git a/Tests/InterfaceLibrary/item.cpp b/Tests/InterfaceLibrary/item.cpp
new file mode 100644
index 0000000..be612c9
--- /dev/null
+++ b/Tests/InterfaceLibrary/item.cpp
@@ -0,0 +1 @@
+int item() { return 0; }
diff --git a/Tests/InterfaceLibrary/item_fake.cpp b/Tests/InterfaceLibrary/item_fake.cpp
new file mode 100644
index 0000000..3944710
--- /dev/null
+++ b/Tests/InterfaceLibrary/item_fake.cpp
@@ -0,0 +1,2 @@
+extern int item_undefined();
+int item() { return item_undefined(); }
diff --git a/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-non-iface-result.txt b/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-non-iface-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-non-iface-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-non-iface-stderr.txt b/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-non-iface-stderr.txt
new file mode 100644
index 0000000..223474b
--- /dev/null
+++ b/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-non-iface-stderr.txt
@@ -0,0 +1,27 @@
+^CMake Error at IMPORTED_LINK_ITEM-non-iface.cmake:[0-9]+ \(set_property\):
+  IMPORTED_LINK_ITEM property may be set only on imported INTERFACE library
+  targets.
+
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Error at IMPORTED_LINK_ITEM-non-iface.cmake:[0-9]+ \(set_property\):
+  IMPORTED_LINK_ITEM property may be set only on imported INTERFACE library
+  targets.
+
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Error at IMPORTED_LINK_ITEM-non-iface.cmake:[0-9]+ \(set_property\):
+  IMPORTED_LINK_ITEM_DEBUG property may be set only on imported INTERFACE
+  library targets.
+
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Error at IMPORTED_LINK_ITEM-non-iface.cmake:[0-9]+ \(set_property\):
+  IMPORTED_LINK_ITEM_DEBUG property may be set only on imported INTERFACE
+  library targets.
+
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-non-iface.cmake b/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-non-iface.cmake
new file mode 100644
index 0000000..db93324
--- /dev/null
+++ b/Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-non-iface.cmake
@@ -0,0 +1,5 @@
+add_custom_target(MyTarget)
+set_property(TARGET MyTarget PROPERTY IMPORTED_LINK_ITEM item1)
+set_property(TARGET MyTarget APPEND PROPERTY IMPORTED_LINK_ITEM item2)
+set_property(TARGET MyTarget PROPERTY IMPORTED_LINK_ITEM_DEBUG item1)
+set_property(TARGET MyTarget APPEND PROPERTY IMPORTED_LINK_ITEM_DEBUG item2)
diff --git a/Tests/RunCMake/interface_library/RunCMakeTest.cmake b/Tests/RunCMake/interface_library/RunCMakeTest.cmake
index 201daa7..d49d773 100644
--- a/Tests/RunCMake/interface_library/RunCMakeTest.cmake
+++ b/Tests/RunCMake/interface_library/RunCMakeTest.cmake
@@ -8,3 +8,4 @@ run_cmake(invalid_signature)
 run_cmake(global-interface)
 run_cmake(genex_link)
 run_cmake(add_custom_command-TARGET)
+run_cmake(IMPORTED_LINK_ITEM-non-iface)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=726bee71d6bffe8a878ebad4f7ae2c10716fe76a
commit 726bee71d6bffe8a878ebad4f7ae2c10716fe76a
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue May 19 15:34:59 2015 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu May 21 09:19:06 2015 -0400

    cmTarget: Refactor GetMappedConfig to choose location property up front
    
    Store the IMPORTED_LOCATION property name in a variable up front
    to avoid duplicating the string literal.

diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 8a3716c..88ec61b 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -5401,6 +5401,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
     // and valid response.
     return true;
     }
+  std::string const locPropBase = "IMPORTED_LOCATION";
 
   // Track the configuration-specific property suffix.
   suffix = "_";
@@ -5427,7 +5428,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
     {
     // Look for this configuration.
     std::string mcUpper = cmSystemTools::UpperCase(*mci);
-    std::string locProp = "IMPORTED_LOCATION_";
+    std::string locProp = locPropBase + "_";
     locProp += mcUpper;
     *loc = this->GetProperty(locProp);
     if(allowImp)
@@ -5457,7 +5458,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
   // configurations.  Look for an exact-match.
   if(!*loc && !*imp)
     {
-    std::string locProp = "IMPORTED_LOCATION";
+    std::string locProp = locPropBase;
     locProp += suffix;
     *loc = this->GetProperty(locProp);
     if(allowImp)
@@ -5477,7 +5478,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
 
     // Look for a configuration-less location.  This may be set by
     // manually-written code.
-    *loc = this->GetProperty("IMPORTED_LOCATION");
+    *loc = this->GetProperty(locPropBase);
     if(allowImp)
       {
       *imp = this->GetProperty("IMPORTED_IMPLIB");
@@ -5499,7 +5500,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
       {
       suffix = "_";
       suffix += cmSystemTools::UpperCase(*aci);
-      std::string locProp = "IMPORTED_LOCATION";
+      std::string locProp = locPropBase;
       locProp += suffix;
       *loc = this->GetProperty(locProp);
       if(allowImp)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=38d55c7ccbd0dddbf12592cc55730a854ea4d9a4
commit 38d55c7ccbd0dddbf12592cc55730a854ea4d9a4
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue May 19 15:33:10 2015 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu May 21 09:19:06 2015 -0400

    cmTarget: Clarify comments in GetMappedConfig
    
    Clarify comments explaining the availability of a target location
    (file on disk) to distinguish this from the existence of the target.

diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 70005b4..8a3716c 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -5446,8 +5446,8 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
     }
 
   // If we needed to find one of the mapped configurations but did not
-  // then the target is not found.  The project does not want any
-  // other configuration.
+  // then the target location is not found.  The project does not want
+  // any other configuration.
   if(!mappedConfigs.empty() && !*loc && !*imp)
     {
     return false;
@@ -5510,7 +5510,8 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
         }
       }
     }
-  // If we have not yet found it then the target is not available.
+
+  // If we have not yet found it then the target location is not available.
   if(!*loc && !*imp)
     {
     return false;

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

Summary of changes:
 Help/manual/cmake-properties.7.rst                 |    2 +
 Help/prop_tgt/IMPORTED_LINK_ITEM.rst               |   27 +++++++
 ...ME_CONFIG.rst => IMPORTED_LINK_ITEM_CONFIG.rst} |    4 +-
 Help/release/dev/FindOpenGL-target.rst             |    5 ++
 Help/release/dev/imported-link-item.rst            |    7 ++
 Modules/FindOpenGL.cmake                           |   59 +++++++++++++++
 Source/cmComputeLinkInformation.cxx                |    7 ++
 Source/cmTarget.cxx                                |   77 ++++++++++++++------
 Source/cmTarget.h                                  |    3 +
 Tests/CMakeLists.txt                               |    1 +
 Tests/FindOpenGL/CMakeLists.txt                    |   11 +++
 Tests/FindOpenGL/Test/CMakeLists.txt               |   30 ++++++++
 Tests/FindOpenGL/Test/main.c                       |   30 ++++++++
 Tests/InterfaceLibrary/CMakeLists.txt              |   17 ++++-
 Tests/InterfaceLibrary/definetestexe.cpp           |    3 +-
 Tests/InterfaceLibrary/item.cpp                    |    1 +
 Tests/InterfaceLibrary/item_fake.cpp               |    2 +
 .../IMPORTED_LINK_ITEM-non-iface-result.txt}       |    0
 .../IMPORTED_LINK_ITEM-non-iface-stderr.txt        |   27 +++++++
 .../IMPORTED_LINK_ITEM-non-iface.cmake             |    5 ++
 .../RunCMake/interface_library/RunCMakeTest.cmake  |    1 +
 21 files changed, 292 insertions(+), 27 deletions(-)
 create mode 100644 Help/prop_tgt/IMPORTED_LINK_ITEM.rst
 copy Help/prop_tgt/{IMPORTED_NO_SONAME_CONFIG.rst => IMPORTED_LINK_ITEM_CONFIG.rst} (56%)
 create mode 100644 Help/release/dev/FindOpenGL-target.rst
 create mode 100644 Help/release/dev/imported-link-item.rst
 create mode 100644 Tests/FindOpenGL/CMakeLists.txt
 create mode 100644 Tests/FindOpenGL/Test/CMakeLists.txt
 create mode 100644 Tests/FindOpenGL/Test/main.c
 create mode 100644 Tests/InterfaceLibrary/item.cpp
 create mode 100644 Tests/InterfaceLibrary/item_fake.cpp
 copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => interface_library/IMPORTED_LINK_ITEM-non-iface-result.txt} (100%)
 create mode 100644 Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-non-iface-stderr.txt
 create mode 100644 Tests/RunCMake/interface_library/IMPORTED_LINK_ITEM-non-iface.cmake


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list