# 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

message(STATUS "Using cmake version ${CMAKE_VERSION}")

cmake_minimum_required(VERSION 3.10...3.16)

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)

target_include_directories(boost_sort INTERFACE include)

target_link_libraries(boost_sort
  INTERFACE
    Boost::config
    Boost::core
    Boost::range
    Boost::static_assert
    Boost::type_traits
)

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

  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()
