mirror of
https://github.com/boostorg/sort.git
synced 2026-01-19 04:42:11 +00:00
Merge pull request #99 from nigels-com/cmake-standalone
cmake: Add standalone build support for building and running unit tests
This commit is contained in:
@@ -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)
|
||||
|
||||
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)
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user