Add BoostDetectToolset.cmake

This commit is contained in:
Peter Dimov
2018-10-05 03:45:42 +03:00
parent 58a4675f66
commit 23ec01f93a
2 changed files with 146 additions and 8 deletions

131
BoostDetectToolset.cmake Normal file
View File

@@ -0,0 +1,131 @@
# Copyright 2017, 2018 Peter Dimov
# 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 REPLACE "([0-9]+)\\.([0-9]+)(\\..*)?" "\\1\\2" _BOOST_COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION})
if(BORLAND)
# Borland is unversioned
set(BOOST_DETECTED_TOOLSET "bcb")
unset(_BOOST_COMPILER_VERSION)
elseif(MINGW)
set(BOOST_DETECTED_TOOLSET "mgw")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set(BOOST_DETECTED_TOOLSET "clang-darwin")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(BOOST_DETECTED_TOOLSET "clang")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
if(WIN32)
# Intel-Win is unversioned
set(BOOST_DETECTED_TOOLSET "iw")
unset(_BOOST_COMPILER_VERSION)
else()
set(BOOST_DETECTED_TOOLSET "il")
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MIPSpro")
set(BOOST_DETECTED_TOOLSET "mp")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
set(BOOST_DETECTED_TOOLSET "sun")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "IBM XL")
set(BOOST_DETECTED_TOOLSET "xlc")
elseif(CMAKE_COMPILER_IS_GNUCXX)
if(APPLE)
set(BOOST_DETECTED_TOOLSET "xgcc")
else()
set(BOOST_DETECTED_TOOLSET "gcc")
endif()
elseif(MSVC)
if(MSVC_VERSION EQUAL 1910)
set(BOOST_DETECTED_TOOLSET "vc141")
elseif(MSVC_VERSION EQUAL 1900)
set(BOOST_DETECTED_TOOLSET "vc140")
elseif(MSVC_VERSION EQUAL 1800)
set(BOOST_DETECTED_TOOLSET "vc120")
elseif(MSVC_VERSION EQUAL 1700)
set(BOOST_DETECTED_TOOLSET "vc110")
elseif(MSVC_VERSION EQUAL 1600)
set(BOOST_DETECTED_TOOLSET "vc100")
elseif(MSVC_VERSION EQUAL 1500)
set(BOOST_DETECTED_TOOLSET "vc90")
elseif(MSVC_VERSION EQUAL 1400)
set(BOOST_DETECTED_TOOLSET "vc80")
elseif(MSVC_VERSION EQUAL 1310)
set(BOOST_DETECTED_TOOLSET "vc71")
elseif(MSVC_VERSION EQUAL 1300)
set(BOOST_DETECTED_TOOLSET "vc7")
elseif(MSVC_VERSION EQUAL 1200)
set(BOOST_DETECTED_TOOLSET "vc6")
endif()
unset(_BOOST_COMPILER_VERSION)
else()
# Unknown toolset
if(Boost_DEBUG)
message(STATUS "BoostDetectToolset: unknown compiler ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
endif()
return()
endif()
# Add version
set(BOOST_DETECTED_TOOLSET ${BOOST_DETECTED_TOOLSET}${_BOOST_COMPILER_VERSION})
unset(_BOOST_COMPILER_VERSION)
if(Boost_DEBUG)
message(STATUS "Boost toolset is ${BOOST_DETECTED_TOOLSET} (${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION})")
endif()

View File

@@ -85,7 +85,7 @@ rule generate-cmake-variant- ( target : sources * : properties * )
"# Generated by Boost $(version)"
""
"if(Boost_DEBUG)"
" message(STATUS \"Found $(fname)\")"
" message(STATUS \" Found $(fname)\")"
"endif()"
""
: true ;
@@ -214,7 +214,7 @@ rule generate-cmake-variant- ( target : sources * : properties * )
"if(CMAKE_SIZEOF_VOID_P EQUAL 8)"
" if(Boost_DEBUG)"
" message(STATUS \" skipped due to CMAKE_SIZEOF_VOID_P EQUAL 8\")"
" message(STATUS \" skipped due to CMAKE_SIZEOF_VOID_P == 8\")"
" endif()"
" return()"
"endif()"
@@ -227,7 +227,7 @@ rule generate-cmake-variant- ( target : sources * : properties * )
"if(CMAKE_SIZEOF_VOID_P EQUAL 4)"
" if(Boost_DEBUG)"
" message(STATUS \" skipped due to CMAKE_SIZEOF_VOID_P EQUAL 4\")"
" message(STATUS \" skipped due to CMAKE_SIZEOF_VOID_P == 4\")"
" endif()"
" return()"
"endif()"
@@ -241,7 +241,14 @@ rule generate-cmake-variant- ( target : sources * : properties * )
"if(Boost_COMPILER AND NOT Boost_COMPILER STREQUAL \"$(toolset)\")"
" if(Boost_DEBUG)"
" message(STATUS \" skipped due to NOT Boost_COMPILER STREQUAL $(toolset)\")"
" message(STATUS \" skipped due to Boost_COMPILER (${Boost_COMPILER}) != $(toolset)\")"
" endif()"
" return()"
"endif()"
""
"if(BOOST_DETECTED_TOOLSET AND NOT BOOST_DETECTED_TOOLSET STREQUAL \"$(toolset)\")"
" if(Boost_DEBUG)"
" message(STATUS \" skipped due to BOOST_DETECTED_TOOLSET (${BOOST_DETECTED_TOOLSET}) != $(toolset)\")"
" endif()"
" return()"
"endif()"
@@ -371,7 +378,7 @@ rule generate-cmake-config- ( target : sources * : properties * )
" INTERFACE_INCLUDE_DIRECTORIES \"\${_IMPORT_PREFIX}/include$(header-subdir)\""
")"
""
"# include(${CMAKE_CURRENT_LIST_DIR}/../BoostDetectToolset-$(version).cmake)"
"include(${CMAKE_CURRENT_LIST_DIR}/../BoostDetectToolset-$(version).cmake)"
""
"if(Boost_DEBUG)"
" message(STATUS \"Scanning ${CMAKE_CURRENT_LIST_DIR}/lib$(name)-variant*.cmake\")"
@@ -381,7 +388,7 @@ rule generate-cmake-config- ( target : sources * : properties * )
""
"foreach(f IN LISTS variants)"
" if(Boost_DEBUG)"
" message(STATUS \"Including ${f}\")"
" message(STATUS \" Including ${f}\")"
" endif()"
" include(${f})"
"endforeach()"
@@ -508,7 +515,7 @@ rule lib ( location : version : name )
{
#.info cmake-config.lib $(name) ;
location = $(location)/cmake/$(name)-$(version) ;
local loc = $(location)/cmake/$(name)-$(version) ;
local library-type = UNKNOWN ;
@@ -517,7 +524,7 @@ rule lib ( location : version : name )
library-type = INTERFACE ;
}
local reqs = <name>$(name) <version>$(version) <location>$(location) <library-type>$(library-type) ;
local reqs = <name>$(name) <version>$(version) <location>$(loc) <library-type>$(library-type) ;
local r ;