mirror of
https://github.com/boostorg/outcome.git
synced 2026-01-19 04:22:13 +00:00
- Bump Boost min cmake required to 3.10 to match standalone Outcome. Also bump minium cmake to 3.10 everywhere else in Outcome, as CI is now failing due to us requested too old a cmake. #314 Replaces https://github.com/boostorg/outcome/pull/8
64 lines
2.2 KiB
CMake
64 lines
2.2 KiB
CMake
# Generated by `boostdep --cmake outcome`
|
|
# Copyright 2020 Peter Dimov
|
|
# Distributed under the Boost Software License, Version 1.0.
|
|
# https://www.boost.org/LICENSE_1_0.txt
|
|
|
|
cmake_minimum_required(VERSION 3.10...4.0 FATAL_ERROR)
|
|
|
|
project(boost_outcome VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
|
|
|
if (${PROJECT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
|
|
# Project is root. Find Boost source.
|
|
set(BOOST_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../.." CACHE STRING "Boost source dir to use when running CMake from this directory")
|
|
if (NOT IS_ABSOLUTE ${BOOST_SRC_DIR})
|
|
set(BOOST_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${BOOST_SRC_DIR}")
|
|
endif()
|
|
set(BOOST_SRC_DIR_IS_VALID ON)
|
|
foreach (F "CMakeLists.txt" "Jamroot" "boost-build.jam" "bootstrap.sh" "libs")
|
|
if (NOT EXISTS "${BOOST_SRC_DIR}/${F}")
|
|
message(STATUS "${BOOST_SRC_DIR}/${F} does not exist. Fallback to find_package.")
|
|
set(BOOST_SRC_DIR_IS_VALID OFF)
|
|
break()
|
|
endif()
|
|
endforeach()
|
|
# Create Boost targets from source dir or boost package.
|
|
set(BOOST_INCLUDE_LIBRARIES config exception system throw_exception test)
|
|
if (BOOST_SRC_DIR_IS_VALID)
|
|
set(BOOST_EXCLUDE_LIBRARIES ${PROJECT_NAME})
|
|
add_subdirectory(${BOOST_SRC_DIR} deps_/boost EXCLUDE_FROM_ALL)
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${BOOST_SRC_DIR}/tools/cmake/include")
|
|
else()
|
|
find_package(Boost 1.81.0 REQUIRED)
|
|
foreach (BOOST_INCLUDE_LIBRARY ${BOOST_INCLUDE_LIBRARIES})
|
|
add_library(Boost::${BOOST_INCLUDE_LIBRARY} ALIAS Boost::headers)
|
|
endforeach ()
|
|
endif()
|
|
endif()
|
|
|
|
add_library(boost_outcome INTERFACE)
|
|
add_library(Boost::outcome ALIAS boost_outcome)
|
|
|
|
target_include_directories(boost_outcome INTERFACE include)
|
|
|
|
target_link_libraries(boost_outcome
|
|
INTERFACE
|
|
Boost::config
|
|
Boost::exception
|
|
Boost::system
|
|
Boost::throw_exception
|
|
)
|
|
|
|
target_compile_features(boost_outcome
|
|
INTERFACE
|
|
cxx_std_14
|
|
)
|
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11)
|
|
target_compile_options(boost_outcome INTERFACE -ftemplate-depth=5000)
|
|
endif ()
|
|
|
|
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
|
|
enable_testing()
|
|
add_subdirectory(test)
|
|
endif()
|