@@ -42,6 +42,7 @@ if (NOT DEFAULT_COMPILER_FLAGS_IS_SET)
42
42
if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX)
43
43
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wpedantic -Werror=return-type -Wno-unused" )
44
44
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Werror=return-type -Wno-unused" )
45
+ add_compile_options ("$<$<CONFIG:RELEASE>:-march=native;-mtune=native>" )
45
46
endif ()
46
47
47
48
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} "
@@ -106,7 +107,7 @@ if (WIN32)
106
107
set (ZLIB_INSTALL_PREFIX "${zlib_dir_assumed} " CACHE PATH "Prefix where zlib is installed" )
107
108
set (PNG_INSTALL_PREFIX "${png_dir_assumed} " CACHE PATH "Prefix where png is installed" )
108
109
set (TIFF_INSTALL_PREFIX "${tiff_dir_assumed} " CACHE PATH "Prefix where tiff is installed" )
109
- set (QT_INSTALL_PREFIX "${qt_dir_assumed} " CACHE PATH "Prefix where Qt5 is installed" )
110
+ set (QT_INSTALL_PREFIX "${qt_dir_assumed} " CACHE PATH "Prefix where Qt is installed" )
110
111
set (BOOST_ROOT "${boost_dir_assumed} " CACHE PATH "Prefix where Boost is installed" )
111
112
112
113
macro (list_append_existing_path Var Path )
@@ -131,7 +132,7 @@ endif()
131
132
find_package (JPEG REQUIRED)
132
133
133
134
if (WIN32 )
134
- add_dynamic_library_locations(JPEG::JPEG)
135
+ add_dynamic_library_locations(JPEG::JPEG "libjpeg-62.dll" )
135
136
endif ()
136
137
137
138
#=================================== ZLIB ===================================#
@@ -147,7 +148,7 @@ endif()
147
148
find_package (PNG REQUIRED)
148
149
149
150
if (WIN32 )
150
- add_dynamic_library_locations(PNG::PNG)
151
+ add_dynamic_library_locations(PNG::PNG "libpng16.dll" )
151
152
endif ()
152
153
153
154
#=================================== TIFF ===================================#
@@ -163,6 +164,8 @@ endif()
163
164
164
165
#================================= Boost ================================#
165
166
167
+ #set(Boost_NO_WARN_NEW_VERSIONS ON)
168
+
166
169
if (WIN32 )
167
170
if (MINGW)
168
171
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
@@ -172,10 +175,11 @@ if (WIN32)
172
175
endif ()
173
176
set (Boost_ARCHITECTURE ${_boost_architecture} CACHE STRING "" )
174
177
178
+ #set(Boost_DEBUG ON)
175
179
string (REGEX MATCHALL "[0-9]+" _boost_compiler_version ${CMAKE_CXX_COMPILER_VERSION} )
176
180
list (GET _boost_compiler_version 0 _boost_compiler_version_major)
177
181
list (GET _boost_compiler_version 1 _boost_compiler_version_minor)
178
- set (Boost_COMPILER "mgw${_boost_compiler_version_major}${_boost_compiler_version_minor } " CACHE STRING "" )
182
+ set (Boost_COMPILER "- mgw${_boost_compiler_version_major} " CACHE STRING "" )
179
183
endif ()
180
184
181
185
real_path_find_glob(boost_include_dir_hints "${BOOST_ROOT} /include/boost-[_0-9]*/boost" )
@@ -202,11 +206,40 @@ endif()
202
206
203
207
#=================================== Qt ===================================#
204
208
205
- set (qt_min_version 5.6)
209
+ set (qt_min_version 5.9)
210
+
206
211
find_package (
207
- Qt5 ${qt_min_version}
212
+ Qt6
213
+ COMPONENTS Core Gui Widgets Xml Network LinguistTools OpenGL Svg OpenGLWidgets
214
+ CONFIG)
215
+ if (Qt6_FOUND)
216
+ set (QT_BINDIR "${QT6_INSTALL_PREFIX} /bin" )
217
+ else ()
218
+ find_package (Qt5 ${qt_min_version}
208
219
COMPONENTS Core Gui Widgets Xml Network LinguistTools OpenGL Svg
209
220
CONFIG REQUIRED)
221
+ set (QT_BINDIR "${QT5_INSTALL_PREFIX} /bin" )
222
+ endif ()
223
+
224
+ if (Qt6_FOUND)
225
+ set (Qt_Core_lib Qt::Core)
226
+ set (Qt_Gui_lib Qt::Gui)
227
+ set (Qt_Network_lib Qt::Network)
228
+ set (Qt_OpenGL_lib Qt::OpenGL)
229
+ set (Qt_Svg_lib Qt::Svg)
230
+ set (Qt_Widgets_lib Qt::Widgets)
231
+ set (Qt_Xml_lib Qt::Xml)
232
+ set (Qt_OpenGLWidgets_lib Qt::OpenGLWidgets)
233
+ else ()
234
+ set (Qt_Core_lib Qt5::Core)
235
+ set (Qt_Gui_lib Qt5::Gui)
236
+ set (Qt_Network_lib Qt5::Network)
237
+ set (Qt_OpenGL_lib Qt5::OpenGL)
238
+ set (Qt_Svg_lib Qt5::Svg)
239
+ set (Qt_Widgets_lib Qt5::Widgets)
240
+ set (Qt_Xml_lib Qt5::Xml)
241
+ endif ()
242
+
210
243
211
244
#=================================== Threads ===================================#
212
245
@@ -293,7 +326,11 @@ finalize_translations(scantailor ${translation_files})
293
326
update_translations_target(update_translations scantailor)
294
327
295
328
list (FILTER translation_files EXCLUDE REGEX ".*untranslated.ts" )
296
- qt5_add_translation(qm_files ${translation_files} )
329
+ if (Qt6_FOUND)
330
+ Qt_add_translation(qm_files ${translation_files} )
331
+ else ()
332
+ Qt5_add_translation(qm_files ${translation_files} )
333
+ endif ()
297
334
add_custom_target (compile_translations ALL DEPENDS ${qm_files} )
298
335
if (WIN32 )
299
336
install (FILES ${qm_files} DESTINATION "${CMAKE_INSTALL_BINDIR} /translations" )
@@ -324,10 +361,17 @@ if (WIN32)
324
361
endmacro ()
325
362
326
363
# Install the DLLs of the dependencies.
327
- set (dep_libs
328
- JPEG::JPEG PNG::PNG ZLIB::ZLIB TIFF::TIFF
329
- Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Xml
330
- Qt5::Network Qt5::OpenGL Qt5::Svg)
364
+ if (Qt6_FOUND)
365
+ set (dep_libs
366
+ JPEG::JPEG PNG::PNG ZLIB::ZLIB TIFF::TIFF
367
+ Qt::Core Qt::Gui Qt::Widgets Qt::Xml
368
+ Qt::Network Qt::OpenGL Qt::Svg Qt6::OpenGLWidgets)
369
+ else ()
370
+ set (dep_libs
371
+ JPEG::JPEG PNG::PNG ZLIB::ZLIB TIFF::TIFF
372
+ Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Xml
373
+ Qt5::Network Qt5::OpenGL Qt5::Svg)
374
+ endif ()
331
375
332
376
foreach (_target ${dep_libs} )
333
377
get_target_property (target_type ${_target} TYPE )
@@ -346,34 +390,37 @@ if (WIN32)
346
390
add_runtime_libs_to_install(DEBUG "${debug_loc} " )
347
391
endforeach ()
348
392
349
- # Install Qt's plugins.
350
- macro (install_qt_plugin SubDir Target )
351
- if (TARGET ${Target} )
352
- get_target_property (target_type ${Target} TYPE )
353
- if (target_type STREQUAL "MODULE_LIBRARY" )
354
- get_target_property (release_loc ${Target} LOCATION_RELEASE )
355
- get_target_property (debug_loc ${Target} LOCATION_DEBUG )
356
- set_if_undefined(debug_loc "${release_loc} " )
357
-
358
- copy_to_build_dir("${release_loc} " SUBDIR ${SubDir} CONFIGURATIONS Release MinSizeRel RelWithDebInfo)
359
- install (PROGRAMS "${release_loc} "
360
- CONFIGURATIONS Release MinSizeRel RelWithDebInfo
393
+ #with Qt6, winqtdeploy is used to deploy plugins; the method below does not work anymore.
394
+ if (NOT Qt6_FOUND)
395
+ # Install Qt plugins.
396
+ macro (install_qt_plugin SubDir Target )
397
+ if (TARGET ${Target} )
398
+ get_target_property (target_type ${Target} TYPE )
399
+ if (target_type STREQUAL "MODULE_LIBRARY" )
400
+ get_target_property (release_loc ${Target} LOCATION_RELEASE )
401
+ get_target_property (debug_loc ${Target} LOCATION_DEBUG )
402
+ set_if_undefined(debug_loc "${release_loc} " )
403
+
404
+ copy_to_build_dir("${release_loc} " SUBDIR ${SubDir} CONFIGURATIONS Release MinSizeRel RelWithDebInfo)
405
+ install (PROGRAMS "${release_loc} "
406
+ CONFIGURATIONS Release MinSizeRel RelWithDebInfo
361
407
DESTINATION "${CMAKE_INSTALL_BINDIR} /${SubDir} " )
362
- copy_to_build_dir("${debug_loc} " SUBDIR ${SubDir} CONFIGURATIONS Debug)
363
- install (PROGRAMS "${debug_loc} "
364
- CONFIGURATIONS Debug
408
+ copy_to_build_dir("${debug_loc} " SUBDIR ${SubDir} CONFIGURATIONS Debug)
409
+ install (PROGRAMS "${debug_loc} "
410
+ CONFIGURATIONS Debug
365
411
DESTINATION "${CMAKE_INSTALL_BINDIR} /${SubDir} " )
412
+ endif ()
366
413
endif ()
367
- endif ()
368
- endmacro ()
414
+ endmacro ()
415
+
416
+ install_qt_plugin("platforms" Qt::QWindowsIntegrationPlugin)
417
+ install_qt_plugin("styles" Qt::QWindowsVistaStylePlugin)
418
+ install_qt_plugin("imageformats" Qt::QJpegPlugin)
419
+ install_qt_plugin("accessible" Qt::QAccessiblePlugin)
420
+ install_qt_plugin("iconengines" Qt::QSvgIconPlugin)
421
+ install_qt_plugin("imageformats" Qt::QSvgPlugin)
422
+ endif ()
369
423
370
- install_qt_plugin("platforms" Qt5::QWindowsIntegrationPlugin)
371
- install_qt_plugin("styles" Qt5::QWindowsVistaStylePlugin)
372
- install_qt_plugin("imageformats" Qt5::QJpegPlugin)
373
- install_qt_plugin("accessible" Qt5::QAccessiblePlugin)
374
- install_qt_plugin("iconengines" Qt5::QSvgIconPlugin)
375
- install_qt_plugin("imageformats" Qt5::QSvgPlugin)
376
-
377
424
# Install MinGW runtime components.
378
425
if (MINGW)
379
426
get_filename_component (_mingw_path ${CMAKE_CXX_COMPILER} PATH )
@@ -453,4 +500,4 @@ if (NOT TARGET uninstall)
453
500
add_custom_target (
454
501
uninstall
455
502
COMMAND "${CMAKE_COMMAND} " -P "${CMAKE_BINARY_DIR} /cmake_uninstall.cmake" )
456
- endif ()
503
+ endif ()
0 commit comments