-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathCMakeLists.txt
109 lines (88 loc) · 3.45 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
# Generated by `boostdep --cmake stl_interfaces`
# Copyright 2020, 2021 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.8...3.20)
project(boost_stl_interfaces VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_stl_interfaces INTERFACE)
add_library(Boost::stl_interfaces ALIAS boost_stl_interfaces)
target_include_directories(boost_stl_interfaces INTERFACE include)
target_link_libraries(boost_stl_interfaces
INTERFACE
Boost::assert
Boost::config
)
target_compile_features(boost_stl_interfaces INTERFACE cxx_std_14)
else()
# Copyright (C) 2019 T. Zachary Laine
#
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
cmake_minimum_required(VERSION 3.5)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
project(stl_interfaces)
##################################################
# C++ standard version selection
##################################################
set(CXX_STD 14 CACHE STRING "Set to X to enable C++X builds.")
message("-- Using -std=c++${CXX_STD}")
if (MSVC)
add_compile_options(/Zc:__cplusplus)
endif()
##################################################
# Sanitizers
##################################################
set(USE_ASAN false CACHE BOOL "Set to true to enable -fsanitize=address when building tests.")
set(USE_UBSAN false CACHE BOOL "Set to true to enable -fsanitize=undefined when building tests.")
if (USE_ASAN AND USE_UBSAN)
message(FATAL_ERROR "USE_ASAN and USE_UBSAN must not be enabled at the same time")
elseif (USE_ASAN)
set(compile_flags -fsanitize=address)
set(link_flags -fsanitize=address)
message("-- Using -fsanitize=address")
elseif (USE_UBSAN)
set(compile_flags -fsanitize=undefined)
set(link_flags -fsanitize=undefined)
message("-- Using -fsanitize=undefined")
endif()
##################################################
# Code coverage
##################################################
if (UNIX)
set(BUILD_COVERAGE false CACHE BOOL "Set to true to enable code coverage when building tests. Only Linux and Mac are supported.")
if (BUILD_COVERAGE)
message("-- Building for code coverage; disabling any sanitizers")
if (APPLE)
set(compile_flags -fprofile-arcs -ftest-coverage)
set(CMAKE_BUILD_TYPE Debug)
set(link_flags --coverage)
else ()
set(compile_flags --coverage)
set(CMAKE_BUILD_TYPE Debug)
set(link_flags --coverage)
endif ()
endif ()
endif ()
##################################################
# Dependencies
##################################################
set(boost_components)
include(dependencies)
##################################################
# stl_interfaces library
##################################################
add_library(stl_interfaces INTERFACE)
target_include_directories(stl_interfaces INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(stl_interfaces INTERFACE boost)
if (link_flags)
target_link_libraries(stl_interfaces INTERFACE ${link_flags})
target_compile_options(stl_interfaces INTERFACE ${compile_flags})
endif ()
if (NOT MSVC)
target_compile_options(stl_interfaces INTERFACE -Wall)
endif ()
add_subdirectory(test)
add_subdirectory(example)
endif()