blob: 6b9914d9ca17891d9d5f3546cb2072cabd8e7c00 (
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
|
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()
# Build imtui as a static lib.
set(BUILD_SHARED_LIBS OFF)
FetchContent_Declare(imtui
GIT_REPOSITORY https://github.com/ggerganov/imtui
GIT_TAG "aa55479de6ea4d3bc0f730aaf91e20c299b61742")
FetchContent_MakeAvailable(imtui)
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
.
)
target_link_libraries(${TARGET} PRIVATE
${CURL_LIBRARIES}
${CPR_LIBS}
nlohmann_json::nlohmann_json
Threads::Threads
pugixml::pugixml
imtui-ncurses
)
target_compile_options(${TARGET} PRIVATE -Wall -Wextra -Wpedantic -Werror)
install(TARGETS ${TARGET} RUNTIME DESTINATION bin)
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
imtui-ncurses
)
endif()
endforeach()
|