CMakeLists.txt 14.5 KB
Newer Older
Laurent Montel's avatar
Laurent Montel committed
1 2
project(koffice)

3
cmake_minimum_required(VERSION 2.6.2 FATAL_ERROR)
Laurent Montel's avatar
Laurent Montel committed
4

5 6 7 8 9 10 11 12
 ############
#############
## Options ##
#############
############

option(BUILD_pigment "Enable the compilation of the pigment CMS libray (needed by krita and karbon)" ON) # we can't use the one coming from macro_optional_add_subdirectory since the option is created after the checks

13 14 15 16 17
 ######################
#######################
## Constants defines ##
#######################
######################
Thomas Zander's avatar
Thomas Zander committed
18

19 20 21 22 23
# define the generic version of the KOffice libraries here
# this makes it easy to advance it when the next KOffice release comes
set(GENERIC_KOFFICE_LIB_VERSION "5.0.0")
set(GENERIC_KOFFICE_LIB_SOVERSION "5")

24
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
25

26 27 28 29 30 31 32 33 34 35
if(KDE4_BUILD_TESTS)
    # only with this definition will the FOO_TEST_EXPORT macro do something
    add_definitions(-DCOMPILING_TESTS)
endif(KDE4_BUILD_TESTS)

 ########################
#########################
## Look for KDE and Qt ##
#########################
########################
36 37
set(KDE_MIN_VERSION "4.1.0")
find_package(KDE4 4.1.0 REQUIRED)
Thomas Zander's avatar
Thomas Zander committed
38
find_package(Qt4 4.5.0 REQUIRED)
39

40
include(KDE4Defaults)
41
include(MacroLibrary)
42 43 44 45 46 47 48 49
include (MacroAdditionalCleanFiles)
include (MacroAddFileDependencies)

 ###########################
############################
## Required dependencies  ##
############################
###########################
50

Laurent Montel's avatar
Laurent Montel committed
51 52
find_package(Perl REQUIRED)
find_package(ZLIB REQUIRED)
53
find_package(PNG REQUIRED)
54

55 56 57
if (APPLE)
   find_package(Carbon REQUIRED)
endif (APPLE)
58

59 60 61 62 63
 ################################
#################################
## Check wich pigment to build ##
#################################
################################
64

65
# NO_PIGMENT disabled everything that uses pigment in the crudest matter possible
66
if (NOT BUILD_pigment)
67 68 69
    add_definitions(-DNO_PIGMENT)
    set (FULL_PIGMENT FALSE)
    set (SMALL_PIGMENT FALSE)
70
else (NOT BUILD_pigment)
71 72

    include_directories(${CMAKE_SOURCE_DIR}/libs/pigment)
73
#        macro_optional_find_package(LCMS)
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
    find_package(LCMS REQUIRED)
    set(REQUIRED_LCMS_VERSION 118)

    if(LCMS_FOUND AND NOT LCMS_VERSION LESS ${REQUIRED_LCMS_VERSION})
        # FULL_PIGMENT is the most desirable state, we can compile Krita!
        set(HAVE_REQUIRED_LCMS_VERSION TRUE)
        set(FULL_PIGMENT TRUE)
        set(SMALL_PIGMENT FALSE)
        add_definitions(-DFULL_PIGMENT)
    else(LCMS_FOUND AND NOT LCMS_VERSION LESS ${REQUIRED_LCMS_VERSION})
        message( FATAL_ERROR "Old LCMS version found, upgrade to 1.18.")
        set(HAVE_REQUIRED_LCMS_VERSION FALSE)
        set(SMALL_PIGMENT TRUE)
        set(FULL_PIGMENT FALSE)
    endif(LCMS_FOUND AND NOT LCMS_VERSION LESS ${REQUIRED_LCMS_VERSION})

    macro_log_feature(HAVE_REQUIRED_LCMS_VERSION "LittleCMS" "Color management engine" "http://www.littlecms.com" FALSE "1.18" "Required by for color management and for Krita")
endif (NOT BUILD_pigment)

# SMALL_PIGMENT provides just the classed needed to compile koffice libs, but not not Krita.
if (SMALL_PIGMENT) 
    add_definitions(-DSMALL_PIGMENT)
endif(SMALL_PIGMENT)

98

99 100 101 102 103 104 105 106 107 108
 ###########################
############################
## Optional dependencies  ##
############################
###########################

##
## Look for OpenGL
##

109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
macro_optional_find_package(OpenGL)
set(HAVE_OPENGL 0)

if(OPENGL_FOUND)
    message(STATUS "Found OpenGL: ${OPENGL_LIBRARIES}")
    if(QT_QTOPENGL_FOUND)
        message(STATUS "Found Qt OpenGL support")
        set(HAVE_OPENGL 1)
    else(QT_QTOPENGL_FOUND)
        message(STATUS "Did NOT find Qt OpenGL support. Check your Qt configuration")
    endif(QT_QTOPENGL_FOUND)
else(OPENGL_FOUND)
    message(STATUS "Did NOT find OpenGL libraries")
endif(OPENGL_FOUND)

configure_file(config-opengl.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-opengl.h )
macro_log_feature(HAVE_OPENGL "OpenGL" "OpenGL support" "" FALSE "" "Required by parts of Krita and optionally by flake")
126

127 128 129 130 131 132 133 134 135 136 137
##
## Look for OpenEXR
##
macro_optional_find_package(OpenEXR)
macro_bool_to_01(OPENEXR_FOUND HAVE_OPENEXR)
configure_file(config-openexr.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-openexr.h )
install( FILES  ${CMAKE_CURRENT_BINARY_DIR}/config-openexr.h DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel)

##
## Test for create ressources
##
138 139
macro_optional_find_package(CreateResources)
macro_log_feature(CreateResources_FOUND "Create Resources" "Create Resources (brushes, palettes etc.)" "http://create.freedesktop.org" FALSE "" "Required by KOffice for optional extra resources.")
Laurent Montel's avatar
Laurent Montel committed
140

141 142 143
##
## Test for kdepimlibs
##
144 145 146
macro_optional_find_package(KdepimLibs)
macro_log_feature(KDEPIMLIBS_FOUND "KDE PIMLibs" "KDE Personal Information Management Libraries" "http://www.kde.org/" FALSE "" "Required by KPlato and the KDE address book integration (available as a module in KDE)")

147 148 149
##
## Test for boost
##
150
macro_optional_find_package(Boost)
151
macro_log_feature(Boost_FOUND "Boost" "Boost C++ Libraries" "http://www.boost.org" FALSE "" "Required by KPresenter")
152

153 154 155 156
##
## Test for eigen2
##
macro_optional_find_package(Eigen2)
157
macro_log_feature(EIGEN2_FOUND "Eigen" "C++ template library for linear algebra" "http://eigen.tuxfamily.org" FALSE "2.0" "Required by KSpread and Krita")
158

159 160 161
##
## Test for blitz
##
162
macro_optional_find_package(Blitz)
163
macro_log_feature(BLITZ_FOUND "QImageBlitz" "Image effect library" "http://www.kde.org" FALSE "" "Required by Krita (available in kdesupport)")
164

165 166 167
##
## Test for QCA2
##
168 169 170
macro_optional_find_package(QCA2)
macro_log_feature(QCA2_FOUND "QCA" "Qt Cryptographic Architecture" "http://delta.affinix.com/qca" FALSE "2.0" "Required for encrypted OpenDocument files support (available as a module in kdesupport)")

171 172 173
##
## Test for exiv2
##
174 175 176
set(EXIV2_MIN_VERSION "0.16")
macro_optional_find_package(Exiv2)
macro_log_feature(EXIV2_FOUND "Exiv2" "Image metadata library and tools" "http://www.exiv2.org" FALSE "0.16" "Required by Krita")
177

178 179 180 181 182
##
## Test for bzip2
##
find_program(BZIP2_EXECUTABLE NAMES bzip2 )
macro_log_feature(BZIP2_EXECUTABLE "bzip2" "High-quality data compressor" "http://www.bzip.org" FALSE "" "Required by Kexi")
Laurent Montel's avatar
Laurent Montel committed
183

Thomas Zander's avatar
Thomas Zander committed
184 185
#Set the build of TextShape changetraker

David Faure's avatar
David Faure committed
186
add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS} ${QT_QTDBUS_DEFINITIONS})
Laurent Montel's avatar
Laurent Montel committed
187

188
if(WIN32)
189 190 191 192 193 194 195 196 197 198 199 200 201 202
    # detect oxygen icon dir at configure time based on KDEDIRS - there may be different package installation locations
    execute_process(COMMAND "${KDE4_KDECONFIG_EXECUTABLE}" --path icon OUTPUT_VARIABLE _dir ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
    file(TO_CMAKE_PATH "${_dir}" __dir)
    find_path(KDE4_ICON_DIR oxygen PATHS
        ${__dir}
    )
    message(STATUS "using oxygen application icons from ${KDE4_ICON_DIR}")

    set(LIB_INSTALL_DIR ${LIB_INSTALL_DIR}
                        RUNTIME DESTINATION ${BIN_INSTALL_DIR}
                        LIBRARY ${INSTALL_TARGETS_DEFAULT_ARGS}
                        ARCHIVE ${INSTALL_TARGETS_DEFAULT_ARGS} )


203 204 205 206
else(WIN32)
    set (KDE4_ICON_DIR  ${CMAKE_INSTALL_PREFIX}/share/icons)
endif(WIN32)

207 208 209
##
## Test endianess
##
David Faure's avatar
David Faure committed
210
include (TestBigEndian)
211 212 213
TEST_BIG_ENDIAN(CMAKE_WORDS_BIGENDIAN)
configure_file(config-endian.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-endian.h )

214 215 216 217 218 219 220 221 222 223 224
##
## Generate a file for prefix information
##
configure_file(config-prefix.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-prefix.h )

 ####################
#####################
## Define includes ##
#####################
####################

225
# for config.h and <toplevel/foo.h> includes (if any?)
226
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
227

228 229 230
# koaction depends on threadweaver
set(KOACTION_INCLUDES ${CMAKE_SOURCE_DIR}/libs/koaction ${CMAKE_BINARY_DIR}/libs/koaction ${KDE4_INCLUDES})

231
# kostore is at the bottom of stack, so it has the dependency on the kde4 includes.
232
set(KOSTORE_INCLUDES ${CMAKE_SOURCE_DIR}/libs/store ${CMAKE_BINARY_DIR}/libs/store ${KDE4_INCLUDES})
233

234 235 236 237 238 239
# kopicture depends on kostore
set(KOPICTURE_INCLUDES ${CMAKE_SOURCE_DIR}/libs/kopicture ${CMAKE_BINARY_DIR}/libs/kopicture ${KOSTORE_INCLUDES})

# koodf depends on kostore and kopicture
set(KOODF_INCLUDES ${CMAKE_SOURCE_DIR}/libs/odf ${CMAKE_BINARY_DIR}/libs/odf ${KOPICTURE_INCLUDES})

240
# flake depends on koodf
241
set(FLAKE_INCLUDES ${CMAKE_SOURCE_DIR}/libs/flake 
242
                   ${KOODF_INCLUDES}
243 244 245 246
                   ${CMAKE_SOURCE_DIR}/libs/kobase 
                   ${CMAKE_SOURCE_DIR}/libs/flake/commands 
                   ${CMAKE_SOURCE_DIR}/libs/flake/tools 
                   ${CMAKE_BINARY_DIR}/libs/flake)
247 248
# pigment depends on koplugin and lcms
set(PIGMENT_INCLUDES ${CMAKE_SOURCE_DIR}/libs/koplugin ${CMAKE_SOURCE_DIR}/libs/pigment ${CMAKE_SOURCE_DIR}/libs/pigment/compositeops ${LCMS_INCLUDE_DIR} ${KDE4_INCLUDES} )
249 250 251

# komain depends on kostore, koplugin, flake and koodf
set(KOMAIN_INCLUDES ${KDE4_INCLUDES}
252 253
                    ${FLAKE_INCLUDES}
                    ${PIGMENT_INCLUDES}
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
                    ${CMAKE_SOURCE_DIR}/libs/koproperties
                    ${CMAKE_SOURCE_DIR}/libs/store
                    ${CMAKE_SOURCE_DIR}/libs/kotext
                    ${CMAKE_SOURCE_DIR}/libs/kotext/changetracker
                    ${CMAKE_SOURCE_DIR}/libs/kotext/styles
                    ${CMAKE_SOURCE_DIR}/libs/kotext/kohyphen
                    ${CMAKE_SOURCE_DIR}/libs/kotext/opendocument
                    ${CMAKE_SOURCE_DIR}/libs/widgets
                    ${CMAKE_SOURCE_DIR}/libs/widgets/progress
                    ${CMAKE_SOURCE_DIR}/libs/widgets/linestyleselector
                    ${CMAKE_SOURCE_DIR}/libs/widgets/aspectbutton
                    ${CMAKE_SOURCE_DIR}/libs/widgets/openpane
                    ${CMAKE_SOURCE_DIR}/libs/widgets/colorwidgets
                    ${CMAKE_SOURCE_DIR}/libs/widgets/resources
                    ${CMAKE_SOURCE_DIR}/libs/widgets/pagelayout
                    ${CMAKE_SOURCE_DIR}/libs/widgets/characterselectiondialog
                    ${CMAKE_SOURCE_DIR}/libs/widgets/csvimportdialog
                    ${CMAKE_SOURCE_DIR}/libs/widgets/documentsectionbox
                    ${CMAKE_SOURCE_DIR}/libs/widgets/zoom
                    ${CMAKE_SOURCE_DIR}/libs/widgets/input
                    ${CMAKE_SOURCE_DIR}/libs/kopicture
                    ${CMAKE_SOURCE_DIR}/libs/koaction
                    ${CMAKE_SOURCE_DIR}/libs/main
                    ${CMAKE_SOURCE_DIR}/libs/resources
                    ${CMAKE_SOURCE_DIR}/libs/koplugin
279 280
 )

281 282 283 284 285 286 287 288 289 290 291 292 293
 # koresources depends on pigment
 set(KORESOURCES_INCLUDES ${CMAKE_SOURCE_DIR}/libs/resources
 			 ${CMAKE_BINARY_DIR}/libs/resources 
 			 ${PIGMENT_INCLUDES} 
			 ${KDE4_INCLUDES})

# KoText depends on store, odf
set(KOTEXT_INCLUDES ${CMAKE_SOURCE_DIR}/libs/kotext/styles
                    ${CMAKE_SOURCE_DIR}/libs/kotext/opendocument
                    ${CMAKE_SOURCE_DIR}/libs/kotext
                    ${CMAKE_SOURCE_DIR}/libs/kotext/changetracker
                    ${CMAKE_BINARY_DIR}/libs/kotext)

294
set(KOKROSS_INCLUDES ${CMAKE_SOURCE_DIR}/libs/kokross ${CMAKE_BINARY_DIR}/libs/kokross)
295

David Faure's avatar
David Faure committed
296 297
# kopageapp
set(KOPAGEAPP_INCLUDES ${CMAKE_SOURCE_DIR}/libs/kopageapp ${CMAKE_SOURCE_DIR}/libs/kopageapp/commands ${CMAKE_BINARY_DIR}/libs/kopageapp )
298

299
set(KOPROPERTIES_INCLUDES ${CMAKE_SOURCE_DIR}/libs/kobase ${CMAKE_BINARY_DIR}/libs/kobase)
Jarosław Staniek's avatar
fix:  
Jarosław Staniek committed
300

301 302 303 304 305
 #############################################
##############################################
## Detect which applications can be compile ##
##############################################
#############################################
306

307
### Karbon: pigment
308
set(SHOULD_BUILD_KARBON TRUE)
309
if (NOT BUILD_pigment)
310
    set(SHOULD_BUILD_KARBON FALSE)
311
endif (NOT BUILD_pigment)
312

313 314 315
### KSpread: eigen2
set(SHOULD_BUILD_KSPREAD TRUE)
if(NOT EIGEN2_FOUND)
Michael Jansen's avatar
Michael Jansen committed
316
    set(SHOULD_BUILD_KSPREAD FALSE)
317
endif(NOT EIGEN2_FOUND)
318

319 320 321
### KPresenter: boost
set(SHOULD_BUILD_KPRESENTER TRUE)
if(NOT Boost_FOUND)
322
    set(SHOULD_BUILD_KPRESENTER FALSE)
323
endif(NOT Boost_FOUND)
324

325 326 327 328 329
### Kexi: bzip2
set(SHOULD_BUILD_KEXI TRUE)
if(NOT BZIP2_EXECUTABLE )
    set(SHOULD_BUILD_KEXI FALSE)
endif(NOT BZIP2_EXECUTABLE )
330

331 332
### Krita: non-win32, pigment, blitz, eigen2, exiv2
set(SHOULD_BUILD_KRITA TRUE)
333
if(WIN32 OR NOT FULL_PIGMENT OR NOT BUILD_pigment OR NOT BLITZ_FOUND OR NOT EIGEN2_FOUND OR NOT EXIV2_FOUND)
334
   set(SHOULD_BUILD_KRITA FALSE)
335
endif(WIN32 OR NOT FULL_PIGMENT OR NOT BUILD_pigment OR NOT BLITZ_FOUND OR NOT EIGEN2_FOUND OR NOT EXIV2_FOUND)
336

337 338 339 340 341 342 343 344 345 346 347 348 349 350 351
### KPlato: kdepimlibs
set(SHOULD_BUILD_KPLATO TRUE)
if(NOT KdepimLibs_FOUND)
    set(SHOULD_BUILD_KPLATO FALSE)
endif(NOT KdepimLibs_FOUND)

 ###################
####################
## Subdirectories ##
####################
###################

add_subdirectory(libs)
add_subdirectory(interfaces)
add_subdirectory(cmake)
352

Boudewijn Rempt's avatar
Boudewijn Rempt committed
353
macro_optional_add_subdirectory(kword)
354 355 356 357 358 359 360
macro_optional_add_subdirectory(kformula)
macro_optional_add_subdirectory(kivio)
macro_optional_add_subdirectory(kounavail)
macro_optional_add_subdirectory(kdgantt)
macro_optional_add_subdirectory(kchart)
macro_optional_add_subdirectory(doc)

361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384
if(SHOULD_BUILD_KPRESENTER)
  macro_optional_add_subdirectory(kpresenter)
endif(SHOULD_BUILD_KPRESENTER)

if(SHOULD_BUILD_KEXI)
    macro_optional_add_subdirectory(kexi)
endif(SHOULD_BUILD_KEXI)

if(SHOULD_BUILD_KPLATO)
    macro_optional_add_subdirectory(kplato)
endif(SHOULD_BUILD_KPLATO)

if(SHOULD_BUILD_KSPREAD)
    macro_optional_add_subdirectory(kspread)
endif(SHOULD_BUILD_KSPREAD)

if(SHOULD_BUILD_KRITA)
  macro_optional_add_subdirectory(krita)
endif(SHOULD_BUILD_KRITA)

if(SHOULD_BUILD_KARBON)
  macro_optional_add_subdirectory(karbon)
endif(SHOULD_BUILD_KARBON)

Laurent Montel's avatar
Laurent Montel committed
385
add_subdirectory(pics)
386
add_subdirectory(plugins)
Laurent Montel's avatar
Laurent Montel committed
387 388
add_subdirectory(servicetypes)
add_subdirectory(templates)
389 390
add_subdirectory(tools)
add_subdirectory(filters)
Laurent Montel's avatar
Laurent Montel committed
391

392
macro_display_feature_log()
393

394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414
macro(macro_display_application_enabled _appName _shouldBuild)
if( BUILD_${_appName} AND ${_shouldBuild} MATCHES "[Tt][Rr][Uu][Ee]" )
  message(STATUS ${_appName} )
endif( BUILD_${_appName} AND ${_shouldBuild} MATCHES "[Tt][Rr][Uu][Ee]" )
endmacro(macro_display_application_enabled)

message(STATUS "---------------- The following applications will be build ----------------" )

macro_display_application_enabled(kword TRUE)
macro_display_application_enabled(kspread ${SHOULD_BUILD_KSPREAD})
macro_display_application_enabled(kpresenter ${SHOULD_BUILD_KPRESENTER})
macro_display_application_enabled(kivio TRUE)
macro_display_application_enabled(kexi ${SHOULD_BUILD_KEXI})
macro_display_application_enabled(kplato ${SHOULD_BUILD_KPLATO})
macro_display_application_enabled(krita ${SHOULD_BUILD_KRITA})
macro_display_application_enabled(karbon ${SHOULD_BUILD_KARBON})
macro_display_application_enabled(kformula TRUE)
macro_display_application_enabled(kchart TRUE)

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

415
add_custom_target(apidox doc/api/gendocs.pl WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})