-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
567 lines (483 loc) · 19 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
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
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0)
IF(NOT DEFINED ST_ARCH)
SET(ST_ARCH "X86")
ENDIF()
IF(ST_ARCH STREQUAL "ARM")
# Because OpenGL is always software here
SET(ENABLE_OPENGL OFF)
SET(ST_USE_QT6 ON)
ENDIF()
IF(POLICY CMP0003)
# Allow linking with full library path instead of -L/path -llibrary
CMAKE_POLICY(SET CMP0003 NEW)
ENDIF()
IF(POLICY CMP0048)
# When PROJECT() is missing the VERSION argument, set the corresponding
# CMake variables to zero.
CMAKE_POLICY(SET CMP0048 NEW)
ENDIF()
SET(
CMAKE_USER_MAKE_RULES_OVERRIDE
"${CMAKE_SOURCE_DIR}/cmake/default_cflags.cmake"
)
SET(
CMAKE_USER_MAKE_RULES_OVERRIDE_CXX
"${CMAKE_SOURCE_DIR}/cmake/default_cxxflags.cmake"
)
PROJECT("Scan Tailor Experimental")
# This should be defined after project because of CMAKE_SIZEOF_VOID_P
MATH(EXPR ST_ARCH_BITS "${CMAKE_SIZEOF_VOID_P} * 8")
IF(ST_ARCH STREQUAL "X86")
SET(ST_FULLARCH "${ST_ARCH}-${ST_ARCH_BITS}")
ELSE()
SET(ST_FULLARCH "${ST_ARCH}${ST_ARCH_BITS}")
ENDIF()
include_directories(src)
# Keep the paths outside of the build directory in RPATH
# when installing. That's useful for building with say
# a custom build of Qt.
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# Scan Tailor needs to find its shared libraries.
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib/scantailor-experimental")
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
IF(MSVC)
# Disable checked iterators for extra performance.
ADD_DEFINITIONS(-D_SECURE_SCL=0)
ENDIF()
IF(DEBUG_CLI)
ADD_DEFINITIONS(-DDEBUG_CLI)
ENDIF(DEBUG_CLI)
ENABLE_TESTING()
# An undocumented side-effect of CONFIGURE_FILE() is that it makes
# the whole project depend on the file we are parsing / copying.
CONFIGURE_FILE(
"${PROJECT_SOURCE_DIR}/src/version.h"
"${PROJECT_BINARY_DIR}/src/.version.h" COPYONLY
)
# Prevent this leftover from old builds to be used in favour
# of the one in ${PROJECT_SOURCE_DIR}
IF(NOT "${PROJECT_BINARY_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}")
FILE(REMOVE "${PROJECT_BINARY_DIR}/src/version.h")
ENDIF()
# Extract STFAMILY and VERSION from version.h
FILE(READ "${PROJECT_SOURCE_DIR}/src/version.h" version_h_contents)
STRING(
REGEX REPLACE
".*#define[ \\t]+STFAMILY[ \\t]+\"([^\"]*)\".*"
"\\1" ST_FAMILY "${version_h_contents}"
)
IF("${ST_FAMILY}" STREQUAL "${version_h_contents}")
MESSAGE(FATAL_ERROR "Failed to extract STFAMILY from version.h")
ENDIF()
STRING(TOLOWER "${ST_FAMILY}" ST_FAMILY_LOWER)
# Make ST_FAMILY with capital letter
STRING(TOUPPER "${ST_FAMILY}" ST_FAMILY)
STRING(SUBSTRING "${ST_FAMILY}" 0 1 ST_FAMILY)
STRING(SUBSTRING "${ST_FAMILY_LOWER}" 1 -1 ST_FAMILY_TEMP)
STRING(CONCAT ST_FAMILY "${ST_FAMILY}" "${ST_FAMILY_TEMP}")
# VERSION must be either empty or be in the form of X.Y.Z.Y
STRING(
REGEX REPLACE
".*#define[ \\t]+VERSION[ \\t]+\"(([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+)?)\".*"
"\\1" ST_VERSION "${version_h_contents}"
)
IF("${ST_VERSION}" STREQUAL "${version_h_contents}")
MESSAGE(FATAL_ERROR "Failed to extract VERSION from version.h")
ENDIF()
# Generate release date string
STRING(SUBSTRING "${ST_VERSION}" "2" "4" ST_RELEASE_YEAR)
STRING(SUBSTRING "${ST_VERSION}" "7" "2" ST_RELEASE_MONTH)
STRING(SUBSTRING "${ST_VERSION}" "10" "2" ST_RELEASE_DAY)
STRING(JOIN "-" ST_RELEASE_DATE "${ST_RELEASE_YEAR}" "${ST_RELEASE_MONTH}" "${ST_RELEASE_DAY}")
# This has to go quite early on, as otherwise we risk picking
# up an identically named header from a system include path.
INCLUDE_DIRECTORIES(src src/foundation src/math src/interaction src/zones)
# For config.h
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/src")
INCLUDE(CheckIncludeFile)
INCLUDE(CheckIncludeFileCXX)
INCLUDE(TestCXXAcceptsFlag)
INCLUDE(CMakeDependentOption)
INCLUDE(cmake/FindPthreads.cmake)
INCLUDE(cmake/SetDefaultBuildType.cmake)
INCLUDE(cmake/SetDefaultGccFlags.cmake)
INCLUDE(cmake/ToNativePath.cmake)
INCLUDE(cmake/UpdateTranslations.cmake)
INCLUDE(cmake/CopyToBuildDir.cmake)
INCLUDE(cmake/LibToDLL.cmake)
ST_SET_DEFAULT_BUILD_TYPE(Release)
IF(CMAKE_COMPILER_IS_GNUCC)
ST_SET_DEFAULT_GCC_FLAGS()
ENDIF(CMAKE_COMPILER_IS_GNUCC)
GET_FILENAME_COMPONENT(source_outer_dir "${PROJECT_SOURCE_DIR}/.." ABSOLUTE)
GET_FILENAME_COMPONENT(build_outer_dir "${PROJECT_BINARY_DIR}/.." ABSOLUTE)
INCLUDE(FindOpenGL)
CMAKE_DEPENDENT_OPTION(
ENABLE_OPENGL "OpenGL may be used for UI acceleration" ON
"OPENGL_FOUND" OFF
)
INCLUDE(FindOpenCL)
CMAKE_DEPENDENT_OPTION(
ENABLE_OPENCL "OpenCL may be used for acceleration of image processing" ON
"OpenCL_FOUND" OFF
)
SET(STAGING_LIBS_DIR "")
IF(WIN32)
SET(STAGING_LIBS_DIR "${DEPS_BUILD_DIR}/staging/libs")
ENDIF()
FIND_PACKAGE(Eigen3 REQUIRED)
INCLUDE_DIRECTORIES(${EIGEN3_INCLUDE_DIR})
add_compile_options(-DEIGEN_MPL2_ONLY)
# Once Eigen starts using C++11 alignas() feature, this can be removed.
ADD_DEFINITIONS(-DEIGEN_DONT_ALIGN_STATICALLY)
SET(CMAKE_AUTOMOC ON)
IF(ST_USE_QT6 STREQUAL "ON")
SET(qt_min_version 6.2.2)
FIND_PACKAGE(Qt6Core ${qt_min_version} REQUIRED)
FIND_PACKAGE(Qt6Gui ${qt_min_version} REQUIRED)
FIND_PACKAGE(Qt6Widgets ${qt_min_version} REQUIRED)
FIND_PACKAGE(Qt6Xml ${qt_min_version} REQUIRED)
FIND_PACKAGE(Qt6Network ${qt_min_version} REQUIRED)
FIND_PACKAGE(Qt6Linguist ${qt_min_version} REQUIRED)
IF(ENABLE_OPENGL)
FIND_PACKAGE(Qt6OpenGL ${qt_min_version} REQUIRED)
ENDIF()
ELSE()
SET(qt_min_version 5.3)
FIND_PACKAGE(Qt5Core ${qt_min_version} REQUIRED)
FIND_PACKAGE(Qt5Gui ${qt_min_version} REQUIRED)
FIND_PACKAGE(Qt5Widgets ${qt_min_version} REQUIRED)
FIND_PACKAGE(Qt5Xml ${qt_min_version} REQUIRED)
FIND_PACKAGE(Qt5Network ${qt_min_version} REQUIRED)
FIND_PACKAGE(Qt5LinguistTools ${qt_min_version} REQUIRED)
IF(ENABLE_OPENGL)
FIND_PACKAGE(Qt5OpenGL ${qt_min_version} REQUIRED)
ENDIF()
IF(NOT DEFINED QT_DEFAULT_MAJOR_VERSION)
SET(QT_DEFAULT_MAJOR_VERSION 5)
ENDIF()
ENDIF()
FIND_PACKAGE(JPEG REQUIRED)
INCLUDE_DIRECTORIES("${JPEG_INCLUDE_DIR}")
FIND_PACKAGE(ZLIB REQUIRED)
INCLUDE_DIRECTORIES("${ZLIB_INCLUDE_DIR}")
FIND_PACKAGE(PNG REQUIRED)
INCLUDE_DIRECTORIES("${PNG_INCLUDE_DIR}")
FIND_PACKAGE(TIFF REQUIRED)
INCLUDE_DIRECTORIES("${TIFF_INCLUDE_DIR}")
IF(WIN32)
ADD_DEFINITIONS(-DUSE_LIBTIFF_DLL)
ENDIF()
# Begin of Boost
IF(NOT ST_NO_TESTS STREQUAL "ON")
IF(WIN32)
SET(Boost_USE_STATIC_LIBS ON)
ELSE(WIN32)
ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK)
ENDIF(WIN32)
SET(Boost_USE_MULTITHREADED ON)
FIND_PACKAGE(Boost 1.35.0 COMPONENTS unit_test_framework)
IF(NOT Boost_FOUND)
MESSAGE(
FATAL_ERROR
"Could not find boost headers or libraries. "
"You may need to install a package named libboost1.35-dev or similarly. "
"Hint: create a Boost_DEBUG variable in cmake and set it to YES."
)
ENDIF(NOT Boost_FOUND)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
ENDIF()
# End of Boost
SET(EXTRA_LIBS "")
IF(UNIX)
FindPthreads()
IF(PTHREADS_FOUND)
ADD_DEFINITIONS(${PTHREADS_CFLAGS})
LINK_LIBRARIES(${PTHREADS_LIBS})
ELSE(PTHREADS_FOUND)
MESSAGE(
FATAL_ERROR
"Could not detect threading flags.\n"
"Try specifying them manually in PTHREADS_CFLAGS and PTHREADS_LIBS."
)
ENDIF(PTHREADS_FOUND)
ELSEIF(WIN32)
ADD_DEFINITIONS(-DNOMINMAX)
ENDIF(UNIX)
# Begin of Boost
IF(NOT ST_NO_TESTS STREQUAL "ON")
ADD_DEFINITIONS(-DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
ENDIF()
# End of Boost
# Generate license file
## Read plain text ScanTailor license
FILE(READ "LICENSE" ST_LICENSE)
## Read HTML ScanTailor license
FILE(READ "src/resources/GPLv3.html" ST_LICENSE_HTML)
SET(ST_LICENSE_HTML "<h1>Scantailor-${ST_FAMILY}-${ST_VERSION}</h1>${ST_LICENSE_HTML}")
## Add additional licenses for dependencies
IF(ST_LICENSE_DEPS_DIR)
SET(ST_LICENSE_SEPARATOR "\n====================\n")
SET(ST_LICENSE_SEARCH "${ST_LICENSE_DEPS_DIR}/*.txt")
FILE(GLOB ST_LICENSE_DEPS_FILES LIST_DIRECTORIES FALSE "${ST_LICENSE_SEARCH}")
FOREACH(ST_LICENSE_DEPS_FILE ${ST_LICENSE_DEPS_FILES})
FILE(READ "${ST_LICENSE_DEPS_FILE}" ST_LICENSE_TEMP)
GET_FILENAME_COMPONENT(ST_LICENSE_DEPS_FILE_SHORTNAME "${ST_LICENSE_DEPS_FILE}" NAME_WLE)
### Append to plain text license
SET(
ST_LICENSE
"${ST_LICENSE}${ST_LICENSE_SEPARATOR}${ST_LICENSE_DEPS_FILE_SHORTNAME}${ST_LICENSE_SEPARATOR}${ST_LICENSE_TEMP}"
)
### Append to HTML license
STRING(REGEX REPLACE "\n" "<br>\n" ST_LICENSE_TEMP "${ST_LICENSE_TEMP}")
SET(ST_LICENSE_HTML "${ST_LICENSE_HTML}<h1>${ST_LICENSE_DEPS_FILE_SHORTNAME}</h1><p>${ST_LICENSE_TEMP}</p>")
ENDFOREACH()
ENDIF()
## Build new license files
CONFIGURE_FILE("LICENSE_COMPLETE.in" "LICENSE_COMPLETE" NEWLINE_STYLE CRLF)
CONFIGURE_FILE("src/resources/license.html.in" "src/resources/license.html" NEWLINE_STYLE CRLF)
IF(WIN32)
LIST(APPEND EXTRA_LIBS winmm imm32 ws2_32 ole32 oleaut32 uuid gdi32 comdlg32 winspool)
ENDIF()
LIST(APPEND EXTRA_LIBS ${TIFF_LIBRARY} ${PNG_LIBRARY} ${ZLIB_LIBRARY} ${JPEG_LIBRARY})
SET(MAYBE_QT_OPENGL_MODULE "")
IF(ENABLE_OPENGL)
LIST(APPEND EXTRA_LIBS ${OPENGL_LIBRARIES})
IF(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
SET(MAYBE_QT_OPENGL_MODULE Qt5::OpenGL)
ELSE()
SET(MAYBE_QT_OPENGL_MODULE Qt6::OpenGL)
ENDIF()
ENDIF()
# Crash reporter, only Windows + MSVC supported for now.
# Must go before generating config.h, as ENABLE_CRASH_REPORTER
# goes in there.
IF(MSVC)
OPTION(ENABLE_CRASH_REPORTER "Enable crash reporter (only for official builds)" OFF)
ENDIF(MSVC)
# Prepare config.h
IF(WIN32)
SET(TRANSLATION_DIRS ".:translations")
SET(STYLESHEETS_DIR "stylesheets")
SET(PLUGIN_DIRS ".")
ELSE()
SET(TRANSLATION_DIRS ".:${CMAKE_INSTALL_PREFIX}/share/scantailor-experimental/translations")
SET(STYLESHEETS_DIR "${CMAKE_INSTALL_PREFIX}/share/scantailor-experimental/stylesheets")
SET(PLUGIN_DIRS ".:${CMAKE_INSTALL_PREFIX}/lib/scantailor-experimental")
ENDIF()
CONFIGURE_FILE(src/config.h.in ${CMAKE_BINARY_DIR}/src/config.h @ONLY)
ADD_SUBDIRECTORY(src)
INCLUDE_DIRECTORIES("${toplevel_ui_sources_BINARY_DIR}")
INSTALL(TARGETS scantailor-experimental scantailor-experimental-cli RUNTIME DESTINATION bin)
IF(ENABLE_CRASH_REPORTER)
FIND_PATH(
SYMBOLS_PATH . PATHS "${build_outer_dir}/symbols"
"${source_outer_dir}/symbols" NO_DEFAULT_PATH
DOC "The directory to write symbol information into."
)
IF(NOT SYMBOLS_PATH)
MESSAGE(FATAL_ERROR "SYMBOLS_PATH directory is not set.")
ENDIF()
# We can't build it, because it requires ATL, which is not part
# of the Visual Studio Express Edition, so we rely on a pre-built
# version which can be found in the Mozilla repository.
FIND_PROGRAM(
DUMP_SYMS_EXECUTABLE dump_syms PATHS "${build_outer_dir}" "${source_outer_dir}"
DOC "Path to dump_syms.exe, which can be found in Mozilla repository."
)
IF(NOT DUMP_SYMS_EXECUTABLE)
MESSAGE(
FATAL_ERROR "dump_syms.exe wasn't found. Specify its location manually by setting the DUMP_SYMS_EXECUTABLE variable. dump_syms.exe may be found in the Mozilla repository under /toolkit/crashreporter/tools/win32"
)
ENDIF()
INCLUDE_DIRECTORIES(crash_reporter crash_reporter/google-breakpad)
TARGET_LINK_LIBRARIES(scantailor-experimental crash_handler)
ENDIF()
# Translations
TRANSLATION_SOURCES(
scantailor-experimental
${common_sources} ${gui_only_sources} ${cli_only_sources}
)
FILE(GLOB TRANSLATION_FILES src/translations/scantailor-experimental_*.ts)
FILE(GLOB CR_TRANSLATION_FILES src/translations/crashreporter_*.ts)
FINALIZE_TRANSLATION_SET(scantailor-experimental ${TRANSLATION_FILES})
FINALIZE_TRANSLATION_SET(crashreporter ${CR_TRANSLATION_FILES})
UPDATE_TRANSLATIONS_TARGET(update_translations scantailor-experimental crashreporter)
SET(ts_files ${TRANSLATION_FILES})
IF(ENABLE_CRASH_REPORTER)
LIST(APPEND ts_files ${CR_TRANSLATION_FILES})
ENDIF(ENABLE_CRASH_REPORTER)
# Don't build *.qm files from *untranslated.ts
SET(FILTERED_TRANSLATION_FILES)
FOREACH(ts_file ${ts_files})
IF ("${ts_file}" MATCHES ".*untranslated.ts")
# Just skip it.
ELSE("${ts_file}" MATCHES ".*untranslated.ts")
LIST(APPEND FILTERED_TRANSLATION_FILES "${ts_file}")
ENDIF("${ts_file}" MATCHES ".*untranslated.ts")
ENDFOREACH(ts_file)
IF(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
QT5_ADD_TRANSLATION(QM_FILES ${FILTERED_TRANSLATION_FILES})
ELSE()
QT6_ADD_TRANSLATION(QM_FILES ${FILTERED_TRANSLATION_FILES})
ENDIF()
ADD_CUSTOM_TARGET(compile_translations ALL DEPENDS ${QM_FILES})
INSTALL(FILES ${QM_FILES} DESTINATION "share/scantailor-experimental/translations")
INSTALL(DIRECTORY "${CMAKE_SOURCE_DIR}/src/stylesheets" DESTINATION "share/scantailor-experimental")
IF(UNIX)
CONFIGURE_FILE("src/io.github.ImageProcessing_ElectronicPublications.scantailor-experimental.metainfo.xml.in" "src/share/metainfo/io.github.ImageProcessing_ElectronicPublications.scantailor-experimental.metainfo.xml")
ENDIF()
INSTALL(DIRECTORY "${CMAKE_SOURCE_DIR}/src/share/" DESTINATION "share")
# Source code packaging
SET(CPACK_CMAKE_GENERATOR "")
SET(CPACK_SOURCE_GENERATOR "TGZ")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "scantailor-experimental-${ST_VERSION}")
SET(
CPACK_SOURCE_IGNORE_FILES
"/\\\\.svn/"
"/\\\\.git/"
"~$"
"\\\\.pcs$"
"TODO.txt"
"CMakeLists.txt.user"
"/doxygen/"
"${CMAKE_BINARY_DIR}"
)
INCLUDE(CPack)
IF(WIN32)
# Copy some DLLs to the staging dir.
find_file(LIBPNG_DLL
NAMES libpng.dll libpng16.dll
PATHS ${CMAKE_PREFIX_PATH}
PATH_SUFFIXES bin lib
NO_DEFAULT_PATH)
IF(NOT LIBPNG_DLL)
message(SEND_ERROR "Could not find LIBPNG dll. You may specify it manually.")
ENDIF()
find_file(LIBJPEG_DLL
NAMES libjpeg.dll jpeg.dll jpeg62.dll
PATHS ${CMAKE_PREFIX_PATH}
PATH_SUFFIXES bin lib
NO_DEFAULT_PATH)
IF(NOT LIBJPEG_DLL)
message(SEND_ERROR "Could not find LIBJPEG dll. You may specify it manually.")
ENDIF()
find_file(LIBTIFF_DLL
NAMES libtiff.dll tiff.dll
PATHS ${CMAKE_PREFIX_PATH}
PATH_SUFFIXES bin lib
NO_DEFAULT_PATH)
IF(NOT LIBTIFF_DLL)
message(SEND_ERROR "Could not find LIBTIFF dll. You may specify it manually.")
ENDIF()
find_file(ZLIB_DLL
NAMES zdll.dll zlib.dll zlib1.dll z.dll
PATHS ${CMAKE_PREFIX_PATH}
PATH_SUFFIXES bin lib
NO_DEFAULT_PATH)
IF(NOT ZLIB_DLL)
message(SEND_ERROR "Could not find ZLIB dll. You may specify it manually.")
ENDIF()
SET(DLL_DIR "${QT_SRC_DIR}/qtbase/bin")
COPY_TO_BUILD_DIR(
"${LIBPNG_DLL}" "${LIBJPEG_DLL}"
"${LIBTIFF_DLL}" "${ZLIB_DLL}"
)
IF(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
SET(QtWidgets_LIBRARIES "${Qt5Widgets_LIBRARIES}")
SET(QtGui_LIBRARIES "${Qt5Gui_LIBRARIES}")
SET(QtCore_LIBRARIES "${Qt5Core_LIBRARIES}")
SET(QtXml_LIBRARIES "${Qt5Xml_LIBRARIES}")
SET(QtOpenGL_LIBRARIES "${Qt5OpenGL_LIBRARIES}")
SET(QtCore_DIR "${Qt5Core_DIR}")
ELSE()
SET(QtWidgets_LIBRARIES "${Qt6Widgets_LIBRARIES}")
SET(QtGui_LIBRARIES "${Qt6Gui_LIBRARIES}")
SET(QtCore_LIBRARIES "${Qt6Core_LIBRARIES}")
SET(QtXml_LIBRARIES "${Qt6Xml_LIBRARIES}")
SET(QtOpenGL_LIBRARIES "${Qt6OpenGL_LIBRARIES}")
SET(QtCore_DIR "${Qt6Core_DIR}")
ENDIF()
# Qt's libs.
SET(
qt_libs
${QtWidgets_LIBRARIES} ${QtGui_LIBRARIES}
${QtCore_LIBRARIES} ${QtXml_LIBRARIES}
)
IF(ENABLE_OPENGL)
LIST(APPEND qt_libs ${QtOpenGL_LIBRARIES})
ENDIF()
FOREACH(target ${qt_libs})
GET_TARGET_PROPERTY(debug_loc "${target}" LOCATION_DEBUG)
GET_TARGET_PROPERTY(release_loc "${target}" LOCATION_RELEASE)
COPY_TO_BUILD_DIR("${debug_loc}" CONFIGURATIONS Debug)
COPY_TO_BUILD_DIR("${release_loc}" CONFIGURATIONS Release MinSizeRel RelWithDebInfo)
ENDFOREACH()
# Qt's plugins.
cmake_path(SET Qt_DIR NORMALIZE "${QtCore_DIR}/../../..")
cmake_path(APPEND Qt_DIR "plugins" OUTPUT_VARIABLE PLUGINS_DIR)
IF(EXISTS "${PLUGINS_DIR}/imageformats/qjpeg.dll")
COPY_TO_BUILD_DIR("${PLUGINS_DIR}/imageformats/qjpeg.dll" SUBDIR imageformats
CONFIGURATIONS Release MinSizeRel RelWithDebInfo)
ENDIF()
IF(EXISTS "${PLUGINS_DIR}/imageformats/qjpegd.dll")
COPY_TO_BUILD_DIR("${PLUGINS_DIR}/imageformats/qjpegd.dll" SUBDIR imageformats
CONFIGURATIONS Debug)
ENDIF()
IF(EXISTS "${PLUGINS_DIR}/imageformats/qtiff.dll")
COPY_TO_BUILD_DIR("${PLUGINS_DIR}/imageformats/qtiff.dll" SUBDIR imageformats
CONFIGURATIONS Release MinSizeRel RelWithDebInfo)
ENDIF()
IF(EXISTS "${PLUGINS_DIR}/imageformats/qtiffd.dll")
COPY_TO_BUILD_DIR("${PLUGINS_DIR}/imageformats/qtiffd.dll" SUBDIR imageformats
CONFIGURATIONS Debug)
ENDIF()
IF(EXISTS "${PLUGINS_DIR}/platforms/qwindows.dll")
COPY_TO_BUILD_DIR("${PLUGINS_DIR}/platforms/qwindows.dll" SUBDIR platforms
CONFIGURATIONS Release MinSizeRel RelWithDebInfo)
ENDIF()
IF(EXISTS "${PLUGINS_DIR}/platforms/qwindowsd.dll")
COPY_TO_BUILD_DIR("${PLUGINS_DIR}/platforms/qwindowsd.dll" SUBDIR platforms
CONFIGURATIONS Debug)
ENDIF()
IF(EXISTS "${PLUGINS_DIR}/styles/qwindowsvistastyle.dll")
COPY_TO_BUILD_DIR("${PLUGINS_DIR}/styles/qwindowsvistastyle.dll" SUBDIR styles
CONFIGURATIONS Release MinSizeRel RelWithDebInfo)
ENDIF()
IF(EXISTS "${PLUGINS_DIR}/styles/qwindowsvistastyled.dll")
COPY_TO_BUILD_DIR("${PLUGINS_DIR}/styles/qwindowsvistastyled.dll" SUBDIR styles
CONFIGURATIONS Debug)
ENDIF()
IF(EXISTS "${PLUGINS_DIR}/styles/qmodernwindowsstyle.dll")
COPY_TO_BUILD_DIR("${PLUGINS_DIR}/styles/qmodernwindowsstyle.dll" SUBDIR styles
CONFIGURATIONS Release MinSizeRel RelWithDebInfo)
ENDIF()
IF(EXISTS "${PLUGINS_DIR}/styles/qmodernwindowsstyled.dll")
COPY_TO_BUILD_DIR("${PLUGINS_DIR}/styles/qmodernwindowsstyled.dll" SUBDIR styles
CONFIGURATIONS Debug)
ENDIF()
IF(EXISTS "${PLUGINS_DIR}/accessible/qtaccessiblewidgets.dll")
COPY_TO_BUILD_DIR(
"${PLUGINS_DIR}/accessible/qtaccessiblewidgets.dll" SUBDIR accessible
CONFIGURATIONS Release MinSizeRel RelWithDebInfo
)
ENDIF()
IF(EXISTS "${PLUGINS_DIR}/accessible/qtaccessiblewidgetsd.dll")
COPY_TO_BUILD_DIR(
"${PLUGINS_DIR}/accessible/qtaccessiblewidgetsd.dll" SUBDIR accessible
CONFIGURATIONS Debug
)
ENDIF()
#Qt's translations
FOREACH(qm_file ${QM_FILES})
STRING(REGEX REPLACE "^.*scantailor-experimental_" "${Qt_DIR}/translations/qtbase_" qtbase_qm_file "${qm_file}")
IF(EXISTS "${qtbase_qm_file}")
COPY_TO_BUILD_DIR( "${qtbase_qm_file}" SUBDIR translations )
ENDIF()
ENDFOREACH()
# Generate the target that will actually do the copying.
GENERATE_COPY_TO_BUILD_DIR_TARGET(copy_to_build_dir)
# Installer for Windows. Must go last.
ADD_SUBDIRECTORY(packaging/windows)
ENDIF(WIN32)