File: CMakeLists.txt

package info (click to toggle)
digikam 4:5.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 273,348 kB
  • ctags: 61,794
  • sloc: cpp: 633,479; xml: 633,268; ansic: 43,487; sql: 3,076; sh: 2,918; perl: 2,386; yacc: 958; python: 495; lex: 308; ruby: 232; lisp: 228; makefile: 42
file content (604 lines) | stat: -rw-r--r-- 27,751 bytes parent folder | download
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
#
# Copyright (c) 2010-2016 by Gilles Caulier, <caulier dot gilles at gmail dot com>
# Copyright (c) 2015      by Veaceslav Munteanu, <veaceslav dot munteanu90 at gmail dot com>
# Copyright (c) 2015      by Mohamed Anwer, <m dot anwer at gmx dot com>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

project(digikam)

message(STATUS "----------------------------------------------------------------------------------")
message(STATUS "Starting CMake configuration for: ${PROJECT_NAME}")

# ==================================================================================================
# Information to update before to release this package.

# digiKam version
set(DIGIKAM_MAJOR_VERSION "5")
set(DIGIKAM_MINOR_VERSION "3")
set(DIGIKAM_PATCH_VERSION "0")

#digiKam release date
set(DIGIKAM_RELEASE_DATE "2016-11-06")

# Suffix to add at end of version string. Usual values are:
# "-git"   : alpha code unstable from git. Do not use in production
# "-beta1" : beta1 release.
# "-beta2" : beta2 release.
# "-beta3" : beta3 release.
# "-rc"    : release candidate.
# ""       : final release. Can be used in production.
set(DIGIKAM_SUFFIX_VERSION "")

# ==================================================================================================
# Set env. variables accordingly.

# NOTE: This string is used to set libdigikamcore and libdigikamdatabase SO version ID
set(DIGIKAM_VERSION_SHORT
    "${DIGIKAM_MAJOR_VERSION}.${DIGIKAM_MINOR_VERSION}.${DIGIKAM_PATCH_VERSION}"
)

set(DIGIKAM_VERSION_STRING
    "${DIGIKAM_VERSION_SHORT}${DIGIKAM_SUFFIX_VERSION}"
)

# Core Database XML version
# We must set this variable here at top level because it is used in both libs/database/core and data/database
# Version history:
# 1 : Original database XML file, published in production.
# 2 : 08-08-2014 : Fix Images.names field size (see bug #327646).
# 3 : 05/11/2015 : Add Face DB schema.
set(DBCORECONFIG_XML_VERSION "3")

# =======================================================

set(CMAKE_MIN_VERSION    "3.0.0")
set(ECM_MIN_VERSION      "1.7.0")
set(KF5_MIN_VERSION      "5.1.0")
set(QT_MIN_VERSION       "5.2.0")
set(KIPI_MIN_VERSION     "5.0.0")
set(KSANE_MIN_VERSION    "5.0.0")
set(LENSFUN_MIN_VERSION  "0.2.6.0")
set(EXIV2_MIN_VERSION    "0.25")
set(AKONADI_MIN_VERSION  "4.89.0")        # Akonadi Contact dependency
set(CALENDAR_MIN_VERSION "4.81.0")        # Calendar Core dependency

cmake_minimum_required(VERSION ${CMAKE_MIN_VERSION})

############## ECM setup ######################

find_package(ECM ${ECM_MIN_VERSION} CONFIG REQUIRED)
set(CMAKE_MODULE_PATH ${digikam_SOURCE_DIR}/cmake/modules ${ECM_MODULE_PATH})

# Cmake macros
include(GenerateExportHeader)
include(CheckFunctionExists)
include(FeatureSummary)
# ECM macros
include(ECMOptionalAddSubdirectory)
include(ECMAddTests)
include(ECMMarkNonGuiExecutable)
include(ECMGenerateHeaders)
include(ECMGeneratePriFile)
include(ECMPackageConfigHelpers)
include(ECMSetupVersion)
include(ECMInstallIcons)
include(ECMAddAppIcon)
include(ECMPoQmTools)
# KDE macros
include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDEFrameworkCompilerSettings)
include(KDECompilerSettings)
# Local macros
include(MacroUtils)
include(MacroLocalLibs)
include(MacroOpenCV)
include(MacroJPEG)
include(MacroBoolTo01)

# ==================================================================================================

option(ENABLE_OPENCV3               "Build digiKam with OpenCV3 instead OpenCV2 (default=OFF)"                           OFF)
option(ENABLE_KFILEMETADATASUPPORT  "Build digiKam with KDE files indexer support (default=OFF)"                         OFF)
option(ENABLE_AKONADICONTACTSUPPORT "Build digiKam with KDE Mail Contacts support (default=OFF)"                         OFF)
option(ENABLE_MEDIAPLAYER           "Build digiKam with QtMultimedia support (default=OFF)"                              OFF)
option(ENABLE_DBUS                  "Build digiKam with DBUS support (default=ON)"                                       ON)
option(ENABLE_APPSTYLES             "Build digiKam with support for changing the widget application style (default=OFF)" OFF)

# Mysql support options (experimental):
option(ENABLE_MYSQLSUPPORT          "Build digiKam with MySQL dabatase support (default=OFF)"                            OFF)
option(ENABLE_INTERNALMYSQL         "Build digiKam with internal MySQL server executable (default=OFF)"                  OFF)


# Debug options:
option(ENABLE_DIGIKAM_MODELTEST     "Enable ModelTest on some models for debugging (default=OFF)"                        OFF)

############## Find Packages ###################

find_package(Qt5 ${QT_MIN_VERSION}
             REQUIRED NO_MODULE COMPONENTS
             Core
             Concurrent
             Widgets
             Gui
             Sql
             Xml
             PrintSupport
             WebKitWidgets
             Network
)

find_package(Qt5 ${QT_MIN_VERSION}
             OPTIONAL_COMPONENTS
             Multimedia
             MultimediaWidgets
             DBus
             OpenGL
)

if(ENABLE_MEDIAPLAYER)
    if(NOT Qt5Multimedia_FOUND OR NOT Qt5MultimediaWidgets_FOUND)
        set(ENABLE_MEDIAPLAYER OFF)
    endif()
endif()

if(ENABLE_DBUS)
    if(NOT Qt5DBus_FOUND)
        set(ENABLE_DBUS OFF)
    endif()
endif()

if(BUILD_TESTING)
    find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS
                 Test)
endif()

find_package(KF5 ${KF5_MIN_VERSION}
             REQUIRED COMPONENTS
             XmlGui
             CoreAddons
             Config
             Service
             WindowSystem
             Solid
             I18n
)

find_package(KF5 ${KF5_MIN_VERSION}
             OPTIONAL_COMPONENTS
             KIO                    # For Desktop integration (Widgets only).
             IconThemes             # For Desktop integration.
             Bookmarks              # For geolocation editor.
             FileMetaData           # For KDE file indexer support.
             ThreadWeaver           # For Panorama tool.
             NotifyConfig           # KDE desktop application notify configuration.
             Notifications          # KDE desktop notifications integration.
)

find_package(KF5 ${AKONADI_MIN_VERSION}
             OPTIONAL_COMPONENTS
             AkonadiContact         # For KDE Mail Contacts support.
)

find_package(KF5 ${CALENDAR_MIN_VERSION}
             OPTIONAL_COMPONENTS
             CalendarCore           # For Calendar tool.
)

if(ENABLE_AKONADICONTACTSUPPORT AND NOT KF5AkonadiContact_FOUND)
    set(ENABLE_KFILEMETADATASUPPORT OFF)
endif()

if(ENABLE_KFILEMETADATASUPPORT AND NOT KF5FileMetaData_FOUND)
    set(ENABLE_KFILEMETADATASUPPORT OFF)
endif()

# Check if KIO have been compiled with KIOWidgets. digiKam only needs this one.
if(KF5KIO_FOUND)
    get_target_property(KIOWidgets_INCLUDE_DIRS KF5::KIOWidgets INTERFACE_INCLUDE_DIRECTORIES)
    message(STATUS "KF5::KIOWidgets include dirs: ${KIOWidgets_INCLUDE_DIRS}")

    if(NOT KIOWidgets_INCLUDE_DIRS)
        message(STATUS "KF5::KIOWidgets not available in shared KIO library. KIO support disabled.")
        set(KF5KIO_FOUND FALSE)
    endif()
endif()

# ==================================================================================================
# Dependencies Rules

# mandatory

DETECT_JPEG()
set(DIGIKAM_LIBJPEG_DIR libjpeg-${JPEG_LIB_VERSION})

find_package(TIFF                       REQUIRED)
find_package(PNG                        REQUIRED)
find_package(Boost                      REQUIRED)
find_package(LCMS2                      REQUIRED)
find_package(EXPAT                      REQUIRED)  # For DNGWriter: XMP SDK need Expat library to compile.
find_package(Threads                    REQUIRED)  # For DNGWriter and LibRaw which needs native threads support.
find_package(Exiv2 ${EXIV2_MIN_VERSION} REQUIRED)

set_package_properties("Exiv2"     PROPERTIES
                       DESCRIPTION "Required to build digiKam"
                       URL         "http://www.exiv2.org"
                       TYPE        RECOMMENDED
                       PURPOSE     "Library to manage image metadata"
)

# -- check OpenCV --------------------------------------------------------------------------------

if(ENABLE_OPENCV3)

    set(OPENCV_MIN_VERSION "3.1.0")
    DETECT_OPENCV(${OPENCV_MIN_VERSION} core highgui objdetect imgproc)

    if(${OpenCV_FOUND})
        if(${OpenCV_VERSION} VERSION_LESS 3.1.0)
            message(STATUS "ENABLE_OPENCV3 option is enabled and OpenCV < 3.1.0 have been found. Disabled ENABLE_OPENCV3")
            set(OpenCV_FOUND FALSE)
        endif()
    endif()

else()

    set(OPENCV_MIN_VERSION "2.4.9")
    DETECT_OPENCV(${OPENCV_MIN_VERSION} core highgui objdetect contrib legacy imgproc)

    if(${OpenCV_FOUND})
        if(${OpenCV_VERSION} VERSION_GREATER 2.4.99)
            message(STATUS "ENABLE_OPENCV3 option is disabled and OpenCV >= 3.0.0 have been found. Enabled ENABLE_OPENCV3")
            set(OpenCV_FOUND FALSE)
        endif()
    endif()

endif()

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/app/utils/libopencv.h.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/app/utils/libopencv.h)

# -- optionals ----------------------------------------------------------------------------------

find_package(FLEX)                                 # For Panorama tool.
find_package(BISON)                                # For Panorama tool.

DETECT_LIBKIPI(${KIPI_MIN_VERSION})
DETECT_LIBKSANE(${KSANE_MIN_VERSION})

find_package(Marble)

find_package(PkgConfig)
#find_package(Jasper) -- disabled by Debian
find_package(Eigen3)                               # For Refocus tool.
find_package(OpenGL)                               # For Presentation tool.

# For Monitor Profiles management with LCMS
find_package(X11)

if(X11_FOUND)
    find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS
                 X11Extras
    )
    set(HAVE_X11 TRUE)
else()
    set(HAVE_X11 FALSE)
endif()

# decide if Presentation tool can be built with OpenGL
if(OPENGL_FOUND AND OPENGL_GLU_FOUND AND Qt5OpenGL_FOUND)
    set(HAVE_OPENGL TRUE)
elseif()
    set(HAVE_OPENGL FALSE)
endif()

# For LibRaw
if(WIN32)
    find_library(WSOCK32_LIBRARY wsock32)
    find_library(WS2_32_LIBRARY ws2_32)
endif()

# -- To link under Solaris (see bug #274484) ------------------------------------------------------

if(NOT WIN32)
    find_library(MATH_LIBRARY m)
endif()

if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
    find_library(KVM_LIBRARY kvm)
endif()

# ==================================================================================================
# More Optional Dependencies

find_package(Doxygen)
find_package(Lqr-1)

# -- libgphoto2 rules --------------------------------------------------------------------------

if(NOT WIN32)

    find_package(Gphoto2)

    if(GPHOTO2_FOUND)

        if("${GPHOTO2_VERSION_STRING}" VERSION_GREATER "2.4.0")
            set(VERSION_GPHOTO2 true)
        else()
            set(VERSION_GPHOTO2 false)
        endif()

        if("${GPHOTO2_VERSION_STRING}" VERSION_GREATER "2.5.0")
            set(VERSION_GPHOTO25 true)
            message(STATUS "libgphoto2 API version >= 2.5")
        else()
            set(VERSION_GPHOTO25 false)
            message(STATUS "libgphoto2 API version < 2.5")
        endif()

        if(VERSION_GPHOTO25)
            set(HAVE_GPHOTO25 1)
        else()
            set(HAVE_GPHOTO25 0)
        endif()

    endif()

endif()

# -- Check LensFun library for Lens auto-correction tool --------------------------------------

find_package(LensFun)

if(LENSFUN_VERSION)
    message(STATUS "liblensfun: Found version ${LENSFUN_VERSION} (required: ${LENSFUN_MIN_VERSION})")
    if(${LENSFUN_VERSION} VERSION_LESS ${LENSFUN_MIN_VERSION})
        set(LENSFUN_FOUND FALSE)
    endif()
else()
    message(STATUS "liblensfun: Version information not found, your version is probably too old.")
    set(LENSFUN_FOUND FALSE)
endif()

# -- Check dependencies for Panorama tool -------------------------------------

if(FLEX_FOUND AND BISON_FOUND AND KF5ThreadWeaver_FOUND)
    set(HAVE_PANORAMA 1)
else()
    set(HAVE_PANORAMA 0)
endif()

# -- compilation options definitions -----------------------------------------------------------

MACRO_BOOL_TO_01(KF5Kipi_FOUND                                          HAVE_KIPI)
MACRO_BOOL_TO_01(KF5Sane_FOUND                                          HAVE_KSANE)
MACRO_BOOL_TO_01(KF5FileMetaData_FOUND                                  HAVE_KFILEMETADATA)
MACRO_BOOL_TO_01(KF5AkonadiContact_FOUND                                HAVE_AKONADICONTACT)
MACRO_BOOL_TO_01(KF5Bookmarks_FOUND                                     HAVE_KBOOKMARKS)
MACRO_BOOL_TO_01(KF5CalendarCore_FOUND                                  HAVE_KCALENDAR)
MACRO_BOOL_TO_01(KF5Notifications_FOUND                                 HAVE_KNOTIFICATIONS)
MACRO_BOOL_TO_01(KF5NotifyConfig_FOUND                                  HAVE_KNOTIFYCONFIG)
MACRO_BOOL_TO_01(KF5KIO_FOUND                                           HAVE_KIO)
MACRO_BOOL_TO_01(KF5IconThemes_FOUND                                    HAVE_KICONTHEMES)
MACRO_BOOL_TO_01(LENSFUN_FOUND                                          HAVE_LENSFUN)
MACRO_BOOL_TO_01(LQR-1_FOUND                                            HAVE_LIBLQR_1)
MACRO_BOOL_TO_01(GPHOTO2_FOUND                                          HAVE_GPHOTO2)
MACRO_BOOL_TO_01(JASPER_FOUND                                           HAVE_JASPER)
MACRO_BOOL_TO_01(EIGEN3_FOUND                                           HAVE_EIGEN3)
MACRO_BOOL_TO_01(MARBLE_FOUND                                           HAVE_MARBLE)
MACRO_BOOL_TO_01(ENABLE_MYSQLSUPPORT                                    HAVE_MYSQLSUPPORT)
MACRO_BOOL_TO_01(ENABLE_INTERNALMYSQL                                   HAVE_INTERNALMYSQL)
MACRO_BOOL_TO_01(ENABLE_MEDIAPLAYER                                     HAVE_MEDIAPLAYER)
MACRO_BOOL_TO_01(ENABLE_DBUS                                            HAVE_DBUS)
MACRO_BOOL_TO_01(ENABLE_APPSTYLES                                       HAVE_APPSTYLE_SUPPORT)

# Whether to use Qt's scaling to downscale previews. Under MacOSX, Qt
# can make use of the higher physical resolution of Retina
# displays. However, it seems that other Qt renderers perform badly at
# this, so disable. If other renderers switch to coarser logical
# pixels, one probably needs this feature on these platforms as well.
MACRO_BOOL_TO_01(APPLE                                                  USE_QT_SCALING)

# Set config files accordingly with optional dependencies

configure_file(app/utils/digikam_config.h.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/app/utils/digikam_config.h)

# ==================================================================================================
# Log messages

message(STATUS "")
message(STATUS "----------------------------------------------------------------------------------")
message(STATUS " digiKam ${DIGIKAM_VERSION_STRING} dependencies results   <http://www.digikam.org>")
message(STATUS "")

PRINT_COMPONENT_COMPILE_STATUS("MySQL Database Support"     ENABLE_MYSQLSUPPORT)
PRINT_COMPONENT_COMPILE_STATUS("MySQL Internal Support"     ENABLE_INTERNALMYSQL)
PRINT_COMPONENT_COMPILE_STATUS("DBUS Support"               ENABLE_DBUS)
PRINT_COMPONENT_COMPILE_STATUS("Application Style Support"  ENABLE_APPSTYLES)


# ================================================================

PRINT_LIBRARY_STATUS("libqt"                  "http://www.qtsoftware.com"                                        "(version >= ${QT_MIN_VERSION})"     Qt5_FOUND)
PRINT_LIBRARY_STATUS("libkde"                 "http://www.kde.org"                                               "(version >= ${KF5_MIN_VERSION})"    KF5_FOUND)
PRINT_LIBRARY_STATUS("libjpeg"                "http://www.ijg.org"                                               "(version >= 6b)"                    JPEG_FOUND)
PRINT_LIBRARY_STATUS("libtiff"                "http://www.remotesensing.org/libtiff"                             "(version >= 3.8.2)"                 TIFF_FOUND)
PRINT_LIBRARY_STATUS("libpng"                 "http://www.libpng.org/pub/png/libpng.html"                        "(version >= 1.2.7)"                 PNG_FOUND)
PRINT_LIBRARY_STATUS("liblcms"                "http://www.littlecms.com"                                         "(version >= 1.0.0)"                 LCMS2_FOUND)
PRINT_LIBRARY_STATUS("libboostgraph"          "http://www.boost.org/doc/libs"                                    "(version >= 1.43.0)"                Boost_FOUND)
PRINT_LIBRARY_STATUS("libopencv"              "http://opencv.willowgarage.com"                                   "(version >= ${OPENCV_MIN_VERSION})" OpenCV_FOUND)
PRINT_LIBRARY_STATUS("libexpat"               "http://expat.sourceforge.net"                                     "(version >= 2.0.0)"                 EXPAT_FOUND)
PRINT_LIBRARY_STATUS("libpthread"             "http://www.gnu.org/software/hurd/libpthread.html"                 "(version >= 2.0.0)"                 CMAKE_USE_PTHREADS_INIT OR CMAKE_USE_WIN32_THREADS_INIT)

# ================================================================

PRINT_OPTIONAL_LIBRARY_STATUS("libkipi"           "https://projects.kde.org/projects/kde/kdegraphics/libs/libkipi"  "(version >= ${KIPI_MIN_VERSION})"     "digiKam will be compiled without Kipi-plugins support."                      KF5Kipi_FOUND)
PRINT_OPTIONAL_LIBRARY_STATUS("libmarble"         "https://projects.kde.org/projects/kde/kdeedu/marble"             "(version >= 0.22.0)"                  "digiKam will be compiled without geolocation maps support."                  MARBLE_FOUND)
PRINT_OPTIONAL_LIBRARY_STATUS("libksane"          "https://projects.kde.org/projects/kde/kdegraphics/libs/libksane" "(version >= ${KSANE_MIN_VERSION})"    "digiKam will be compiled without libksane support."                          KF5Sane_FOUND)
PRINT_OPTIONAL_LIBRARY_STATUS("libkfilemetadata"  "https://projects.kde.org/projects/kde/kdelibs/baloo"             "(version >= ${KF5_MIN_VERSION})"      "digiKam will be compiled without KDE file metadata support."                 KF5FileMetaData_FOUND)
PRINT_OPTIONAL_LIBRARY_STATUS("libakonadicontact" "https://projects.kde.org/projects/kde/kdepimlibs"                "(version >= ${AKONADI_MIN_VERSION})"  "digiKam will be compiled without KDE address book support."                  KF5AkonadiContact_FOUND)
PRINT_OPTIONAL_LIBRARY_STATUS("libkcalcore"       "https://projects.kde.org/projects/kde/pim/kcalcore"              "(version >= ${CALENDAR_MIN_VERSION})" "digiKam will be compiled without KDE calendar support."                      KF5CalendarCore_FOUND)
PRINT_OPTIONAL_LIBRARY_STATUS("libthreadweaver"   "https://projects.kde.org/projects/frameworks/threadweaver"       "(version >= ${KF5_MIN_VERSION})"      "digiKam will be compiled without Panorama support."                          KF5ThreadWeaver_FOUND)
PRINT_OPTIONAL_LIBRARY_STATUS("libkbookmarks"     "https://projects.kde.org/projects/frameworks/kbookmarks"         "(version >= ${KF5_MIN_VERSION})"      "digiKam will be compiled without KDE desktop bookmarks support."             KF5Bookmarks_FOUND)
PRINT_OPTIONAL_LIBRARY_STATUS("libkiconthemes"    "https://projects.kde.org/projects/frameworks/kiconthemes"        "(version >= ${KF5_MIN_VERSION})"      "digiKam will be compiled without KDE desktop icon themes support."           KF5IconThemes_FOUND)
PRINT_OPTIONAL_LIBRARY_STATUS("libknotifications" "https://projects.kde.org/projects/frameworks/knotifications"     "(version >= ${KF5_MIN_VERSION})"      "digiKam will be compiled without KDE desktop notifications support."         KF5Notifications_FOUND)
PRINT_OPTIONAL_LIBRARY_STATUS("libknotifyconfig"  "https://projects.kde.org/projects/frameworks/knotifyconfig"      "(version >= ${KF5_MIN_VERSION})"      "digiKam will be compiled without KDE desktop notify configuration support."  KF5NotifyConfig_FOUND)
PRINT_OPTIONAL_LIBRARY_STATUS("libkio"            "https://projects.kde.org/projects/frameworks/kio"                "(version >= ${KF5_MIN_VERSION})"      "digiKam will be compiled without KDE desktop integration support."           KF5KIO_FOUND)
PRINT_OPTIONAL_LIBRARY_STATUS("flex"              "http://flex.sourceforge.net/"                                    "(version >= 2.5.0)"                   "digiKam will be compiled without Panorama support."                          FLEX_FOUND)
PRINT_OPTIONAL_LIBRARY_STATUS("bison"             "https://www.gnu.org/software/bison/"                             "(version >= 2.5.0)"                   "digiKam will be compiled without Panorama support."                          BISON_FOUND)
PRINT_OPTIONAL_LIBRARY_STATUS("libjasper"         "http://www.ece.uvic.ca/~mdadams/jasper"                          "(version >= 1.7.0)"                   "digiKam will be compiled without JPEG2000 support."                          JASPER_FOUND)
PRINT_OPTIONAL_LIBRARY_STATUS("liblensfun"        "http://lensfun.sourceforge.net"                                  "(version >= 0.2.6)"                   "digiKam will be compiled without Lens Auto Correction tool support."         LENSFUN_FOUND)
PRINT_OPTIONAL_LIBRARY_STATUS("liblqr-1"          "http://liblqr.wikidot.com"                                       "(version >= 0.4.1)"                   "digiKam will be compiled without Contents Aware Resizer tool support."       LQR-1_FOUND)
PRINT_OPTIONAL_LIBRARY_STATUS("libeigen3"         "http://eigen.tuxfamily.org"                                      "(version >= 3.0.0)"                   "digiKam will be compiled without Refocus tool support."                      EIGEN3_FOUND)
PRINT_OPTIONAL_LIBRARY_STATUS("libgphoto2"        "http://www.gphoto.org"                                           "(version >= 2.4.0)"                   "digiKam will be compiled without GPhoto2 camera drivers support."            GPHOTO2_FOUND)
PRINT_OPTIONAL_LIBRARY_STATUS("doxygen"           "http://www.doxygen.org"                                          "(version >= 1.8.0)"                   "digiKam will be compiled without API documentation building support."        DOXYGEN_FOUND)
PRINT_OPTIONAL_LIBRARY_STATUS("OpenGL"            "http://www.mesa3d.org"                                           "(version >= 11.0.0)"                  "digiKam will be compiled without OpneGL support."                            HAVE_OPENGL)

if(ENABLE_MEDIAPLAYER)
    PRINT_OPTIONAL_QTMODULE_STATUS("Qt5 Multimedia"        Qt5Multimedia_FOUND)
    PRINT_OPTIONAL_QTMODULE_STATUS("Qt5 MultimediaWidgets" Qt5MultimediaWidgets_FOUND)
endif()

# ================================================================

if(Qt5_FOUND       AND
   KF5_FOUND       AND
   JPEG_FOUND      AND
   TIFF_FOUND      AND
   PNG_FOUND       AND
   LCMS2_FOUND     AND
   Boost_FOUND     AND
   EXIV2_FOUND     AND
   OpenCV_FOUND    AND
   EXPAT_FOUND     AND
   (CMAKE_USE_PTHREADS_INIT OR CMAKE_USE_WIN32_THREADS_INIT)
  )
    message(STATUS " digiKam can be compiled.................. YES")
    set(DIGIKAM_CAN_BE_COMPILED true)
else()
    message(FATAL_ERROR " digiKam will be compiled................. NO  (Look README file for more details about dependencies)")
    set(DIGIKAM_CAN_BE_COMPILED false)
endif()

message(STATUS "----------------------------------------------------------------------------------")
message(STATUS "")

if(DIGIKAM_CAN_BE_COMPILED)

    # ==================================================================================================
    # Create git version header

    # We only do this IF we are in a .git dir
    find_file(GIT_MARKER entries PATHS ${CMAKE_SOURCE_DIR}/.git)

    if(NOT GIT_MARKER)
        set(GIT_MARKER ${CMAKE_SOURCE_DIR}/CMakeLists.txt)  # Dummy file
    endif()

    # Add a custom command to drive the git script whenever the git entries
    # file changes.
    configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/gitscript.cmake.in"
                   "${CMAKE_CURRENT_BINARY_DIR}/gitscript.cmake"
                   @ONLY)

    # Add a custom target to drive the custom command.
    add_custom_target(digikam-gitversion ALL COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/gitscript.cmake")

    # ==================================================================================================
    # To prevent warnings from M$ compiler

    if(WIN32 AND MSVC)
        add_definitions(-D_CRT_SECURE_NO_WARNINGS)
        add_definitions(-D_ATL_SECURE_NO_WARNINGS)
        add_definitions(-D_AFX_SECURE_NO_WARNINGS)
    endif()

    # ==================================================================================================
    # Definitions rules

    # Remove pedantic GCC flag which generate a lots of warnings on the console with qCDebug()
    while(CMAKE_CXX_FLAGS MATCHES "-pedantic")
        string(REPLACE "-pedantic" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
    endwhile()

    # translations catalog
    add_definitions(-DTRANSLATION_DOMAIN=\"digikam\")

    # NOTE: with libpgf 6.11.24 OpenMP is not very well supported. We disable it to be safe.
    # See B.K.O #273765 for details.
    add_definitions(-DLIBPGF_DISABLE_OPENMP)

    # To force to declare as exported classes in all sub components.
    # This will only done near to library declaration in Cmake files.
    if(WIN32)
        add_definitions(-Ddigikamcore_EXPORTS)
        add_definitions(-Ddigikamdatabase_EXPORTS)
    endif()

    # Enable C++ Exceptions support, require by Greycstoration algorithm (CImg.h) and PGF codec
    kde_enable_exceptions()

    # ==================================================================================================
    # Includes rules

    # Recursively get all directories which contain header files
    set(DK_INCLUDES_ALL "")

    HEADER_DIRECTORIES(DK_LOCAL_INCLUDES_RAW)

    # This macro will set all paths which do not containt libjpeg-
    # We will add later the directory we need

    foreach(var ${DK_LOCAL_INCLUDES_RAW})
        string(REGEX MATCH "libjpeg-" item ${var})
        if(item STREQUAL "")
            list(APPEND DK_LOCAL_INCLUDES ${var})
        endif()
    endforeach()

    set(DK_LOCAL_INCLUDES ${DK_LOCAL_INCLUDES}
                          libs/jpegutils/${DIGIKAM_LIBJPEG_DIR})

    include_directories(${DK_LOCAL_INCLUDES})

    # for config headers digikam_version.h gitversion.h digikam_config.h digikam_dbconfig.h libopencv.h
    include_directories(${CMAKE_CURRENT_BINARY_DIR}/app/utils)

    include_directories(${OpenCV_INCLUDE_DIRS})

    # ==================================================================================================
    # Common targets parts

    set(CMAKE_POSITION_INDEPENDENT_CODE ON)
    add_subdirectory(data)
    add_subdirectory(libs)
    add_subdirectory(utilities)
    add_subdirectory(app)
    add_subdirectory(showfoto)

    if(BUILD_TESTING)
        add_subdirectory(tests)
    endif()

    if(NOT WIN32)
        configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/digikam.lsm.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/digikam.lsm)
    endif()

endif()

# ==================================================================================================
# API documentation generation

if(DOXYGEN_FOUND)

    set(API_DIR    ${CMAKE_BINARY_DIR}/api)
    set(SOURCE_DIR ${CMAKE_SOURCE_DIR})
    set(DOXYFILE   ${CMAKE_BINARY_DIR}/Doxyfile)
    set(WARNFILE   ${CMAKE_BINARY_DIR}/doxygen-warn.log)

    configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/Doxyfile.cmake.in ${DOXYFILE})

    add_custom_target(doc ${DOXYGEN_EXECUTABLE} ${DOXYFILE}
                      WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
endif()