summaryrefslogtreecommitdiff
path: root/kde-apps/gwenview/files/gwenview-18.12.1-exiv2-0.27.patch
blob: 3e528e49285283cfffd13628545b30040dd3b386 (plain)
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
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
From 3637438dd1a772ee65e6b3091087bde89dc91db0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
Date: Sun, 30 Dec 2018 02:46:28 +0100
Subject: [PATCH 1/4] Use forward declaration for Exiv2::Image, port to
 std::unique_ptr

Summary:
Instead of the Exiv2::Image::AutoPtr typedef just use a forward declaration
for Exiv2::Image, and use std::unique_ptr instead of std::auto_ptr.

The forward declaration avoids pulling in Exiv2 declarations everywhere,
e.g. via document.h.

Although it would be possible to use std::auto_ptr, unique_ptr is
preferable for two reasons:
- ownership transfer is explicit (std::move, release()/reset())
- Exiv2 0.28 will use std::unique_ptr as well, i.e. the code is forward
compatible.

Reviewers: #gwenview, cfeck, ngraham

Reviewed By: #gwenview, ngraham

Subscribers: lbeltrame, ngraham, asturmlechner, shubham

Tags: #gwenview

Differential Revision: https://phabricator.kde.org/D17872
---
 lib/cms/cmsprofile.cpp                |  3 +++
 lib/cms/cmsprofile.h                  |  8 +++++---
 lib/document/abstractdocumentimpl.cpp |  5 +++--
 lib/document/abstractdocumentimpl.h   |  7 ++++++-
 lib/document/document.cpp             |  7 +++++--
 lib/document/document.h               | 11 ++++++++---
 lib/document/document_p.h             | 10 +++++++++-
 lib/document/loadingdocumentimpl.cpp  |  7 +++++--
 lib/exiv2imageloader.cpp              | 13 ++++++-------
 lib/exiv2imageloader.h                | 11 ++++++++---
 lib/jpegcontent.cpp                   | 10 +++++-----
 lib/timeutils.cpp                     |  8 +++++---
 tests/auto/cmsprofiletest.cpp         |  4 ++--
 tests/auto/imagemetainfomodeltest.cpp |  9 +++++++--
 14 files changed, 77 insertions(+), 36 deletions(-)

diff --git a/lib/cms/cmsprofile.cpp b/lib/cms/cmsprofile.cpp
index 188b90a4..7d2b753e 100644
--- a/lib/cms/cmsprofile.cpp
+++ b/lib/cms/cmsprofile.cpp
@@ -42,6 +42,9 @@ extern "C" {
 // lcms
 #include <lcms2.h>
 
+// Exiv2
+#include <exiv2/exiv2.hpp>
+
 // X11
 #ifdef HAVE_X11
 #include <X11/Xlib.h>
diff --git a/lib/cms/cmsprofile.h b/lib/cms/cmsprofile.h
index a2a38a87..06c7672d 100644
--- a/lib/cms/cmsprofile.h
+++ b/lib/cms/cmsprofile.h
@@ -29,12 +29,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
 #include <QExplicitlySharedDataPointer>
 #include <QSharedData>
 
-// Exiv2
-#include <exiv2/image.hpp>
-
 class QByteArray;
 class QString;
 
+namespace Exiv2
+{
+    class Image;
+}
+
 typedef void* cmsHPROFILE;
 
 namespace Gwenview
diff --git a/lib/document/abstractdocumentimpl.cpp b/lib/document/abstractdocumentimpl.cpp
index d841ae5f..d3d0002c 100644
--- a/lib/document/abstractdocumentimpl.cpp
+++ b/lib/document/abstractdocumentimpl.cpp
@@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 // Self
 #include "abstractdocumentimpl.h"
 
+#include <exiv2/exiv2.hpp>
 // Qt
 
 // KDE
@@ -77,9 +78,9 @@ void AbstractDocumentImpl::setDocumentKind(MimeTypeUtils::Kind kind)
     d->mDocument->setKind(kind);
 }
 
-void AbstractDocumentImpl::setDocumentExiv2Image(Exiv2::Image::AutoPtr image)
+void AbstractDocumentImpl::setDocumentExiv2Image(std::unique_ptr<Exiv2::Image> image)
 {
-    d->mDocument->setExiv2Image(image);
+    d->mDocument->setExiv2Image(std::move(image));
 }
 
 void AbstractDocumentImpl::setDocumentDownSampledImage(const QImage& image, int invertedZoom)
diff --git a/lib/document/abstractdocumentimpl.h b/lib/document/abstractdocumentimpl.h
index 5d6862b8..6c6be825 100644
--- a/lib/document/abstractdocumentimpl.h
+++ b/lib/document/abstractdocumentimpl.h
@@ -34,6 +34,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 class QImage;
 class QRect;
 
+namespace Exiv2
+{
+    class Image;
+}
+
 namespace Gwenview
 {
 
@@ -108,7 +113,7 @@ protected:
     void setDocumentImageSize(const QSize& size);
     void setDocumentKind(MimeTypeUtils::Kind);
     void setDocumentFormat(const QByteArray& format);
-    void setDocumentExiv2Image(Exiv2::Image::AutoPtr);
+    void setDocumentExiv2Image(std::unique_ptr<Exiv2::Image>);
     void setDocumentDownSampledImage(const QImage&, int invertedZoom);
     void setDocumentCmsProfile(Cms::Profile::Ptr profile);
     void setDocumentErrorString(const QString&);
diff --git a/lib/document/document.cpp b/lib/document/document.cpp
index c760be96..27003b3e 100644
--- a/lib/document/document.cpp
+++ b/lib/document/document.cpp
@@ -31,6 +31,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 #include <KLocalizedString>
 #include <KJobUiDelegate>
 
+// Exiv2
+#include <exiv2/exiv2.hpp>
+
 // Local
 #include "documentjob.h"
 #include "emptydocumentimpl.h"
@@ -388,9 +391,9 @@ AbstractDocumentEditor* Document::editor()
     return d->mImpl->editor();
 }
 
-void Document::setExiv2Image(Exiv2::Image::AutoPtr image)
+void Document::setExiv2Image(std::unique_ptr<Exiv2::Image> image)
 {
-    d->mExiv2Image = image;
+    d->mExiv2Image = std::move(image);
     d->mImageMetaInfoModel.setExiv2Image(d->mExiv2Image.get());
     emit metaInfoUpdated();
 }
diff --git a/lib/document/document.h b/lib/document/document.h
index 782111d9..4b2b3d48 100644
--- a/lib/document/document.h
+++ b/lib/document/document.h
@@ -22,8 +22,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 #include <lib/gwenviewlib_export.h>
 
-#include <string.h>
-#include <exiv2/image.hpp>
+// STL
+#include <memory>
 
 // Qt
 #include <QObject>
@@ -43,6 +43,11 @@ class QUndoStack;
 class KJob;
 class QUrl;
 
+namespace Exiv2
+{
+    class Image;
+}
+
 namespace Gwenview
 {
 
@@ -235,7 +240,7 @@ private:
     void setKind(MimeTypeUtils::Kind);
     void setFormat(const QByteArray&);
     void setSize(const QSize&);
-    void setExiv2Image(Exiv2::Image::AutoPtr);
+    void setExiv2Image(std::unique_ptr<Exiv2::Image>);
     void setDownSampledImage(const QImage&, int invertedZoom);
     void switchToImpl(AbstractDocumentImpl* impl);
     void setErrorString(const QString&);
diff --git a/lib/document/document_p.h b/lib/document/document_p.h
index 00c6f7ff..2701440f 100644
--- a/lib/document/document_p.h
+++ b/lib/document/document_p.h
@@ -21,6 +21,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
 #ifndef DOCUMENT_P_H
 #define DOCUMENT_P_H
 
+// STL
+#include <memory>
+
 // Local
 #include <imagemetainfomodel.h>
 #include <document/documentjob.h>
@@ -34,6 +37,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
 #include <QUndoStack>
 #include <QPointer>
 
+namespace Exiv2
+{
+    class Image;
+}
+
 namespace Gwenview
 {
 
@@ -54,7 +62,7 @@ struct DocumentPrivate
     QSize mSize;
     QImage mImage;
     QMap<int, QImage> mDownSampledImageMap;
-    Exiv2::Image::AutoPtr mExiv2Image;
+    std::unique_ptr<Exiv2::Image> mExiv2Image;
     MimeTypeUtils::Kind mKind;
     QByteArray mFormat;
     ImageMetaInfoModel mImageMetaInfoModel;
diff --git a/lib/document/loadingdocumentimpl.cpp b/lib/document/loadingdocumentimpl.cpp
index 713ef32c..3bcf613a 100644
--- a/lib/document/loadingdocumentimpl.cpp
+++ b/lib/document/loadingdocumentimpl.cpp
@@ -24,6 +24,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 // STL
 #include <memory>
 
+// Exiv2
+#include <exiv2/exiv2.hpp>
+
 // Qt
 #include <QBuffer>
 #include <QByteArray>
@@ -100,7 +103,7 @@ struct LoadingDocumentImplPrivate
     QByteArray mData;
     QByteArray mFormat;
     QSize mImageSize;
-    Exiv2::Image::AutoPtr mExiv2Image;
+    std::unique_ptr<Exiv2::Image> mExiv2Image;
     std::unique_ptr<JpegContent> mJpegContent;
     QImage mImage;
     Cms::Profile::Ptr mCmsProfile;
@@ -488,7 +491,7 @@ void LoadingDocumentImpl::slotMetaInfoLoaded()
 
     setDocumentFormat(d->mFormat);
     setDocumentImageSize(d->mImageSize);
-    setDocumentExiv2Image(d->mExiv2Image);
+    setDocumentExiv2Image(std::move(d->mExiv2Image));
     setDocumentCmsProfile(d->mCmsProfile);
 
     d->mMetaInfoLoaded = true;
diff --git a/lib/exiv2imageloader.cpp b/lib/exiv2imageloader.cpp
index c298c9c3..49bdf2c8 100644
--- a/lib/exiv2imageloader.cpp
+++ b/lib/exiv2imageloader.cpp
@@ -29,8 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 // KDE
 
 // Exiv2
-#include <exiv2/error.hpp>
-#include <exiv2/types.hpp>
+#include <exiv2/exiv2.hpp>
 
 // Local
 
@@ -39,7 +38,7 @@ namespace Gwenview
 
 struct Exiv2ImageLoaderPrivate
 {
-    Exiv2::Image::AutoPtr mImage;
+    std::unique_ptr<Exiv2::Image> mImage;
     QString mErrorMessage;
 };
 
@@ -57,7 +56,7 @@ bool Exiv2ImageLoader::load(const QString& filePath)
 {
     QByteArray filePathByteArray = QFile::encodeName(filePath);
     try {
-        d->mImage = Exiv2::ImageFactory::open(filePathByteArray.constData());
+        d->mImage.reset(Exiv2::ImageFactory::open(filePathByteArray.constData()).release());
         d->mImage->readMetadata();
     } catch (const Exiv2::Error& error) {
         d->mErrorMessage = error.what();
@@ -69,7 +68,7 @@ bool Exiv2ImageLoader::load(const QString& filePath)
 bool Exiv2ImageLoader::load(const QByteArray& data)
 {
     try {
-        d->mImage = Exiv2::ImageFactory::open((unsigned char*)data.constData(), data.size());
+        d->mImage.reset(Exiv2::ImageFactory::open((unsigned char*)data.constData(), data.size()).release());
         d->mImage->readMetadata();
     } catch (const Exiv2::Error& error) {
         d->mErrorMessage = error.what();
@@ -83,9 +82,9 @@ QString Exiv2ImageLoader::errorMessage() const
     return d->mErrorMessage;
 }
 
-Exiv2::Image::AutoPtr Exiv2ImageLoader::popImage()
+std::unique_ptr<Exiv2::Image> Exiv2ImageLoader::popImage()
 {
-    return d->mImage;
+    return std::move(d->mImage);
 }
 
 } // namespace
diff --git a/lib/exiv2imageloader.h b/lib/exiv2imageloader.h
index 57ef24d2..12a45b68 100644
--- a/lib/exiv2imageloader.h
+++ b/lib/exiv2imageloader.h
@@ -23,13 +23,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
 #include <lib/gwenviewlib_export.h>
 
+// STL
+#include <memory>
+
 // Qt
 
 // KDE
 
 // Exiv2
-#include <string.h>
-#include <exiv2/image.hpp>
+namespace Exiv2
+{
+    class Image;
+}
 
 // Local
 
@@ -54,7 +59,7 @@ public:
     bool load(const QString&);
     bool load(const QByteArray&);
     QString errorMessage() const;
-    Exiv2::Image::AutoPtr popImage();
+    std::unique_ptr<Exiv2::Image> popImage();
 
 private:
     Exiv2ImageLoaderPrivate* const d;
diff --git a/lib/jpegcontent.cpp b/lib/jpegcontent.cpp
index d203da5a..989a1a54 100644
--- a/lib/jpegcontent.cpp
+++ b/lib/jpegcontent.cpp
@@ -42,8 +42,7 @@ extern "C" {
 #include <KLocalizedString>
 
 // Exiv2
-#include <exiv2/exif.hpp>
-#include <exiv2/image.hpp>
+#include <exiv2/exiv2.hpp>
 
 // Local
 #include "jpegerrormanager.h"
@@ -216,12 +215,12 @@ bool JpegContent::load(const QString& path)
 
 bool JpegContent::loadFromData(const QByteArray& data)
 {
-    Exiv2::Image::AutoPtr image;
+    std::unique_ptr<Exiv2::Image> image;
     Exiv2ImageLoader loader;
     if (!loader.load(data)) {
         qCritical() << "Could not load image with Exiv2, reported error:" << loader.errorMessage();
     }
-    image = loader.popImage();
+    image.reset(loader.popImage().release());
 
     return loadFromData(data, image.get());
 }
@@ -603,7 +602,8 @@ bool JpegContent::save(QIODevice* device)
         d->mPendingTransformation = false;
     }
 
-    Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open((unsigned char*)d->mRawData.data(), d->mRawData.size());
+    std::unique_ptr<Exiv2::Image> image;
+    image.reset(Exiv2::ImageFactory::open((unsigned char*)d->mRawData.data(), d->mRawData.size()).release());
 
     // Store Exif info
     image->setExifData(d->mExifData);
diff --git a/lib/timeutils.cpp b/lib/timeutils.cpp
index 1fcecc98..ecce3891 100644
--- a/lib/timeutils.cpp
+++ b/lib/timeutils.cpp
@@ -21,6 +21,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
 // Self
 #include "timeutils.h"
 
+// STL
+#include <memory>
+
 // Qt
 #include <QFile>
 #include <QDateTime>
@@ -30,8 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
 #include <KFileItem>
 
 // Exiv2
-#include <exiv2/exif.hpp>
-#include <exiv2/image.hpp>
+#include <exiv2/exiv2.hpp>
 
 // Local
 #include <lib/exiv2imageloader.h>
@@ -92,7 +94,7 @@ struct CacheItem
         if (!loader.load(path)) {
             return false;
         }
-        Exiv2::Image::AutoPtr img = loader.popImage();
+        std::unique_ptr<Exiv2::Image> img(loader.popImage().release());
         try {
             Exiv2::ExifData exifData = img->exifData();
             if (exifData.empty()) {
diff --git a/tests/auto/cmsprofiletest.cpp b/tests/auto/cmsprofiletest.cpp
index 4efc441b..f4c7f9e5 100644
--- a/tests/auto/cmsprofiletest.cpp
+++ b/tests/auto/cmsprofiletest.cpp
@@ -69,7 +69,7 @@ void CmsProfileTest::testLoadFromImageData_data()
 void CmsProfileTest::testLoadFromExiv2Image()
 {
     QFETCH(QString, fileName);
-    Exiv2::Image::AutoPtr image;
+    std::unique_ptr<Exiv2::Image> image;
     {
         QByteArray data;
         QString path = pathForTestFile(fileName);
@@ -80,7 +80,7 @@ void CmsProfileTest::testLoadFromExiv2Image()
 
         Exiv2ImageLoader loader;
         QVERIFY(loader.load(data));
-        image = loader.popImage();
+        image.reset(loader.popImage().release());
     }
     Cms::Profile::Ptr ptr = Cms::Profile::loadFromExiv2Image(image.get());
     QVERIFY(!ptr.isNull());
diff --git a/tests/auto/imagemetainfomodeltest.cpp b/tests/auto/imagemetainfomodeltest.cpp
index e3ec8d30..5a286b00 100644
--- a/tests/auto/imagemetainfomodeltest.cpp
+++ b/tests/auto/imagemetainfomodeltest.cpp
@@ -17,6 +17,10 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 */
+
+// STL
+#include <memory>
+
 // Qt
 
 // KDE
@@ -28,7 +32,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 #include "../lib/imagemetainfomodel.h"
 #include "testutils.h"
 
-#include <exiv2/exif.hpp>
+// Exiv2
+#include <exiv2/exiv2.hpp>
 
 #include "imagemetainfomodeltest.h"
 
@@ -46,7 +51,7 @@ void ImageMetaInfoModelTest::testCatchExiv2Errors()
         data = file.readAll();
     }
 
-    Exiv2::Image::AutoPtr image;
+    std::unique_ptr<Exiv2::Image> image;
     {
         Exiv2ImageLoader loader;
         QVERIFY(loader.load(data));
-- 
2.20.1


From fa287bfbd0bc95856c6a98bab2d81199a1618526 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
Date: Sat, 29 Dec 2018 23:39:30 +0100
Subject: [PATCH 2/4] Compile more files with enabled exceptions, required for
 exiv2 0.27

Summary:
The (exception based) error handling is now pulled in by e.g. image.hpp,
so more files require enabled exception handling.

Depends on D17872

Test Plan: build

Reviewers: #gwenview, ngraham, cfeck, asturmlechner

Reviewed By: #gwenview, ngraham

Subscribers: wbauer, lbeltrame

Tags: #gwenview

Differential Revision: https://phabricator.kde.org/D17873
---
 lib/CMakeLists.txt | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 5f135a4d..365bcb86 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -227,6 +227,11 @@ kde_source_files_enable_exceptions(
     exiv2imageloader.cpp
     imagemetainfomodel.cpp
     timeutils.cpp
+    cms/cmsprofile.cpp
+    document/abstractdocumentimpl.cpp
+    document/document.cpp
+    document/loadingdocumentimpl.cpp
+    jpegcontent.cpp
     )
 
 ki18n_wrap_ui(gwenviewlib_SRCS
-- 
2.20.1


From 6b3407024e1d297ed8466d1e7710a9f7804dc265 Mon Sep 17 00:00:00 2001
From: Andreas Sturmlechner <asturm@gentoo.org>
Date: Wed, 6 Feb 2019 22:38:55 +0100
Subject: [PATCH 4/4] Switch to FindLibExiv2 in ECM 5.54

---
 CMakeLists.txt            |   3 +-
 app/CMakeLists.txt        |   2 +-
 cmake/FindExiv2.cmake     | 117 --------------------------------------
 importer/CMakeLists.txt   |   2 +-
 lib/CMakeLists.txt        |   4 +-
 part/CMakeLists.txt       |   2 +-
 tests/auto/CMakeLists.txt |   2 +-
 7 files changed, 7 insertions(+), 125 deletions(-)
 delete mode 100644 cmake/FindExiv2.cmake

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f8bb85e7..7181f6c9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -97,8 +97,7 @@ set_package_properties(JPEG PROPERTIES URL "http://libjpeg.sourceforge.net/" DES
 find_package(PNG)
 set_package_properties(PNG PROPERTIES URL "http://www.libpng.org" DESCRIPTION "PNG image manipulation support" TYPE REQUIRED)
 
-find_package(Exiv2)
-set_package_properties(Exiv2 PROPERTIES URL "http://www.exiv2.org" DESCRIPTION "image metadata support" TYPE REQUIRED)
+find_package(LibExiv2)
 
 find_package(CFitsio)
 set_package_properties(CFitsio PROPERTIES URL "http://heasarc.gsfc.nasa.gov/fitsio/fitsio.html" DESCRIPTION "FITS format support" TYPE OPTIONAL)
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index 5fe34d69..eabd494d 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -1,6 +1,6 @@
 include_directories(
     ${CMAKE_CURRENT_SOURCE_DIR}/..
-    ${EXIV2_INCLUDE_DIR}
+    ${LibExiv2_INCLUDE_DIRS}
     )
 
 # For lib/gwenviewconfig.h and config-gwenview.h
diff --git a/importer/CMakeLists.txt b/importer/CMakeLists.txt
index 81e585c1..39e219b7 100644
--- a/importer/CMakeLists.txt
+++ b/importer/CMakeLists.txt
@@ -3,7 +3,7 @@ project(importer)
 include_directories(
     ${CMAKE_CURRENT_SOURCE_DIR}/..
     ${CMAKE_CURRENT_BINARY_DIR}/..
-    ${EXIV2_INCLUDE_DIR}
+    ${LibExiv2_INCLUDE_DIRS}
     )
 
 set(importer_SRCS
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 365bcb86..dcf9757c 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -53,7 +53,7 @@ include_directories(
     ${CMAKE_CURRENT_SOURCE_DIR}/${GV_JPEG_DIR}
     ${CMAKE_CURRENT_SOURCE_DIR}/..
     ${CMAKE_CURRENT_BINARY_DIR}
-    ${EXIV2_INCLUDE_DIR}
+    ${LibExiv2_INCLUDE_DIRS}
     ${JPEG_INCLUDE_DIR}
     ${PNG_INCLUDE_DIRS}
     )
@@ -265,7 +265,7 @@ target_link_libraries(gwenviewlib
    KF5::WindowSystem
    KF5::IconThemes
     ${JPEG_LIBRARY}
-    ${EXIV2_LIBRARIES}
+    LibExiv2::LibExiv2
     ${PNG_LIBRARIES}
     ${LCMS2_LIBRARIES}
     ${PHONON_LIBRARY}
diff --git a/part/CMakeLists.txt b/part/CMakeLists.txt
index 9d17eed2..03dcf92f 100644
--- a/part/CMakeLists.txt
+++ b/part/CMakeLists.txt
@@ -2,7 +2,7 @@ add_definitions(-DTRANSLATION_DOMAIN="gwenview")
 
 include_directories(
     ${CMAKE_CURRENT_SOURCE_DIR}/..
-    ${EXIV2_INCLUDE_DIR}
+    ${LibExiv2_INCLUDE_DIRS}
     )
 
 set(gvpart_SRCS
diff --git a/tests/auto/CMakeLists.txt b/tests/auto/CMakeLists.txt
index d5d3f015..9cc0e3b5 100644
--- a/tests/auto/CMakeLists.txt
+++ b/tests/auto/CMakeLists.txt
@@ -14,7 +14,7 @@ endmacro(gv_add_unit_test)
 include_directories(
     ${gwenview_SOURCE_DIR}
     ${importer_SOURCE_DIR}
-    ${EXIV2_INCLUDE_DIR}
+    ${LibExiv2_INCLUDE_DIRS}
     )
 
 # For config-gwenview.h
-- 
2.20.1