Skip to content

Commit

Permalink
Enable compilation with Qt6 and MSVC
Browse files Browse the repository at this point in the history
Add missing headers, account for the different target path, change the
Qt binary dir determination method.
  • Loading branch information
kunzjacq committed Feb 25, 2022
1 parent a4c655f commit 4df65ca
Show file tree
Hide file tree
Showing 35 changed files with 72 additions and 29 deletions.
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,15 @@ find_package(
Qt6
COMPONENTS Core Gui Widgets Xml Network LinguistTools OpenGL Svg OpenGLWidgets
CONFIG)
if (NOT Qt6_FOUND)
if (Qt6_FOUND)
set(QT_BINDIR "${QT6_INSTALL_PREFIX}/bin")
else()
find_package(Qt5 ${qt_min_version}
COMPONENTS Core Gui Widgets Xml Network LinguistTools OpenGL Svg
CONFIG REQUIRED)
set(QT_BINDIR "${QT5_INSTALL_PREFIX}/bin")
endif()

get_filename_component(QT_BINDIR ${QT_QMAKE_EXECUTABLE} DIRECTORY)

if(Qt6_FOUND)
set(Qt_Core_lib Qt::Core)
set(Qt_Gui_lib Qt::Gui)
Expand Down
2 changes: 1 addition & 1 deletion src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ if (Qt6_FOUND AND WIN32)
add_custom_command(
TARGET scantailor
POST_BUILD
COMMAND ${QT_BINDIR}/windeployqt ${CMAKE_BINARY_DIR}
COMMAND ${QT_BINDIR}/windeployqt $<TARGET_FILE_DIR:scantailor>
COMMENT "deploy qt files alongside binary (e.g. plugins)"
)
install(CODE "execute_process(COMMAND ${QT_BINDIR}/windeployqt ${CMAKE_INSTALL_PREFIX})")
Expand Down
2 changes: 2 additions & 0 deletions src/core/BlackOnWhiteEstimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include "BlackOnWhiteEstimator.h"

#include <stdexcept>

#include <imageproc/Binarize.h>
#include <imageproc/Grayscale.h>
#include <imageproc/Morphology.h>
Expand Down
1 change: 1 addition & 0 deletions src/core/filters/output/OutputGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include <boost/bind/bind.hpp>
#include <boost/function.hpp>
#include <cmath>
#include <stdexcept>

#include "ColorParams.h"
#include "DebugImages.h"
Expand Down
4 changes: 3 additions & 1 deletion src/core/filters/output/OutputImageBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include "OutputImageBuilder.h"

#include <stdexcept>

#include <imageproc/BinaryImage.h>

#include "ForegroundType.h"
Expand Down Expand Up @@ -69,4 +71,4 @@ OutputImageBuilder& OutputImageBuilder::setForegroundType(const ForegroundType&
m_foregroundType = std::make_unique<ForegroundType>(foregroundImage);
return *this;
}
} // namespace output
} // namespace output
3 changes: 2 additions & 1 deletion src/dewarping/RasterDewarper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <QDebug>
#include <cmath>
#include <stdexcept>

#include "CylindricalSurfaceDewarper.h"

Expand Down Expand Up @@ -527,4 +528,4 @@ QImage RasterDewarper::dewarp(const QImage& src,
return dewarpRgb(src.convertToFormat(QImage::Format_RGB32), dstSize, distortionModel, modelDomain, bgColor);
}
} // RasterDewarper::dewarp
} // namespace dewarping
} // namespace dewarping
3 changes: 2 additions & 1 deletion src/imageproc/AdjustBrightness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "AdjustBrightness.h"

#include <QImage>
#include <stdexcept>

namespace imageproc {
void adjustBrightness(QImage& rgbImage, const QImage& brightness, const double wr, const double wb) {
Expand Down Expand Up @@ -73,4 +74,4 @@ void adjustBrightnessYUV(QImage& rgbImage, const QImage& brightness) {
void adjustBrightnessGrayscale(QImage& rgbImage, const QImage& brightness) {
adjustBrightness(rgbImage, brightness, 11.0 / 32.0, 5.0 / 32.0);
}
} // namespace imageproc
} // namespace imageproc
3 changes: 2 additions & 1 deletion src/imageproc/BackgroundColorCalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "BackgroundColorCalculator.h"

#include <cassert>
#include <stdexcept>

#include "Binarize.h"
#include "BinaryImage.h"
Expand Down Expand Up @@ -197,4 +198,4 @@ QColor BackgroundColorCalculator::calcDominantColor(const QImage& img, const Bin
return QColor(dominantRed, dominantGreen, dominantBlue);
}
}
} // namespace imageproc
} // namespace imageproc
3 changes: 2 additions & 1 deletion src/imageproc/Binarize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <QDebug>
#include <cassert>
#include <cmath>
#include <stdexcept>

#include "BinaryImage.h"
#include "Grayscale.h"
Expand Down Expand Up @@ -199,4 +200,4 @@ BinaryImage binarizeWolf(const QImage& src,
BinaryImage peakThreshold(const QImage& image) {
return BinaryImage(image, BinaryThreshold::peakThreshold(image));
}
} // namespace imageproc
} // namespace imageproc
2 changes: 1 addition & 1 deletion src/imageproc/BinaryImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1051,4 +1051,4 @@ void* BinaryImage::SharedData::operator new(size_t, const NumWords numWords) {
void BinaryImage::SharedData::operator delete(void* addr, NumWords) {
free(addr);
}
} // namespace imageproc
} // namespace imageproc
3 changes: 2 additions & 1 deletion src/imageproc/BinaryThreshold.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <QDebug>
#include <cassert>
#include <iostream>
#include <stdexcept>

#include "Grayscale.h"
#include "Morphology.h"
Expand Down Expand Up @@ -171,4 +172,4 @@ BinaryThreshold BinaryThreshold::mokjiThreshold(const QImage& image,
const double threshold = 0.5 * nominator / denominator;
return BinaryThreshold((int) (threshold + 0.5));
} // BinaryThreshold::mokjiThreshold
} // namespace imageproc
} // namespace imageproc
3 changes: 2 additions & 1 deletion src/imageproc/ColorSegmenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <QImage>
#include <cmath>
#include <stdexcept>

#include "BinaryImage.h"
#include "BinaryThreshold.h"
Expand Down Expand Up @@ -404,4 +405,4 @@ GrayImage ColorSegmenter::segment(const BinaryImage& image, const GrayImage& gra
ConnectivityMap segmentsMap = buildMapFromGrayscale(image);
return buildGrayImage(segmentsMap, grayImage);
}
} // namespace imageproc
} // namespace imageproc
3 changes: 2 additions & 1 deletion src/imageproc/ConnectivityMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <QDebug>
#include <QImage>
#include <stdexcept>

#include "BinaryImage.h"
#include "BitOps.h"
Expand Down Expand Up @@ -571,4 +572,4 @@ void ConnectivityMap::remapIds(const std::vector<uint32_t>& map) {
}
}
}
} // namespace imageproc
} // namespace imageproc
3 changes: 2 additions & 1 deletion src/imageproc/DrawOver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <QImage>
#include <cassert>
#include <stdexcept>

#include "BinaryImage.h"
#include "RasterOp.h"
Expand Down Expand Up @@ -52,4 +53,4 @@ void drawOver(QImage& dst, const QRect& dstRect, const QImage& src, const QRect&
srcLine += srcBpl;
}
} // drawOver
} // namespace imageproc
} // namespace imageproc
4 changes: 3 additions & 1 deletion src/imageproc/Grayscale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include "Grayscale.h"

#include <stdexcept>

#include "BinaryImage.h"
#include "BitOps.h"

Expand Down Expand Up @@ -443,4 +445,4 @@ void GrayscaleHistogram::fromAnyImage(const QImage& img, const BinaryImage& mask
}
}
}
} // namespace imageproc
} // namespace imageproc
4 changes: 3 additions & 1 deletion src/imageproc/ImageCombination.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Copyright (C) 2019 Joseph Artsimovich <[email protected]>, 4lex4 <[email protected]>
// Use of this source code is governed by the GNU GPLv3 license that can be found in the LICENSE file.


#include "ImageCombination.h"

#include <QImage>
#include <unordered_map>
#include <unordered_set>
#include <stdexcept>

#include "BinaryImage.h"

Expand Down Expand Up @@ -403,4 +405,4 @@ void applyMask(QImage& image, const BinaryImage& bwMask, const BWColor fillingCo

impl::applyMask(image, bwMask, fillingColor);
}
} // namespace imageproc
} // namespace imageproc
3 changes: 2 additions & 1 deletion src/imageproc/InfluenceMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "InfluenceMap.h"

#include <QImage>
#include <stdexcept>

#include "BinaryImage.h"
#include "BitOps.h"
Expand Down Expand Up @@ -254,4 +255,4 @@ QImage InfluenceMap::visualized() const {
}
return dst;
} // InfluenceMap::visualized
} // namespace imageproc
} // namespace imageproc
3 changes: 2 additions & 1 deletion src/imageproc/Morphology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <QDebug>
#include <cassert>
#include <cmath>
#include <stdexcept>

#include "BinaryImage.h"
#include "GrayImage.h"
Expand Down Expand Up @@ -1110,4 +1111,4 @@ BinaryImage blackTopHatTransform(const BinaryImage& src,
BinaryImage blackTopHatTransform(const BinaryImage& src, const QSize& brick, BWColor srcSurroundings) {
return blackTopHatTransform(src, brick, src.rect(), srcSurroundings);
}
} // namespace imageproc
} // namespace imageproc
4 changes: 3 additions & 1 deletion src/imageproc/OrthogonalRotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include "OrthogonalRotation.h"

#include <stdexcept>

#include "BinaryImage.h"
#include "RasterOp.h"

Expand Down Expand Up @@ -151,4 +153,4 @@ BinaryImage orthogonalRotation(const BinaryImage& src, const QRect& srcRect, con
BinaryImage orthogonalRotation(const BinaryImage& src, const int degrees) {
return orthogonalRotation(src, src.rect(), degrees);
}
} // namespace imageproc
} // namespace imageproc
1 change: 1 addition & 0 deletions src/imageproc/PolygonRasterizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <QPolygonF>
#include <boost/foreach.hpp>
#include <cassert>
#include <stdexcept>

#include "BinaryImage.h"
#include "PolygonUtils.h"
Expand Down
2 changes: 2 additions & 0 deletions src/imageproc/PolynomialSurface.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (C) 2019 Joseph Artsimovich <[email protected]>, 4lex4 <[email protected]>
// Use of this source code is governed by the GNU GPLv3 license that can be found in the LICENSE file.

#include <stdexcept>

#include "PolynomialSurface.h"

#include <QDebug>
Expand Down
1 change: 1 addition & 0 deletions src/imageproc/Posterizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "Posterizer.h"

#include <stdexcept>
#include <cassert>
#include <set>
#include <unordered_set>
Expand Down
1 change: 1 addition & 0 deletions src/imageproc/RastLineFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "RastLineFinder.h"

#include <stdexcept>
#include <boost/foreach.hpp>
#include <cassert>
#include <cmath>
Expand Down
1 change: 1 addition & 0 deletions src/imageproc/RastLineFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <QLineF>
#include <QPointF>
#include <stdexcept>
#include <cstddef>
#include <string>
#include <vector>
Expand Down
3 changes: 2 additions & 1 deletion src/imageproc/ReduceThreshold.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "ReduceThreshold.h"

#include <stdexcept>
#include <cassert>

namespace imageproc {
Expand Down Expand Up @@ -272,4 +273,4 @@ void ReduceThreshold::reduceVertLine(const int threshold) {

m_image = dst;
} // ReduceThreshold::reduceVertLine
} // namespace imageproc
} // namespace imageproc
4 changes: 3 additions & 1 deletion src/imageproc/SavGolFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include "SavGolFilter.h"

#include <stdexcept>

#include "Grayscale.h"
#include "SavGolKernel.h"

Expand Down Expand Up @@ -274,4 +276,4 @@ QImage savGolFilter(const QImage& src, const QSize& windowSize, const int horDeg
}
return savGolFilterGrayToGray(toGrayscale(src), windowSize, horDegree, vertDegree);
}
} // namespace imageproc
} // namespace imageproc
3 changes: 2 additions & 1 deletion src/imageproc/Scale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "Scale.h"

#include <stdexcept>
#include <cassert>

#include "GrayImage.h"
Expand Down Expand Up @@ -355,4 +356,4 @@ GrayImage scaleToGray(const GrayImage& src, const QSize& dstSize) {
}
return scaleGrayToGray(src, dstSize);
}
} // namespace imageproc
} // namespace imageproc
3 changes: 2 additions & 1 deletion src/imageproc/SeedFill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "SeedFill.h"

#include <QDebug>
#include <stdexcept>

#include "GrayImage.h"
#include "SeedFillGeneric.h"
Expand Down Expand Up @@ -448,4 +449,4 @@ GrayImage seedFillGraySlow(const GrayImage& seed, const GrayImage& mask, const C
}
return img;
}
} // namespace imageproc
} // namespace imageproc
3 changes: 2 additions & 1 deletion src/imageproc/Shear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "Shear.h"

#include <stdexcept>
#include <cassert>
#include <cmath>

Expand Down Expand Up @@ -168,4 +169,4 @@ void hShearInPlace(BinaryImage& image, const double shear, const double yOrigin,
void vShearInPlace(BinaryImage& image, const double shear, const double xOrigin, const BWColor backgroundColor) {
vShearFromTo(image, image, shear, xOrigin, backgroundColor);
}
} // namespace imageproc
} // namespace imageproc
Loading

0 comments on commit 4df65ca

Please sign in to comment.