CMakeLists.txt 13.3 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
 ############
#############
## Options ##
#############
############

11 12 13 14 15
 ######################
#######################
## Constants defines ##
#######################
######################
Thomas Zander's avatar
Thomas Zander committed
16

17 18
# define the generic version of the KOffice libraries here
# this makes it easy to advance it when the next KOffice release comes
Cyrille Berger's avatar
Cyrille Berger committed
19 20
set(GENERIC_KOFFICE_LIB_VERSION "6.0.0")
set(GENERIC_KOFFICE_LIB_SOVERSION "6")
21

22
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
23

24 25 26 27 28
#
# WARNING: don't change the SHOULD_BUILD_app if an application
# doesn't build, but rather add the following line:
# option(BUILD_app "Build directory app" OFF)
#
29 30
#eg:
#option(BUILD_kexi "Build directory kexi" OFF) # kexi isn't buildable at the moment
31

Jos van den Oever's avatar
Jos van den Oever committed
32
option(TINY "compile a tiny KOffice" OFF)
33 34 35 36 37 38 39 40 41 42 43 44 45 46

IF (TINY)
    set(SHOULD_BUILD_KWORD TRUE)
    set(SHOULD_BUILD_KPRESENTER TRUE)
    set(SHOULD_BUILD_KSPREAD TRUE)
    set(SHOULD_BUILD_KARBON FALSE)
    set(SHOULD_BUILD_KRITA FALSE)
    set(SHOULD_BUILD_KEXI FALSE)
    set(SHOULD_BUILD_KIVIO FALSE)
    set(SHOULD_BUILD_KPLATO FALSE)
    set(SHOULD_BUILD_KFORMULA FALSE)
    set(SHOULD_BUILD_KCHART TRUE)
    set(SHOULD_BUILD_KDGANTT FALSE)
    set(SHOULD_BUILD_KOUNAVAIL FALSE)
47
    set(SHOULD_BUILD_SCRIPTING FALSE)
48 49 50 51 52 53
ELSE(TINY)
    set(SHOULD_BUILD_KWORD TRUE)
    set(SHOULD_BUILD_KPRESENTER TRUE)
    set(SHOULD_BUILD_KSPREAD TRUE)
    set(SHOULD_BUILD_KARBON TRUE)
    set(SHOULD_BUILD_KRITA TRUE)
Jarosław Staniek's avatar
Jarosław Staniek committed
54
    set(SHOULD_BUILD_KEXI TRUE)
55 56 57 58 59 60
    set(SHOULD_BUILD_KIVIO TRUE)
    set(SHOULD_BUILD_KPLATO TRUE)
    set(SHOULD_BUILD_KFORMULA TRUE)
    set(SHOULD_BUILD_KCHART TRUE)
    set(SHOULD_BUILD_KDGANTT TRUE)
    set(SHOULD_BUILD_KOUNAVAIL TRUE)
61
    set(SHOULD_BUILD_SCRIPTING TRUE)
62 63
ENDIF(TINY)

64 65 66 67 68 69 70 71 72 73
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 ##
#########################
########################
74 75
set(KDE_MIN_VERSION "4.1.0")
find_package(KDE4 4.1.0 REQUIRED)
Thomas Zander's avatar
Thomas Zander committed
76
find_package(Qt4 4.5.0 REQUIRED)
77

78
include(KDE4Defaults)
79
include(MacroLibrary)
80 81 82
include (MacroAdditionalCleanFiles)
include (MacroAddFileDependencies)

83 84 85 86 87
#
# Test for KDE >= 4.3.0
#
macro_ensure_version( "4.3.0" ${KDE_VERSION} KDE4_3_0 )

88 89 90 91 92
 ###########################
############################
## Required dependencies  ##
############################
###########################
93

Laurent Montel's avatar
Laurent Montel committed
94 95
find_package(Perl REQUIRED)
find_package(ZLIB REQUIRED)
96
find_package(PNG REQUIRED)
97

98 99 100
if (APPLE)
   find_package(Carbon REQUIRED)
endif (APPLE)
101

102 103
 ################################
#################################
104
## Check for OpenEXR           ##
105 106
#################################
################################
107

108

109 110 111 112
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)
113

114

115 116 117 118 119 120 121 122 123 124
 ###########################
############################
## Optional dependencies  ##
############################
###########################

##
## Look for OpenGL
##

125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
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")
142

143 144 145
##
## Test for create ressources
##
146
macro_optional_find_package(CreateResources)
147
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
148

149 150 151
##
## Test for kdepimlibs
##
152 153 154
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)")

155 156 157
##
## Test for boost
##
158
macro_optional_find_package(Boost)
159
macro_log_feature(Boost_FOUND "Boost" "Boost C++ Libraries" "http://www.boost.org" FALSE "" "Required by KPresenter")
160

161 162 163 164
##
## Test for eigen2
##
macro_optional_find_package(Eigen2)
165
macro_log_feature(EIGEN2_FOUND "Eigen" "C++ template library for linear algebra" "http://eigen.tuxfamily.org" FALSE "2.0" "Required by KSpread and Krita")
166

167 168 169
##
## Test for blitz
##
170
macro_optional_find_package(Blitz)
171
macro_log_feature(BLITZ_FOUND "QImageBlitz" "Image effect library" "http://www.kde.org" FALSE "" "Required by Krita (available in kdesupport)")
172

173 174 175
##
## Test for QCA2
##
176 177 178
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)")

179 180 181
##
## Test for exiv2
##
182 183 184
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")
185

186 187 188 189 190
##
## 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
191

Thomas Zander's avatar
Thomas Zander committed
192 193
#Set the build of TextShape changetraker

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

196
if(WIN32)
197 198 199 200 201 202 203 204 205 206 207 208 209 210
    # 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} )


211 212 213 214
else(WIN32)
    set (KDE4_ICON_DIR  ${CMAKE_INSTALL_PREFIX}/share/icons)
endif(WIN32)

215 216 217
##
## Test endianess
##
David Faure's avatar
David Faure committed
218
include (TestBigEndian)
219 220 221
TEST_BIG_ENDIAN(CMAKE_WORDS_BIGENDIAN)
configure_file(config-endian.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-endian.h )

222 223 224 225 226 227 228 229 230 231 232
##
## Generate a file for prefix information
##
configure_file(config-prefix.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-prefix.h )

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

233 234 235
# WARNING: make sure that QT_INCLUDES is the first directory to be added to include_directory before
#          any other include directory

236
# for config.h and <toplevel/foo.h> includes (if any?)
Boudewijn Rempt's avatar
Boudewijn Rempt committed
237
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/interfaces )
238

239

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

243 244 245 246 247 248
# koplugin is at the bottom of the stack
set(KOPLUGIN_INCLUDES ${CMAKE_SOURCE_DIR}/libs/koplugin)

# kobase is at the bottom of the stack
set(KOBASE_INCLUDES ${CMAKE_SOURCE_DIR}/libs/kobase)

249
# koodf depends on kostore, kobase and koodf
250 251 252
set(KOODF_INCLUDES ${CMAKE_SOURCE_DIR}/libs/odf
                   ${CMAKE_BINARY_DIR}/libs/odf
                   ${KOBASE_INCLUDES}
253
                   ${KOSTORE_INCLUDES})
254

Boudewijn Rempt's avatar
Boudewijn Rempt committed
255

256
# pigment depends on koplugin and lcms
257
set(PIGMENT_INCLUDES ${KOPLUGIN_INCLUDES}
258 259
                   ${CMAKE_SOURCE_DIR}/libs/pigment
                   ${CMAKE_SOURCE_DIR}/libs/pigment/compositeops
260
                   ${CMAKE_SOURCE_DIR}/libs/pigment/resources
261 262 263
                   ${QT_INCLUDES}
                   ${KDE4_INCLUDES}
                   ${LCMS_INCLUDE_DIR} )
264

265 266 267 268 269 270 271 272
# flake depends on koodf and pigment
set(FLAKE_INCLUDES ${CMAKE_SOURCE_DIR}/libs/flake
                   ${KOODF_INCLUDES}
                   ${KOPLUGIN_INCLUDES}
                   ${PIGMENT_INCLUDES}
                   ${CMAKE_SOURCE_DIR}/libs/flake/commands
                   ${CMAKE_SOURCE_DIR}/libs/flake/tools
                   ${CMAKE_BINARY_DIR}/libs/flake)
273 274 275 276 277 278 279 280 281 282 283

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

# komain depends on kotext & flake
284
set(KOMAIN_INCLUDES ${KDE4_INCLUDES}
285
                    ${KOTEXT_INCLUDES}
286 287
                    ${CMAKE_SOURCE_DIR}/libs/widgets
                    ${CMAKE_SOURCE_DIR}/libs/main
288
                    ${CMAKE_SOURCE_DIR}/libs/main/config)
289

290 291 292
if(SHOULD_BUILD_SCRIPTING)
  set(KOKROSS_INCLUDES ${CMAKE_SOURCE_DIR}/libs/kokross ${CMAKE_BINARY_DIR}/libs/kokross)
endif(SHOULD_BUILD_SCRIPTING)
293

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

297 298 299 300 301
 #############################################
##############################################
## Detect which applications can be compile ##
##############################################
#############################################
302

303 304 305 306 307 308
#
# WARNING: when adding a dependency if there is allready a line
# containing SHOULD_BUILD_app, don't add a new one, just add
# the test to the if construct
#

309
### Karbon: pigment
310
set(SHOULD_BUILD_KARBON FALSE)
311

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

317 318
### KPresenter: boost
if(NOT Boost_FOUND)
319
    set(SHOULD_BUILD_KPRESENTER FALSE)
320
endif(NOT Boost_FOUND)
321

322 323 324 325
### Kexi: bzip2
if(NOT BZIP2_EXECUTABLE )
    set(SHOULD_BUILD_KEXI FALSE)
endif(NOT BZIP2_EXECUTABLE )
326

Carlo Segato's avatar
Carlo Segato committed
327
### Krita: pigment, blitz, eigen2, exiv2
328
if(NOT BLITZ_FOUND OR NOT EIGEN2_FOUND OR NOT EXIV2_FOUND OR NOT KDE4_3_0)
329
   set(SHOULD_BUILD_KRITA FALSE)
330
endif(NOT BLITZ_FOUND OR NOT EIGEN2_FOUND OR NOT EXIV2_FOUND OR NOT KDE4_3_0)
331

332 333 334 335 336 337 338 339 340 341 342 343 344 345
### KPlato: kdepimlibs
if(NOT KdepimLibs_FOUND)
    set(SHOULD_BUILD_KPLATO FALSE)
endif(NOT KdepimLibs_FOUND)

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

add_subdirectory(libs)
add_subdirectory(interfaces)
add_subdirectory(cmake)
346

347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369
if(SHOULD_BUILD_KWORD)
    macro_optional_add_subdirectory(kword)
endif(SHOULD_BUILD_KWORD)

if (SHOULD_BUILD_KFORMULA)
    macro_optional_add_subdirectory(kformula)
endif (SHOULD_BUILD_KFORMULA)

if (SHOULD_BUILD_KIVIO)
    macro_optional_add_subdirectory(kivio)
endif (SHOULD_BUILD_KIVIO)

if (SHOULD_BUILD_KOUNAVAIL)
    macro_optional_add_subdirectory(kounavail)
endif (SHOULD_BUILD_KOUNAVAIL)    

if (SHOULD_BUILD_KPLATO)
    macro_optional_add_subdirectory(kdgantt)
endif (SHOULD_BUILD_KPLATO)

if (SHOULD_BUILD_KCHART)
    macro_optional_add_subdirectory(kchart)
endif (SHOULD_BUILD_KCHART)
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
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)

395 396
macro_optional_add_subdirectory(doc)

Laurent Montel's avatar
Laurent Montel committed
397
add_subdirectory(pics)
398
add_subdirectory(plugins)
Laurent Montel's avatar
Laurent Montel committed
399 400
add_subdirectory(servicetypes)
add_subdirectory(templates)
401 402
add_subdirectory(tools)
add_subdirectory(filters)
Laurent Montel's avatar
Laurent Montel committed
403

404
macro_display_feature_log()
405

406 407 408 409 410 411
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)

David Faure's avatar
David Faure committed
412
message(STATUS "---------------- The following applications will be built ----------------" )
413

414
macro_display_application_enabled(kword ${SHOULD_BUILD_KWORD})
415 416
macro_display_application_enabled(kspread ${SHOULD_BUILD_KSPREAD})
macro_display_application_enabled(kpresenter ${SHOULD_BUILD_KPRESENTER})
417
macro_display_application_enabled(kivio ${SHOULD_BUILD_KIVIO})
418 419 420 421
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})
422 423
macro_display_application_enabled(kformula ${SHOULD_BUILD_KFORMULA})
macro_display_application_enabled(kchart ${SHOULD_BUILD_KCHART})
424 425 426

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

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