diff options
author | Brad King <brad.king@kitware.com> | 2019-09-04 12:24:09 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-09-04 13:09:31 (GMT) |
commit | 907d3ed824d8b82525c687747662b358accded9c (patch) | |
tree | 6baaa730cb82ba91d00fb100cfb47dd0751da3a8 | |
parent | 2d357b7a682070fc98f520212d82efa821fc821c (diff) | |
download | CMake-907d3ed824d8b82525c687747662b358accded9c.zip CMake-907d3ed824d8b82525c687747662b358accded9c.tar.gz CMake-907d3ed824d8b82525c687747662b358accded9c.tar.bz2 |
FindBoost: Tolerate future Boost INTERFACE libraries
Since commit 0dd6772a89 (FindBoost: Add legacy variables and targets for
compatibility, 2019-06-14, v3.15.0-rc2~3^2~1) we query imported targets
provided by `BoostConfig.cmake` for their `IMPORTED_LOCATION_<cfg>`.
Querying this property is not allowed on INTERFACE libraries, so add a
condition to avoid doing so in case Boost adds one in the future.
Suggested-by: Alexander Grund <alexander.grund@tu-dresden.de>
Issue: #19656, #19402
-rw-r--r-- | Modules/FindBoost.cmake | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 845a373..078000f 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -353,14 +353,20 @@ function(_boost_set_legacy_variables_from_config) _boost_set_if_unset(Boost_${uppercomp}_LIBRARY "${target}") _boost_set_if_unset(Boost_${uppercomp}_LIBRARIES "${target}") # Very old legacy variable list(APPEND libraries "${target}") - foreach(cfg RELEASE DEBUG) - get_target_property(lib ${target} IMPORTED_LOCATION_${cfg}) - if(lib) - get_filename_component(lib_dir "${lib}" DIRECTORY) - list(APPEND library_dirs ${lib_dir}) - _boost_set_cache_if_unset(Boost_${uppercomp}_LIBRARY_${cfg} "${lib}") - endif() - endforeach() + get_property(type TARGET "${target}" PROPERTY TYPE) + if(NOT type STREQUAL "INTERFACE_LIBRARY") + foreach(cfg RELEASE DEBUG) + get_target_property(lib ${target} IMPORTED_LOCATION_${cfg}) + if(lib) + get_filename_component(lib_dir "${lib}" DIRECTORY) + list(APPEND library_dirs ${lib_dir}) + _boost_set_cache_if_unset(Boost_${uppercomp}_LIBRARY_${cfg} "${lib}") + endif() + endforeach() + elseif(Boost_DEBUG OR Boost_VERBOSE) + # For projects using only the Boost::* targets this warning can be safely ignored. + message(WARNING "Imported target '${target}' for required component '${comp}' has no artifact. Legacy variables for this component might be missing. Refer to the documentation of your Boost installation for help on variables to use.") + endif() _boost_get_canonical_target_name("${comp}" canonical_target) if(NOT TARGET "${canonical_target}") add_library("${canonical_target}" INTERFACE IMPORTED) |