Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
# Generated by `boostdep --cmake sort`
# Copyright 2020 Peter Dimov
# Copyright 2025 Nigel Stewart
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt

cmake_minimum_required(VERSION 3.5...3.16)
message(STATUS "Using cmake version ${CMAKE_VERSION}")

project(boost_sort VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
cmake_minimum_required(VERSION 3.10...3.16)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You wrote

it's find_package(Boost) that seems problematic prior to cmake-3.10.

In which way? What is the issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ PATH=/opt/cmake-3.9.0-Linux-x86_64/bin:$PATH cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DBUILD_TESTING=Y -DCMAKE_CXX_COMPILER=clang++-18 && ninja check
-- Using cmake version 3.9.0
-- The CXX compiler identification is Clang 18.1.3
...
-- Found Boost 1.89.0 at /opt/boost-1.89.0/lib/cmake/Boost-1.89.0
--   Requested configuration: QUIET REQUIRED COMPONENTS core;range;included_test_exec_monitor
...
-- Found boost_numeric_conversion 1.89.0 at /opt/boost-1.89.0/lib/cmake/boost_numeric_conversion-1.89.0
Boost 1.85 found.
Found Boost components:
   core;range;included_test_exec_monitor
CMake Error in /opt/cmake-3.9.0-Linux-x86_64/share/cmake-3.9/Modules/FindBoost.cmake:
  cmake_policy PUSH without matching POP
Call Stack (most recent call first):
  CMakeLists.txt:22 (find_package)


-- Configuring incomplete, errors occurred!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, a bug introduced in CMake 3.9 and fixed in 3.9.1


if(BOOST_SUPERPROJECT_VERSION)
project(boost_sort VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
else()
project(boost_sort LANGUAGES CXX)
endif()

# Test coverage in stand-alone mode requires boost dependencies
if(BUILD_TESTING AND NOT BOOST_SUPERPROJECT_VERSION)
set(Boost_DEBUG ON)
find_package(Boost 1.85 REQUIRED COMPONENTS core range included_test_exec_monitor)
endif()

add_library(boost_sort INTERFACE)
add_library(Boost::sort ALIAS boost_sort)
Expand All @@ -21,8 +34,17 @@ target_link_libraries(boost_sort
Boost::type_traits
)

# Testing
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")

add_subdirectory(test)
if(NOT BOOST_SUPERPROJECT_VERSION)
include(CTest)
enable_testing()
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
add_dependencies(check tests)
endif()

# Follow the Boost convention: don't build test targets by default,
# and only when explicitly requested by building target tests
add_subdirectory(test EXCLUDE_FROM_ALL)
endif()