-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
77 lines (62 loc) · 2.04 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
cmake_minimum_required(VERSION 3.11)
cmake_policy(SET CMP0077 NEW)
project(cerberus-cpp LANGUAGES CXX)
set(CERBERUS_CPP_MAIN_PROJECT OFF)
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
set(CERBERUS_CPP_MAIN_PROJECT ON)
endif()
option(CERBERUS_CPP_FIND_YAML_CPP "Enable find_package(yaml-cpp)." ON)
option(CERBERUS_CPP_INSTALL "Enable generation of cerberus-cpp install targets" ${CERBERUS_CPP_MAIN_PROJECT})
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# When building documentation from readthedocs.io, we need to
# run CMake, but we do not need to build C++ code, so we should
# skip any required dependencies.
set(REQUIRED_STRING REQUIRED)
if(DOCS_ONLY)
set(REQUIRED_STRING "")
endif()
if(${CERBERUS_CPP_FIND_YAML_CPP})
find_package(yaml-cpp 0.6 ${REQUIRED_STRING})
endif()
# Add library target that can be linked against
add_library(cerberus-cpp INTERFACE)
target_include_directories(
cerberus-cpp
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_link_libraries(cerberus-cpp INTERFACE yaml-cpp)
# Add an alias target for use if this project is included as a subproject in another project
add_library(cerberus-cpp::cerberus-cpp ALIAS cerberus-cpp)
# Add documentation building
add_subdirectory(doc)
# Add the testing subdirectories
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/ext/Catch2/CMakeLists.txt)
include(CTest)
add_subdirectory(ext/Catch2)
add_subdirectory(test)
endif()
# Installation rules
include(GNUInstallDirs)
if (CERBERUS_CPP_INSTALL)
install(
TARGETS cerberus-cpp
EXPORT cerberus-cpp-config
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(
EXPORT cerberus-cpp-config
NAMESPACE cerberus-cpp::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cerberus-cpp
)
install(
DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
endif()
include(FeatureSummary)
feature_summary(WHAT ALL)