-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
293 lines (241 loc) · 8.54 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
cmake_minimum_required(VERSION 3.5)
project(pass-simple VERSION 1.0.12 LANGUAGES CXX)
# include(cmake/CPM.cmake)
# CPMAddPackage("gh:TheLartians/Format.cmake@1.7.3")
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
CMAKE_POLICY(SET CMP0071 NEW)
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(MACOSX TRUE)
endif()
if(UNIX AND NOT APPLE)
set(LINUX TRUE)
endif()
if(WIN32 OR MSVC OR MSYS OR MINGW)
set(WINDOWS TRUE)
endif()
# rnpgp specific
set(BUILD_TESTING OFF)
if(MACOSX)
# set(CMAKE_OSX_ARCHITECTURES "x86_64" )
# include( "/Users/macos/vcpkg/scripts/buildsystems/vcpkg.cmake")
endif()
if(LINUX)
# include( "/opt/vcpkg/scripts/buildsystems/vcpkg.cmake")
endif()
if(WINDOWS)
set(DCRYPTO_BACKEND "botan" )
include( "D:/vcpkg/scripts/buildsystems/vcpkg.cmake")
endif()
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets LinguistTools QuickWidgets Concurrent LabsFolderListModel Svg QuickControls2)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets LinguistTools QuickWidgets Concurrent LabsFolderListModel Svg QuickControls2)
qt_standard_project_setup(REQUIRES 6.5)
set(APP_ICON_RESOURCE_WINDOWS "${CMAKE_CURRENT_SOURCE_DIR}/rc.qrc")
add_subdirectory(QmlApp)
add_subdirectory(EditYaml)
add_subdirectory(InputType)
add_subdirectory(DropdownWithList)
add_subdirectory(Datetime)
add_subdirectory(QmlCore)
# generated files should be on build dir only
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(PROJECT_SOURCES
main.cpp
mainwindow.cpp
mainwindow.h
mainwindow.ui
about.ui
${TS_FILES}
${APP_ICON_RESOURCE_WINDOWS}
)
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(MACOSX TRUE)
set(PROJECT_OS "MACOSX")
endif()
if(UNIX AND NOT APPLE)
set(LINUX TRUE)
set(PROJECT_OS "LINUX")
endif()
if(WIN32 OR MSVC OR MSYS OR MINGW)
set(WINDOWS TRUE)
set(PROJECT_OS "WINDOWS")
endif()
configure_file("${PROJECT_SOURCE_DIR}/config.h.in" "${CMAKE_BINARY_DIR}/config.h")
if(MACOSX)
# Application icon
set(MACOSX_BUNDLE_ICON_FILE icon.icns)
set(APP_ICON_MACOSX ${CMAKE_CURRENT_SOURCE_DIR}/icon.icns)
set_source_files_properties(${APP_ICON_MACOSX} PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources")
set(CPACK_PACKAGE_NAME pass-simple)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Pass simple")
set(CPACK_PACKAGE_VENDOR "shemeshg")
include(CPack)
endif()
set(QML_IMPORT_PATH ${CMAKE_SOURCE_DIR}/QmlApp
${CMAKE_SOURCE_DIR}/EditYaml
${CMAKE_SOURCE_DIR}/InputType
${CMAKE_SOURCE_DIR}/DropdownWithList
${CMAKE_SOURCE_DIR}/Datetime
${CMAKE_SOURCE_DIR}/QmlCore
CACHE STRING "" FORCE)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(pass-simple
MANUAL_FINALIZATION
${PROJECT_SOURCES}
${APP_ICON_MACOSX}
)
# Define target properties for Android with Qt 6 as:
# set_property(TARGET pass-simple APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
else()
if(ANDROID)
add_library(pass-simple SHARED
${PROJECT_SOURCES}
)
# Define properties for Android with Qt 5 after find_package() calls as:
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
else()
add_executable(pass-simple
${PROJECT_SOURCES}
)
endif()
qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
endif()
if(UNIX)
# LibGpgError bug must include_directories on root, but can be linked in subdirectory
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/gpgfactory/libpgpfactory/cmake)
find_package(LibGpgError REQUIRED)
include_directories(${LibGpgError_INCLUDE_DIRS})
# End LibGpgError
endif()
add_subdirectory(gpgfactory/libpgpfactory)
set(TS_FILES ts/pass-simple_en_US.ts)
target_link_libraries(pass-simple PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::QuickWidgets
Qt6::Concurrent
Qt${QT_VERSION_MAJOR}::LabsFolderListModel
Qt${QT_VERSION_MAJOR}::Svg
Qt${QT_VERSION_MAJOR}::QuickControls2
QmlApp
EditYaml
InputType
DropdownWithList
Datetime
QmlCore
libpgpfactory
)
set_target_properties(pass-simple PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER PassSimple.shemeshg.com
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
OUTPUT_NAME "pass-simple"
)
if(LINUX)
set(CPACK_PACKAGE_NAME pass-simple)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Pass simple")
set(CPACK_PACKAGE_VENDOR "shemeshg")
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
set(CPACK_VERBATIM_VARIABLES ON)
set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/pass-simple")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "shemeshg <https://github.com/shemeshg>")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libxcb-cursor-dev,libc6,libstdc++6,libgcc-s1,pass,gnupg2,libgpgme-dev,libgpgmepp-dev")
INSTALL(FILES pass-simple.desktop DESTINATION share/applications)
install(FILES pass-simple.png DESTINATION share/icons/hicolor/256x256/apps)
install(FILES script/pass-simple.sh DESTINATION bin)
# dynamically configured debian control scripts
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/script/postinst
${CMAKE_CURRENT_BINARY_DIR}/script/postinst)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/script/prerm
${CMAKE_CURRENT_BINARY_DIR}/script/prerm)
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_BINARY_DIR}/script/postinst;${CMAKE_CURRENT_BINARY_DIR}/script/prerm;")
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA, ./script/postinst)
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA, ./script/prerm)
include(CPack)
set (ubuntu_so_files /lib/x86_64-linux-gnu/librnp.so.0.17.0
/lib/libbotan-3.so.2.2.0)
endif()
if(APPLE)
set(mac_SOURCES
macutils/AppKitImpl.mm
macutils/AppKit.h)
endif()
qt_add_qml_module(pass-simple
URI MainQml
VERSION 1.0
SOURCES
mainqmltype.h mainqmltype.cpp
GpgIdManageType.h GpgIdManageType.cpp
JsAsync.h JsAsync.cpp
UiGuard.h UiGuard.cpp
appfilesysmodel.h appfilesysmodel.cpp
AppSettings.cpp AppSettings.h
${mac_SOURCES}
# bug totp
QtTotp/totp.h
QtTotp/totp.cpp
QtTotp/Base32.h
QtTotp/Base32.cpp
QtTotp/Clock.h
QtTotp/Clock.cpp
QtTotp/getTotp.h
# end bug totp
# hygen srcs
QML_FILES Main.qml
)
if(CMAKE_BUILD_TYPE STREQUAL "Release")
set_property(TARGET pass-simple PROPERTY WIN32_EXECUTABLE true)
if(WINDOWS)
install(DIRECTORY
R:/WinDll/
DESTINATION bin)
# set the install/uninstall icon used for the installer itself
set (CPACK_NSIS_MUI_ICON
"${CMAKE_SOURCE_DIR}/icon.ico")
set (CPACK_NSIS_MUI_UNIICON
"${CMAKE_SOURCE_DIR}/icon.ico")
# set the add/remove programs icon using an installed executable
SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\pass-simple.exe")
set (CPACK_NSIS_PACKAGE_NAME "pass-simple")
set (CPACK_RESOURCE_FILE_LICENSE
"${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set (CPACK_CREATE_DESKTOP_LINKS pass-simple)
set (CPACK_PACKAGE_INSTALL_DIRECTORY "pass-simple")
set (CPACK_PACKAGE_INSTALL_REGISTRY_KEY "pass-simple")
set (CPACK_PACKAGE_EXECUTABLES "pass-simple" "pass-simple")
cpack_add_component(cli DISPLAY_NAME
"rnpgp cli" )
cpack_add_component(development DISPLAY_NAME
"pass-simple" )
set (CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
set(CPACK_NSIS_CREATE_ICONS_EXTRA
"CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\pass-simple.lnk' '$INSTDIR\\\\bin\\\\pass-simple.exe' '' '$INSTDIR\\\\bin\\\\icon.ico'"
)
include(CPack)
endif()
endif()
install(TARGETS pass-simple
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(pass-simple)
endif()
# Generate the deployment script for the target pass-simple.
qt_generate_deploy_qml_app_script(
TARGET pass-simple
OUTPUT_SCRIPT deploy_script
POST_INCLUDE_FILES
${POST_INCLUDE_FILES}
${ubuntu_so_files}
NO_UNSUPPORTED_PLATFORM_ERROR
)
# Call the deployment script on "cmake --install".
install(SCRIPT ${deploy_script})