-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
181 lines (157 loc) · 4.41 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
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
175
176
177
178
179
180
181
cmake_minimum_required(VERSION 3.19)
project(MonitoringSystem VERSION 1.0.0 LANGUAGES CXX)
set(CMAKE_AUTOMOC ON)
find_package(CURL REQUIRED)
find_package(Qt6 6.2 REQUIRED COMPONENTS
Gui
Core
Quick
QuickControls2
)
include_directories(
${CURL_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/model/manager/notification
${CMAKE_CURRENT_SOURCE_DIR}/model/manager/watcher
${CMAKE_CURRENT_SOURCE_DIR}/model/manager/config
${CMAKE_CURRENT_SOURCE_DIR}/model/settings/agent
${CMAKE_CURRENT_SOURCE_DIR}/model/manager/agent
${CMAKE_CURRENT_SOURCE_DIR}/model/agents/agent
${CMAKE_CURRENT_SOURCE_DIR}/model/manager/log
${CMAKE_CURRENT_SOURCE_DIR}/model/kernel
)
set(HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/model/manager/notification/notification_manager.h
${CMAKE_CURRENT_SOURCE_DIR}/model/manager/watcher/watcher_manager.h
${CMAKE_CURRENT_SOURCE_DIR}/model/manager/config/config_manager.h
${CMAKE_CURRENT_SOURCE_DIR}/model/settings/agent/agent_settings.h
${CMAKE_CURRENT_SOURCE_DIR}/model/manager/agent/agent_manager.h
${CMAKE_CURRENT_SOURCE_DIR}/model/manager/log/log_manager.h
${CMAKE_CURRENT_SOURCE_DIR}/model/agents/agent/agent.h
${CMAKE_CURRENT_SOURCE_DIR}/model/kernel/kernel.h
)
set(SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/model/manager/notification/notification_manager.cc
${CMAKE_CURRENT_SOURCE_DIR}/model/manager/watcher/watcher_manager.cc
${CMAKE_CURRENT_SOURCE_DIR}/model/manager/config/config_manager.cc
${CMAKE_CURRENT_SOURCE_DIR}/model/settings/agent/agent_settings.cc
${CMAKE_CURRENT_SOURCE_DIR}/model/manager/agent/agent_manager.cc
${CMAKE_CURRENT_SOURCE_DIR}/model/manager/log/log_manager.cc
${CMAKE_CURRENT_SOURCE_DIR}/model/agents/agent/agent.cc
${CMAKE_CURRENT_SOURCE_DIR}/model/kernel/kernel.cc
)
set(PROJECT_RESOURCES
${HEADERS}
${SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/main.cc
)
qt_add_executable(${PROJECT_NAME}
${PROJECT_RESOURCES}
)
add_definitions(
-DBUILD_DIR="${CMAKE_BINARY_DIR}"
)
qt_add_resources(${PROJECT_NAME} "icon"
PREFIX "/"
BASE data/icon
FILES
data/icon/appicon.png
)
qt_add_resources(${PROJECT_NAME} "qml"
PREFIX "/"
BASE module
FILES
module/Main.qml
module/Agents.qml
module/Logs.qml
module/Settings.qml
)
qt_add_resources(${PROJECT_NAME} "controls"
PREFIX "/"
BASE styles
FILES
styles/qtquickcontrols2.conf
)
target_compile_features(${PROJECT_NAME}
PUBLIC
cxx_std_17
)
target_compile_options(
${PROJECT_NAME}
PRIVATE
-Wall
-Werror
-Wextra
-Wpedantic
)
target_link_libraries(${PROJECT_NAME}
PRIVATE
Qt6::Gui
Qt6::Core
Qt6::Quick
CURL::libcurl
Qt6::QuickControls2
)
if(APPLE)
set_target_properties(${PROJECT_NAME} PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME}
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
)
elseif(UNIX AND NOT APPLE)
set_target_properties(${PROJECT_NAME} PROPERTIES
INSTALL_RPATH "$ORIGIN"
)
else()
message(FATAL_ERROR "unsupported platform")
endif()
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD COMMAND
${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/agents
)
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD COMMAND
${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/logs
)
find_program(CPPCHECK cppcheck)
if(CPPCHECK)
message(STATUS "cppcheck found: ${CPPCHECK}")
list(
APPEND CPPCHECK_ARGS
"--enable=all"
"--inconclusive"
"--quiet"
"--language=c++"
"--std=c++17"
"--suppress=missingInclude"
"--suppress=unusedFunction"
"--suppress=unusedStructMember"
"--suppress=unknownMacro"
"--suppress=constParameter"
"--verbose"
)
add_custom_target(
cppcheck
COMMAND ${CPPCHECK} ${CPPCHECK_ARGS} ${PROJECT_RESOURCES}
)
else()
message(STATUS "cppcheck not found")
endif()
find_program(CLANG_FORMAT clang-format)
if(CLANG_FORMAT)
message(STATUS "clang-format found: ${CLANG_FORMAT}")
list(
APPEND CLANG_ARGS
"-n"
"-style=Google"
"--verbose"
)
add_custom_target(
clang-format
COMMAND ${CLANG_FORMAT} ${CLANG_ARGS} ${PROJECT_RESOURCES}
)
else()
message(STATUS "clang-format not found")
endif()