File: CMakeLists.txt

package info (click to toggle)
scribus 1.3.3.13.dfsg~svn20081228-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 54,668 kB
  • ctags: 14,434
  • sloc: cpp: 165,840; ansic: 8,920; python: 3,149; xml: 419; makefile: 114; perl: 94; sh: 69
file content (525 lines) | stat: -rw-r--r-- 16,469 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
#CMAKE SETUP
#Require 2.4.2 for Qt finding
#Require 2.4.3 for moc change detection
#Require 2.4.3 for rpath updates for custom cairo install
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.3 FATAL_ERROR)

SET(CMAKE_COLOR_MAKEFILE ON)
SET(CMAKE_VERBOSE_MAKEFILE OFF)
SET(CMAKE_INCLUDE_CURRENT_DIR TRUE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
#SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
#SET(CMAKE_SKIP_RPATH:BOOL NO)
SET(CMAKE_SKIP_RULE_DEPENDENCY TRUE)

SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
# SET(CMAKE_SHARED_MODULE_LINK_FLAGS "${CMAKE_SHARED_MODULE_LINK_FLAGS} -export-dynamic")
# SET(CMAKE_SHARED_MODULE_LINK_CXX_FLAGS "${CMAKE_SHARED_MODULE_LINK_CXX_FLAGS} -export-dynamic")
# SET(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} -export-dynamic")
# SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -export-dynamic")
# MESSAGE(STATUS ${CMAKE_SHARED_MODULE_LINK_FLAGS})
# MESSAGE(STATUS ${CMAKE_SHARED_MODULE_LINK_CXX_FLAGS})
# MESSAGE(STATUS ${CMAKE_SHARED_LIBRARY_C_FLAGS})
# MESSAGE(STATUS ${CMAKE_SHARED_LIBRARY_CXX_FLAGS})
# MESSAGE(STATUS ${CMAKE_CXX_CREATE_SHARED_MODULE})
# MESSAGE(STATUS ${CMAKE_CXX_CREATE_SHARED_LIBRARY})

#IMPORT FROM COMMANDLINE
# SET with cmake -DWANT_CAIRO=1, etc
# MESSAGE(STATUS ${WANT_CAIRO})
# MESSAGE(STATUS ${WANT_LIBART})
# MESSAGE(STATUS ${WANT_DEBUG})

# SET(WANT_CAIRO 0)
# SET(WANT_LIBART 1)

#PROJECT SETUP
PROJECT(scribus)
SET (VERSION_MAJOR "1")
SET (VERSION_MINOR "3")
SET (VERSION_PATCH "3.13svn")
SET (VERSION_SUFFIX "")
SET (VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${VERSION_SUFFIX})
MESSAGE(STATUS "Scribus ${VERSION} will be built to install into ${CMAKE_INSTALL_PREFIX}")

SET(PLUGIN_PERMISSIONS WORLD_EXECUTE GROUP_EXECUTE OWNER_EXECUTE WORLD_READ GROUP_READ OWNER_READ OWNER_WRITE)

SET(MAIN_DIR_NAME "scribus")

##############################################################################################################
########## check for the CPU we build for                                                           ##########

EXECUTE_PROCESS(
    COMMAND ${CMAKE_C_COMPILER} -dumpmachine
    OUTPUT_VARIABLE MACHINE
    OUTPUT_STRIP_TRAILING_WHITESPACE
)
MESSAGE(STATUS "Building for target ${MACHINE}")

STRING(REGEX MATCH "(i?86-*)|(athlon-*)|(pentium-*)" _machine_x86 "${MACHINE}")
IF (_machine_x86)
    MESSAGE(STATUS "Found target X86")
    SET(ARCH_X86 1)
ENDIF (_machine_x86)

STRING(REGEX MATCH "(x86_64-*)|(X86_64-*)|(AMD64-*)|(amd64-*)" _machine_x86_64 "${MACHINE}")
IF (_machine_x86_64)
    MESSAGE(STATUS "Found target X86_64")
    SET(ARCH_X86_64 1)
ENDIF (_machine_x86_64)

STRING(REGEX MATCH "(ppc-*)" _machine_ppc "${MACHINE}")
IF (_machine_ppc)
    MESSAGE(STATUS "Found target PPC")
    SET(ARCH_PPC 1)
ENDIF (_machine_ppc)

STRING(REGEX MATCH "(sparc-*)" _machine_sparc "${MACHINE}")
IF (_machine_sparc)
    MESSAGE(STATUS "Found target Sparc")
    SET(ARCH_SPARC 1)
ENDIF (_machine_sparc)

STRING(REGEX MATCH "(sparcv9-*)" _machine_sparcv9 "${MACHINE}")
IF (_machine_sparcv9)
    MESSAGE(STATUS "Found target Sparc v9")
    SET(ARCH_SPARCV9 1)
ENDIF (_machine_sparcv9)

STRING(REGEX MATCH "(sparc64-*)" _machine_sparc64 "${MACHINE}")
IF (_machine_sparc64)
    MESSAGE(STATUS "Found target Sparc64")
    SET(ARCH_SPARC64 1)
    SET(ARCH64BIT 1)
ENDIF (_machine_sparc64)


#convert any 64 bit build into generic 64 tag for below
IF (ARCH_X86_64) 
  SET(ARCH64BIT 1)
ENDIF (ARCH_X86_64)

##############################################################################################################
########## Versioning Setup                                                                         ##########

IF(TAG_VERSION)
  MESSAGE(STATUS "Previously selected version tag: ${TAG_VERSION}")
  SET(WANT_VERSIONING 1)
  SET(CACHED_VERSIONING 1)
ENDIF(TAG_VERSION)
IF (WANT_VERSIONING AND NOT CACHED_VERSIONING)
  IF (NOT CUSTOM_VERSIONTAG)
    SET(TAG_VERSION "-${VERSION}" CACHE TYPE STRING)
  ELSE (NOT CUSTOM_VERSIONTAG)
    SET(TAG_VERSION ${CUSTOM_VERSIONTAG} CACHE TYPE STRING)
  ENDIF (NOT CUSTOM_VERSIONTAG)
ENDIF (WANT_VERSIONING AND NOT CACHED_VERSIONING)

#MAN
SET(MANDIR "share/man/")
SET(SHAREDIR "share/${MAIN_DIR_NAME}${TAG_VERSION}/")
ADD_DEFINITIONS("-DSHAREDIR=\\\"${CMAKE_INSTALL_PREFIX}/${SHAREDIR}\\\"")
#SHARE
IF(TAG_VERSION)
  SET(DOCDIR "share/doc/${MAIN_DIR_NAME}${TAG_VERSION}/")
ELSE(TAG_VERSION)
  SET(DOCDIR "share/doc/${MAIN_DIR_NAME}-${VERSION}/")
ENDIF (TAG_VERSION)
ADD_DEFINITIONS("-DSHAREDIR=\\\"${CMAKE_INSTALL_PREFIX}/${SHAREDIR}\\\"")
SET(DOCDIR "share/doc/${MAIN_DIR_NAME}${TAG_VERSION}/")
ADD_DEFINITIONS("-DDOCDIR=\\\"${CMAKE_INSTALL_PREFIX}/${DOCDIR}\\\"")
SET(ICONDIR "share/${MAIN_DIR_NAME}${TAG_VERSION}/icons/")
ADD_DEFINITIONS("-DICONDIR=\\\"${CMAKE_INSTALL_PREFIX}/${ICONDIR}\\\"")
SET(SAMPLESDIR "share/${MAIN_DIR_NAME}${TAG_VERSION}/samples/")
ADD_DEFINITIONS("-DSAMPLESDIR=\\\"${CMAKE_INSTALL_PREFIX}/${SAMPLESDIR}\\\"")
SET(SCRIPTSDIR "share/${MAIN_DIR_NAME}${TAG_VERSION}/scripts/")
ADD_DEFINITIONS("-DSCRIPTSDIR=\\\"${CMAKE_INSTALL_PREFIX}/${SCRIPTSDIR}\\\"")
SET(TEMPLATEDIR "share/${MAIN_DIR_NAME}${TAG_VERSION}/templates/")
ADD_DEFINITIONS("-DTEMPLATEDIR=\\\"${CMAKE_INSTALL_PREFIX}/${TEMPLATEDIR}\\\"")


#DESKTOP backport from 1.3.5
SET(DESKTOPDIR "share/applications/")
ADD_DEFINITIONS("-DDESKTOPDIR=\\\"${CMAKE_INSTALL_PREFIX}/${DESKTOPDIR}\\\"")

#LIB LOCATION - lib or lib64 normally
#LIB
IF(WANT_LIB64)
  IF(NOT ARCH64BIT)
    MESSAGE(STATUS "WARNING: BUILDING 64 Bit build on non 64 bit architecture")
  ENDIF(NOT ARCH64BIT)
  SET(LIB_SUFFIX "64" CACHE TYPE STRING)
ENDIF(WANT_LIB64)
#OVERRIDE WANT_LIB64 with WANT_LIB32 if both exist
IF(WANT_LIB32)
  IF(ARCH64BIT)
    MESSAGE(STATUS "WARNING: FORCING 32 Bit build on 64 bit architecture")
  ENDIF(ARCH64BIT)
  SET(LIB_SUFFIX "" CACHE TYPE STRING)
  SET(WANT_LIB64 "")
ENDIF(WANT_LIB32)
#Auto build 64 bit if user doesnt force 32 bit and we detect 64 bit
IF(ARCH64BIT AND NOT LIB_SUFFIX)
  IF(NOT WANT_LIB32)
    IF(NOT WANT_LIB64)
      MESSAGE(STATUS "Autodetected 64 bit architecture, building for 64 Bit")
      SET(LIB_SUFFIX "64" CACHE TYPE STRING)
    ENDIF(NOT WANT_LIB64)
  ENDIF(NOT WANT_LIB32)
ENDIF(ARCH64BIT AND NOT LIB_SUFFIX)


SET(LIB_DIR_NAME "lib${LIB_SUFFIX}")
SET(LIBDIR "${LIB_DIR_NAME}/${MAIN_DIR_NAME}${TAG_VERSION}/")
ADD_DEFINITIONS("-DLIBDIR=\\\"${CMAKE_INSTALL_PREFIX}/${LIBDIR}\\\"")

#PLUGINS
SET(PLUGINDIR "${LIB_DIR_NAME}/${MAIN_DIR_NAME}${TAG_VERSION}/plugins/")
ADD_DEFINITIONS("-DPLUGINDIR=\\\"${CMAKE_INSTALL_PREFIX}/${PLUGINDIR}\\\"")

# older version 
#SET(LIBDIR "lib/${MAIN_DIR_NAME}${TAG_VERSION}/")
#ADD_DEFINITIONS("-DLIBDIR=\\\"${CMAKE_INSTALL_PREFIX}/${LIBDIR}\\\"")
#SET(PLUGINDIR "lib/${MAIN_DIR_NAME}${TAG_VERSION}/plugins/")
#ADD_DEFINITIONS("-DPLUGINDIR=\\\"${CMAKE_INSTALL_PREFIX}/${PLUGINDIR}\\\"")
#set(CMAKE_INSTALL_RPATH ${PLUGINDIR})

# Set the XDG mime stuff
SET(MIMEDIR "share/mime/packages/")
SET(MIMELNKDIR "share/mimelnk/application/")

#BUILD SETUP
#None, Debug, Release, .. or custom ones
#SET(WANT_DEBUG 1)
IF(WANT_DEBUG)
  SET(CMAKE_BUILD_TYPE Debug)
ELSE(WANT_DEBUG)
  SET(CMAKE_BUILD_TYPE RELEASE)
ENDIF(WANT_DEBUG)

IF(APPLE)
  SET( ENV{MACOSX_DEPLOYMENT_TARGET} 10.3 ) 
  SET( ENV{LD_PREBIND} 1 )
  SET( ENV{LD_PREBIND_ALLOW_OVERLAP} 1 )
  SET(CMAKE_CXX_FLAGS_DEBUG "-O2 -g3 -fno-inline-functions -Wall")
  SET(CMAKE_C_FLAGS_DEBUG "-O2 -g3 -fno-inline-functions -Wall")
  SET(BUILD_MAC_BUNDLE 1)
ELSE(APPLE)
  SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -Wall")
  SET(CMAKE_C_FLAGS_DEBUG "-O0 -g3 -Wall")
ENDIF(APPLE)
SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -Wall")
SET(CMAKE_C_FLAGS_RELEASE "-O2 -Wall")


INCLUDE (${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
INCLUDE (CheckIncludeFile)
TEST_BIG_ENDIAN(WORDS_BIGENDIAN)

#FIND DEPENDENCIES
# START QT
SET (QT_MT_REQUIRED true)
SET (QT_MIN_VERSION "3.3.4")
FIND_PACKAGE(Qt3 REQUIRED)
IF (QT_FOUND)
  MESSAGE("Qt3 Found OK (${qt_version_str})")
#   MESSAGE("$ENV{QTDIR}")
#   MESSAGE("${QT_MOC_EXECUTABLE}")
#   MESSAGE("${QT_UIC_EXECUTABLE}")
#   MESSAGE("${QT_QT_LIBRARY}")
#   MESSAGE("${QT_INCLUDE_DIR}")
#   MESSAGE("${qt_version_str}")
#   MESSAGE(${qt_version_str_lib})
ELSE(QT_FOUND)
  MESSAGE(FATAL_ERROR "No Qt3")
ENDIF(QT_FOUND)
# END QT
# START PNG, JPEG, TIFF
FIND_PACKAGE(PNG REQUIRED)
IF (PNG_FOUND)
  MESSAGE("PNG Library Found OK")
ENDIF(PNG_FOUND)
FIND_PACKAGE(JPEG REQUIRED)
IF (JPEG_FOUND)
  MESSAGE("JPEG Library Found OK")
ENDIF(JPEG_FOUND)
FIND_PACKAGE(TIFF REQUIRED)
IF (TIFF_FOUND)
  MESSAGE("TIFF Library Found OK")
  SET(HAVE_TIFF 1)
  IF(WANT_TIFF_CMYKA)
    ADD_DEFINITIONS(-DTIFF_CMYKA_SUPPORT)
  ENDIF(WANT_TIFF_CMYKA)
ELSE(TIFF_FOUND)
  MESSAGE(FATAL_ERROR "Could not find the TIFF Library")
ENDIF(TIFF_FOUND)
FIND_PACKAGE(ZLIB REQUIRED)
IF (ZLIB_FOUND)
  MESSAGE("ZLIB Library Found OK")
  SET(HAVE_LIBZ 1)
ENDIF(ZLIB_FOUND)
FIND_PACKAGE(PythonLibs REQUIRED)
IF (PYTHON_LIBRARY)
  MESSAGE("Python Library Found OK")
  SET(HAVE_PYTHON 1)
  SET(COMPILE_PYTHON 1)
ENDIF(PYTHON_LIBRARY)

# START FREETYPE
IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 2.6)
  SET(FREETYPE_DIR ${CMAKE_MODULE_PATH})
  FIND_PACKAGE(FREETYPE REQUIRED)
  IF (FREETYPE_FOUND)
    MESSAGE("FreeType2 Library Found OK")
    INCLUDE(CheckLibraryExists)
    CHECK_LIBRARY_EXISTS(libfreetype.so FT_Get_First_Char "" HAVE_FREETYPE_FIRST)
    CHECK_LIBRARY_EXISTS(libfreetype.so FT_Get_Next_Char "" HAVE_FREETYPE_NEXT)
  ENDIF(FREETYPE_FOUND)
  SET(CFLAGS "${CFLAGS}"."${LIBFREETYPE_CFLAGS}")
ELSE(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 2.6)
  FIND_PACKAGE(Freetype REQUIRED)
  IF (FREETYPE_FOUND)
    MESSAGE(STATUS "FreeType2 Library Found OK")
    INCLUDE(CheckLibraryExists)
    CHECK_LIBRARY_EXISTS(libfreetype.so FT_Get_First_Char "" HAVE_FREETYPE_FIRST)
    CHECK_LIBRARY_EXISTS(libfreetype.so FT_Get_Next_Char "" HAVE_FREETYPE_NEXT)
  ELSE (FREETYPE_FOUND)
    MESSAGE(FATAL_ERROR "No Freetype Found")
  ENDIF(FREETYPE_FOUND)
ENDIF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 2.6)
# END FREETYPE

# If we have a RENDER_LIB selected from a previous cmake run, then use it
# otherwise, we should be defaulting to Libart_LGPL for 1.3.3.x
IF(RENDER_LIB)
  MESSAGE(STATUS "Previously selected rendering system: ${RENDER_LIB}")
ELSE(RENDER_LIB)
  IF (NOT WANT_CAIRO)
    SET(WANT_LIBART 1)
  ENDIF (NOT WANT_CAIRO)
ENDIF(RENDER_LIB)

# START LIBART_LGPL
IF (WANT_LIBART OR RENDER_LIB STREQUAL "LIBART")
  SET(LIBART_LGPL_DIR ${CMAKE_MODULE_PATH})
  FIND_PACKAGE(LIBART_LGPL REQUIRED)
  IF(LIBART_LGPL_FOUND)
    SET(RENDER_LIB "LIBART" CACHE TYPE STRING)
    MESSAGE("Libart_LGPL Library Found OK")
  ELSE(LIBART_LGPL_FOUND)
    SET(OLDRENDERLIBLOST TRUE)
  ENDIF(LIBART_LGPL_FOUND)
ELSE (WANT_LIBART OR RENDER_LIB STREQUAL "LIBART")
  # START CAIRO
  SET(CAIRO_DIR ${CMAKE_MODULE_PATH})
  FIND_PACKAGE(CAIRO)
  IF(CAIRO_FOUND)
    MESSAGE("CAIRO Library Found OK")
    SET(RENDER_LIB "CAIRO" CACHE TYPE STRING)
  ELSE(CAIRO_FOUND)
    SET(OLDRENDERLIBLOST TRUE)
  ENDIF(CAIRO_FOUND)
  # END CAIRO
ENDIF (WANT_LIBART OR RENDER_LIB STREQUAL "LIBART")
# END LIBART_LGPL

IF(NOT RENDER_LIB OR OLDRENDERLIBLOST)
  MESSAGE(FATAL_ERROR "ERROR: Neither LibArt_LGPL nor cairo have been selected or found, please correct and restart cmake")
ENDIF(NOT RENDER_LIB OR OLDRENDERLIBLOST)


# START CUPS
SET(CUPS_DIR ${CMAKE_MODULE_PATH})
FIND_PACKAGE(CUPS REQUIRED)
IF(CUPS_FOUND)
  SET(HAVE_CUPS 1)
  MESSAGE("CUPS Library Found OK")
ENDIF(CUPS_FOUND)
# END CUPS

# START LIBXML2
SET(LIBXML2_DIR ${CMAKE_MODULE_PATH})
FIND_PACKAGE(LIBXML2 REQUIRED)
IF(LIBXML2_FOUND)
  SET(HAVE_XML 1)
  MESSAGE("LIBXML2 Library Found OK")
ENDIF(LIBXML2_FOUND)
# END LIBXML2

# START LCMS
SET(LCMS_DIR ${CMAKE_MODULE_PATH})
FIND_PACKAGE(LCMS REQUIRED)
IF(LCMS_FOUND)
  SET(HAVE_CMS 1)
  SET(CMS_INC "lcms.h")
  MESSAGE("LittleCMS Library Found OK")
ELSE(LCMS_FOUND)
  MESSAGE(FATAL_ERROR "Could not find the LittleCMS Library")
ENDIF(LCMS_FOUND)
# END LCMS

# START FONTCONFIG
SET(FONTCONFIG_DIR ${CMAKE_MODULE_PATH})
FIND_PACKAGE(FONTCONFIG)
IF(FONTCONFIG_FOUND)
	MESSAGE("FontConfig Found OK")
	SET(HAVE_FONTCONFIG 1)
ENDIF(FONTCONFIG_FOUND)
# END FONTCONFIG

ADD_DEFINITIONS(${QT_DEFINITIONS})

CHECK_INCLUDE_FILE("dlfcn.h" HAVE_DLFCN_H)
IF(HAVE_DLFCN_H)
  ADD_DEFINITIONS(-DHAVE_DLFCN_H)
ENDIF(HAVE_DLFCN_H)

CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
IF(HAVE_UNISTD_H)
  ADD_DEFINITIONS(-DHAVE_UNISTD_H)
ENDIF(HAVE_UNISTD_H)

CHECK_INCLUDE_FILE("sys/types.h" HAVE_SYS_TYPES_H)
# IF(HAVE_SYS_TYPES_H)
#   ADD_DEFINITIONS(-DHAVE_SYS_TYPES_H)
# ENDIF(HAVE_SYS_TYPES_H)

CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H)
# IF(HAVE_SYS_STAT_H)
#   ADD_DEFINITIONS(-DHAVE_SYS_STAT_H)
# ENDIF(HAVE_SYS_STAT_H)


#Create configure files.. config.h and uninstall
#config.h
INCLUDE (ConfigureChecks.cmake)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
ADD_DEFINITIONS("-DHAVE_CONFIG_H")
#uninstall
CONFIGURE_FILE(
  "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
  "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  IMMEDIATE @ONLY)

ADD_CUSTOM_TARGET(uninstall
  "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")

#Load our SCRIBUSQT package which gives us filename.moc instead of moc_filename.*
SET(SCRIBUSQT_DIR ${CMAKE_MODULE_PATH})
FIND_PACKAGE(SCRIBUSQT)

#Set up include dirs with all found packages
INCLUDE_DIRECTORIES(
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/scribus
${QT_INCLUDE_DIR}
${QT_INCLUDE_PATH}
${CUPS_INCLUDE_DIR}
${FREETYPE_INCLUDE_DIR}
${FONTCONFIG_INCLUDE_DIR}
${LCMS_INCLUDE_DIR}
${LIBXML2_INCLUDE_DIR}
${PYTHON_INCLUDE_PATH}
${JPEG_INCLUDE_DIR}
${PNG_INCLUDE_DIR}
${TIFF_INCLUDE_DIR}
${ZLIB_INCLUDE_DIR}
${FREETYPE_INCLUDE_DIRS}
)

#Set up libraries to link with all found packages

#Select Libart_LGPL or Cairo
IF(RENDER_LIB STREQUAL "LIBART")
  INCLUDE_DIRECTORIES(${LIBART_LGPL_INCLUDE_DIR})
  LINK_LIBRARIES(${LIBART_LGPL_LIBRARIES})
ENDIF(RENDER_LIB STREQUAL "LIBART")
IF(RENDER_LIB STREQUAL "CAIRO")
  INCLUDE_DIRECTORIES(${CAIRO_INCLUDE_DIR})
  LINK_LIBRARIES(${CAIRO_LIBRARIES})
  LINK_DIRECTORIES(${PREFIX_CAIRO_LIB})
  SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${PREFIX_CAIRO_LIB}")
ENDIF(RENDER_LIB STREQUAL "CAIRO")

MESSAGE("RPATH: ${CMAKE_INSTALL_RPATH}")

LINK_LIBRARIES (
${QT_QT_LIBRARY}
${CUPS_LIBRARIES}
${FREETYPE_LIBRARIES}
${FONTCONFIG_LIBRARIES}
${LCMS_LIBRARIES}
${LIBXML2_LIBRARIES}
${PYTHON_LIBRARIES}
${TIFF_LIBRARIES}
${JPEG_LIBRARIES}
${ZLIB_LIBRARIES}
)

IF(WIN32)
  LINK_LIBRARIES(
    ${QT_QTMAIN_LIBRARY}
  )
ENDIF(WIN32)

IF(WIN32)
  ADD_DEFINITIONS(-DQT_DLL)
ENDIF(WIN32)

IF(APPLE)
  LINK_LIBRARIES( "-undefined dynamic_lookup" ) 
  LINK_LIBRARIES( "-framework CoreFoundation" ) 
ENDIF(APPLE)

#Add our source subdirs
ADD_SUBDIRECTORY(scribus)

#Install our READMEs etc.
INSTALL(FILES
AUTHORS
BUILDING
ChangeLog
ChangeLogSVN
COPYING
INSTALL
NEWS
PACKAGING
README
README.MacOSX
README.OS2
TODO

  DESTINATION ${DOCDIR}
)
INSTALL(FILES
scribus.xml
DESTINATION ${MIMEDIR}
)
#KDE workaround until it starts supporting freedesktop spec
INSTALL(FILES
  vnd.scribus.desktop
  DESTINATION ${MIMELNKDIR}
)
#Install the desktop file
#INSTALL(FILES
#scribus.desktop
#DESTINATION ${DESKTOPDIR}
#)

# If the cmake version includes cpack, use it
IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
  SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Scribus is an open source publishing application for Linux, Mac OSX and Windows")
  SET(CPACK_PACKAGE_VENDOR "Scribus Team")
  SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
  SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/README")
  SET(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}")
  SET(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
  SET(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}")
  SET(CPACK_PACKAGE_INSTALL_DIRECTORY "Scribus ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
  SET(CPACK_PACKAGE_EXECUTABLES "scribus${TAG_VERSION}")
  SET(CPACK_SOURCE_PACKAGE_FILE_NAME "scribus-${VERSION}")
  SET(CPACK_SOURCE_GENERATOR TBZ2)
## I'll make this prettier later - ignore any tarballs in the root
  SET(CPACK_SOURCE_IGNORE_FILES CMakeCache.txt scribus-1.3.3.12.tar.bz2 scribus-1.3.3.12.tar.Z scribus-1.3.3.12.tar.gz "~$" "\\\\.cvsignore$" "^${PROJECT_SOURCE_DIR}.*/CVS/" "^${PROJECT_SOURCE_DIR}/debian/" "^${PROJECT_SOURCE_DIR}/old/" "^${PROJECT_SOURCE_DIR}.*/CVSROOT/" "^${PROJECT_SOURCE_DIR}.*/autom4te.cache/")
  INCLUDE(CPack)
ENDIF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")