blob: 8cab78fbbe70eccf303ecaa6fd9128fca54d00cc (
plain)
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
cmake_minimum_required (VERSION 3.16)
project(rttt)
set(CMAKE_EXPORT_COMPILE_COMMANDS "on")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# dependencies
#add_subdirectory(third-party)
include(FetchContent)
find_package(CURL REQUIRED)
find_package(pugixml)
if (NOT pugixml_FOUND)
FetchContent_Declare(pugixml
GIT_REPOSITORY https://github.com/zeux/pugixml GIT_TAG v1.11.4)
FetchContent_MakeAvailable(pugixml)
endif()
find_library(CPR cpr)
set(CPR_LIBS cpr)
if (NOT CPR)
set(CPR_FORCE_USE_SYSTEM_CURL ON)
FetchContent_Declare(cpr
GIT_REPOSITORY https://github.com/libcpr/cpr.git
GIT_TAG 1.7.2)
FetchContent_MakeAvailable(cpr)
set(CPR_LIBS cpr::cpr)
endif()
find_package(nlohmann_json)
if (NOT nlohmann_json_FOUND)
FetchContent_Declare(json
GIT_REPOSITORY https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent
GIT_TAG v3.10.4)
FetchContent_GetProperties(json)
if(NOT json_POPULATED)
FetchContent_Populate(json)
add_subdirectory(${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
endif()
find_package(ftxui)
if (NOT ftxui_FOUND)
set(FETCHCONTENT_UPDATES_DISCONNECTED TRUE)
FetchContent_Declare(ftxui
GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui
GIT_TAG b63aa9e
#GIT_TAG v3.0.0
)
FetchContent_GetProperties(ftxui)
if(NOT ftxui_POPULATED)
FetchContent_Populate(ftxui)
add_subdirectory(${ftxui_SOURCE_DIR} ${ftxui_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
endif()
find_package(fmt)
if (NOT fmt_FOUND)
FetchContent_Declare(fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG master
)
FetchContent_MakeAvailable(fmt)
endif()
set (CPPZMQ_BUILD_TESTS OFF CACHE INTERNAL "Turn off cppzmq tests")
find_package(cppzmq)
if (NOT cppzmq_FOUND)
FetchContent_Declare(cppzmq
GIT_REPOSITORY https://github.com/zeromq/cppzmq
GIT_TAG v4.8.1
)
FetchContent_MakeAvailable(cppzmq)
endif()
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
# main
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Set a default build type if none was specified
set(default_build_type "Release")
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
set(default_build_type "Debug")
endif()
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
# Program name and sources
set (TARGET rttt)
set (SOURCES src/main.cpp)
# Setup executable
add_executable(${TARGET} ${SOURCES})
target_include_directories(${TARGET}
PRIVATE src/
PRIVATE test/include/
)
target_link_libraries(${TARGET}
PRIVATE ${CURL_LIBRARIES}
PRIVATE ${CPR_LIBS}
PRIVATE nlohmann_json::nlohmann_json
PRIVATE Threads::Threads
PRIVATE pugixml::pugixml
PRIVATE ftxui::screen
PRIVATE ftxui::dom
PRIVATE ftxui::component # No
PRIVATE fmt::fmt
PRIVATE cppzmq
)
# rttt-send
add_executable(rttt-send src/rttt-send.cpp)
target_link_libraries(rttt-send
PRIVATE cppzmq
PRIVATE fmt::fmt
)
# General options
target_compile_options(${TARGET} PRIVATE -Wall -Wextra -Wpedantic -Werror)
install(TARGETS ${TARGET} RUNTIME DESTINATION bin)
install(TARGETS rttt-send RUNTIME DESTINATION bin)
# Test files
FILE(GLOB TESTFILES test/catch_*.cpp)
foreach(TESTFILE ${TESTFILES})
get_filename_component(NAME ${TESTFILE} NAME_WE)
if (NOT "catch_login" STREQUAL ${NAME} OR EXISTS "test/login_credentials.hpp")
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
add_executable(${NAME} ${TESTFILE})
else()
add_executable(${NAME} EXCLUDE_FROM_ALL ${TESTFILE})
endif()
target_include_directories(${NAME} PRIVATE
.
test/include/
src/
)
target_link_libraries(${NAME} PRIVATE
${CURL_LIBRARIES}
${CPR_LIBS}
nlohmann_json::nlohmann_json
Threads::Threads
pugixml::pugixml
PRIVATE ftxui::screen
PRIVATE ftxui::dom
PRIVATE ftxui::component # No
PRIVATE fmt::fmt
)
endif()
endforeach()
|