mirror of
https://github.com/boostorg/stl_interfaces.git
synced 2025-05-11 13:44:07 +00:00
110 lines
3.5 KiB
CMake
110 lines
3.5 KiB
CMake
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()
|