CMakeLists.txt 11.2 KB
Newer Older
1
#
2
# Copyright (c) 2010-2018 by Gilles Caulier, <caulier dot gilles at gmail dot com>
3
4
5
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
6
#
7

8
9
10
project(kipi-plugins)

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

13
# =======================================================
Andi Clemens's avatar
Andi Clemens committed
14
# Information to update before to release this package.
15

Gilles Caulier's avatar
Gilles Caulier committed
16
# kipi-plugins version
17
set(KIPIPLUGINS_MAJOR_VERSION "5")
Gilles Caulier's avatar
Gilles Caulier committed
18
set(KIPIPLUGINS_MINOR_VERSION "9")
19
set(KIPIPLUGINS_PATCH_VERSION "1")
20

Gilles Caulier's avatar
Gilles Caulier committed
21
# Suffix to add at end of version string. Usual values are:
22
# "-git"   : alpha code unstable from git. Do not use in production
Gilles Caulier's avatar
Gilles Caulier committed
23
24
25
26
27
# "-beta1" : beta1 release.
# "-beta2" : beta2 release.
# "-beta3" : beta3 release.
# "-rc"    : release candidate.
# ""       : final relase. Can be used in production.
Gilles Caulier's avatar
5.0.0    
Gilles Caulier committed
28
set(KIPIPLUGINS_SUFFIX_VERSION "")
Gilles Caulier's avatar
Gilles Caulier committed
29

30
31
32
# =======================================================
# Set env. variables accordinly.

33
set(KIPIPLUGINS_VERSION_STRING
Gilles Caulier's avatar
Gilles Caulier committed
34
    "${KIPIPLUGINS_MAJOR_VERSION}.${KIPIPLUGINS_MINOR_VERSION}.${KIPIPLUGINS_PATCH_VERSION}${KIPIPLUGINS_SUFFIX_VERSION}"
35
)
36

37
# NOTE: This string is used to set libkipiplugins SO version ID
38
set(KIPIPLUGINS_LIB_SO_VERSION_STRING
39
    "${KIPIPLUGINS_MAJOR_VERSION}.${KIPIPLUGINS_MINOR_VERSION}.${KIPIPLUGINS_PATCH_VERSION}"
40
)
41
42

# =======================================================
Gilles Caulier's avatar
add    
Gilles Caulier committed
43

Gilles Caulier's avatar
Gilles Caulier committed
44
set(CMAKE_MIN_VERSION    "3.0.0")
45
set(KF5_MIN_VERSION      "5.18.0")
46
set(QT_MIN_VERSION       "5.6.0")
47
set(KIPI_MIN_VERSION     "5.0.0")
48
cmake_minimum_required(VERSION ${CMAKE_MIN_VERSION})
49

50
############## ECM setup ######################
Gilles Caulier's avatar
polish    
Gilles Caulier committed
51

52
find_package(ECM ${KF5_MIN_VERSION} CONFIG REQUIRED)
53
set(CMAKE_MODULE_PATH ${kipi-plugins_SOURCE_DIR}/cmake/modules ${ECM_MODULE_PATH})
54

Gilles Caulier's avatar
Gilles Caulier committed
55
# Cmake macros
56
include(GenerateExportHeader)
Gilles Caulier's avatar
Gilles Caulier committed
57
58
59
60
61
62
include(CheckFunctionExists)
include(FeatureSummary)
# ECM macros
include(ECMOptionalAddSubdirectory)
include(ECMAddTests)
include(ECMMarkNonGuiExecutable)
63
64
65
include(ECMGenerateHeaders)
include(ECMGeneratePriFile)
include(ECMSetupVersion)
Gilles Caulier's avatar
Gilles Caulier committed
66
include(ECMInstallIcons)
67
include(ECMAddAppIcon)
Gilles Caulier's avatar
Gilles Caulier committed
68
# KDE macros
69
70
71
include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDEFrameworkCompilerSettings)
Gilles Caulier's avatar
Gilles Caulier committed
72
73
include(KDECompilerSettings)
# Local macros
74
include(MacroUtils)
75
include(MacroLocalLibs)
Gilles Caulier's avatar
Gilles Caulier committed
76

77
78
##########################################################################

79
80
option(ENABLE_KIO    "Build Kipi-plugins with KIO support (default=ON)" ON)
option(ENABLE_LEGACY "Build Kipi-plugins with legacy plugins support (default=ON)" ON)
81

82
############## Find Packages ###################
83

Gilles Caulier's avatar
polish    
Gilles Caulier committed
84
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS
85
86
             Core
             Widgets
Gilles Caulier's avatar
port ++    
Gilles Caulier committed
87
             PrintSupport
88
             Gui
Gilles Caulier's avatar
Gilles Caulier committed
89
             Xml
Gilles Caulier's avatar
polish    
Gilles Caulier committed
90
             XmlPatterns
Shourya Singh Gupta's avatar
Shourya Singh Gupta committed
91
92
             Svg
             Concurrent
93
             Network
Gilles Caulier's avatar
polish    
Gilles Caulier committed
94
95
)

Gilles Caulier's avatar
Gilles Caulier committed
96
if(BUILD_TESTING)
Gilles Caulier's avatar
polish    
Gilles Caulier committed
97
    find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS
Gilles Caulier's avatar
Gilles Caulier committed
98
99
100
                 Test)
endif()

Gilles Caulier's avatar
polish    
Gilles Caulier committed
101
find_package(KF5 ${KF5_MIN_VERSION}
102
             REQUIRED COMPONENTS
103
             Config
Gilles Caulier's avatar
polish    
Gilles Caulier committed
104
105
             WindowSystem
             XmlGui
106
             I18n
107
108
)

Gilles Caulier's avatar
Gilles Caulier committed
109
find_package(KF5 ${KF5_MIN_VERSION} QUIET
110
111
             OPTIONAL_COMPONENTS
             Archive      # for FlashExport
112
113
)

114
115
if(ENABLE_KIO)

Gilles Caulier's avatar
Gilles Caulier committed
116
    find_package(KF5 ${KF5_MIN_VERSION} QUIET
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
                 OPTIONAL_COMPONENTS
                 KIO          # Some kipi-plugins depends of KIO indeep.
    )

    # Check if KIO have been compiled with KIOWidgets. Some tools rely only to KIO core, some other with KIOWidgets too..
    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. Some tools will not be compiled.")
            set(KF5KIOWidgets_FOUND FALSE)
        else()
            set(KF5KIOWidgets_FOUND TRUE)
        endif()
Gilles Caulier's avatar
Gilles Caulier committed
133
134

    endif()
135

Gilles Caulier's avatar
Gilles Caulier committed
136
137
endif()

138
# Dependencies detection required by all plugins
139

140
DETECT_LIBKIPI(${KIPI_MIN_VERSION})
141

142
if(KF5Kipi_FOUND)
143

144
    # -- Optional dependencies detection required by some plugins -------------------------------------
145

Shourya Singh Gupta's avatar
Shourya Singh Gupta committed
146
147
    DETECT_LIBMEDIAWIKI(5.0.0)                                                 # For Mediawiki.
    DETECT_LIBKVKONTAKTE(4.70.0)                                               # For VKontakte.
Gilles Caulier's avatar
Gilles Caulier committed
148

149
150
    # ==================================================================================================
    # Log messages
151

152
153
    message(STATUS "")
    message(STATUS "----------------------------------------------------------------------------------")
Gilles Caulier's avatar
Gilles Caulier committed
154
    message(STATUS " ${PROJECT_NAME} ${KIPIPLUGINS_VERSION_STRING} dependencies results")
155
    message(STATUS "")
156

157
158
    # Require shared libraries results.

159
    PRINT_LIBRARY_STATUS("libqt"     "http://www.qtsoftware.com"                                        "(version >= ${QT_MIN_VERSION})"     Qt5_FOUND)
Gilles Caulier's avatar
polish    
Gilles Caulier committed
160
    PRINT_LIBRARY_STATUS("libkde"    "http://www.kde.org"                                               "(version >= ${KF5_MIN_VERSION})"    KF5_FOUND)
Gilles Caulier's avatar
polish    
Gilles Caulier committed
161
    PRINT_LIBRARY_STATUS("libkipi"   "https://projects.kde.org/projects/kde/kdegraphics/libs/libkipi"   "(version >= ${KIPI_MIN_VERSION}))"  KF5Kipi_FOUND)
162
163
164

    # Optional shared libraries results.

165
    PRINT_OPTIONAL_LIBRARY_STATUS("libkio"          "https://projects.kde.org/projects/frameworks/kio"                "(version >= ${KF5_MIN_VERSION})"      "Kipi-plugins will be compiled without libkio support."          KF5KIO_FOUND)
166
167
168
    PRINT_OPTIONAL_LIBRARY_STATUS("libkarchive"     "https://projects.kde.org/projects/frameworks/karchive"           "(version >= ${KF5_MIN_VERSION})"      "Kipi-plugins will be compiled without libkarchive support."     KF5Archive_FOUND)
    PRINT_OPTIONAL_LIBRARY_STATUS("libmediawiki"    "https://projects.kde.org/projects/extragear/libs/libmediawiki"   "(version >= ${KF5_MIN_VERSION})"      "Kipi-plugins will be compiled without libmediawiki support."    KF5MediaWiki_FOUND)
    PRINT_OPTIONAL_LIBRARY_STATUS("libkvkontakte"   "https://projects.kde.org/projects/extragear/libs/libkvkontakte"  "(version >= 4.70.0)"                  "Kipi-plugins will be compiled without libkvkontakte support."   KF5Vkontakte_FOUND)
Shourya Singh Gupta's avatar
Shourya Singh Gupta committed
169

170
    # Optional plugins results ----------------------------------------------------------------------------
Gilles Caulier's avatar
polish    
Gilles Caulier committed
171

172
173
174
175
176
177
178
179
180
181
182
183
    message(STATUS "")

    if(Qt5_FOUND AND KF5_FOUND AND KF5Kipi_FOUND)
        set(KIPI_COMPILE_MESSAGE "kipi-plugins will be compiled")
        FILL_WITH_DOTS(KIPI_COMPILE_MESSAGE)
        message(STATUS " ${KIPI_COMPILE_MESSAGE} YES")
        set(KIPIPLUGINS_CAN_BE_COMPILED true)
    else()
        message(FATAL_ERROR " kipi-plugins will not be compiled! Look README file for more details about dependencies...")
        set(KIPIPLUGINS_CAN_BE_COMPILED false)
    endif()

184
    PRINT_COMPONENT_COMPILE_STATUS("Legacy plugins"     ENABLE_LEGACY)
Shourya Singh Gupta's avatar
Shourya Singh Gupta committed
185
186
    PRINT_COMPONENT_COMPILE_STATUS("VKontakte"          KF5Vkontakte_FOUND)
    PRINT_COMPONENT_COMPILE_STATUS("Mediawiki"          KF5MediaWiki_FOUND)
187
    PRINT_COMPONENT_COMPILE_STATUS("FlashExport"        KF5Archive_FOUND)
Gilles Caulier's avatar
polish    
Gilles Caulier committed
188

189
    # ==================================================================================================
190

191
    if(KIPIPLUGINS_CAN_BE_COMPILED)
192
193
194
195
196

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

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

199
200
201
        if(NOT GIT_MARKER)
            set (GIT_MARKER ${CMAKE_SOURCE_DIR}/CMakeLists.txt)  # Dummy file
        endif()
202
203
204

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

        # Add a custom target to drive the custom command.
210
        add_custom_target(kipiplugins-gitversion
Gilles Caulier's avatar
polish    
Gilles Caulier committed
211
                          ALL COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/gitscript.cmake")
212
213

        # ==================================================================================================
Gilles Caulier's avatar
polish    
Gilles Caulier committed
214

215
        include_directories(${CMAKE_CURRENT_SOURCE_DIR}/common/libkipiplugins
216
217
218
219
                            ${CMAKE_CURRENT_BINARY_DIR}/common/libkipiplugins
                            ${CMAKE_CURRENT_SOURCE_DIR}/common/libkipiplugins/dialogs
                            ${CMAKE_CURRENT_SOURCE_DIR}/common/libkipiplugins/widgets
                            ${CMAKE_CURRENT_SOURCE_DIR}/common/libkipiplugins/tools
220
                            ${CMAKE_CURRENT_SOURCE_DIR}/common/libkipiplugins/o2/src
221
                            ${KF5Kipi_INCLUDE_DIRS}
222
223
224
225
                        )

        # To prevent warnings from M$ compiler

226
227
228
229
230
        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()
231

232
233
234
235
236
        # 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()

237
238
239
240
241
        # Remove Wdate-time GCC flag which generate a lots of compile warnings
        while(CMAKE_CXX_FLAGS MATCHES "-Wdate-time")
            string(REPLACE "-Wdate-time" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
        endwhile()

242
243
        add_definitions(-DQT_NO_URL_CAST_FROM_STRING)

244
        add_subdirectory(common)
245
        add_subdirectory(flickr)
246
        add_subdirectory(dropbox)
247
        add_subdirectory(facebook)
248
        add_subdirectory(imgur)
249
        add_subdirectory(piwigo)
250
        add_subdirectory(rajce)
251
        add_subdirectory(smug)
252
        add_subdirectory(imageshack)
253
        add_subdirectory(yandexfotki)
Maik Qualmann's avatar
Maik Qualmann committed
254
        add_subdirectory(googleservices)
255

256
257
258
259
260
261
262
263
264
265
        if(ENABLE_LEGACY)
            add_subdirectory(printimages)
            add_subdirectory(kmlexport)
            add_subdirectory(sendimages)
            add_subdirectory(jalbum)

            if(KF5Archive_FOUND)
                add_subdirectory(flashexport)
            endif()

266
267
        endif()

268
269
270
271
        if(KF5Vkontakte_FOUND)
            add_subdirectory(vkontakte)
        endif()

272
273
274
275
        if(KF5MediaWiki_FOUND)
            add_subdirectory(mediawiki)
        endif()

Maik Qualmann's avatar
polish    
Maik Qualmann committed
276
277
        if(KF5KIO_FOUND AND KF5KIOWidgets_FOUND)
            add_subdirectory(remotestorage)    # kioimportwindow.cpp, kioexportwindow.cpp
278
279
        endif()

280
    endif()
281

282
else()
283

284
285
    message(STATUS "")
    message(STATUS "----------------------------------------------------------------------------------")
286
    message(STATUS " ${PROJECT_NAME} ${KIPIPLUGINS_VERSION_STRING} will not be compiled")
Gilles Caulier's avatar
polish    
Gilles Caulier committed
287
288

    PRINT_OPTIONAL_LIBRARY_STATUS("libkipi"
289
                                  "https://cgit.kde.org/libkipi.git"
Gilles Caulier's avatar
polish    
Gilles Caulier committed
290
                                  "(version >= ${KIPI_MIN_VERSION}))"
291
                                  "Kipi Plugins needs this library to be compiled."
Gilles Caulier's avatar
polish    
Gilles Caulier committed
292
293
294
                                  KF5Kipi_FOUND
    )

295
    message(STATUS "")
296

297
endif()