Merge topic 'FindBoost-vs-prebuilt'

c3a281fd FindBoost: Search in official Windows prebuilt binary library directory
3720d5f4 FindBoost: Test `CMAKE_CXX_COMPILER_{ID,VERSION}` instead of `MSVC*`
This commit is contained in:
Brad King 2016-06-06 09:20:07 -04:00 committed by CMake Topic Stage
commit c3b268e40d

View File

@ -209,6 +209,7 @@
# Copyright 2007 Mike Jackson # Copyright 2007 Mike Jackson
# Copyright 2008 Andreas Pakulat <apaku@gmx.de> # Copyright 2008 Andreas Pakulat <apaku@gmx.de>
# Copyright 2008-2012 Philip Lowman <philip@yhbt.com> # Copyright 2008-2012 Philip Lowman <philip@yhbt.com>
# Copyright 2016 Alex Turbov <i.zaufi@gmail.com>
# #
# Distributed under the OSI-approved BSD License (the "License"); # Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details. # see accompanying file Copyright.txt for details.
@ -442,24 +443,26 @@ function(_Boost_GUESS_COMPILER_PREFIX _ret)
endif() endif()
elseif (GHSMULTI) elseif (GHSMULTI)
set(_boost_COMPILER "-ghs") set(_boost_COMPILER "-ghs")
elseif (MSVC14) elseif("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
set(_boost_COMPILER "-vc140") if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19)
elseif (MSVC12) set(_boost_COMPILER "-vc140")
set(_boost_COMPILER "-vc120") elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18)
elseif (MSVC11) set(_boost_COMPILER "-vc120")
set(_boost_COMPILER "-vc110") elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17)
elseif (MSVC10) set(_boost_COMPILER "-vc110")
set(_boost_COMPILER "-vc100") elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16)
elseif (MSVC90) set(_boost_COMPILER "-vc100")
set(_boost_COMPILER "-vc90") elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15)
elseif (MSVC80) set(_boost_COMPILER "-vc90")
set(_boost_COMPILER "-vc80") elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14)
elseif (MSVC71) set(_boost_COMPILER "-vc80")
set(_boost_COMPILER "-vc71") elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.10)
elseif (MSVC70) # Good luck! set(_boost_COMPILER "-vc71")
set(_boost_COMPILER "-vc7") # yes, this is correct elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13) # Good luck!
elseif (MSVC60) # Good luck! set(_boost_COMPILER "-vc7") # yes, this is correct
set(_boost_COMPILER "-vc6") # yes, this is correct else() # MSVC60 Good luck!
set(_boost_COMPILER "-vc6") # yes, this is correct
endif()
elseif (BORLAND) elseif (BORLAND)
set(_boost_COMPILER "-bcb") set(_boost_COMPILER "-bcb")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro") elseif(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
@ -861,6 +864,37 @@ function(_Boost_MISSING_DEPENDENCIES componentvar extravar)
set(${extravar} ${_boost_extra_components} PARENT_SCOPE) set(${extravar} ${_boost_extra_components} PARENT_SCOPE)
endfunction() endfunction()
#
# Update library search directory hint variable with paths used by prebuilt boost binaries.
#
# Prebuilt windows binaries (https://sourceforge.net/projects/boost/files/boost-binaries/)
# have library directories named using MSVC compiler version and architecture.
# This function would append corresponding directories if MSVC is a current compiler,
# so having `BOOST_ROOT` would be enough to specify to find everything.
#
macro(_Boost_UPDATE_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS componentlibvar basedir)
if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_arch_suffix 64)
else()
set(_arch_suffix 32)
endif()
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19)
list(APPEND ${componentlibvar} ${${basedir}}/lib${_arch_suffix}-msvc-14.0)
elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18)
list(APPEND ${componentlibvar} ${${basedir}}/lib${_arch_suffix}-msvc-12.0)
elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17)
list(APPEND ${componentlibvar} ${${basedir}}/lib${_arch_suffix}-msvc-11.0)
elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16)
list(APPEND ${componentlibvar} ${${basedir}}/lib${_arch_suffix}-msvc-10.0)
elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15)
list(APPEND ${componentlibvar} ${${basedir}}/lib${_arch_suffix}-msvc-9.0)
elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14)
list(APPEND ${componentlibvar} ${${basedir}}/lib${_arch_suffix}-msvc-8.0)
endif()
endif()
endmacro()
# #
# End functions/macros # End functions/macros
# #
@ -1261,7 +1295,8 @@ endif()
# g using debug versions of the standard and runtime # g using debug versions of the standard and runtime
# support libraries # support libraries
if(WIN32 AND Boost_USE_DEBUG_RUNTIME) if(WIN32 AND Boost_USE_DEBUG_RUNTIME)
if(MSVC OR "${CMAKE_CXX_COMPILER}" MATCHES "icl" if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC"
OR "${CMAKE_CXX_COMPILER}" MATCHES "icl"
OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc") OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc")
set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}g") set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}g")
endif() endif()
@ -1319,8 +1354,10 @@ foreach(c DEBUG RELEASE)
if(BOOST_ROOT) if(BOOST_ROOT)
list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} ${BOOST_ROOT}/lib ${BOOST_ROOT}/stage/lib) list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} ${BOOST_ROOT}/lib ${BOOST_ROOT}/stage/lib)
_Boost_UPDATE_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} BOOST_ROOT)
elseif(_ENV_BOOST_ROOT) elseif(_ENV_BOOST_ROOT)
list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} ${_ENV_BOOST_ROOT}/lib ${_ENV_BOOST_ROOT}/stage/lib) list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} ${_ENV_BOOST_ROOT}/lib ${_ENV_BOOST_ROOT}/stage/lib)
_Boost_UPDATE_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} _ENV_BOOST_ROOT)
endif() endif()
list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c}