diff --git a/BoostConfig.cmake b/BoostConfig.cmake index 8c28ba6..a4df63a 100644 --- a/BoostConfig.cmake +++ b/BoostConfig.cmake @@ -44,11 +44,9 @@ # Boost_VERBOSE: Enable verbose output # Boost_DEBUG: Enable debug (even more verbose) output -if(Boost_VERBOSE OR Boost_DEBUG) - - message(STATUS "Found Boost ${Boost_VERSION} at ${Boost_DIR}") - +function(_boost_output_requested_configuration) # Output requested configuration (f.ex. "REQUIRED COMPONENTS filesystem") + # Function used for scoping if(Boost_FIND_QUIETLY) set(_BOOST_CONFIG "${_BOOST_CONFIG} QUIET") @@ -77,11 +75,12 @@ if(Boost_VERBOSE OR Boost_DEBUG) if(_BOOST_CONFIG) message(STATUS " Requested configuration:${_BOOST_CONFIG}") endif() +endfunction() - unset(_BOOST_CONFIG) - unset(_BOOST_COMPONENTS) - unset(_BOOST_OPTIONAL_COMPONENTS) +if(Boost_VERBOSE OR Boost_DEBUG) + message(STATUS "Found Boost ${Boost_VERSION} at ${Boost_DIR}") + _boost_output_requested_configuration() endif() macro(boost_find_component comp req) diff --git a/BoostDetectToolset.cmake b/BoostDetectToolset.cmake index 11c1f77..5928bf5 100644 --- a/BoostDetectToolset.cmake +++ b/BoostDetectToolset.cmake @@ -2,155 +2,149 @@ # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) -string(REGEX MATCHALL "[0-9]+" _BOOST_COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION}) +function(boost_detect_toolset) + string(REGEX MATCHALL "[0-9]+" _BOOST_COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION}) -list(GET _BOOST_COMPILER_VERSION 0 _BOOST_COMPILER_VERSION_MAJOR) -list(GET _BOOST_COMPILER_VERSION 1 _BOOST_COMPILER_VERSION_MINOR) + list(GET _BOOST_COMPILER_VERSION 0 _BOOST_COMPILER_VERSION_MAJOR) + list(GET _BOOST_COMPILER_VERSION 1 _BOOST_COMPILER_VERSION_MINOR) -if(BORLAND) + if(BORLAND) - # Borland is unversioned + # Borland is unversioned - set(BOOST_DETECTED_TOOLSET "bcb") + set(BOOST_DETECTED_TOOLSET "bcb") - set(_BOOST_COMPILER_VERSION_MAJOR) - set(_BOOST_COMPILER_VERSION_MINOR) - -elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") - - set(BOOST_DETECTED_TOOLSET "clang-darwin") - -elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - - if(MSVC) - set(BOOST_DETECTED_TOOLSET "clangw") - else() - set(BOOST_DETECTED_TOOLSET "clang") - endif() - - if(_BOOST_COMPILER_VERSION_MAJOR GREATER 3) + set(_BOOST_COMPILER_VERSION_MAJOR) set(_BOOST_COMPILER_VERSION_MINOR) - endif() - -elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - if(WIN32) + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") - # Intel-Win is unversioned + set(BOOST_DETECTED_TOOLSET "clang-darwin") - set(BOOST_DETECTED_TOOLSET "iw") + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - set(_BOOST_COMPILER_VERSION_MAJOR) - set(_BOOST_COMPILER_VERSION_MINOR) + if(MSVC) + set(BOOST_DETECTED_TOOLSET "clangw") + else() + set(BOOST_DETECTED_TOOLSET "clang") + endif() - else() + if(_BOOST_COMPILER_VERSION_MAJOR GREATER 3) + set(_BOOST_COMPILER_VERSION_MINOR) + endif() - set(BOOST_DETECTED_TOOLSET "il") + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - endif() + if(WIN32) -elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MIPSpro") + # Intel-Win is unversioned - set(BOOST_DETECTED_TOOLSET "mp") + set(BOOST_DETECTED_TOOLSET "iw") -elseif(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro") + set(_BOOST_COMPILER_VERSION_MAJOR) + set(_BOOST_COMPILER_VERSION_MINOR) - set(BOOST_DETECTED_TOOLSET "sun") + else() -elseif(CMAKE_CXX_COMPILER_ID STREQUAL "IBM XL") + set(BOOST_DETECTED_TOOLSET "il") - set(BOOST_DETECTED_TOOLSET "xlc") + endif() -elseif(MINGW) + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MIPSpro") - set(BOOST_DETECTED_TOOLSET "mgw") + set(BOOST_DETECTED_TOOLSET "mp") - if(_BOOST_COMPILER_VERSION_MAJOR GREATER 4) - set(_BOOST_COMPILER_VERSION_MINOR) - endif() + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro") -elseif(CMAKE_COMPILER_IS_GNUCXX) + set(BOOST_DETECTED_TOOLSET "sun") - if(APPLE) - set(BOOST_DETECTED_TOOLSET "xgcc") - else() - set(BOOST_DETECTED_TOOLSET "gcc") - endif() + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "IBM XL") - if(_BOOST_COMPILER_VERSION_MAJOR GREATER 4) - set(_BOOST_COMPILER_VERSION_MINOR) - endif() + set(BOOST_DETECTED_TOOLSET "xlc") -elseif(MSVC) + elseif(MINGW) - if((MSVC_VERSION GREATER 1919) AND (MSVC_VERSION LESS 1930)) + set(BOOST_DETECTED_TOOLSET "mgw") - set(BOOST_DETECTED_TOOLSET "vc142") + if(_BOOST_COMPILER_VERSION_MAJOR GREATER 4) + set(_BOOST_COMPILER_VERSION_MINOR) + endif() - elseif((MSVC_VERSION GREATER 1909) AND (MSVC_VERSION LESS 1920)) + elseif(CMAKE_COMPILER_IS_GNUCXX) - set(BOOST_DETECTED_TOOLSET "vc141") + if(APPLE) + set(BOOST_DETECTED_TOOLSET "xgcc") + else() + set(BOOST_DETECTED_TOOLSET "gcc") + endif() - elseif(MSVC_VERSION EQUAL 1900) + if(_BOOST_COMPILER_VERSION_MAJOR GREATER 4) + set(_BOOST_COMPILER_VERSION_MINOR) + endif() - set(BOOST_DETECTED_TOOLSET "vc140") + elseif(MSVC) - elseif(MSVC_VERSION EQUAL 1800) + if((MSVC_VERSION GREATER 1919) AND (MSVC_VERSION LESS 1930)) - set(BOOST_DETECTED_TOOLSET "vc120") + set(BOOST_DETECTED_TOOLSET "vc142") - elseif(MSVC_VERSION EQUAL 1700) + elseif((MSVC_VERSION GREATER 1909) AND (MSVC_VERSION LESS 1920)) - set(BOOST_DETECTED_TOOLSET "vc110") + set(BOOST_DETECTED_TOOLSET "vc141") - elseif(MSVC_VERSION EQUAL 1600) + elseif(MSVC_VERSION EQUAL 1900) - set(BOOST_DETECTED_TOOLSET "vc100") + set(BOOST_DETECTED_TOOLSET "vc140") - elseif(MSVC_VERSION EQUAL 1500) + elseif(MSVC_VERSION EQUAL 1800) - set(BOOST_DETECTED_TOOLSET "vc90") + set(BOOST_DETECTED_TOOLSET "vc120") - elseif(MSVC_VERSION EQUAL 1400) + elseif(MSVC_VERSION EQUAL 1700) - set(BOOST_DETECTED_TOOLSET "vc80") + set(BOOST_DETECTED_TOOLSET "vc110") - elseif(MSVC_VERSION EQUAL 1310) + elseif(MSVC_VERSION EQUAL 1600) - set(BOOST_DETECTED_TOOLSET "vc71") + set(BOOST_DETECTED_TOOLSET "vc100") - elseif(MSVC_VERSION EQUAL 1300) + elseif(MSVC_VERSION EQUAL 1500) - set(BOOST_DETECTED_TOOLSET "vc7") + set(BOOST_DETECTED_TOOLSET "vc90") - elseif(MSVC_VERSION EQUAL 1200) + elseif(MSVC_VERSION EQUAL 1400) - set(BOOST_DETECTED_TOOLSET "vc6") + set(BOOST_DETECTED_TOOLSET "vc80") - endif() + elseif(MSVC_VERSION EQUAL 1310) - set(_BOOST_COMPILER_VERSION_MAJOR) - set(_BOOST_COMPILER_VERSION_MINOR) + set(BOOST_DETECTED_TOOLSET "vc71") -endif() + elseif(MSVC_VERSION EQUAL 1300) -# Add version + set(BOOST_DETECTED_TOOLSET "vc7") -if(BOOST_DETECTED_TOOLSET) - set(BOOST_DETECTED_TOOLSET ${BOOST_DETECTED_TOOLSET}${_BOOST_COMPILER_VERSION_MAJOR}${_BOOST_COMPILER_VERSION_MINOR}) -endif() + elseif(MSVC_VERSION EQUAL 1200) -unset(_BOOST_COMPILER_VERSION) -unset(_BOOST_COMPILER_VERSION_MAJOR) -unset(_BOOST_COMPILER_VERSION_MINOR) + set(BOOST_DETECTED_TOOLSET "vc6") -if("${BOOST_DETECTED_TOOLSET}" STREQUAL "") + endif() - # Unknown toolset - message(STATUS "Boost toolset is unknown (compiler ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION})") + set(_BOOST_COMPILER_VERSION_MAJOR) + set(_BOOST_COMPILER_VERSION_MINOR) -elseif(Boost_DEBUG) + endif() - message(STATUS "Boost toolset is ${BOOST_DETECTED_TOOLSET} (${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION})") + # Add version -endif() + if(BOOST_DETECTED_TOOLSET) + set(BOOST_DETECTED_TOOLSET ${BOOST_DETECTED_TOOLSET}${_BOOST_COMPILER_VERSION_MAJOR}${_BOOST_COMPILER_VERSION_MINOR} PARENT_SCOPE) + if(Boost_DEBUG) + message(STATUS "Boost toolset is ${BOOST_DETECTED_TOOLSET} (${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION})") + endif() + else() + set(BOOST_DETECTED_TOOLSET "" PARENT_SCOPE) + # Unknown toolset + message(STATUS "Boost toolset is unknown (compiler ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION})") + endif() +endfunction() diff --git a/BoostFindVariants.cmake b/BoostFindVariants.cmake new file mode 100644 index 0000000..e301427 --- /dev/null +++ b/BoostFindVariants.cmake @@ -0,0 +1,54 @@ + +# Find variants of a library by searching for lib-variant*.cmake +# files in the current folder +# name -- Name, e.g. 'system' +# lib_name -- Library name, e.g. 'boost_system' +function(boost_find_variants name lib_name) + if(NOT DEFINED _BOOST_LIBDIR) + message(FATAL_ERROR "Internal error: _BOOST_LIBDIR not defined") + endif() + + include(${CMAKE_CURRENT_LIST_DIR}/../BoostDetectToolset.cmake) + + if(Boost_DEBUG) + message(STATUS "Scanning ${CMAKE_CURRENT_LIST_DIR}/lib${lib_name}-variant*.cmake") + endif() + + file(GLOB __boost_variants "${CMAKE_CURRENT_LIST_DIR}/lib${lib_name}-variant*.cmake") + + set(__boost_skipped "") + macro(_BOOST_SKIPPED fname reason) + if(Boost_VERBOSE OR Boost_DEBUG) + message(STATUS " [ ] ${fname}") + endif() + list(APPEND __boost_skipped "${fname} (${reason})") + endmacro() + + string(TOUPPER "_BOOST_${name}_DEPS" deps_var) + set(${deps_var} "") + + foreach(f IN LISTS __boost_variants) + if(Boost_DEBUG) + message(STATUS " Including ${f}") + endif() + include(${f}) + endforeach() + + get_target_property(__boost_configs Boost::${name} IMPORTED_CONFIGURATIONS) + + if(__boost_variants AND NOT __boost_configs) + set(__boost_message "No suitable build variant has been found.") + if(__boost_skipped) + set(__boost_message "${__boost_message}\nThe following variants have been tried and rejected:") + foreach(s IN LISTS __boost_skipped) + set(__boost_message "${__boost_message}\n* ${s}") + endforeach() + endif() + set(${lib_name}_FOUND 0 PARENT_SCOPE) + set(${lib_name}_NOT_FOUND_MESSAGE "${__boost_message}" PARENT_SCOPE) + else() + set(${lib_name}_FOUND 1 PARENT_SCOPE) + list(REMOVE_DUPLICATES ${deps_var}) + set(${deps_var} "${${deps_var}}" PARENT_SCOPE) + endif() +endfunction() diff --git a/boost-install.jam b/boost-install.jam index f2e2999..c6c7b2e 100644 --- a/boost-install.jam +++ b/boost-install.jam @@ -500,7 +500,7 @@ local rule get-dir ( name : dir ) { print.text - "get_filename_component($(name) \"${_BOOST_CMAKEDIR}/$(dir)/\" ABSOLUTE)" + "get_filename_component($(name) \"${CMAKE_CURRENT_LIST_DIR}/../$(dir)/\" ABSOLUTE)" : true ; } @@ -549,12 +549,9 @@ rule generate-cmake-config- ( target : sources * : properties * ) " message(STATUS \"Found $(name) ${$(name)_VERSION} at ${$(name)_DIR}\")" "endif()" "" - "# Compute the include and library directories relative to this file." - "get_filename_component(_BOOST_CMAKEDIR \"${CMAKE_CURRENT_LIST_DIR}/../\" ABSOLUTE)" : true ; get-dir "_BOOST_INCLUDEDIR" : $(includedir) ; - get-dir "_BOOST_LIBDIR" : $(libdir) ; print.text @@ -564,67 +561,26 @@ rule generate-cmake-config- ( target : sources * : properties * ) "" "set_target_properties($(ltarget) PROPERTIES" " INTERFACE_INCLUDE_DIRECTORIES \"\${_BOOST_INCLUDEDIR}\"" - " INTERFACE_COMPILE_DEFINITIONS \"BOOST_ALL_NO_LIB\"" + " INTERFACE_COMPILE_DEFINITIONS BOOST_ALL_NO_LIB" ")" + "unset(_BOOST_INCLUDEDIR)" "" : true ; if $(library-type) != INTERFACE { + get-dir "_BOOST_LIBDIR" : $(libdir) ; print.text - "include(${CMAKE_CURRENT_LIST_DIR}/../BoostDetectToolset-$(version).cmake)" - "" - "if(Boost_DEBUG)" - " message(STATUS \"Scanning ${CMAKE_CURRENT_LIST_DIR}/lib$(name)-variant*.cmake\")" - "endif()" - "" - "file(GLOB __boost_variants \"${CMAKE_CURRENT_LIST_DIR}/lib$(name)-variant*.cmake\")" - "" - "macro(_BOOST_SKIPPED fname reason)" - " if(Boost_VERBOSE OR Boost_DEBUG)" - " message(STATUS \" [ ] ${fname}\")" - " endif()" - " list(APPEND __boost_skipped \"${fname} (${reason})\")" - "endmacro()" - "" - "foreach(f IN LISTS __boost_variants)" - " if(Boost_DEBUG)" - " message(STATUS \" Including ${f}\")" - " endif()" - " include(${f})" - "endforeach()" - "" + "include(${CMAKE_CURRENT_LIST_DIR}/../BoostFindVariants.cmake)" + "boost_find_variants($(lname) $(name))" "unset(_BOOST_LIBDIR)" - "unset(_BOOST_INCLUDEDIR)" - "unset(_BOOST_CMAKEDIR)" - "" - "get_target_property(__boost_configs $(ltarget) IMPORTED_CONFIGURATIONS)" "" - "if(__boost_variants AND NOT __boost_configs)" - " set(__boost_message \"No suitable build variant has been found.\")" - " if(__boost_skipped)" - " set(__boost_message \"${__boost_message}\\nThe following variants have been tried and rejected:\")" - " foreach(s IN LISTS __boost_skipped)" - " set(__boost_message \"${__boost_message}\\n* ${s}\")" - " endforeach()" - " endif()" - " set($(name)_FOUND 0)" - " set($(name)_NOT_FOUND_MESSAGE ${__boost_message})" - " unset(__boost_message)" - " unset(__boost_skipped)" - " unset(__boost_configs)" - " unset(__boost_variants)" - " unset(_BOOST_$(lname:U)_DEPS)" + "if(NOT $(name)_FOUND)" " return()" "endif()" "" - "unset(__boost_skipped)" - "unset(__boost_configs)" - "unset(__boost_variants)" - "" "if(_BOOST_$(lname:U)_DEPS)" - " list(REMOVE_DUPLICATES _BOOST_$(lname:U)_DEPS)" " if(Boost_VERBOSE OR Boost_DEBUG)" " message(STATUS \"Adding $(name) dependencies: ${_BOOST_$(lname:U)_DEPS}\")" " endif()" @@ -805,9 +761,6 @@ rule install-cmake-config ( name * ) { local p = [ project.current ] ; - alias install-detect-toolset ; - $(p).mark-target-as-explicit install-detect-toolset ; - alias install-cmake-config ; $(p).mark-target-as-explicit install-cmake-config ; } @@ -837,14 +790,19 @@ rule install-cmake-config ( name * ) local p = [ project.current ] ; - # Target install-detect-toolset - local boost-install-dir = [ modules.binding $(__name__) ] ; boost-install-dir = $(boost-install-dir:D) ; - install install-detect-toolset : $(boost-install-dir)/BoostDetectToolset.cmake : $(cmakedir) BoostDetectToolset-$(BOOST_VERSION).cmake ; + # Target install-detect-toolset + + install install-detect-toolset : $(boost-install-dir)/BoostDetectToolset.cmake : $(cmakedir) ; $(p).mark-target-as-explicit install-detect-toolset ; + # Target install-find-variants + + install install-find-variants : $(boost-install-dir)/BoostFindVariants.cmake : $(cmakedir) ; + $(p).mark-target-as-explicit install-find-variants ; + # Target install-boost-config install install-boost-config : $(boost-install-dir)/BoostConfig.cmake : $(cmakedir)/Boost-$(BOOST_VERSION) ; @@ -860,7 +818,7 @@ rule install-cmake-config ( name * ) # Target install-cmake-config - alias install-cmake-config : $(configs) install-detect-toolset install-boost-config install-boost-config-version ; + alias install-cmake-config : $(configs) install-detect-toolset install-find-variants install-boost-config install-boost-config-version ; $(p).mark-target-as-explicit install-cmake-config ; } }