-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
101 lines (80 loc) · 3.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# check the minimum version
cmake_minimum_required( VERSION 3.10 )
# the project name
project( alternative-routing-lib )
# ==-----------------------------------------------------------------------== #
# General configure section
# ==-----------------------------------------------------------------------== #
# force the Release build if not already set
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif(NOT CMAKE_BUILD_TYPE)
# ==-----------------------------------------------------------------------== #
# Alternative Routing Library
# ==-----------------------------------------------------------------------== #
# Find Boost dependencies
find_package(Boost REQUIRED COMPONENTS graph)
add_subdirectory(include/arlib)
add_subdirectory(src/arlib)
add_library(arlib STATIC ${ARLIB_HEADERS} ${ARLIB_SRC})
add_library(arlib::arlib ALIAS arlib)
target_compile_options(arlib PUBLIC -std=c++17)
target_include_directories(arlib
PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(arlib
PUBLIC
Boost::graph
)
# Link <filesystem> library
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
target_link_libraries(arlib PRIVATE c++fs)
endif()
else()
target_link_libraries(arlib PRIVATE stdc++fs)
endif()
# ==-----------------------------------------------------------------------== #
# Install
# ==-----------------------------------------------------------------------== #
set(arlib_VERSION 1.0.0)
include(CMakePackageConfigHelpers)
write_basic_package_version_file("arlibConfigVersion.cmake"
VERSION ${arlib_VERSION}
COMPATIBILITY SameMajorVersion)
# Install library, target and config files
install(TARGETS arlib EXPORT arlibTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)
install(EXPORT arlibTargets
FILE arlibTargets.cmake
NAMESPACE arlib::
DESTINATION lib/cmake/arlib
)
install(FILES
"${PROJECT_SOURCE_DIR}/cmake/arlibConfig.cmake"
"${PROJECT_BINARY_DIR}/arlibConfigVersion.cmake"
DESTINATION
lib/cmake/arlib)
# Install library headers
install(DIRECTORY include/arlib DESTINATION include
FILES_MATCHING PATTERN "*.hpp")
# ==-----------------------------------------------------------------------== #
# Unit Tests
# ==-----------------------------------------------------------------------== #
add_subdirectory(test)
enable_testing(true)
add_test(NAME tests COMMAND tests)
# ==-----------------------------------------------------------------------== #
# Other
# ==-----------------------------------------------------------------------== #
# Documentation
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/doc")
# Examples
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/examples")