From 15340654a4ea309515555f0fd0aa82877566e996 Mon Sep 17 00:00:00 2001 From: Martijn Otto Date: Fri, 18 Jun 2021 11:01:42 +0200 Subject: [PATCH 1/2] Fix boost build toolchain options not being used The issue was due to the options only being set for the gcc toolchain, and then only for a specific version. On platforms defaulting to a different toolchain (e.g. macOS) this didn't work at all. Additionally, some missing flags were not propagated, in particular the CMAKE_OSX_DEPLOYMENT_TARGET, CMAKE_OSX_SYSROOT and CMAKE_OSX_ARCHITECTURES --- .../boost-modular-build-helper/CMakeLists.txt | 37 ++++++++++++++++--- .../boost-modular-build.cmake | 13 +++++++ .../user-config.jam | 2 +- ports/boost-modular-build-helper/vcpkg.json | 2 +- versions/b-/boost-modular-build-helper.json | 5 +++ versions/baseline.json | 2 +- 6 files changed, 53 insertions(+), 8 deletions(-) diff --git a/ports/boost-modular-build-helper/CMakeLists.txt b/ports/boost-modular-build-helper/CMakeLists.txt index 043636ee8d9629..d5db3c1f5e9635 100644 --- a/ports/boost-modular-build-helper/CMakeLists.txt +++ b/ports/boost-modular-build-helper/CMakeLists.txt @@ -46,13 +46,17 @@ else() endif() if(APPLE) - list(APPEND B2_OPTIONS target-os=darwin toolset=clang) + set(B2_TOOLSET clang) + list(APPEND B2_OPTIONS target-os=darwin) elseif(WIN32) - list(APPEND B2_OPTIONS target-os=windows toolset=gcc) + set(B2_TOOLSET gcc) + list(APPEND B2_OPTIONS target-os=windows) elseif(ANDROID) - list(APPEND B2_OPTIONS target-os=android toolset=gcc) + set(B2_TOOLSET gcc) + list(APPEND B2_OPTIONS target-os=android) else() - list(APPEND B2_OPTIONS target-os=linux toolset=gcc) + set(B2_TOOLSET gcc) + list(APPEND B2_OPTIONS target-os=linux) endif() if(WIN32) @@ -80,6 +84,28 @@ elseif(CMAKE_BUILD_TYPE STREQUAL "Debug") endif() endif() +if(APPLE) + if(CMAKE_OSX_DEPLOYMENT_TARGET) + set(CXXFLAGS "-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET} ${CXXFLAGS}") + set(CFLAGS "-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET} ${CFLAGS}") + set(LDFLAGS "-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET} ${LDFLAGS}") + endif() + + if(CMAKE_OSX_SYSROOT) + set(CXXFLAGS "-isysroot ${CMAKE_OSX_SYSROOT} ${CXXFLAGS}") + set(CFLAGS "-isysroot ${CMAKE_OSX_SYSROOT} ${CFLAGS}") + set(LDFLAGS "-isysroot ${CMAKE_OSX_SYSROOT} ${LDFLAGS}") + endif() + + # if specific architectures are set, configure them, + # if not set, this will still default to current arch + foreach(ARCH ${CMAKE_OSX_ARCHITECTURES}) + set(CXXFLAGS "-arch ${ARCH} ${CXXFLAGS}") + set(CFLAGS "-arch ${ARCH} ${CFLAGS}") + set(LDFLAGS "-arch ${ARCH} ${LDFLAGS}") + endforeach() +endif() + string(STRIP "${CXXFLAGS}" CXXFLAGS) string(STRIP "${CFLAGS}" CFLAGS) string(STRIP "${LDFLAGS}" LDFLAGS) @@ -122,7 +148,7 @@ foreach(INCDIR ${CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES}) endforeach() if(APPLE) - set(CXXFLAGS "${CXXFLAGS} -D_DARWIN_C_SOURCE -std=c++11 -stdlib=libc++") + set(CXXFLAGS "${CXXFLAGS} -D_DARWIN_C_SOURCE -std=c++11 -stdlib=libc++") set(LDFLAGS "${LDFLAGS} -stdlib=libc++") endif() @@ -157,6 +183,7 @@ endif() add_custom_target(boost ALL COMMAND "${B2_EXE}" + toolset=${B2_TOOLSET} --user-config=${CMAKE_CURRENT_BINARY_DIR}/user-config.jam --stagedir=${CMAKE_CURRENT_BINARY_DIR}/stage --build-dir=${CMAKE_CURRENT_BINARY_DIR} diff --git a/ports/boost-modular-build-helper/boost-modular-build.cmake b/ports/boost-modular-build-helper/boost-modular-build.cmake index 3acc75afda72a2..51259815d3fa71 100644 --- a/ports/boost-modular-build-helper/boost-modular-build.cmake +++ b/ports/boost-modular-build-helper/boost-modular-build.cmake @@ -84,6 +84,19 @@ function(boost_modular_build) if(DEFINED _bm_BOOST_CMAKE_FRAGMENT) list(APPEND configure_option "-DBOOST_CMAKE_FRAGMENT=${_bm_BOOST_CMAKE_FRAGMENT}") endif() + if(VCPKG_TARGET_IS_OSX) + if(VCPKG_OSX_DEPLOYMENT_TARGET) + list(APPEND configure_options "-DCMAKE_OSX_DEPLOYMENT_TARGET=${VCPKG_OSX_DEPLOYMENT_TARGET}") + endif() + if(VCPKG_OSX_SYSROOT) + list(APPEND configure_options "-DCMAKE_OSX_SYSROOT=${VCPKG_OSX_SYSROOT}") + endif() + if(VCPKG_OSX_ARCHITECTURES) + # note: VCPKG_OSX_ARCHITECTURES is a list and must be enclosed in quotes + list(APPEND configure_options "-DCMAKE_OSX_ARCHITECTURES=\"${VCPKG_OSX_ARCHITECTURES}\"") + endif() + endif() + vcpkg_configure_cmake( SOURCE_PATH ${BOOST_BUILD_INSTALLED_DIR}/share/boost-build PREFER_NINJA diff --git a/ports/boost-modular-build-helper/user-config.jam b/ports/boost-modular-build-helper/user-config.jam index 550423965fd33c..afd1d7dc6ac06c 100644 --- a/ports/boost-modular-build-helper/user-config.jam +++ b/ports/boost-modular-build-helper/user-config.jam @@ -10,7 +10,7 @@ if "@VCPKG_PLATFORM_TOOLSET@" != "external" } else { - using gcc : 5.4.1 : @CMAKE_CXX_COMPILER@ + using @B2_TOOLSET@ : : @CMAKE_CXX_COMPILER@ : @CMAKE_RANLIB@ @CMAKE_AR@ diff --git a/ports/boost-modular-build-helper/vcpkg.json b/ports/boost-modular-build-helper/vcpkg.json index e8475362d26a99..699b93b47809bf 100644 --- a/ports/boost-modular-build-helper/vcpkg.json +++ b/ports/boost-modular-build-helper/vcpkg.json @@ -1,7 +1,7 @@ { "name": "boost-modular-build-helper", "version-string": "1.75.0", - "port-version": 9, + "port-version": 10, "dependencies": [ "boost-build", "boost-uninstall" diff --git a/versions/b-/boost-modular-build-helper.json b/versions/b-/boost-modular-build-helper.json index cdd24d924b3fb3..f093cf5137340c 100644 --- a/versions/b-/boost-modular-build-helper.json +++ b/versions/b-/boost-modular-build-helper.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "09b58787785be0fcc5fb86560ef421eb341aa537", + "version-string": "1.75.0", + "port-version": 10 + }, { "git-tree": "c475b268ac42e886acfdc783944e1e3a988b0ac8", "version-string": "1.75.0", diff --git a/versions/baseline.json b/versions/baseline.json index 80fa1b42119a4a..12e9ded125ac33 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -738,7 +738,7 @@ }, "boost-modular-build-helper": { "baseline": "1.75.0", - "port-version": 9 + "port-version": 10 }, "boost-move": { "baseline": "1.75.0", From 8de63e429b889f5e20f8b385850bcc1d6663b85a Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Thu, 1 Jul 2021 15:59:57 +0000 Subject: [PATCH 2/2] [boost-modular-build-helper] Apply CR comments --- ports/boost-modular-build-helper/CMakeLists.txt | 2 +- .../boost-modular-build.cmake | 12 ------------ versions/b-/boost-modular-build-helper.json | 2 +- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/ports/boost-modular-build-helper/CMakeLists.txt b/ports/boost-modular-build-helper/CMakeLists.txt index d5db3c1f5e9635..b38b0e3137fdef 100644 --- a/ports/boost-modular-build-helper/CMakeLists.txt +++ b/ports/boost-modular-build-helper/CMakeLists.txt @@ -99,7 +99,7 @@ if(APPLE) # if specific architectures are set, configure them, # if not set, this will still default to current arch - foreach(ARCH ${CMAKE_OSX_ARCHITECTURES}) + foreach(ARCH IN LISTS CMAKE_OSX_ARCHITECTURES) set(CXXFLAGS "-arch ${ARCH} ${CXXFLAGS}") set(CFLAGS "-arch ${ARCH} ${CFLAGS}") set(LDFLAGS "-arch ${ARCH} ${LDFLAGS}") diff --git a/ports/boost-modular-build-helper/boost-modular-build.cmake b/ports/boost-modular-build-helper/boost-modular-build.cmake index 51259815d3fa71..69eb899a16db99 100644 --- a/ports/boost-modular-build-helper/boost-modular-build.cmake +++ b/ports/boost-modular-build-helper/boost-modular-build.cmake @@ -84,18 +84,6 @@ function(boost_modular_build) if(DEFINED _bm_BOOST_CMAKE_FRAGMENT) list(APPEND configure_option "-DBOOST_CMAKE_FRAGMENT=${_bm_BOOST_CMAKE_FRAGMENT}") endif() - if(VCPKG_TARGET_IS_OSX) - if(VCPKG_OSX_DEPLOYMENT_TARGET) - list(APPEND configure_options "-DCMAKE_OSX_DEPLOYMENT_TARGET=${VCPKG_OSX_DEPLOYMENT_TARGET}") - endif() - if(VCPKG_OSX_SYSROOT) - list(APPEND configure_options "-DCMAKE_OSX_SYSROOT=${VCPKG_OSX_SYSROOT}") - endif() - if(VCPKG_OSX_ARCHITECTURES) - # note: VCPKG_OSX_ARCHITECTURES is a list and must be enclosed in quotes - list(APPEND configure_options "-DCMAKE_OSX_ARCHITECTURES=\"${VCPKG_OSX_ARCHITECTURES}\"") - endif() - endif() vcpkg_configure_cmake( SOURCE_PATH ${BOOST_BUILD_INSTALLED_DIR}/share/boost-build diff --git a/versions/b-/boost-modular-build-helper.json b/versions/b-/boost-modular-build-helper.json index f093cf5137340c..67ffb430dc2550 100644 --- a/versions/b-/boost-modular-build-helper.json +++ b/versions/b-/boost-modular-build-helper.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "09b58787785be0fcc5fb86560ef421eb341aa537", + "git-tree": "95cad6d5f2d9a858aacbb3b2bc0e3a0db4b06b4b", "version-string": "1.75.0", "port-version": 10 },