The CMakeExpandedImportedTargets module used only the deprecated
IMPORTED_LINK_INTERFACE_LIBRARIES property to resolve transitive
dependencies.
Since the current `install(EXPORT ...)` command generates target files that
populate INTERFACE_LINK_LIBRARIES instead, the expand module was not
working correctly with the imported libraries generated by `install(EXPORT
...)`.

I considered this a bugfix so I based the commit onto the release branch.

Please review and apply if it's ok.
Tamas


>From f2df88ec4180595a3fcc4c6be9b2d38e46162cc3 Mon Sep 17 00:00:00 2001
From: Tamas Kenez <tamas.ke...@gmail.com>
Date: Wed, 15 Jul 2015 17:47:50 +0200
Subject: [PATCH] CMakeExpandImportedTargets: use INTERFACE_LINK_LIBRARIES if
 non-empty

The deprecated IMPORTED_LINK_INTERFACE_LIBRARIES should be
overridden by INTERFACE_LINK_LIBRARIES if it's non-empty.

Unlike IMPORTED_LINK_INTERFACE_LIBRARIES, INTERFACE_LINK_LIBRARIES
usually contains config-related generator expressions which must
be resolved according to the selected configuration.
---
 Modules/CMakeExpandImportedTargets.cmake | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/Modules/CMakeExpandImportedTargets.cmake
b/Modules/CMakeExpandImportedTargets.cmake
index 8ac3364..b110e51 100644
--- a/Modules/CMakeExpandImportedTargets.cmake
+++ b/Modules/CMakeExpandImportedTargets.cmake
@@ -102,7 +102,27 @@ function(CMAKE_EXPAND_IMPORTED_TARGETS _RESULT )
             list(GET _importedConfigs ${_configIndexToUse}
_importedConfigToUse)

             get_target_property(_importedLocation "${_CURRENT_LIB}"
IMPORTED_LOCATION_${_importedConfigToUse})
-            get_target_property(_linkInterfaceLibs "${_CURRENT_LIB}"
IMPORTED_LINK_INTERFACE_LIBRARIES_${_importedConfigToUse} )
+            get_target_property(_linkInterfaceLibs "${_CURRENT_LIB}"
INTERFACE_LINK_LIBRARIES)
+            if(_linkInterfaceLibs)
+               # resolve $<CONFIG:...> generator expressions
+               string(REGEX REPLACE "\\$<CONFIG:${_importedConfigToUse}>"
"1"
+                  _linkInterfaceLibs "${_linkInterfaceLibs}")
+               string(REGEX REPLACE "\\$<CONFIG:[^>]*>" "0"
+                  _linkInterfaceLibs "${_linkInterfaceLibs}")
+               # resolve $<NOT:(0|1)>
+               string(REGEX REPLACE "\\$<NOT:0>" "1"
+                  _linkInterfaceLibs "${_linkInterfaceLibs}")
+               string(REGEX REPLACE "\\$<NOT:1>" "0"
+                  _linkInterfaceLibs "${_linkInterfaceLibs}")
+               # resolve $<(0|1):...>
+               # empty items will be ignored by `foreach` later
+               string(REGEX REPLACE "\\$<0:[^>]*>" ""
+                  _linkInterfaceLibs "${_linkInterfaceLibs}")
+               string(REGEX REPLACE "\\$<1:([^>]*)>" "\\1"
+                  _linkInterfaceLibs "${_linkInterfaceLibs}")
+            else()
+               get_target_property(_linkInterfaceLibs "${_CURRENT_LIB}"
IMPORTED_LINK_INTERFACE_LIBRARIES_${_importedConfigToUse} )
+            endif()

             list(APPEND _CCSR_NEW_REQ_LIBS  "${_importedLocation}")
 #            message(STATUS "Appending lib ${_CURRENT_LIB} as
${_importedLocation}")
-- 
1.9.4.msysgit.2
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to