-
Notifications
You must be signed in to change notification settings - Fork 112
/
CMakeLists.txt
102 lines (64 loc) · 2.1 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
102
cmake_minimum_required(VERSION 3.12)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
# config
include(RoqConfig)
# version (using git tag)
include(GetGitRepoVersion)
message("Using GIT_REPO_VERSION=${GIT_REPO_VERSION}")
# project
project(roq-api VERSION ${GIT_REPO_VERSION})
# filesystem
include(GNUInstallDirs)
# dependencies
find_package(fmt REQUIRED)
find_package(magic_enum REQUIRED)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest)
endif()
if(BUILD_TESTING)
find_package(Catch2 REQUIRED)
endif()
# autogen
find_program(ROQ_AUTOGEN roq-autogen REQUIRED)
set(TEMPLATE_DIR ${CMAKE_SOURCE_DIR}/scripts/templates)
set(SCHEMA_LINK_DIR ${CMAKE_SOURCE_DIR}/schema)
# clang-format
find_program(CLANG_FORMAT clang-format REQUIRED)
# includes
include_directories(${CMAKE_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR})
# sub-projects
add_subdirectory(${CMAKE_SOURCE_DIR}/schema)
add_subdirectory(${CMAKE_SOURCE_DIR}/include)
if(BUILD_TESTING)
add_subdirectory(${CMAKE_SOURCE_DIR}/test)
endif()
# project
add_library(${PROJECT_NAME} INTERFACE)
add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}-include-cpp)
# install (public headers)
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/include/roq/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/roq
FILES_MATCHING
PATTERN "*.h*"
PATTERN "CMakeFiles" EXCLUDE)
# doxygen
option(BUILD_DOCS "Enable doxygen" OFF)
if(BUILD_DOCS)
find_package(Doxygen)
add_subdirectory(${CMAKE_SOURCE_DIR}/doxygen)
add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}-doxygen)
add_dependencies(${PROJECT_NAME}-doxygen ${PROJECT_NAME}-include-cpp)
endif()
# install (cmake)
install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-config)
install(FILES ${CMAKE_SOURCE_DIR}/CHANGELOG.md DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/${PROJECT_NAME})
set(CMAKE_LIB_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
export(
TARGETS ${PROJECT_NAME}
NAMESPACE ${PROJECT_NAME}::
FILE ${CMAKE_LIB_DIR}/${PROJECT_NAME}-config.cmake)
install(
EXPORT ${PROJECT_NAME}-config
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CMAKE_LIB_DIR})