-
-
Notifications
You must be signed in to change notification settings - Fork 130
/
CMakeLists.txt
203 lines (173 loc) · 6.57 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
cmake_minimum_required(VERSION 3.20.0)
file(READ VERSION VERSION)
string(REGEX MATCHALL "[0-9]+" VERSION_LIST ${VERSION})
list(GET VERSION_LIST 0 VERSION_MAJOR)
list(GET VERSION_LIST 1 VERSION_MINOR)
list(GET VERSION_LIST 2 VERSION_PATCH)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "Minimum macOS version" FORCE)
project(apk-editor-studio
VERSION ${VERSION}
HOMEPAGE_URL https://qwertycube.com/apk-editor-studio/
LANGUAGES CXX
)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
if(UNIX AND NOT APPLE)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
endif()
add_executable(apk-editor-studio)
add_subdirectory(src)
find_package(Qt5 COMPONENTS Widgets Xml Network LinguistTools REQUIRED)
target_compile_definitions(apk-editor-studio PRIVATE
APPLICATION="APK Editor Studio"
VERSION="${VERSION}"
)
option(PORTABLE "Portable build" OFF)
if(PORTABLE)
target_compile_definitions(apk-editor-studio PRIVATE PORTABLE)
endif()
if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Release")
set_property(TARGET apk-editor-studio PROPERTY WIN32_EXECUTABLE TRUE)
endif()
set(TS_FILES
src/translations/apk-editor-studio.ar.ts
src/translations/apk-editor-studio.az.ts
src/translations/apk-editor-studio.bqi.ts
src/translations/apk-editor-studio.ckb.ts
src/translations/apk-editor-studio.cs.ts
src/translations/apk-editor-studio.de.ts
src/translations/apk-editor-studio.el.ts
src/translations/apk-editor-studio.en_GB.ts
src/translations/apk-editor-studio.es.ts
src/translations/apk-editor-studio.es_MX.ts
src/translations/apk-editor-studio.fa.ts
src/translations/apk-editor-studio.fr.ts
src/translations/apk-editor-studio.he.ts
src/translations/apk-editor-studio.hu.ts
src/translations/apk-editor-studio.id.ts
src/translations/apk-editor-studio.it.ts
src/translations/apk-editor-studio.ja.ts
src/translations/apk-editor-studio.ko.ts
src/translations/apk-editor-studio.pl.ts
src/translations/apk-editor-studio.pt.ts
src/translations/apk-editor-studio.ro.ts
src/translations/apk-editor-studio.ru.ts
src/translations/apk-editor-studio.sv.ts
src/translations/apk-editor-studio.tr.ts
src/translations/apk-editor-studio.uk.ts
src/translations/apk-editor-studio.vi.ts
src/translations/apk-editor-studio.zh_CN.ts
)
set_source_files_properties(${TS_FILES} PROPERTIES
# TODO Output .qm files to build directory
OUTPUT_LOCATION ${CMAKE_SOURCE_DIR}/dist/all/resources/translations
)
qt5_add_translation(QM_FILES ${TS_FILES})
target_sources(apk-editor-studio PRIVATE ${QM_FILES})
target_include_directories(apk-editor-studio PRIVATE src lib)
# KSyntaxHighlighting
add_subdirectory(lib/KSyntaxHighlighting EXCLUDE_FROM_ALL)
# QtKeychain
set(QTKEYCHAIN_STATIC ON CACHE BOOL "Build QtKeychain statically")
set(BUILD_TRANSLATIONS OFF CACHE BOOL "Build QtKeychain translations")
add_subdirectory(lib/QtKeychain EXCLUDE_FROM_ALL)
target_compile_definitions(apk-editor-studio PRIVATE QTKEYCHAIN_NO_EXPORT)
# SingleApplication
set(QAPPLICATION_CLASS QApplication CACHE STRING "Inheritance class for SingleApplication")
add_subdirectory(lib/SingleApplication EXCLUDE_FROM_ALL)
# DarkStyle
target_sources(apk-editor-studio PRIVATE
lib/DarkStyle/DarkStyle.cpp
lib/DarkStyle/darkstyle.qrc
)
target_link_libraries(apk-editor-studio
Qt5::Widgets
Qt5::Xml
Qt5::Network
KSyntaxHighlighting
SingleApplication::SingleApplication
qt5keychain
)
# Deployment
macro(deploy)
add_custom_command(
TARGET apk-editor-studio POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${ARGV1}
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/dist/${ARGV0}
${ARGV1}
)
endmacro()
function(find OUTPUT_VARIABLE FILE SEARCH_PATH)
cmake_path(NORMAL_PATH SEARCH_PATH OUTPUT_VARIABLE SEARCH_PATH)
find_file(${OUTPUT_VARIABLE} ${FILE} PATHS ${SEARCH_PATH}
NO_DEFAULT_PATH NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH
NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH
)
endfunction()
if(NOT QT_QMAKE_EXECUTABLE)
get_target_property(QT_QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION)
endif()
get_filename_component(QT_BIN_DIR "${QT_QMAKE_EXECUTABLE}" DIRECTORY)
if(WIN32)
deploy(all $<TARGET_FILE_DIR:apk-editor-studio>)
deploy(windows $<TARGET_FILE_DIR:apk-editor-studio>)
# Qt libraries
add_custom_command(
TARGET apk-editor-studio POST_BUILD
COMMAND ${QT_BIN_DIR}\\windeployqt
--core
--gui
--network
--widgets
--no-quick-import
--no-translations
--no-system-d3d-compiler
--no-compiler-runtime
--no-angle
--no-opengl-sw
$<TARGET_FILE:apk-editor-studio>
)
# OpenSSL DLLs
if(OPENSSL_ROOT_DIR)
find(OPENSSL_LIBCRYPTO_DLL "libcrypto-1_1.dll" "${OPENSSL_ROOT_DIR}/bin")
find(OPENSSL_LIBSSL_DLL "libssl-1_1.dll" "${OPENSSL_ROOT_DIR}/bin")
add_custom_command(
TARGET apk-editor-studio POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${OPENSSL_LIBCRYPTO_DLL} $<TARGET_FILE_DIR:apk-editor-studio>
COMMAND ${CMAKE_COMMAND} -E copy ${OPENSSL_LIBSSL_DLL} $<TARGET_FILE_DIR:apk-editor-studio>
)
else()
message("OpenSSL deployment disabled: OPENSSL_ROOT_DIR is not provided")
endif()
# Windows icons, version info, etc.
configure_file(
src/windows.rc.in
${CMAKE_BINARY_DIR}/windows.rc
@ONLY)
target_sources(apk-editor-studio PRIVATE ${CMAKE_BINARY_DIR}/windows.rc)
elseif(UNIX AND NOT APPLE)
deploy(all ${CMAKE_BINARY_DIR}/share/apk-editor-studio)
deploy(linux ${CMAKE_BINARY_DIR})
elseif(APPLE)
set_target_properties(apk-editor-studio PROPERTIES
MACOSX_BUNDLE ON
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/dist/macos/Info.plist.in
)
deploy(all $<TARGET_FILE_DIR:apk-editor-studio>)
deploy(macos/app $<TARGET_FILE_DIR:apk-editor-studio>/../..)
add_custom_command(
TARGET apk-editor-studio POST_BUILD
COMMAND ${QT_BIN_DIR}/macdeployqt
$<TARGET_FILE_DIR:apk-editor-studio>/../..
)
endif()
# Installation
if(WIN32)
install(DIRECTORY $<TARGET_FILE_DIR:apk-editor-studio>/ DESTINATION .)
elseif(UNIX AND NOT APPLE)
install(DIRECTORY ${CMAKE_BINARY_DIR}/bin/ DESTINATION bin USE_SOURCE_PERMISSIONS)
install(DIRECTORY ${CMAKE_BINARY_DIR}/share/ DESTINATION share)
endif()