forked from boostorg/outcome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
63 lines (54 loc) · 2.22 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# 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.5...3.16)
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()