Skip to content

Commit

Permalink
Merge pull request #1226.
Browse files Browse the repository at this point in the history
Remove dependency on Boost Test when not needed
  • Loading branch information
lballabio committed Nov 8, 2021
2 parents 1e73532 + 0d8f961 commit 903de0f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -17,7 +17,7 @@ quantlib.elc
quantlib.pc
QuantLib.spec
CMakeCache.txt
CMakeUserPresets.txt
CMakeUserPresets.json
Docs/.time-stamp
Docs/.time-stamp-html
Docs/.time-stamp-online
Expand Down
50 changes: 35 additions & 15 deletions CMakeLists.txt
Expand Up @@ -85,21 +85,6 @@ if (NOT DEFINED Boost_USE_STATIC_RUNTIME)
set(Boost_USE_STATIC_RUNTIME ${MSVC})
endif()

# Boost thread and unit_test_framework needed for tests and benchmark
find_package(Boost 1.58.0 REQUIRED COMPONENTS thread unit_test_framework)

# Avoid using Boost auto-linking
add_compile_definitions(BOOST_ALL_NO_LIB)

if (QL_ENABLE_OPENMP)
find_package(OpenMP REQUIRED)
endif()

# Parallel test runner needs library rt on *nix for shm_open, etc.
if (QL_ENABLE_PARALLEL_UNIT_TEST_RUNNER AND UNIX AND NOT APPLE)
find_library(RT_LIBRARY rt REQUIRED)
endif()

# Require C++11 or higher
if (NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
Expand All @@ -114,6 +99,41 @@ if (NOT DEFINED CMAKE_CXX_EXTENSIONS)
set(CMAKE_CXX_EXTENSIONS FALSE)
endif()

if (NOT DEFINED QL_BOOST_VERSION)
# Boost 1.75.0 or greater required for compiling with C++20
if (CMAKE_CXX_STANDARD GREATER_EQUAL 20)
set(QL_BOOST_VERSION 1.75.0)
else()
set(QL_BOOST_VERSION 1.58.0)
endif()
endif()

if (NOT DEFINED QL_BOOST_COMPONENTS)
# Boost thread and unit_test_framework needed for tests and benchmark
if (QL_BUILD_TEST_SUITE OR QL_BUILD_BENCHMARK)
set(QL_BOOST_COMPONENTS thread unit_test_framework)
else()
set(QL_BOOST_COMPONENTS thread)
endif()
endif()

find_package(Boost ${QL_BOOST_VERSION} REQUIRED COMPONENTS ${QL_BOOST_COMPONENTS})

# Do not warn about Boost versions higher than 1.58.0
set(Boost_NO_WARN_NEW_VERSIONS ON)

# Avoid using Boost auto-linking
add_compile_definitions(BOOST_ALL_NO_LIB)

if (QL_ENABLE_OPENMP)
find_package(OpenMP REQUIRED)
endif()

# Parallel test runner needs library rt on *nix for shm_open, etc.
if (QL_ENABLE_PARALLEL_UNIT_TEST_RUNNER AND UNIX AND NOT APPLE)
find_library(RT_LIBRARY rt REQUIRED)
endif()

# If available, use PIC for shared libs and PIE for executables
if (NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
Expand Down

0 comments on commit 903de0f

Please sign in to comment.