|
1 | | -# Copyright (c) 2018-2025 Jean-Louis Leroy |
| 1 | +# Generated by `boostdep --cmake openmethod` |
| 2 | +# Copyright 2020, 2021 Peter Dimov |
2 | 3 | # Distributed under the Boost Software License, Version 1.0. |
3 | | -# See accompanying file LICENSE_1_0.txt |
4 | | -# or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 4 | +# https://www.boost.org/LICENSE_1_0.txt |
5 | 5 |
|
6 | | -cmake_minimum_required(VERSION 3.10) |
| 6 | +cmake_minimum_required(VERSION 3.5...3.20) |
7 | 7 |
|
8 | | -if(POLICY CMP0167) |
9 | | - cmake_policy(SET CMP0074 NEW) |
| 8 | +project(boost_openmethod VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) |
| 9 | + |
| 10 | +set(BOOST_OPENMETHOD_IS_ROOT OFF) |
| 11 | +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) |
| 12 | + set(BOOST_OPENMETHOD_IS_ROOT ON) |
10 | 13 | endif() |
11 | 14 |
|
12 | | -if(POLICY CMP0167) |
13 | | - cmake_policy(SET CMP0167 NEW) |
| 15 | +if(BOOST_OPENMETHOD_IS_ROOT) |
| 16 | + include(CTest) |
| 17 | +endif() |
| 18 | +if(NOT BOOST_SUPERPROJECT_VERSION) |
| 19 | + option(BOOST_OPENMETHOD_INSTALL "Install boost::openmethod files" ON) |
| 20 | + option(BOOST_OPENMETHOD_BUILD_TESTS "Build boost::openmethod tests" ${BUILD_TESTING}) |
| 21 | + option(BOOST_OPENMETHOD_BUILD_EXAMPLES "Build boost::openmethod examples" ${BOOST_OPENMETHOD_IS_ROOT}) |
| 22 | +else() |
| 23 | + set(BOOST_OPENMETHOD_BUILD_TESTS ${BUILD_TESTING}) |
14 | 24 | endif() |
15 | 25 |
|
16 | | -project(boost_openmethod VERSION 1.87.0 LANGUAGES CXX) |
| 26 | +if(BOOST_OPENMETHOD_IS_ROOT) |
| 27 | + # |
| 28 | + # Building inside Boost tree, but as a separate project e.g. on Travis or |
| 29 | + # other CI, or when producing Visual Studio Solution and Projects. |
17 | 30 |
|
18 | | -if(NOT CMAKE_CXX_STANDARD) |
19 | | - set(CMAKE_CXX_STANDARD 17) |
| 31 | + set(BOOST_INCLUDE_LIBRARIES openmethod) |
| 32 | + set(BOOST_EXCLUDE_LIBRARIES openmethod) |
| 33 | + list(APPEND BOOST_INCLUDE_LIBRARIES test) |
| 34 | + if(BOOST_OPENMETHOD_BUILD_EXAMPLES) |
| 35 | + # list(APPEND BOOST_INCLUDE_LIBRARIES optional) |
| 36 | + endif() |
| 37 | + |
| 38 | + set(CMAKE_FOLDER _deps) |
| 39 | + add_subdirectory(../.. _deps/boost EXCLUDE_FROM_ALL) |
| 40 | + unset(CMAKE_FOLDER) |
20 | 41 | endif() |
21 | | -set(CMAKE_CXX_STANDARD_REQUIRED ON) |
22 | 42 |
|
23 | 43 | add_library(boost_openmethod INTERFACE) |
24 | 44 | add_library(Boost::openmethod ALIAS boost_openmethod) |
25 | 45 |
|
26 | | -target_include_directories(boost_openmethod INTERFACE include) |
27 | | - |
28 | | -find_package(Boost COMPONENTS) |
29 | | -target_link_libraries(boost_openmethod INTERFACE Boost::boost) |
| 46 | +target_compile_features(boost_openmethod INTERFACE cxx_std_17) |
30 | 47 |
|
31 | | -if(MSVC) |
32 | | - add_compile_options(/EHsc /FAs /bigobj) |
33 | | -endif() |
| 48 | +target_include_directories(boost_openmethod INTERFACE include) |
34 | 49 |
|
35 | | -if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") |
36 | | - message(STATUS "Enabling sanitizers") |
37 | | - add_compile_options( |
38 | | - -fPIC -Wno-deprecated-declarations -Wall -Wextra -Werror |
39 | | - -fsanitize=undefined -fsanitize=address -fsanitize=leak) |
40 | | - add_link_options(-fsanitize=undefined -fsanitize=address -fsanitize=leak) |
41 | | -endif() |
| 50 | +target_link_libraries( |
| 51 | + boost_openmethod |
| 52 | + INTERFACE |
| 53 | + Boost::assert |
| 54 | + Boost::config |
| 55 | + Boost::core |
| 56 | + Boost::dynamic_bitset |
| 57 | + Boost::mp11 |
| 58 | + Boost::preprocessor |
| 59 | +) |
42 | 60 |
|
43 | | -if(BUILD_TESTING) |
44 | | - message(STATUS "Building tests") |
45 | | - include(CTest) |
| 61 | +if(BOOST_OPENMETHOD_BUILD_TESTS) |
46 | 62 | enable_testing() |
47 | 63 | add_subdirectory(test) |
48 | 64 | endif() |
49 | 65 |
|
50 | | -if(BUILD_EXAMPLES) |
51 | | - message(STATUS "Building examples") |
| 66 | +if(BOOST_OPENMETHOD_BUILD_EXAMPLES) |
52 | 67 | add_subdirectory(example) |
53 | 68 | endif() |
0 commit comments