-
Notifications
You must be signed in to change notification settings - Fork 39
/
CMakeLists.txt
254 lines (210 loc) · 8.55 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
#
# Copyright (C) 2020 Adrian Carpenter
#
# This file is part of a regex101.com offline application.
#
# https://github.com/fizzyade/regex101
#
# =====================================================================
# The regex101 web content is owned and used with permission from
# Firas Dib at regex101.com. This application is an unofficial
# tool to provide an offline application version of the website.
# =====================================================================
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# macOS deployment
# ----------------
#
# ./deploy.py --appleid="[email protected]" \
# --password="@keychain:signingpassword" -\
# --cert="Developer ID Application: Adrian Carpenter (5JN9ZQ38G6)" \
# --arch=x86_64 \
# --type=release \
# --qtdir="/Users/adriancarpenter/Qt/5.15.0/clang_64"
#
# Windows deployment
# ------------------
#
# python deploy.py --curlbin="C:\Tools\curl\bin\curl.exe" ^
# --qtdir="C:\Qt\5.14.2\msvc2017_64" ^
# --type=release ^
# --cert="Open Source Developer, Adrian Carpenter"
#
# Linux deployment
# ----------------
#
# ./deploy.py --qtdir="/home/adrian/Qt/5.14.2/gcc_64" \
# --curlbin="/usr/bin/curl” \
# -—cert=05DDE1C3F3B50B53112A13C231A0DBA53EEA9FE6
#
# ------------
#
# The follow definitions are available to the compiler preprocessor:
#
# APPLICATION_LONG_NAME The full application name.
# APPLICATION_SHORT_NAME The abbreviated application name.
#
# APPLICATION_GIT_YEAR The year of the current git commit.
# APPLICATION_GIT_MONTH The month of the current git commit.
# APPLICATION_GIT_DAY The day of the current git commit.
# APPLICATION_GIT_BRANCH The branch of the current git commit.
# APPLICATION_GIT_HASH The hash of the current git commit.
cmake_minimum_required(VERSION 3.5)
set(APPLICATION_SHORT_NAME "regex101")
set(APPLICATION_LONG_NAME "Regular Expressions 101")
project(${APPLICATION_LONG_NAME} LANGUAGES CXX)
if((APPLE) AND (CMAKE_OSX_ARCHITECTURES MATCHES "arm64"))
set(APPLICATION_PLATFORM_ARCH "arm64")
else()
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(APPLICATION_PLATFORM_ARCH "x86_64")
else()
set(APPLICATION_PLATFORM_ARCH "x86_32")
endif()
endif()
set(APPLICATON_SOURCE_ROOT "${CMAKE_CURRENT_LIST_DIR}")
set(APPLICATION_BIN_OUTPUT "${CMAKE_CURRENT_LIST_DIR}/bin/${APPLICATION_PLATFORM_ARCH}/${CMAKE_BUILD_TYPE}")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# The list of source files
set(APPLICATION_SOURCES
main.cpp
MainWindow.cpp
MainWindow.h
MainWindow.ui
RegExAboutDialog.cpp
RegExAboutDialog.h
RegExApiEndpoint.cpp
RegExApiEndpoint.h
RegExNullWebEnginePage.cpp
RegExNullWebEnginePage.h
RegExSplashScreen.cpp
RegExSplashScreen.h
RegExUrlRequestInterceptor.cpp
RegExUrlRequestInterceptor.h
RegExUrlSchemeHandler.cpp
RegExUrlSchemeHandler.h
RegExWebEnginePage.cpp
RegExWebEnginePage.h
RegExWebEngineProfile.cpp
RegExWebEngineProfile.h
regex101.qrc
assets/regex101.icns
Info.plist.in
opensans.qrc
SettingsDialog.cpp
SettingsDialog.h
TransparentWidget.cpp
TransparentWidget.h
RegExDatabase.cpp
RegExDatabase.h
ISettingsPage.h
DatabaseSettingsPage.cpp
DatabaseSettingsPage.h
DatabaseSettingsPage.ui
GeneralSettingsPage.cpp
GeneralSettingsPage.h
GeneralSettingsPage.ui
Cloner.cpp
Cloner.h
)
# List of Qt libraries used by the application
set(APPLICATION_QT_LIBRARIES
Core
Gui
Sql
WebEngineWidgets
WebChannel
Widgets
)
if(APPLE)
list(APPEND APPLICATION_SOURCES
MacHelper.mm
MacHelper.h
)
list(APPEND APPLICATION_QT_LIBRARIES MacExtras)
endif()
# Check that the Qt libraries are available
find_package(Qt5 COMPONENTS ${APPLICATION_QT_LIBRARIES} REQUIRED)
# use Git to produce version information and pass into compiler
find_package(Git REQUIRED)
execute_process(COMMAND git --git-dir=${APPLICATON_SOURCE_ROOT}/.git log -1 --format=%cd --date=format:%Y OUTPUT_VARIABLE APPLICATION_GIT_YEAR)
execute_process(COMMAND git --git-dir=${APPLICATON_SOURCE_ROOT}/.git log -1 --format=%cd --date=format:%m OUTPUT_VARIABLE APPLICATION_GIT_MONTH)
execute_process(COMMAND git --git-dir=${APPLICATON_SOURCE_ROOT}/.git log -1 --format=%cd --date=format:%d OUTPUT_VARIABLE APPLICATION_GIT_DAY)
execute_process(COMMAND git --git-dir=${APPLICATON_SOURCE_ROOT}/.git log -1 --format=%h OUTPUT_VARIABLE APPLICATION_GIT_HASH)
execute_process(COMMAND git --git-dir=${APPLICATON_SOURCE_ROOT}/.git branch --show-current OUTPUT_VARIABLE APPLICATION_GIT_BRANCH)
execute_process(COMMAND git --git-dir=${APPLICATON_SOURCE_ROOT}/.git diff --quiet HEAD RESULT_VARIABLE APPLICATION_GIT_UNCOMMITED)
if (APPLICATION_GIT_UNCOMMITED EQUAL 1)
set(APPLICATION_GIT_UNCOMMITED "+")
else()
set(APPLICATION_GIT_UNCOMMITED "")
endif()
if ("${APPLICATION_GIT_YEAR}" STREQUAL "")
set(APPLICATION_GIT_YEAR 0)
set(APPLICATION_GIT_MONTH 0)
set(APPLICATION_GIT_DAY 0)
set(APPLICATION_GIT_BRANCH none)
set(APPLICATION_GIT_HASH 0)
else()
string(STRIP "${APPLICATION_GIT_YEAR}" APPLICATION_GIT_YEAR)
string(STRIP "${APPLICATION_GIT_MONTH}" APPLICATION_GIT_MONTH)
string(STRIP "${APPLICATION_GIT_DAY}" APPLICATION_GIT_DAY)
string(STRIP "${APPLICATION_GIT_BRANCH}" APPLICATION_GIT_BRANCH)
string(STRIP "${APPLICATION_GIT_HASH}" APPLICATION_GIT_HASH)
endif()
# Add prepressor definitions
add_definitions("-DAPPLICATION_GIT_YEAR=\"${APPLICATION_GIT_YEAR}\"")
add_definitions("-DAPPLICATION_GIT_MONTH=\"${APPLICATION_GIT_MONTH}\"")
add_definitions("-DAPPLICATION_GIT_DAY=\"${APPLICATION_GIT_DAY}\"")
add_definitions("-DAPPLICATION_GIT_BRANCH=\"${APPLICATION_GIT_BRANCH}\"")
add_definitions("-DAPPLICATION_GIT_HASH=\"${APPLICATION_GIT_HASH}\"")
add_definitions("-DAPPLICATION_LONG_NAME=\"${APPLICATION_LONG_NAME}\"")
add_definitions("-DAPPLICATION_SHORT_NAME=\"${APPLICATION_SHORT_NAME}\"")
# Generate the list of Qt libraries to link into the application
set(APPLICATION_QT_LINK_LIBRARIES "")
foreach(arg IN ITEMS ${APPLICATION_QT_LIBRARIES})
list(APPEND APPLICATION_QT_LINK_LIBRARIES "Qt5::${arg}")
endforeach()
# Create an application executable (and ensure it's an application bundle under macOS)
add_executable(${APPLICATION_SHORT_NAME} MACOSX_BUNDLE ${APPLICATION_SOURCES})
# Set the target executable name
set_target_properties(${APPLICATION_SHORT_NAME} PROPERTIES OUTPUT_NAME "${APPLICATION_LONG_NAME}")
# Set the folder where the binary should be placed
set_target_properties(${APPLICATION_SHORT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${APPLICATION_BIN_OUTPUT})
# If macOS build, then ensure the icon is copied to the bundle and set up the Info.plist file
if(APPLE)
set_source_files_properties("assets/${APPLICATION_SHORT_NAME}.icns" PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
set_target_properties(${APPLICATION_SHORT_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${APPLICATON_SOURCE_ROOT}/Info.plist.in)
set(APPLICATION_BUNDLE_NAME "${CMAKE_PROJECT_NAME}")
set(APPLICATION_BUNDLE_ICONS "${APPLICATION_SHORT_NAME}.icns")
set(APPLICATION_BUNDLE_IDENTIFIER "com.nedrysoft.${APPLICATION_SHORT_NAME}")
set(APPLICATION_BUNDLE_SCHEME "${APPLICATION_SHORT_NAME}")
endif()
# nodejs static libration
if(EXISTS ${APPLICATON_SOURCE_ROOT}/libnode)
target_include_directories(${APPLICATION_SHORT_NAME} PRIVATE "${APPLICATON_SOURCE_ROOT}/libnode/include")
list(APPEND APPLICATION_QT_LINK_LIBRARIES "-L${APPLICATON_SOURCE_ROOT}/libnode/lib")
list(APPEND APPLICATION_QT_LINK_LIBRARIES "node")
endif()
# cocoa frameworks
if(APPLE)
list(APPEND APPLICATION_QT_LINK_LIBRARIES "-framework AppKit")
endif()
# Set the libraries be linked in
target_link_libraries(${APPLICATION_SHORT_NAME} PRIVATE ${APPLICATION_QT_LINK_LIBRARIES})