Update the CMakeLists.txt files for System and Regex, because they are header-only in 1.89 and above and no longer have components

This commit is contained in:
Peter Dimov
2025-11-13 18:17:32 +02:00
parent c6d7e2c036
commit 7d00157773
2 changed files with 14 additions and 27 deletions

View File

@@ -18,32 +18,19 @@ if(USE_STAGED_BOOST)
set(BOOST_HINTS HINTS ../../../../stage)
endif()
if(USE_BOOST_PACKAGE)
# Regex is header-only in b2 starting from 1.89, so there's no `regex` component anymore
find_package(Boost ${BOOST_VERSION} EXACT REQUIRED COMPONENTS regex ${BOOST_HINTS})
find_package(Boost ${BOOST_VERSION} EXACT REQUIRED OPTIONAL_COMPONENTS regex ${BOOST_HINTS})
# Using `include_directories`, `link_directories`, `link_libraries`
# is bad practice, done here for testing purposes. The right, "modern
# CMake", thing to do is `target_link_libraries(main Boost::regex)`.
# Using `include_directories`, `link_directories`, `link_libraries`
# is bad practice, only done here for testing purposes.
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
link_libraries(${Boost_LIBRARIES})
else()
find_package(boost_regex ${BOOST_VERSION} EXACT CONFIG REQUIRED ${BOOST_HINTS})
endif()
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
link_libraries(${Boost_LIBRARIES})
add_executable(main quick.cpp)
if(NOT USE_BOOST_PACKAGE)
target_link_libraries(main Boost::regex)
endif()
enable_testing()
add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure --no-tests=error -C $<CONFIG>)

View File

@@ -18,18 +18,18 @@ if(USE_STAGED_BOOST)
set(BOOST_HINTS HINTS ../../../../stage)
endif()
if(USE_BOOST_PACKAGE)
# System is header-only in b2 starting from 1.89, so there's no `system` component anymore
find_package(Boost ${BOOST_VERSION} EXACT REQUIRED COMPONENTS system ${BOOST_HINTS})
find_package(Boost ${BOOST_VERSION} EXACT REQUIRED OPTIONAL_COMPONENTS system ${BOOST_HINTS})
else()
# Using `include_directories`, `link_directories`, `link_libraries`
# is bad practice, only done here for testing purposes.
find_package(boost_system ${BOOST_VERSION} EXACT CONFIG REQUIRED ${BOOST_HINTS})
endif()
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
link_libraries(${Boost_LIBRARIES})
add_executable(main quick.cpp)
target_link_libraries(main Boost::system)
enable_testing()
add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure --no-tests=error -C $<CONFIG>)