summaryrefslogtreecommitdiffstats
path: root/Modules/FindBoost.cmake
diff options
context:
space:
mode:
authorMateusz Łoskot <mateusz@loskot.net>2018-11-07 23:12:03 (GMT)
committerBrad King <brad.king@kitware.com>2018-11-09 16:52:43 (GMT)
commitb71667a395dcbb32046646cf8a6f98ea8d595bba (patch)
treed73cd41fb9ac8565f951b3c24ef810181b497832 /Modules/FindBoost.cmake
parentcda0b14ec32ad3d3aa67dd12d75aa34ffb1bcd19 (diff)
downloadCMake-b71667a395dcbb32046646cf8a6f98ea8d595bba.zip
CMake-b71667a395dcbb32046646cf8a6f98ea8d595bba.tar.gz
CMake-b71667a395dcbb32046646cf8a6f98ea8d595bba.tar.bz2
FindBoost: Improve compiler prefix detection for GCC 5+ and clang 4+
Add recognition of compiler version and prefix for clang. Accommodate changes to version numbering scheme for GCC 5+ and clang 4+ - Minor number becomes patch, so excluded it from compiler prefix. - Improves searching for Boost 1.69+ libraries built with GCC 5+ and clang 4+, where library names are generated with compiler tag based on major version only eg. -gcc5 for GC 5.5.0 or -clang6 for clang 6.0.0 - Follows up related changes in upcoming Boost 1.69 https://github.com/boostorg/build/pull/349 Dump detected compiler version in Boost_DEBUG message. Replace use of CMAKE_COMPILER_IS_GNUCXX with CMAKE_CXX_COMPILER_ID.
Diffstat (limited to 'Modules/FindBoost.cmake')
-rw-r--r--Modules/FindBoost.cmake33
1 files changed, 26 insertions, 7 deletions
diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake
index 0794a6f..8cde30d 100644
--- a/Modules/FindBoost.cmake
+++ b/Modules/FindBoost.cmake
@@ -413,11 +413,17 @@ endmacro()
# Runs compiler with "-dumpversion" and parses major/minor
# version with a regex.
#
-function(_Boost_COMPILER_DUMPVERSION _OUTPUT_VERSION)
- string(REGEX REPLACE "([0-9]+)\\.([0-9]+)(\\.[0-9]+)?" "\\1\\2"
- _boost_COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION})
+function(_Boost_COMPILER_DUMPVERSION _OUTPUT_VERSION _OUTPUT_VERSION_MAJOR _OUTPUT_VERSION_MINOR)
+ string(REGEX REPLACE "([0-9]+)\\.([0-9]+)(\\.[0-9]+)?" "\\1"
+ _boost_COMPILER_VERSION_MAJOR ${CMAKE_CXX_COMPILER_VERSION})
+ string(REGEX REPLACE "([0-9]+)\\.([0-9]+)(\\.[0-9]+)?" "\\2"
+ _boost_COMPILER_VERSION_MINOR ${CMAKE_CXX_COMPILER_VERSION})
+
+ set(_boost_COMPILER_VERSION "${_boost_COMPILER_VERSION_MAJOR}${_boost_COMPILER_VERSION_MINOR}")
set(${_OUTPUT_VERSION} ${_boost_COMPILER_VERSION} PARENT_SCOPE)
+ set(${_OUTPUT_VERSION_MAJOR} ${_boost_COMPILER_VERSION_MAJOR} PARENT_SCOPE)
+ set(${_OUTPUT_VERSION_MINOR} ${_boost_COMPILER_VERSION_MINOR} PARENT_SCOPE)
endfunction()
#
@@ -482,15 +488,25 @@ function(_Boost_GUESS_COMPILER_PREFIX _ret)
if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34)
set(_boost_COMPILER "-mgw") # no GCC version encoding prior to 1.34
else()
- _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION)
+ _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION _boost_COMPILER_VERSION_MAJOR _boost_COMPILER_VERSION_MINOR)
set(_boost_COMPILER "-mgw${_boost_COMPILER_VERSION}")
endif()
elseif (UNIX)
- if (CMAKE_COMPILER_IS_GNUCXX)
+ _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION _boost_COMPILER_VERSION_MAJOR _boost_COMPILER_VERSION_MINOR)
+ if(NOT Boost_VERSION VERSION_LESS 106900)
+ # From GCC 5 and clang 4, versioning changes and minor becomes patch.
+ # For those compilers, patch is exclude from compiler tag in Boost 1.69+ library naming.
+ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND _boost_COMPILER_VERSION_MAJOR VERSION_GREATER 4)
+ set(_boost_COMPILER_VERSION "${_boost_COMPILER_VERSION_MAJOR}")
+ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND _boost_COMPILER_VERSION_MAJOR VERSION_GREATER 3)
+ set(_boost_COMPILER_VERSION "${_boost_COMPILER_VERSION_MAJOR}")
+ endif()
+ endif()
+
+ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34)
set(_boost_COMPILER "-gcc") # no GCC version encoding prior to 1.34
else()
- _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION)
# Determine which version of GCC we have.
if(APPLE)
if(Boost_MINOR_VERSION)
@@ -512,7 +528,10 @@ function(_Boost_GUESS_COMPILER_PREFIX _ret)
set(_boost_COMPILER "-gcc${_boost_COMPILER_VERSION}")
endif()
endif()
- endif ()
+ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ # TODO: Find out any Boost version constraints vs clang support.
+ set(_boost_COMPILER "-clang${_boost_COMPILER_VERSION}")
+ endif()
else()
# TODO at least Boost_DEBUG here?
set(_boost_COMPILER "")