From 504fbcda34fe7fa91c91ef5b26a9e021c338c8f2 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 2 Jul 2017 03:26:31 +0300 Subject: [PATCH] Add support for installing more than one MSVC toolset --- cmake/BoostDetectToolset.cmake | 35 ++++++++++++++++++++++++++++++++++ cmake/Jamfile | 30 ++++++++++++++++++++++++++--- 2 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 cmake/BoostDetectToolset.cmake diff --git a/cmake/BoostDetectToolset.cmake b/cmake/BoostDetectToolset.cmake new file mode 100644 index 0000000000..7b45d1c53a --- /dev/null +++ b/cmake/BoostDetectToolset.cmake @@ -0,0 +1,35 @@ +# +# BoostDetectToolset: defines BOOST_DETECTED_TOOLSET +# +# Copyright 2017 Peter Dimov +# +# Distributed under the Boost Software License 1.0 +# + +set(BOOST_DETECTED_TOOLSET "") + +if(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() +elseif(MINGW) + set(BOOST_DETECTED_TOOLSET "mgw") +endif() diff --git a/cmake/Jamfile b/cmake/Jamfile index b41cd70c26..3f5bf61a52 100644 --- a/cmake/Jamfile +++ b/cmake/Jamfile @@ -17,6 +17,7 @@ import "class" : new ; import feature ; import toolset ; import regex ; +import common ; if "--debug-cmake" in [ modules.peek : ARGV ] { @@ -117,6 +118,9 @@ local rule generate-config ( target type ) ")" "" "get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)" + "" + "include(${_DIR}/../BoostDetectToolset-$(BOOST_VERSION).cmake)" + "" "file(GLOB CONFIG_FILES "${_DIR}/libboost_$(name)-config-variant*.cmake")" "foreach(f ${CONFIG_FILES})" " include(${f})" @@ -275,11 +279,23 @@ rule generate-config-variant- ( target : sources * : properties * ) print.text "# runtime-debugging=$(runtime-debugging)" "" : true ; - local toolset = [ $(ps).get ] ; + local toolset = [ MATCH ^-(.*) : [ common.format-name : "" : "" : $(ps) ] ] ; .info generate-config-variant-: toolset is $(toolset) ; print.text "# toolset=$(toolset)" "" : true ; + print.text + + "if(NOT \"${BOOST_TOOLSET}\" STREQUAL \"\")" + " if(NOT \"${BOOST_TOOLSET}\" STREQUAL \"$(toolset)\")" + " return()" + " endif()" + "elseif(NOT \"${BOOST_DETECTED_TOOLSET}\" STREQUAL \"\" AND NOT \"${BOOST_DETECTED_TOOLSET}\" STREQUAL \"$(toolset)\")" + " return()" + "endif()" + "" + : true ; + local name = [ MATCH boost_(.*)-config-variant-.*cmake : $(target) ] ; .info generate-config-variant-: name is $(name) ; @@ -445,12 +461,20 @@ for dir in $(library-dirs) explicit $(dir)-install ; } +# BoostDetectToolset.cmake + +install BoostDetectToolset-stage : BoostDetectToolset.cmake : BoostDetectToolset-$(BOOST_VERSION).cmake $(BOOST_STAGE_LOCATE)/lib/cmake ; +explicit BoostDetectToolset-stage ; + +install BoostDetectToolset-install : BoostDetectToolset.cmake : BoostDetectToolset-$(BOOST_VERSION).cmake $(libdir)/cmake ; +explicit BoostDetectToolset-install ; + # stage -alias stage : $(library-dirs)-stage ; +alias stage : BoostDetectToolset-stage $(library-dirs)-stage ; explicit stage ; # install -alias install : $(library-dirs)-install ; +alias install : BoostDetectToolset-install $(library-dirs)-install ; explicit install ;