diff --git a/.github/workflows/CI-unixish.yml b/.github/workflows/CI-unixish.yml index 97e3b1f97c5..9b720b95b4a 100644 --- a/.github/workflows/CI-unixish.yml +++ b/.github/workflows/CI-unixish.yml @@ -266,14 +266,42 @@ jobs: with: key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }} + - name: Run CMake on macOS (force Boost) + run: | + # make sure we fail when Boost is requested and not available. + # will fail because no package configuration is available. + if cmake -S . -B cmake.output.boost-force-noavail -G "Unix Makefiles" -DUSE_BOOST=On; then + exit 1 + else + exit 0 + fi + # coreutils contains "nproc" - - name: Install missing software on macos + - name: Install missing software on macOS run: | brew install coreutils boost - - name: CMake build on macOS (with Boost) + - name: Run CMake on macOS (force Boost) + run: | + cmake -S . -B cmake.output.boost-force -G "Unix Makefiles" -DUSE_BOOST=On + + - name: Run CMake on macOS (no Boost) + run: | + # make sure Boost is not used when disabled even though it is available + cmake -S . -B cmake.output.boost-no -G "Unix Makefiles" -DUSE_BOOST=Off + if grep -q '\-DHAVE_BOOST' ./cmake.output.boost-no/compile_commands.json; then + exit 1 + else + exit 0 + fi + + - name: Run CMake on macOS (with Boost) run: | 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 + grep -q '\-DHAVE_BOOST' ./cmake.output.boost/compile_commands.json + + - name: Build with CMake on macOS (with Boost) + run: | cmake --build cmake.output.boost -- -j$(nproc) build: diff --git a/cmake/findDependencies.cmake b/cmake/findDependencies.cmake index 726bb792b8f..bda9d5f953d 100644 --- a/cmake/findDependencies.cmake +++ b/cmake/findDependencies.cmake @@ -83,11 +83,12 @@ if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.30") cmake_policy(SET CMP0167 NEW) endif() -# we are only using the header-only "container" component so we can unconditionally search for it if(USE_BOOST) - find_package(Boost REQUIRED) -else() - find_package(Boost) + if(USE_BOOST STREQUAL "Auto") + find_package(Boost) + else() + find_package(Boost REQUIRED) + endif() endif() find_program(LIBXML2_XMLLINT_EXECUTABLE xmllint) diff --git a/cmake/options.cmake b/cmake/options.cmake index 7982cc678ed..f4efb2f329a 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -31,6 +31,7 @@ if(WARNINGS_ARE_ERRORS) endif() option(EXTERNALS_AS_SYSTEM "Treat externals as system includes" OFF) +# we are only using the header-only "container" Boost component so we can unconditionally search for it by default set(USE_MATCHCOMPILER "Auto" CACHE STRING "Usage of match compiler") set_property(CACHE USE_MATCHCOMPILER PROPERTY STRINGS Auto Off On Verify) if(USE_MATCHCOMPILER) @@ -88,7 +89,8 @@ option(DISALLOW_THREAD_EXECUTOR "Disallow usage of ThreadExecutor for -j" if(DISALLOW_THREAD_EXECUTOR AND WIN32) message(FATAL_ERROR "Cannot disable usage of ThreadExecutor on Windows as no other executor implementation is currently available") endif() -option(USE_BOOST "Force usage of Boost" OFF) +set(USE_BOOST "Auto" CACHE STRING "Usage of Boost") +set_property(CACHE USE_BOOST PROPERTY STRINGS Auto Off On) option(USE_BOOST_INT128 "Usage of Boost.Multiprecision 128-bit integer for Mathlib" OFF) if (NOT USE_BOOST AND USE_BOOST_INT128) message(FATAL_ERROR "USE_BOOST_INT128 requires USE_BOOST to be enabled") diff --git a/cmake/printInfo.cmake b/cmake/printInfo.cmake index 10b3c5bf322..76c8112ce8a 100644 --- a/cmake/printInfo.cmake +++ b/cmake/printInfo.cmake @@ -87,10 +87,12 @@ if(NOT USE_BUNDLED_TINYXML2) endif() message(STATUS) message(STATUS "USE_BOOST = ${USE_BOOST}") -message(STATUS "Boost_FOUND = ${Boost_FOUND}") -message(STATUS "Boost_VERSION_STRING = ${Boost_VERSION_STRING}") -message(STATUS "Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS}") -message(STATUS "USE_BOOST_INT128 = ${USE_BOOST_INT128}") +if(USE_BOOST) + message(STATUS "Boost_FOUND = ${Boost_FOUND}") + message(STATUS "Boost_VERSION_STRING = ${Boost_VERSION_STRING}") + message(STATUS "Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS}") + message(STATUS "USE_BOOST_INT128 = ${USE_BOOST_INT128}") +endif() message(STATUS) message(STATUS "USE_LIBCXX = ${USE_LIBCXX}") message(STATUS)