Skip to content

Commit d816219

Browse files
authored
fixed #14003 - made it possible to disable Boost again (#7730)
1 parent 3ea3af0 commit d816219

File tree

4 files changed

+44
-11
lines changed

4 files changed

+44
-11
lines changed

.github/workflows/CI-unixish.yml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,42 @@ jobs:
266266
with:
267267
key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }}
268268

269+
- name: Run CMake on macOS (force Boost)
270+
run: |
271+
# make sure we fail when Boost is requested and not available.
272+
# will fail because no package configuration is available.
273+
if cmake -S . -B cmake.output.boost-force-noavail -G "Unix Makefiles" -DUSE_BOOST=On; then
274+
exit 1
275+
else
276+
exit 0
277+
fi
278+
269279
# coreutils contains "nproc"
270-
- name: Install missing software on macos
280+
- name: Install missing software on macOS
271281
run: |
272282
brew install coreutils boost
273283
274-
- name: CMake build on macOS (with Boost)
284+
- name: Run CMake on macOS (force Boost)
285+
run: |
286+
cmake -S . -B cmake.output.boost-force -G "Unix Makefiles" -DUSE_BOOST=On
287+
288+
- name: Run CMake on macOS (no Boost)
289+
run: |
290+
# make sure Boost is not used when disabled even though it is available
291+
cmake -S . -B cmake.output.boost-no -G "Unix Makefiles" -DUSE_BOOST=Off
292+
if grep -q '\-DHAVE_BOOST' ./cmake.output.boost-no/compile_commands.json; then
293+
exit 1
294+
else
295+
exit 0
296+
fi
297+
298+
- name: Run CMake on macOS (with Boost)
275299
run: |
276300
cmake -S . -B cmake.output.boost -G "Unix Makefiles" -DBUILD_TESTS=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
301+
grep -q '\-DHAVE_BOOST' ./cmake.output.boost/compile_commands.json
302+
303+
- name: Build with CMake on macOS (with Boost)
304+
run: |
277305
cmake --build cmake.output.boost -- -j$(nproc)
278306
279307
build:

cmake/findDependencies.cmake

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,12 @@ if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.30")
8383
cmake_policy(SET CMP0167 NEW)
8484
endif()
8585

86-
# we are only using the header-only "container" component so we can unconditionally search for it
8786
if(USE_BOOST)
88-
find_package(Boost REQUIRED)
89-
else()
90-
find_package(Boost)
87+
if(USE_BOOST STREQUAL "Auto")
88+
find_package(Boost)
89+
else()
90+
find_package(Boost REQUIRED)
91+
endif()
9192
endif()
9293

9394
find_program(LIBXML2_XMLLINT_EXECUTABLE xmllint)

cmake/options.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ if(WARNINGS_ARE_ERRORS)
3131
endif()
3232
option(EXTERNALS_AS_SYSTEM "Treat externals as system includes" OFF)
3333

34+
# we are only using the header-only "container" Boost component so we can unconditionally search for it by default
3435
set(USE_MATCHCOMPILER "Auto" CACHE STRING "Usage of match compiler")
3536
set_property(CACHE USE_MATCHCOMPILER PROPERTY STRINGS Auto Off On Verify)
3637
if(USE_MATCHCOMPILER)
@@ -88,7 +89,8 @@ option(DISALLOW_THREAD_EXECUTOR "Disallow usage of ThreadExecutor for -j"
8889
if(DISALLOW_THREAD_EXECUTOR AND WIN32)
8990
message(FATAL_ERROR "Cannot disable usage of ThreadExecutor on Windows as no other executor implementation is currently available")
9091
endif()
91-
option(USE_BOOST "Force usage of Boost" OFF)
92+
set(USE_BOOST "Auto" CACHE STRING "Usage of Boost")
93+
set_property(CACHE USE_BOOST PROPERTY STRINGS Auto Off On)
9294
option(USE_BOOST_INT128 "Usage of Boost.Multiprecision 128-bit integer for Mathlib" OFF)
9395
if (NOT USE_BOOST AND USE_BOOST_INT128)
9496
message(FATAL_ERROR "USE_BOOST_INT128 requires USE_BOOST to be enabled")

cmake/printInfo.cmake

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,12 @@ if(NOT USE_BUNDLED_TINYXML2)
8787
endif()
8888
message(STATUS)
8989
message(STATUS "USE_BOOST = ${USE_BOOST}")
90-
message(STATUS "Boost_FOUND = ${Boost_FOUND}")
91-
message(STATUS "Boost_VERSION_STRING = ${Boost_VERSION_STRING}")
92-
message(STATUS "Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS}")
93-
message(STATUS "USE_BOOST_INT128 = ${USE_BOOST_INT128}")
90+
if(USE_BOOST)
91+
message(STATUS "Boost_FOUND = ${Boost_FOUND}")
92+
message(STATUS "Boost_VERSION_STRING = ${Boost_VERSION_STRING}")
93+
message(STATUS "Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS}")
94+
message(STATUS "USE_BOOST_INT128 = ${USE_BOOST_INT128}")
95+
endif()
9496
message(STATUS)
9597
message(STATUS "USE_LIBCXX = ${USE_LIBCXX}")
9698
message(STATUS)

0 commit comments

Comments
 (0)