Skip to content

Commit 70d87e4

Browse files
authored
Merge branch 'master' into develop
2 parents 8d4e15f + 155807e commit 70d87e4

File tree

92 files changed

+880
-628
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+880
-628
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
build/
1+
CMakeLists.txt.user
2+
build/
3+

CMakeLists.txt

+83-36
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ if (NOT DEFAULT_COMPILER_FLAGS_IS_SET)
4242
if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX)
4343
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wpedantic -Werror=return-type -Wno-unused")
4444
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>")
4546
endif()
4647

4748
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}"
@@ -106,7 +107,7 @@ if (WIN32)
106107
set(ZLIB_INSTALL_PREFIX "${zlib_dir_assumed}" CACHE PATH "Prefix where zlib is installed")
107108
set(PNG_INSTALL_PREFIX "${png_dir_assumed}" CACHE PATH "Prefix where png is installed")
108109
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")
110111
set(BOOST_ROOT "${boost_dir_assumed}" CACHE PATH "Prefix where Boost is installed")
111112

112113
macro(list_append_existing_path Var Path)
@@ -131,7 +132,7 @@ endif()
131132
find_package(JPEG REQUIRED)
132133

133134
if (WIN32)
134-
add_dynamic_library_locations(JPEG::JPEG)
135+
add_dynamic_library_locations(JPEG::JPEG "libjpeg-62.dll")
135136
endif()
136137

137138
#=================================== ZLIB ===================================#
@@ -147,7 +148,7 @@ endif()
147148
find_package(PNG REQUIRED)
148149

149150
if (WIN32)
150-
add_dynamic_library_locations(PNG::PNG)
151+
add_dynamic_library_locations(PNG::PNG "libpng16.dll")
151152
endif()
152153

153154
#=================================== TIFF ===================================#
@@ -163,6 +164,8 @@ endif()
163164

164165
#================================= Boost ================================#
165166

167+
#set(Boost_NO_WARN_NEW_VERSIONS ON)
168+
166169
if (WIN32)
167170
if (MINGW)
168171
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
@@ -172,10 +175,11 @@ if (WIN32)
172175
endif()
173176
set(Boost_ARCHITECTURE ${_boost_architecture} CACHE STRING "")
174177

178+
#set(Boost_DEBUG ON)
175179
string(REGEX MATCHALL "[0-9]+" _boost_compiler_version ${CMAKE_CXX_COMPILER_VERSION})
176180
list(GET _boost_compiler_version 0 _boost_compiler_version_major)
177181
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 "")
179183
endif()
180184

181185
real_path_find_glob(boost_include_dir_hints "${BOOST_ROOT}/include/boost-[_0-9]*/boost")
@@ -202,11 +206,40 @@ endif()
202206

203207
#=================================== Qt ===================================#
204208

205-
set(qt_min_version 5.6)
209+
set(qt_min_version 5.9)
210+
206211
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}
208219
COMPONENTS Core Gui Widgets Xml Network LinguistTools OpenGL Svg
209220
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+
210243

211244
#=================================== Threads ===================================#
212245

@@ -293,7 +326,11 @@ finalize_translations(scantailor ${translation_files})
293326
update_translations_target(update_translations scantailor)
294327

295328
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()
297334
add_custom_target(compile_translations ALL DEPENDS ${qm_files})
298335
if (WIN32)
299336
install(FILES ${qm_files} DESTINATION "${CMAKE_INSTALL_BINDIR}/translations")
@@ -324,10 +361,17 @@ if (WIN32)
324361
endmacro()
325362

326363
# 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()
331375

332376
foreach (_target ${dep_libs})
333377
get_target_property(target_type ${_target} TYPE)
@@ -346,34 +390,37 @@ if (WIN32)
346390
add_runtime_libs_to_install(DEBUG "${debug_loc}")
347391
endforeach()
348392

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
361407
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
365411
DESTINATION "${CMAKE_INSTALL_BINDIR}/${SubDir}")
412+
endif()
366413
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()
369423

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-
377424
# Install MinGW runtime components.
378425
if (MINGW)
379426
get_filename_component(_mingw_path ${CMAKE_CXX_COMPILER} PATH)
@@ -453,4 +500,4 @@ if (NOT TARGET uninstall)
453500
add_custom_target(
454501
uninstall
455502
COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake")
456-
endif()
503+
endif()

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -413,4 +413,4 @@ has't been moved due to dirty realization. Their functionality is fully covered
413413
Building
414414
----------
415415

416-
Go to [this repository](https://github.com/4lex4/scantailor-libs-build) and follow the instructions given there.
416+
Go to [this repository](https://github.com/vigri/scantailor-libs-build) and follow the instructions given there.

cmake/AddDynamicLibraryLocations.cmake

+10-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# appropriate <prefix name>_DYNAMIC_LIBRARY_<Config> cache variables should be set
1515
# or the locations should be added to CMAKE_PROGRAM_PATH or CMAKE_PREFIX_PATH variables.
1616
#
17+
# An optional argument can be used to specify a non-standard name for the dynamic library.
1718

1819
function(add_dynamic_library_locations Targets)
1920
foreach(_target ${Targets})
@@ -38,10 +39,16 @@ function(add_dynamic_library_locations Targets)
3839
get_filename_component(imp_loc_ext ${imp_loc} EXT)
3940
if (imp_loc_ext STREQUAL CMAKE_IMPORT_LIBRARY_SUFFIX)
4041
get_filename_component(lib_name_we ${imp_loc} NAME_WE)
42+
set(candidate_names
43+
"${lib_name_we}${CMAKE_SHARED_LIBRARY_SUFFIX}")
44+
if(DEFINED ARGV1)
45+
list(APPEND candidate_names ${ARGV1})
46+
endif()
4147
find_program(
4248
${_target}_${dynamic_lib}
43-
NAMES ${lib_name_we}${CMAKE_SHARED_LIBRARY_SUFFIX}
44-
DOC Path to the dynamic library of the shared target \(skip it if the target is not shared\).)
49+
NAMES ${candidate_names}
50+
DOC Path to the dynamic library of the shared target \(skip it if the target is not shared\).
51+
NO_CACHE)
4552
if (${_target}_${dynamic_lib})
4653
set_target_properties(
4754
${_target} PROPERTIES
@@ -50,4 +57,4 @@ function(add_dynamic_library_locations Targets)
5057
endif()
5158
endforeach()
5259
endforeach()
53-
endfunction()
60+
endfunction()

cmake/UpdateTranslations.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ macro (update_translations_target _update_target) #, _targets
7272
set(_commands "")
7373
foreach (_target ${ARGN})
7474
list(
75-
APPEND _commands COMMAND Qt5::lupdate -locations absolute -no-obsolete
75+
APPEND _commands COMMAND Qt6::lupdate -locations absolute -no-obsolete
7676
-pro "${CMAKE_BINARY_DIR}/update_translations_${_target}.pro")
7777
endforeach()
7878

src/app/CMakeLists.txt

+12-1
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,15 @@ target_include_directories(
7979
"$<TARGET_PROPERTY:TIFF::TIFF,INTERFACE_INCLUDE_DIRECTORIES>")
8080
install(TARGETS scantailor RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
8181

82-
translation_sources(scantailor ${gui_only_sources} ${gui_only_ui_files})
82+
if (Qt6_FOUND AND WIN32)
83+
#manage plugins with windeployqt.
84+
add_custom_command(
85+
TARGET scantailor
86+
POST_BUILD
87+
COMMAND ${QT_BINDIR}/windeployqt $<TARGET_FILE:scantailor>
88+
COMMENT "deploy qt files alongside binary (e.g. plugins)"
89+
)
90+
install(CODE "execute_process(COMMAND \"${QT_BINDIR}/windeployqt\" \"\$\{CMAKE_INSTALL_PREFIX\}\")")
91+
endif()
92+
93+
translation_sources(scantailor ${gui_only_sources} ${gui_only_ui_files})

src/app/MainWindow.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <QSortFilterProxyModel>
1616
#include <QStackedLayout>
1717
#include <QtWidgets/QInputDialog>
18+
#include <QActionGroup>
1819
#include <boost/lambda/lambda.hpp>
1920
#include <memory>
2021

src/app/ProjectFilesDialog.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <QMessageBox>
1010
#include <QSettings>
1111
#include <QSortFilterProxyModel>
12+
#include <QVector>
1213
#include <deque>
1314

1415
#include "ImageMetadataLoader.h"

src/app/RelinkablePathVisualization.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
#include <QPaintEvent>
88
#include <QPushButton>
99
#include <QStyle>
10+
#include <QFile>
1011
#include <QStyleOption>
1112
#include <QStylePainter>
12-
#include <boost/bind.hpp>
13+
#include <boost/bind/bind.hpp>
1314

1415
#include "ColorSchemeManager.h"
1516
#include "RelinkablePath.h"
@@ -38,7 +39,6 @@ class RelinkablePathVisualization::ComponentButton : public QPushButton {
3839
RelinkablePathVisualization::RelinkablePathVisualization(QWidget* parent)
3940
: QWidget(parent), m_layout(new QHBoxLayout(this)) {
4041
m_layout->setSpacing(0);
41-
m_layout->setMargin(0);
4242
}
4343

4444
void RelinkablePathVisualization::clear() {
@@ -53,8 +53,12 @@ void RelinkablePathVisualization::clear() {
5353

5454
void RelinkablePathVisualization::setPath(const RelinkablePath& path, bool clickable) {
5555
clear();
56-
57-
QStringList components(path.normalizedPath().split(QChar('/'), QString::SkipEmptyParts));
56+
#if QT_VERSION_MAJOR == 5 and QT_VERSION_MINOR < 14
57+
auto opt = QString::SkipEmptyParts;
58+
#else
59+
auto opt = Qt::SkipEmptyParts;
60+
#endif
61+
QStringList components(path.normalizedPath().split(QChar('/'), opt));
5862
if (components.empty()) {
5963
return;
6064
}

src/app/main.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
#include "MainWindow.h"
1717

1818
int main(int argc, char* argv[]) {
19+
#if QT_VERSION_MAJOR == 5
1920
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
2021
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
21-
22+
#endif
2223
Application app(argc, argv);
2324

2425
#ifdef _WIN32

src/core/Application.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ std::list<QString> Application::getLanguagesList() const {
5858
}
5959

6060
void Application::initTranslations() {
61-
const QStringList translationDirs(QString::fromUtf8(TRANSLATION_DIRS).split(QChar(':'), QString::SkipEmptyParts));
61+
#if QT_VERSION_MAJOR == 5 and QT_VERSION_MINOR < 14
62+
auto opt = QString::SkipEmptyParts;
63+
#else
64+
auto opt = Qt::SkipEmptyParts;
65+
#endif
66+
const QStringList translationDirs(QString::fromUtf8(TRANSLATION_DIRS).split(QChar(':'), opt));
6267

6368
const QStringList languageFileFilter("scantailor_*.qm");
6469
for (const QString& path : translationDirs) {

src/core/BackgroundTask.h

+15-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,21 @@ class BackgroundTask : public AbstractCommand<FilterResultPtr>, public TaskStatu
2626

2727
Type type() const { return m_type; }
2828

29-
void cancel() override { m_cancelFlag.store(1); }
30-
31-
bool isCancelled() const override { return m_cancelFlag.load() != 0; }
29+
void cancel() override {
30+
#if QT_VERSION_MAJOR == 5 and QT_VERSION_MINOR < 14
31+
m_cancelFlag.store(1);
32+
#else
33+
m_cancelFlag.storeRelaxed(1);
34+
#endif
35+
}
36+
37+
bool isCancelled() const override {
38+
#if QT_VERSION_MAJOR == 5 and QT_VERSION_MINOR < 14
39+
return m_cancelFlag.load() != 0;
40+
#else
41+
return m_cancelFlag.loadRelaxed() != 0;
42+
#endif
43+
}
3244

3345
/**
3446
* \brief If cancelled, throws CancelledException.

src/core/BlackOnWhiteEstimator.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#include "BlackOnWhiteEstimator.h"
55

6+
#include <stdexcept>
7+
68
#include <imageproc/Binarize.h>
79
#include <imageproc/Grayscale.h>
810
#include <imageproc/Morphology.h>

0 commit comments

Comments
 (0)