-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
198 lines (176 loc) · 4.66 KB
/
Copy pathCMakeLists.txt
File metadata and controls
198 lines (176 loc) · 4.66 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
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
cmake_minimum_required(VERSION 3.16)
project(Shuttle
VERSION 1.1.0
LANGUAGES CXX
)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# -------------------------
# Version appli (unique)
# -------------------------
set(APP_VERSION "1.1.0")
string(REPLACE "." "," APP_VERSION_COMMA "${APP_VERSION}")
add_definitions(-DAPP_VERSION="${APP_VERSION}")
# -------------------------
# Génération du fichier RC
# -------------------------
if (WIN32)
string(REPLACE "\\" "/" CMAKE_SOURCE_DIR_FIXED "${CMAKE_SOURCE_DIR}")
configure_file(
${CMAKE_SOURCE_DIR}/app.rc.in
${CMAKE_BINARY_DIR}/app.rc
@ONLY
)
# Copie l'icône dans le build dir pour que le .rc la trouve
configure_file(
${CMAKE_SOURCE_DIR}/Asset/Icone.ico
${CMAKE_BINARY_DIR}/Asset/Icone.ico
COPYONLY
)
configure_file(
${CMAKE_SOURCE_DIR}/Asset/IconeOFF.ico
${CMAKE_BINARY_DIR}/Asset/IconeOFF.ico
COPYONLY
)
configure_file(
${CMAKE_SOURCE_DIR}/Asset/IconeON.ico
${CMAKE_BINARY_DIR}/Asset/IconeON.ico
COPYONLY
)
endif()
# -------------------------
# OpenSSL
# -------------------------
if(WIN32)
set(OPENSSL_USE_STATIC_LIBS TRUE)
endif()
find_package(OpenSSL REQUIRED)
if (WIN32)
add_definitions(-DOPENSSL_USE_STATIC_LIBS)
endif()
# -------------------------
# Qt Widgets (statique)
# -------------------------
find_package(Qt6 REQUIRED COMPONENTS Widgets)
# -------------------------
# Libssh2
# -------------------------
if(WIN32)
set(LIBSSH2_INCLUDE_DIR "C:/dev/libssh2/include")
set(LIBSSH2_LIBRARY "C:/dev/libssh2/build/src/libssh2.lib")
endif()
if (UNIX AND NOT APPLE)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBSSH2 REQUIRED libssh2)
endif()
# -------------------------
# Sources / Headers
# -------------------------
file(GLOB_RECURSE SOURCES
"${CMAKE_SOURCE_DIR}/src/core/*.cpp"
"${CMAKE_SOURCE_DIR}/src/ui/*.cpp"
"${CMAKE_SOURCE_DIR}/src/ui/tab/*.cpp"
"${CMAKE_SOURCE_DIR}/src/ui/monitor/*.cpp"
"${CMAKE_SOURCE_DIR}/src/ssh/*.cpp"
"${CMAKE_SOURCE_DIR}/src/sftp/*.cpp"
"${CMAKE_SOURCE_DIR}/src/terminal/*.cpp"
)
file(GLOB_RECURSE HEADERS
"${CMAKE_SOURCE_DIR}/src/core/*.h"
"${CMAKE_SOURCE_DIR}/src/ui/*.h"
"${CMAKE_SOURCE_DIR}/src/ui/tab/*.h"
"${CMAKE_SOURCE_DIR}/src/ui/monitor/*.h"
"${CMAKE_SOURCE_DIR}/src/ssh/*.h"
"${CMAKE_SOURCE_DIR}/src/sftp/*.h"
"${CMAKE_SOURCE_DIR}/src/terminal/*.h"
)
# -------------------------
# Exécutable
# -------------------------
qt_add_executable(${PROJECT_NAME}
src/main.cpp
${SOURCES}
${HEADERS}
)
# -------------------------
# Copie Asset
# -------------------------
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/Asset
$<TARGET_FILE_DIR:${PROJECT_NAME}>/Asset
)
# -------------------------
# Ressources Qt (Windows + Linux)
# -------------------------
qt_add_resources(${PROJECT_NAME} "resources"
PREFIX "/icons"
FILES
Asset/Icone.png
Asset/IconeOFF.png
Asset/IconeON.png
)
qt_add_resources(${PROJECT_NAME} "translations"
PREFIX "/translations"
FILES
Asset/translations/shuttle_fr.qm
Asset/translations/shuttle_en.qm
Asset/translations/shuttle_bz.qm
Asset/translations/shuttle_ja.qm
)
# -------------------------
# Ressources Windows (.rc)
# -------------------------
if (WIN32)
# Force le compilateur de ressources
set_source_files_properties(${CMAKE_BINARY_DIR}/app.rc
PROPERTIES
LANGUAGE RC
)
target_sources(${PROJECT_NAME} PRIVATE app.rc "src/core/LockManager.cpp" "src/core/LockManager.h")
set_target_properties(${PROJECT_NAME}
PROPERTIES
WIN32_EXECUTABLE TRUE
)
endif()
# -------------------------
# Includes
# -------------------------
target_include_directories(${PROJECT_NAME}
PRIVATE
${LIBSSH2_INCLUDE_DIR}
${LIBSSH2_INCLUDE_DIRS}
)
# -------------------------
# Link
# -------------------------
target_link_libraries(${PROJECT_NAME}
PRIVATE
Qt6::Widgets
OpenSSL::SSL
OpenSSL::Crypto
)
# -------------------------
# Link Windows
# -------------------------
if (WIN32)
target_link_libraries(${PROJECT_NAME}
PRIVATE
${LIBSSH2_LIBRARY}
ws2_32
advapi32
crypt32
)
endif()
# -------------------------
# Link Linux
# -------------------------
if (UNIX AND NOT APPLE)
target_link_libraries(${PROJECT_NAME}
PRIVATE
${LIBSSH2_LIBRARIES}
)
endif()