-
Notifications
You must be signed in to change notification settings - Fork 28
/
CMakeLists6.txt
521 lines (450 loc) · 20.9 KB
/
CMakeLists6.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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
########################################################
#
# This is a CMake configuration file.
# To use it you need CMake which can be
# downloaded from here:
# http://www.cmake.org/cmake/resources/software.html
#
#########################################################
#############################################################################
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
#############################################################################
if (CMAKE_VERSION VERSION_GREATER "3.27.9")
cmake_policy(SET CMP0153 OLD)
endif()
if( UNIX AND NOT APPLE )
# Qt6 packages minimum version 6.2 for Linux
set(QT6_NEEDED 6.4)
else()
# Qt6 packages
set(QT6_NEEDED 6.4)
endif()
find_package(Qt6 ${QT6_NEEDED} COMPONENTS Network WebEngineCore WebEngineWidgets Svg Widgets Xml PrintSupport LinguistTools)
set(CMAKE_AUTOMOC ON)
set( SOURCE_FILES
main.cpp
MainApplication.cpp
pageedit_constants.cpp
AppEventFilter.cpp
MainWindow.cpp
SelectCharacter.cpp
SelectFiles.cpp
SelectHyperlink.cpp
SelectId.cpp
SimplePage.cpp
WebPageEdit.cpp
WebViewEdit.cpp
Inspector.cpp
Preferences.cpp
AppearanceWidget.cpp
GeneralSettings.cpp
UILanguage.cpp
UIDictionary.cpp
SettingsStore.cpp
FocusSelectLineEdit.cpp
SearchToolbar.cpp
Utility.cpp
URLInterceptor.cpp
GumboInterface.cpp
HTMLEncodingResolver.cpp
OPFReader.cpp
PEDarkStyle.cpp
webviewprinter.cpp
ClipEditor.cpp
ClipEditorModel.cpp
ClipEditorTreeView.cpp
ClipsWindow.cpp
ClassInfo.cpp
WebProfileMgr.cpp
TagAtts.cpp
QuickParser.cpp
)
set( HEADER_FILES
MainApplication.h
pageedit_constants.h
pageedit_exception.h
AppEventFilter.h
MainWindow.h
Zoomable.h
Viewer.h
ElementIndex.h
SelectCharacter.h
SelectFiles.h
SelectHyperlink.h
SelectId.h
SimplePage.h
WebPageEdit.h
WebViewEdit.h
Inspector.h
Preferences.h
PreferencesWidget.h
AppearanceWidget.h
GeneralSettings.h
UILanguage.h
UIDictionary.h
SettingsStore.h
FocusSelectLineEdit.h
SearchToolbar.h
Utility.h
URLInterceptor.h
GumboInterface.h
HTMLEncodingResolver.h
OPFReader.h
PEDarkStyle.h
webviewprinter.h
ClipEditor.h
ClipEditorModel.h
ClipEditorTreeView.h
ClipsWindow.h
ClassInfo.h
WebProfileMgr.h
TagAtts.h
QuickParser.h
)
set( FORM_FILES
main.ui
SelectCharacter.ui
SelectFiles.ui
SelectHyperlink.ui
SelectId.ui
Preferences.ui
PAppearanceWidget.ui
PGeneralSettings.ui
SearchToolbar.ui
ClipEditor.ui
)
set( RESOURCE_FILES
icons/icons.qrc
javascript/javascript.qrc
dark/dark.qrc
)
if (APPLE)
LIST(APPEND SOURCE_FILES
macos_menu_and_window_fixes.mm
)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework AppKit")
endif()
file( GLOB TS_FILES ts/pageedit_*.ts )
file( GLOB EXAMPLE_FILES examples/* )
set( DICTIONARY_FILES
de_DE
en_GB
en_US
es
fr
)
set( LINUX_DESKTOP_FILE
platform/linux/freedesktop/pageedit.desktop
)
#############################################################################
# Runs UIC on specified files
qt6_wrap_ui( UI_FILES_H ${FORM_FILES} )
set_property( SOURCE ${UI_FILES_H} PROPERTY SKIP_AUTOMOC ON )
# Runs RCC on specified files
qt6_add_resources( QRC_FILES_CPP ${RESOURCE_FILES} )
set_property( SOURCE ${QRC_FILES_CPP} PROPERTY SKIP_AUTOMOC ON )
# Runs lrelease on the specified files
qt6_add_translation( QM_FILES ${TS_FILES} )
# Check if platform is 64 bit
if( NOT APPLE )
if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
set( 64_BIT_PLATFORM 0 )
else()
set( 64_BIT_PLATFORM 1 )
endif()
endif()
# Define the PageEdit version string for use in source files
set_source_files_properties( Utility.cpp PROPERTIES COMPILE_DEFINITIONS PAGEEDIT_VERSION="${PAGEEDIT_FULL_VERSION}" )
set_source_files_properties( main.cpp PROPERTIES COMPILE_DEFINITIONS PAGEEDIT_VERSION="${PAGEEDIT_FULL_VERSION}" )
set( ALL_SOURCES ${SOURCE_FILES} ${HEADER_FILES} ${UI_FILES_H} ${QRC_FILES_CPP} ${QM_FILES} )
# Adding resource (RC) files for Windows
# Grab the current year so copyright notice is updated on Windows file properties
string( TIMESTAMP BUILD_YEAR "%Y" )
if ( WIN32 )
configure_file( version.rc.in ${PROJECT_BINARY_DIR}/version.rc )
set( WINDOWS_RC_FILES
icons/icon.rc
${PROJECT_BINARY_DIR}/version.rc
)
list( APPEND ALL_SOURCES ${WINDOWS_RC_FILES} )
endif()
# Apple bundle configuration
if( APPLE )
exec_program("mkdir -p ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/PageEdit.app/Contents/Resources")
# exec_program("unzip ${MATHJAX_ZIP} -d ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/PageEdit.app/Contents/polyfills")
exec_program("cp ${PROJECT_SOURCE_DIR}/icons/PageEdit.icns ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/PageEdit.app/Contents/Resources")
exec_program("cp ${PROJECT_SOURCE_DIR}/icons/xhtml.icns ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/PageEdit.app/Contents/Resources")
# Create translation directory.
exec_program("mkdir -p ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/PageEdit.app/Contents/translations")
exec_program("mkdir -p ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/PageEdit.app/Contents/lib")
# Copy the PLIST file...
exec_program("cp ${PROJECT_SOURCE_DIR}/platform/mac/MacOSXBundleInfo.plist ${PROJECT_BINARY_DIR}")
# ...and set the PageEdit version string
exec_program("sed -i -e 's/PEVERSION/${PAGEDIT_FULL_VERSION}/g' ${PROJECT_BINARY_DIR}/MacOSXBundleInfo.plist")
# create a directory for holding spellcheck dictionaries to be found by qtwebengine
# convert them to .bdic files in the correct location
exec_program("mkdir -p ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/PageEdit.app/Contents/Resources/qtwebengine_dictionaries")
foreach( DICT ${DICTIONARY_FILES} )
exec_program("qwebengine_convert_dict ${PROJECT_SOURCE_DIR}/dictionaries/${DICT}.dic ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/PageEdit.app/Contents/Resources/qtwebengine_dictionaries/${DICT}.bdic")
endforeach( DICT )
exec_program("mkdir -p ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/PageEdit.app/Contents/examples")
endif()
#############################################################################
# We need to pick up the ui*.h files,
# and the headers for the linked-to libraries.
# The directories are in reverse order because we're using before to
# put our include dirs before any system ones.
include_directories( BEFORE
${GUMBO_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR} )
#############################################################################
# We make bundles for Mac OS X
if ( APPLE )
add_executable( ${PROJECT_NAME} MACOSX_BUNDLE ${ALL_SOURCES} )
set_target_properties( ${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/MacOSXBundleInfo.plist )
set_target_properties(${PROJECT_NAME} PROPERTIES CMAKE_SKIP_BUILD_RPATH TRUE)
# ...and a normal executable for everything else.
else()
add_executable( ${PROJECT_NAME} WIN32 ${ALL_SOURCES} )
endif()
# No need to explicity link Qt6::WinMain or to use the qt6_use_modules macro since CMAKE 2.8.11. We require CMAKE 3.0.0
target_link_libraries( ${PROJECT_NAME} ${GUMBO_LIBRARIES} Qt6::Widgets Qt6::PrintSupport
Qt6::WebEngineCore Qt6::WebEngineWidgets Qt6::Svg Qt6::Network)
#############################################################################
# "Link time code generation" flags for MSVC
if( MSVC )
add_definitions( /DUNICODE /D_UNICODE /DHAVE_ROUND )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL" )
set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG" )
# "Print all warnings" flag for GCC
elseif( CMAKE_COMPILER_IS_GNUCXX )
add_definitions( -Wall )
endif()
get_target_property(QMAKE_EXECUTABLE Qt6::qmake LOCATION)
function(QUERY_QMAKE VAR RESULT)
exec_program(${QMAKE_EXECUTABLE} ARGS "-query ${VAR}" RETURN_VALUE return_code OUTPUT_VARIABLE output )
if(NOT return_code)
file(TO_CMAKE_PATH "${output}" output)
set(${RESULT} ${output} PARENT_SCOPE)
endif(NOT return_code)
endfunction(QUERY_QMAKE)
###############################################################################
if( UNIX AND NOT APPLE )
if ( NOT SHARE_INSTALL_PREFIX )
set ( SHARE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} )
endif()
set ( PAGEEDIT_SHARE_ROOT "${SHARE_INSTALL_PREFIX}/share/${PROJECT_NAME}" )
# Set some defines that pageedit_constants.cpp can then access
set_property (
SOURCE pageedit_constants.cpp
PROPERTY COMPILE_DEFINITIONS
PAGEEDIT_SHARE_ROOT="${PAGEEDIT_SHARE_ROOT}"
)
query_qmake( QT_INSTALL_BINS QT_INSTALL_BINS_DIR )
query_qmake( QT_INSTALL_DATA QT_INSTALL_DATA_DIR )
query_qmake( QT_INSTALL_LIBEXECS QT_INSTALL_LIBEXECS_DIR )
# Bundled dictionaries will be coverted to qtwebengine spellcheck dicts with qwebengine_convert_dict
# by default and installed to qmake -query QT_INSTALL_DATA + ./qtwebengine_dictionaries.
# Use -DINSTALL_BUNDLED_DICTS=0 to prevent this.
set( CONVERTDICT ${QT_INSTALL_LIBEXECS_DIR}/qwebengine_convert_dict )
if ( NOT DEFINED INSTALL_BUNDLED_DICTS )
set ( INSTALL_BUNDLED_DICTS 1 )
endif()
set( SPELLCHECK_DICTS_SRC ${PROJECT_SOURCE_DIR}/dictionaries )
# Create converted dics in bin folder so spellcheck can work in the build directory
set( CONVERTED_DICTS_DEST ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/qtwebengine_dictionaries )
# Remove previous directories
if ( EXISTS ${CONVERTED_DICTS_DEST} )
file( REMOVE_RECURSE ${CONVERTED_DICTS_DEST} )
endif()
# Create convert the spellcheck dictionaries into the newly created destination folder
if ( INSTALL_BUNDLED_DICTS )
file( MAKE_DIRECTORY ${CONVERTED_DICTS_DEST} )
foreach( DICT ${DICTIONARY_FILES} )
execute_process( COMMAND ${CONVERTDICT} ${SPELLCHECK_DICTS_SRC}/${DICT}.dic ${CONVERTED_DICTS_DEST}/${DICT}.bdic )
endforeach( DICT )
endif()
# Standard Linux 'make install'
install( TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} )
install( FILES ${LINUX_DESKTOP_FILE} DESTINATION ${SHARE_INSTALL_PREFIX}/share/applications/ )
set( ICON_SIZE 32 48 128 256)
foreach( SIZE ${ICON_SIZE} )
install( FILES ${PROJECT_SOURCE_DIR}/icons/app_icon_${SIZE}.png DESTINATION
${SHARE_INSTALL_PREFIX}/share/icons/hicolor/${SIZE}x${SIZE}/apps RENAME pageedit.png )
endforeach( SIZE )
install( FILES ${PROJECT_SOURCE_DIR}/icons/app_icon_scalable.svg DESTINATION
${SHARE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps RENAME pageedit.svg )
install( FILES ${QM_FILES} DESTINATION ${PAGEEDIT_SHARE_ROOT}/translations/ )
# Install converted dicts to qmake -query QT_INSTALL_DATA + ./qtwebengine_dictionaries
if ( INSTALL_BUNDLED_DICTS )
install( DIRECTORY ${CONVERTED_DICTS_DEST} DESTINATION ${QT_INSTALL_DATA_DIR} )
endif()
install( FILES ${EXAMPLE_FILES} DESTINATION ${PAGEEDIT_SHARE_ROOT}/examples/ )
endif()
# For Mac, add frameworks and make a DMG
if( APPLE )
query_qmake(QT_INSTALL_TRANSLATIONS QT_TRANSLATIONS_DIR)
set( WORK_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" )
set( MAIN_PACKAGE_DIR ${WORK_DIR}/PageEdit.app )
if ("${CODE_SIGN_ID}" STREQUAL "")
add_custom_target( addframeworks
COMMAND macdeployqt PageEdit.app
WORKING_DIRECTORY ${WORK_DIR}
DEPENDS ${PROJECT_NAME} )
ELSE ()
add_custom_target( addframeworks
COMMAND macdeployqt PageEdit.app -codesign="${CODE_SIGN_ID}"
WORKING_DIRECTORY ${WORK_DIR}
DEPENDS ${PROJECT_NAME} )
ENDIF ()
add_custom_target( makedmg
COMMAND macdeployqt PageEdit.app -dmg
WORKING_DIRECTORY ${WORK_DIR})
add_custom_command( TARGET ${PROJECT_NAME} POST_BUILD COMMAND cp ${PROJECT_BINARY_DIR}/*.qm ${WORK_DIR}/PageEdit.app/Contents/translations/ )
foreach( QM ${QM_FILES} )
# Copy Qt's qm files that coincide with the above
# message( "QM = ${QM}")
string( REGEX REPLACE "(.*)(pageedit_)(.*)(\\.qm)" "\\1;\\2;\\3;\\4" PATH_ELEMENTS "${QM}" )
list( GET PATH_ELEMENTS 2 LANG_ID )
# message( "LANG_ID = ${LANG_ID}")
set( QTBASE_QM ${QT_TRANSLATIONS_DIR}/qtbase_${LANG_ID}.qm )
# message( "QTBASE_QM = ${QTBASE_QM}" )
if ( EXISTS ${QTBASE_QM} )
add_custom_command( TARGET ${PROJECT_NAME} POST_BUILD COMMAND cp ${QTBASE_QM} ${WORK_DIR}/PageEdit.app/Contents/translations/ )
endif()
endforeach( QM )
# add_custom_command( TARGET ${PROJECT_NAME} POST_BUILD COMMAND cp ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/../lib/*.dylib ${WORK_DIR}/PageEdit.app/Contents/lib/ )
# add_custom_command( TARGET ${PROJECT_NAME} POST_BUILD COMMAND install_name_tool -rpath ${CMAKE_BINARY_DIR}/lib "@executable_path/../lib" ${WORK_DIR}/PageEdit.app/Contents/MacOS/PageEdit )
add_custom_command( TARGET ${PROJECT_NAME} POST_BUILD COMMAND cp ${CMAKE_SOURCE_DIR}/examples/* ${WORK_DIR}/PageEdit.app/Contents/examples )
endif()
if ( MSVC )
query_qmake( QT_INSTALL_BINS QT_INSTALL_BINS )
query_qmake( QT_INSTALL_TRANSLATIONS QT_TRANSLATIONS_DIR )
set( TEMP_PACKAGE_DIR ${CMAKE_BINARY_DIR}/temp_folder )
set( MAIN_PACKAGE_DIR ${TEMP_PACKAGE_DIR}/PageEdit )
set( OUTPUT_PACKAGE_DIR ${CMAKE_BINARY_DIR}/deploy )
set( WINDEPLOYQT ${QT_INSTALL_BINS}/windeployqt.exe )
set( CONVERTDICT ${QT_INSTALL_BINS}/qwebengine_convert_dict.exe )
# ISS conf file for the Inno Setup compiler
# We first create a CMake configured version of the ISS file,
# and then we copy it to the temp folder every time we need to build the installer.
if ( NOT DEFINED INNO_COMP )
set( INNO_COMP zip/7 )
endif()
set( ISS_MAIN_LOCATION ${CMAKE_SOURCE_DIR}/installer/PageEdit.iss )
set( ISS_CONFIGURED_LOCATION ${CMAKE_BINARY_DIR}/PageEdit_configured.iss )
set( ISS_TEMP_LOCATION ${CMAKE_BINARY_DIR}/temp_folder/PageEdit_configured.iss )
# Specify platform var for Inno
if ( 64_BIT_PLATFORM )
# Used in the ISS CMake configuration
set( ISS_ARCH "x64" )
set( ISS_SETUP_FILENAME_PLATFORM "-x64" )
endif()
# Creates a copy of the ISS file in ${ISS_CONFIGURED_LOCATION} and then configures it
# Used in the ISS CMake configuration
set( LICENSE_LOCATION ${CMAKE_SOURCE_DIR}/installer/win_installer_note.txt )
configure_file( ${ISS_MAIN_LOCATION} ${ISS_CONFIGURED_LOCATION} )
set( pf_x86 "ProgramFiles(x86)" )
find_program(SEVENZIP_BIN
NAMES 7z 7za
HINTS "$ENV{${pf_x86}}/7-zip" "$ENV{ProgramFiles}/7-zip" "$ENV{ProgramW6432}/7-zip"
PATH_SUFFIXES bin
DOC "7zip executable"
)
message( "\n7zip location: ${SEVENZIP_BIN}\n" )
if( DEPLOY_SFX )
set( SEVENZIP_ARGS a -t7z -sfx -mx9 -xr!bearer )
set( SEVENZIP_OUTPUT "${PROJECT_NAME}_${PAGEEDIT_FULL_VERSION}.exe" )
else()
set( SEVENZIP_ARGS a -tzip -xr!bearer )
set( SEVENZIP_OUTPUT "${PROJECT_NAME}_${PAGEEDIT_FULL_VERSION}.zip" )
endif()
# Run Inno Setup's iscc compiler (*AFTER* all the PRE_BUILD custom commands execute)
add_custom_target( deployinstaller
COMMAND cmake -E echo "For this to work, Inno Setup's iscc compiler needs to be installed and on the system path."
COMMAND iscc ${ISS_TEMP_LOCATION} )
# Create zip archive (or self-extracting zip) instead of Windows installer
add_custom_target( deployzip
COMMAND ${CMAKE_COMMAND} -E echo "For this to work, 7zip needs to be installed (and possibly on the system path)."
COMMAND del ${SEVENZIP_OUTPUT}
COMMAND ${SEVENZIP_BIN} ${SEVENZIP_ARGS} ${SEVENZIP_OUTPUT} ${MAIN_PACKAGE_DIR}
WORKING_DIRECTORY ${OUTPUT_PACKAGE_DIR} )
# Intermediate step to create folders and copy files
set( TARGET_FOR_COPY copyfiles )
add_custom_target( ${TARGET_FOR_COPY}
COMMENT "Copying files to temporary location..."
DEPENDS ${PROJECT_NAME} )
add_dependencies( deployzip ${TARGET_FOR_COPY} )
add_dependencies( deployinstaller ${TARGET_FOR_COPY} )
add_custom_command( TARGET ${TARGET_FOR_COPY} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${MAIN_PACKAGE_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory ${OUTPUT_PACKAGE_DIR} )
# Set the path of the application executable
set( EXE_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX} )
# Copy the application executable
add_custom_command( TARGET ${TARGET_FOR_COPY} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${EXE_PATH} ${MAIN_PACKAGE_DIR} )
# Copy ISS file to temp folder location
add_custom_command( TARGET ${TARGET_FOR_COPY} PRE_BUILD
COMMAND cmake -E copy ${ISS_CONFIGURED_LOCATION} ${ISS_TEMP_LOCATION} )
add_custom_command( TARGET ${TARGET_FOR_COPY} POST_BUILD
COMMAND ${WINDEPLOYQT} --release --no-translations --no-compiler-runtime --dir ${MAIN_PACKAGE_DIR}
--libdir ${MAIN_PACKAGE_DIR} ${MAIN_PACKAGE_DIR}/${PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX} )
# Copy ICU libs. Windeployqt does not always pick up all three.
set( ICU_BIN_LIBS icudt icuin icuuc )
add_custom_command( TARGET ${TARGET_FOR_COPY} PRE_BUILD COMMAND cmake -E make_directory ${MAIN_PACKAGE_DIR}/ )
foreach( lib ${ICU_BIN_LIBS} )
# If the three are there (any version), copy them. Otherwise keep going without them.
file( GLOB ICU_LIB ${QT_INSTALL_BINS}/${lib}*.dll )
list( LENGTH ICU_LIB PATHS_LEN )
if( PATHS_LEN GREATER 0 )
foreach( ICU ${ICU_LIB} )
add_custom_command( TARGET ${TARGET_FOR_COPY} PRE_BUILD COMMAND cmake -E copy ${ICU} ${MAIN_PACKAGE_DIR}/ )
endforeach( ICU )
endif()
endforeach( lib )
# Copy the translation qm files
if( NOT EXISTS ${MAIN_PACKAGE_DIR}/translations )
add_custom_command( TARGET ${TARGET_FOR_COPY} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${MAIN_PACKAGE_DIR}/translations/ )
endif()
foreach( QM ${QM_FILES} )
# Copy PageEdit's qm files
add_custom_command( TARGET ${TARGET_FOR_COPY} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${QM} ${MAIN_PACKAGE_DIR}/translations/ )
# Copy Qt's qm files that coincide with the above
# message( "QM = ${QM}")
string( REGEX REPLACE "(.*)(pageedit_)(.*)(\\.qm)" "\\1;\\2;\\3;\\4" PATH_ELEMENTS "${QM}" )
list( GET PATH_ELEMENTS 2 LANG_ID )
# message( "LANG_ID = ${LANG_ID}")
set( QTBASE_QM ${QT_TRANSLATIONS_DIR}/qtbase_${LANG_ID}.qm )
# message( "QTBASE_QM = ${QTBASE_QM}" )
if ( EXISTS ${QTBASE_QM} )
add_custom_command( TARGET ${TARGET_FOR_COPY} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${QTBASE_QM} ${MAIN_PACKAGE_DIR}/translations/ )
endif()
endforeach( QM )
# Convert and copy the spellcheck dictionaries
if( NOT EXISTS ${MAIN_PACKAGE_DIR}/qtwebengine_dictionaries )
add_custom_command( TARGET ${TARGET_FOR_COPY} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${MAIN_PACKAGE_DIR}/qtwebengine_dictionaries/ )
endif()
foreach( DICT ${DICTIONARY_FILES} )
add_custom_command( TARGET ${TARGET_FOR_COPY} POST_BUILD
COMMAND ${CONVERTDICT} ${PROJECT_SOURCE_DIR}/dictionaries/${DICT}.dic ${MAIN_PACKAGE_DIR}/qtwebengine_dictionaries/${DICT}.bdic )
endforeach( DICT )
# Copy Examples
if( NOT EXISTS ${MAIN_PACKAGE_DIR}/examples )
add_custom_command( TARGET ${TARGET_FOR_COPY} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${MAIN_PACKAGE_DIR}/examples/ )
endif()
foreach( EXAMPLE ${EXAMPLE_FILES} )
add_custom_command( TARGET ${TARGET_FOR_COPY} POST_BUILD COMMAND cmake -E copy ${EXAMPLE} ${MAIN_PACKAGE_DIR}/examples/ )
endforeach( EXAMPLE )
# Remove the temp directory used for building the installer
add_custom_command( TARGET deployzip POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEMP_PACKAGE_DIR}
COMMENT "Removing temporary directory..." )
add_custom_command( TARGET deployinstaller POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEMP_PACKAGE_DIR}
COMMENT "Removing temporary directory..." )
endif( MSVC )