-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
127 lines (97 loc) · 2.73 KB
/
CMakeLists.txt
File metadata and controls
127 lines (97 loc) · 2.73 KB
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
cmake_minimum_required(VERSION 3.16)
project(tg-cli CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip
)
FetchContent_MakeAvailable(googletest)
enable_testing()
include(GoogleTest)
set(ENV_FILE "${CMAKE_SOURCE_DIR}/.env")
if (EXISTS "${ENV_FILE}")
file(READ "${ENV_FILE}" ENV_CONTENTS)
string(REPLACE "\n" ";" ENV_LINES "${ENV_CONTENTS}")
foreach (line ${ENV_LINES})
if (line MATCHES "^#.*" OR line STREQUAL "")
continue()
endif ()
string(REGEX MATCH "^[A-Za-z_][A-Za-z0-9_]*" KEY "${line}")
string(REPLACE "${KEY}=" "" VALUE "${line}")
set(${KEY} "${VALUE}")
add_compile_definitions(${KEY}="${VALUE}")
endforeach ()
endif ()
set(DEFAULT_TDLIB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/third_party/td/tdlib")
set(TDLIB_ROOT "${DEFAULT_TDLIB_ROOT}" CACHE PATH
"Path to TDLib install dir (with include/ and lib/)")
if (NOT EXISTS "${TDLIB_ROOT}/include/td" OR NOT EXISTS "${TDLIB_ROOT}/lib")
message(FATAL_ERROR
"TDLib not found at TDLIB_ROOT='${TDLIB_ROOT}'. "
"Did you run TDLib build & install in third_party/td?"
)
endif ()
set(Td_DIR "${TDLIB_ROOT}/lib/cmake/Td")
find_package(Td 1.8.58 REQUIRED)
# TG CLI LIB
add_library(tg-cli-lib
src/label/Label.cpp
src/tgClient/TgClientTdlib.cpp
src/controllers/AuthController.cpp
src/controllers/GetChatsController.cpp
src/controllers/SendMessageController.cpp
src/controllers/ChatHistoryController.cpp
src/controllers/LabelsController.cpp
src/facade/TgClientFacade.cpp
src/label/LabelsParser.cpp
)
target_include_directories(tg-cli-lib
PUBLIC ${TDLIB_ROOT}/include
)
target_link_directories(tg-cli-lib
PUBLIC ${TDLIB_ROOT}/lib
)
target_link_libraries(tg-cli-lib
PUBLIC Td::TdStatic
)
# TG CLI
add_executable(tg-cli main/main.cpp)
target_include_directories(tg-cli
PRIVATE src
)
target_link_directories(tg-cli
PRIVATE src
)
target_link_libraries(tg-cli
PRIVATE tg-cli-lib
)
# CORE TEST
add_executable(core_test
core_test/main.cpp
)
target_include_directories(core_test
PRIVATE src
)
target_link_directories(core_test
PRIVATE src
)
target_link_libraries(core_test
PRIVATE tg-cli-lib
)
# TEST
add_executable(tests tests/test.cpp
tests/label/Label.cpp
tests/label/LabelParserTest.cpp
)
target_include_directories(tests
PRIVATE src
)
target_link_directories(tests
PRIVATE src
)
target_link_libraries(tests
PRIVATE tg-cli-lib gtest_main
)
gtest_discover_tests(tests)