diff options
Diffstat (limited to 'Modules/CMakeExpandImportedTargets.cmake')
-rw-r--r-- | Modules/CMakeExpandImportedTargets.cmake | 75 |
1 files changed, 44 insertions, 31 deletions
diff --git a/Modules/CMakeExpandImportedTargets.cmake b/Modules/CMakeExpandImportedTargets.cmake index f5c009cad..ad065f050 100644 --- a/Modules/CMakeExpandImportedTargets.cmake +++ b/Modules/CMakeExpandImportedTargets.cmake @@ -1,36 +1,41 @@ -# CMAKE_EXPAND_IMPORTED_TARGETS(<var> LIBRARIES lib1 lib2...libN -# [CONFIGURATION <config>] ) +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#.rst: +# CMakeExpandImportedTargets +# -------------------------- +# +# Deprecated. Do not use. +# +# This module was once needed to expand imported targets to the underlying +# libraries they reference on disk for use with the :command:`try_compile` +# and :command:`try_run` commands. These commands now support imported +# libraries in their ``LINK_LIBRARIES`` options (since CMake 2.8.11 +# for :command:`try_compile` and since CMake 3.2 for :command:`try_run`). +# +# This module does not support the policy :policy:`CMP0022` ``NEW`` +# behavior or use of the :prop_tgt:`INTERFACE_LINK_LIBRARIES` property +# because :manual:`generator expressions <cmake-generator-expressions(7)>` +# cannot be evaluated during configuration. +# +# :: +# +# CMAKE_EXPAND_IMPORTED_TARGETS(<var> LIBRARIES lib1 lib2...libN +# [CONFIGURATION <config>]) # # CMAKE_EXPAND_IMPORTED_TARGETS() takes a list of libraries and replaces -# all imported targets contained in this list with their actual file paths -# of the referenced libraries on disk, including the libraries from their -# link interfaces. -# If a CONFIGURATION is given, it uses the respective configuration of the -# imported targets if it exists. If no CONFIGURATION is given, it uses -# the first configuration from ${CMAKE_CONFIGURATION_TYPES} if set, otherwise -# ${CMAKE_BUILD_TYPE}. -# This macro is used by all Check*.cmake files which use -# try_compile() or try_run() and support CMAKE_REQUIRED_LIBRARIES , so that -# these checks support imported targets in CMAKE_REQUIRED_LIBRARIES: -# cmake_expand_imported_targets(expandedLibs LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -# CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}" ) - - -#============================================================================= -# Copyright 2012 Kitware, Inc. -# Copyright 2009-2012 Alexander Neundorf <neundorf@kde.org> +# all imported targets contained in this list with their actual file +# paths of the referenced libraries on disk, including the libraries +# from their link interfaces. If a CONFIGURATION is given, it uses the +# respective configuration of the imported targets if it exists. If no +# CONFIGURATION is given, it uses the first configuration from +# ${CMAKE_CONFIGURATION_TYPES} if set, otherwise ${CMAKE_BUILD_TYPE}. # -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. +# :: # -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake) +# cmake_expand_imported_targets(expandedLibs +# LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} +# CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}" ) function(CMAKE_EXPAND_IMPORTED_TARGETS _RESULT ) @@ -63,7 +68,11 @@ function(CMAKE_EXPAND_IMPORTED_TARGETS _RESULT ) set(_CCSR_NEW_REQ_LIBS ) set(_CHECK_FOR_IMPORTED_TARGETS FALSE) foreach(_CURRENT_LIB ${_CCSR_REQ_LIBS}) - get_target_property(_importedConfigs "${_CURRENT_LIB}" IMPORTED_CONFIGURATIONS) + if(TARGET "${_CURRENT_LIB}") + get_target_property(_importedConfigs "${_CURRENT_LIB}" IMPORTED_CONFIGURATIONS) + else() + set(_importedConfigs "") + endif() if (_importedConfigs) # message(STATUS "Detected imported target ${_CURRENT_LIB}") # Ok, so this is an imported target. @@ -115,7 +124,11 @@ function(CMAKE_EXPAND_IMPORTED_TARGETS _RESULT ) # all remaining imported target names (there shouldn't be any left anyway). set(_CCSR_NEW_REQ_LIBS ) foreach(_CURRENT_LIB ${_CCSR_REQ_LIBS}) - get_target_property(_importedConfigs "${_CURRENT_LIB}" IMPORTED_CONFIGURATIONS) + if(TARGET "${_CURRENT_LIB}") + get_target_property(_importedConfigs "${_CURRENT_LIB}" IMPORTED_CONFIGURATIONS) + else() + set(_importedConfigs "") + endif() if (NOT _importedConfigs) list(APPEND _CCSR_NEW_REQ_LIBS "${_CURRENT_LIB}" ) # message(STATUS "final: appending ${_CURRENT_LIB}") |