1 # Copyright (C) 2019 T. Zachary Laine
3 # Distributed under the Boost Software License, Version 1.0. (See
4 # accompanying file LICENSE_1_0.txt or copy at
5 # http://www.boost.org/LICENSE_1_0.txt)
6 cmake_minimum_required(VERSION 3.5)
7 list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
9 project(stl_interfaces)
11 ##################################################
12 # C++ standard version selection
13 ##################################################
14 set(CXX_STD 14 CACHE STRING "Set to X to enable C++X builds.")
15 message("-- Using -std=c++${CXX_STD}")
18 ##################################################
20 ##################################################
21 set(USE_ASAN false CACHE BOOL "Set to true to enable -fsanitize=address when building tests.")
22 set(USE_UBSAN false CACHE BOOL "Set to true to enable -fsanitize=undefined when building tests.")
23 if (USE_ASAN AND USE_UBSAN)
24 message(FATAL_ERROR "USE_ASAN and USE_UBSAN must not be enabled at the same time")
26 set(compile_flags -fsanitize=address)
27 set(link_flags -fsanitize=address)
28 message("-- Using -fsanitize=address")
30 set(compile_flags -fsanitize=undefined)
31 set(link_flags -fsanitize=undefined)
32 message("-- Using -fsanitize=undefined")
36 ##################################################
38 ##################################################
40 set(BUILD_COVERAGE false CACHE BOOL "Set to true to enable code coverage when building tests. Only Linux and Mac are supported.")
42 message("-- Building for code coverage; disabling any sanitizers")
44 set(compile_flags -fprofile-arcs -ftest-coverage)
45 set(CMAKE_BUILD_TYPE Debug)
46 set(link_flags --coverage)
48 set(compile_flags --coverage)
49 set(CMAKE_BUILD_TYPE Debug)
50 set(link_flags --coverage)
56 ##################################################
58 ##################################################
62 ##################################################
63 # stl_interfaces library
64 ##################################################
65 add_library(stl_interfaces INTERFACE)
67 target_include_directories(stl_interfaces INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
68 target_link_libraries(stl_interfaces INTERFACE boost)
70 target_link_libraries(stl_interfaces INTERFACE ${link_flags})
71 target_compile_options(stl_interfaces INTERFACE ${compile_flags})
74 target_compile_options(stl_interfaces INTERFACE -Wall)
78 add_subdirectory(test)
79 add_subdirectory(example)