FindBoost: Introduce new imported target Boost::headers

This commit is contained in:
Dennis Klein
2019-05-03 19:43:27 +02:00
parent d6c12f374d
commit 26634752d0
2 changed files with 20 additions and 5 deletions

View File

@@ -0,0 +1,5 @@
FindBoost-fphsa
---------------
* The :module:`FindBoost` module defines a new imported target
``Boost::headers`` (same as ``Boost::boost``).

View File

@@ -72,8 +72,9 @@ and saves search results persistently in CMake cache entries::
The following :prop_tgt:`IMPORTED` targets are also defined::
Boost::boost - Target for header-only dependencies
Boost::headers - Target for header-only dependencies
(Boost include directory)
alias: Boost::boost
Boost::<C> - Target for specific component dependency
(shared or static library); <C> is lower-
case
@@ -2062,15 +2063,24 @@ endif()
# ------------------------------------------------------------------------
if(Boost_FOUND)
# For header-only libraries
if(NOT TARGET Boost::boost)
add_library(Boost::boost INTERFACE IMPORTED)
# The builtin CMake package in Boost 1.70+ introduces a new name
# for the header-only lib, let's provide the same UI in module mode
if(NOT TARGET Boost::headers)
add_library(Boost::headers INTERFACE IMPORTED)
if(Boost_INCLUDE_DIRS)
set_target_properties(Boost::boost PROPERTIES
set_target_properties(Boost::headers PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}")
endif()
endif()
# Define the old target name for header-only libraries for backwards
# compat.
if(NOT TARGET Boost::boost)
add_library(Boost::boost INTERFACE IMPORTED)
set_target_properties(Boost::boost
PROPERTIES INTERFACE_LINK_LIBRARIES Boost::headers)
endif()
foreach(COMPONENT ${Boost_FIND_COMPONENTS})
if(_Boost_IMPORTED_TARGETS AND NOT TARGET Boost::${COMPONENT})
string(TOUPPER ${COMPONENT} UPPERCOMPONENT)