[cmake-developers] [PATCH] CMakeExpandImportedTargets: use INTERFACE_LINK_LIBRARIES if non-empty
Tamás Kenéz
tamas.kenez at gmail.com
Wed Jul 15 11:56:27 EDT 2015
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.kenez at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20150715/8472fec1/attachment-0001.html>
More information about the cmake-developers
mailing list