-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
94 lines (74 loc) · 2.54 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
#
# Copyright (c) 2020 Damian Jarek ([email protected])
#
# 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)
#
# Official repository: https://github.com/djarek/canary
#
cmake_minimum_required(VERSION 3.8)
project(canary VERSION 2 LANGUAGES CXX)
# TODO: Don't require Boost if ASIO standalone option is required
find_package(Boost 1.70
COMPONENTS
system
REQUIRED)
find_package (Threads)
add_library(canary INTERFACE)
add_library(canary::canary ALIAS canary)
target_include_directories(canary INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_link_libraries(
canary
INTERFACE
Boost::system
Threads::Threads)
target_compile_features(canary INTERFACE cxx_std_11)
include(CTest)
if(BUILD_TESTING)
enable_testing()
add_subdirectory(tests)
endif()
option(CANARY_BUILD_EXAMPLES "Build examples." OFF)
option(CANARY_BUILD_COROUTINE_EXAMPLES "Build examples using C++20 coroutines." OFF)
if(CANARY_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
include(GNUInstallDirs)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING
PATTERN "*.hpp"
PATTERN "*.ipp")
install(TARGETS canary
EXPORT canaryTargets
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
set(canary_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
unset(CMAKE_SIZEOF_VOID_P)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"canaryConfigVersion.cmake"
COMPATIBILITY AnyNewerVersion)
set(CMAKE_SIZEOF_VOID_P ${canary_SIZEOF_VOID_P})
unset(canary_SIZEOF_VOID_P)
install(FILES
"canaryConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/canaryConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/canary)
install(EXPORT canaryTargets
FILE canaryTargets.cmake
NAMESPACE canary::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/canary)
option(CANARY_BUILD_DOCS "Build canary documentation." OFF)
if (CANARY_BUILD_DOCS)
file(GLOB CANARY_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/canary/*.hpp")
find_package(standardese REQUIRED)
standardese_generate(canary_docs
INCLUDE_DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/include
${Boost_INCLUDE_DIR}
MACRO_DEFINITION
CANARY_SEPARATE_COMPILATION
INPUT ${CANARY_HEADERS})
endif()