diff options
author | Deniz Bahadir <d.bahadir@gmx.de> | 2017-08-31 10:46:36 (GMT) |
---|---|---|
committer | Deniz Bahadir <dbahadir@benocs.com> | 2017-09-06 15:58:45 (GMT) |
commit | e6159e1842650c894c642964f448b01ae6eb8a99 (patch) | |
tree | 3ee53f3bf3423a64cca172a2b3fa2509873f53fa /Modules/FindBoost.cmake | |
parent | b4efc1936ac4d4154c7d9215165a805b2a6056d5 (diff) | |
download | CMake-e6159e1842650c894c642964f448b01ae6eb8a99.zip CMake-e6159e1842650c894c642964f448b01ae6eb8a99.tar.gz CMake-e6159e1842650c894c642964f448b01ae6eb8a99.tar.bz2 |
FindBoost: Add option to prevent finding DEBUG/RELEASE Boost-libs
With the use of options `Boost_USE_DEBUG_LIBS` and
`Boost_USE_RELEASE_LIBS` it is now possible to skip searching for either
DEBUG or RELEASE Boost libraries.
This is useful if Boost is installed on the system in multiple
directories but only one of them should be used which only contains e.g.
the RELEASE libraries. Without this change the DEBUG libraries might be
found in the other directory which might not be desired at all.
Diffstat (limited to 'Modules/FindBoost.cmake')
-rw-r--r-- | Modules/FindBoost.cmake | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index b28f2b8..7de5b5b 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -107,6 +107,10 @@ # Users or projects may tell this module which variant to find by # setting variables:: # +# Boost_USE_DEBUG_LIBS - Set to ON or OFF to specify whether to search +# and use the debug libraries. Default is ON. +# Boost_USE_RELEASE_LIBS - Set to ON or OFF to specify whether to search +# and use the release libraries. Default is ON. # Boost_USE_MULTITHREADED - Set to OFF to use the non-multithreaded # libraries ('mt' tag). Default is ON. # Boost_USE_STATIC_LIBS - Set to ON to force the use of the static @@ -183,9 +187,11 @@ # target_link_libraries(foo Boost::date_time Boost::filesystem # Boost::iostreams) # -# Example to find Boost headers and some *static* libraries:: +# Example to find Boost headers and some *static* (release only) libraries:: # -# set(Boost_USE_STATIC_LIBS ON) # only find static libs +# set(Boost_USE_STATIC_LIBS ON) # only find static libs +# set(Boost_USE_DEBUG_LIBS OFF) # ignore debug libs and +# set(Boost_USE_RELEASE_LIBS ON) # only find release libs # set(Boost_USE_MULTITHREADED ON) # set(Boost_USE_STATIC_RUNTIME OFF) # find_package(Boost 1.36.0 COMPONENTS date_time filesystem system ...) @@ -298,7 +304,7 @@ macro(_Boost_ADJUST_LIB_VARS basename) endif() # If the debug & release library ends up being the same, omit the keywords - if(${Boost_${basename}_LIBRARY_RELEASE} STREQUAL ${Boost_${basename}_LIBRARY_DEBUG}) + if("${Boost_${basename}_LIBRARY_RELEASE}" STREQUAL "${Boost_${basename}_LIBRARY_DEBUG}") set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} ) set(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE} ) endif() @@ -996,8 +1002,14 @@ if(NOT Boost_LIBRARY_DIR_DEBUG AND Boost_LIBRARY_DIR) set(Boost_LIBRARY_DIR_DEBUG "${Boost_LIBRARY_DIR}") endif() +if(NOT DEFINED Boost_USE_DEBUG_LIBS) + set(Boost_USE_DEBUG_LIBS TRUE) +endif() +if(NOT DEFINED Boost_USE_RELEASE_LIBS) + set(Boost_USE_RELEASE_LIBS TRUE) +endif() if(NOT DEFINED Boost_USE_MULTITHREADED) - set(Boost_USE_MULTITHREADED TRUE) + set(Boost_USE_MULTITHREADED TRUE) endif() if(NOT DEFINED Boost_USE_DEBUG_RUNTIME) set(Boost_USE_DEBUG_RUNTIME TRUE) @@ -1631,12 +1643,14 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS}) # Avoid passing backslashes to _Boost_FIND_LIBRARY due to macro re-parsing. string(REPLACE "\\" "/" _boost_LIBRARY_SEARCH_DIRS_tmp "${_boost_LIBRARY_SEARCH_DIRS_RELEASE}") - _Boost_FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE RELEASE - NAMES ${_boost_RELEASE_NAMES} - HINTS ${_boost_LIBRARY_SEARCH_DIRS_tmp} - NAMES_PER_DIR - DOC "${_boost_docstring_release}" - ) + if(Boost_USE_RELEASE_LIBS) + _Boost_FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE RELEASE + NAMES ${_boost_RELEASE_NAMES} + HINTS ${_boost_LIBRARY_SEARCH_DIRS_tmp} + NAMES_PER_DIR + DOC "${_boost_docstring_release}" + ) + endif() # # Find DEBUG libraries @@ -1680,12 +1694,14 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS}) # Avoid passing backslashes to _Boost_FIND_LIBRARY due to macro re-parsing. string(REPLACE "\\" "/" _boost_LIBRARY_SEARCH_DIRS_tmp "${_boost_LIBRARY_SEARCH_DIRS_DEBUG}") - _Boost_FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG DEBUG - NAMES ${_boost_DEBUG_NAMES} - HINTS ${_boost_LIBRARY_SEARCH_DIRS_tmp} - NAMES_PER_DIR - DOC "${_boost_docstring_debug}" - ) + if(Boost_USE_DEBUG_LIBS) + _Boost_FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG DEBUG + NAMES ${_boost_DEBUG_NAMES} + HINTS ${_boost_LIBRARY_SEARCH_DIRS_tmp} + NAMES_PER_DIR + DOC "${_boost_docstring_debug}" + ) + endif () if(Boost_REALPATH) _Boost_SWAP_WITH_REALPATH(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "${_boost_docstring_release}") |