-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
94 lines (78 loc) · 2.42 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
cmake_minimum_required(VERSION 3.10)
project(router
VERSION 0.0.1
LANGUAGES CXX
)
add_library(router INTERFACE)
add_library(router::router ALIAS router)
target_compile_features(router INTERFACE cxx_std_17)
target_include_directories(router INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
set(ROUTER_MASTER_PROJECT OFF)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(ROUTER_MASTER_PROJECT ON)
endif()
option(ROUTER_TEST "Build the tests" ${ROUTER_MASTER_PROJECT})
# only override the warning options if we're build as the master
# project, in other cases leave them alone since we might be added
# to a project with laxer standards for dealing with warnings
if (ROUTER_MASTER_PROJECT)
# msvc does not support normal options
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# set warning level to 4
target_compile_options(router INTERFACE /W4)
else()
# include helper to enable only options which are supported
include(cmake/target_supported_compile_options.cmake)
# try all the regular options and enable them if possible
target_supported_compile_options(router INTERFACE -Wall)
target_supported_compile_options(router INTERFACE -Wextra)
target_supported_compile_options(router INTERFACE -Wdeprecated)
target_supported_compile_options(router INTERFACE -Wdocumentation)
endif()
endif()
install(
DIRECTORY include/router
DESTINATION include
)
install(
FILES include/router.h
DESTINATION include
)
install(
TARGETS router
EXPORT router-targets
DESTINATION lib
)
install(
EXPORT router-targets
NAMESPACE router::
DESTINATION lib/cmake/router
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/router/router-config-version.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
export(
EXPORT router-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/router/router-targets.cmake"
NAMESPACE router::
)
configure_file(cmake/router-config.cmake
"${CMAKE_CURRENT_BINARY_DIR}/router/router-config.cmake"
COPYONLY
)
install(
FILES
cmake/router-config.cmake
"${CMAKE_CURRENT_BINARY_DIR}/router/router-config-version.cmake"
DESTINATION
lib/cmake/router
)
if (ROUTER_TEST)
add_subdirectory(tests)
endif()