Subversion Repositories Scribus

Rev

Rev 21337 | Rev 21379 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
10215 cbradney 1
##############################################################################################################
2
########## CMake Setup                                                                              ##########
3
 
9680 cbradney 4
#Set our CMake minimum version
18447 craig 5
#Require 2.8.9 for Qt5
21377 craig 6
#Require 3.1.0 for Qt 5.7 C++ 11 easy support
20014 craig 7
#Require 3.2.0 for add_custom_target with byproducts
21377 craig 8
CMAKE_MINIMUM_REQUIRED(VERSION 3.2.0 FATAL_ERROR)
5758 cbradney 9
 
9680 cbradney 10
#Pretty colors
5142 cbradney 11
SET(CMAKE_COLOR_MAKEFILE ON)
20014 craig 12
#Don't force verbose
9715 avox 13
SET(CMAKE_VERBOSE_MAKEFILE OFF)
9680 cbradney 14
#Include current dir
5142 cbradney 15
SET(CMAKE_INCLUDE_CURRENT_DIR TRUE)
21013 craig 16
#Don't allow in source builds
21016 craig 17
#SET(CMAKE_DISABLE_SOURCE_CHANGES ON)
18
#SET(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
21013 craig 19
 
20
 
10459 cbradney 21
#RPATH setup - more below too
10327 cbradney 22
IF (WANT_NORPATH OR WANT_DISTROBUILD)
20014 craig 23
	SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
10327 cbradney 24
ELSE (WANT_NORPATH OR WANT_DISTROBUILD)
20014 craig 25
	SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
10327 cbradney 26
ENDIF (WANT_NORPATH OR WANT_DISTROBUILD)
10459 cbradney 27
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
9715 avox 28
SET(CMAKE_SKIP_RULE_DEPENDENCY TRUE)
8902 cbradney 29
SET(CMAKE_SKIP_BUILD_RPATH TRUE)
30
 
10215 cbradney 31
INCLUDE(CheckIncludeFile)
32
INCLUDE(CheckCCompilerFlag)
33
INCLUDE(CheckCXXCompilerFlag)
34
INCLUDE(CheckTypeSize)
35
INCLUDE(TestBigEndian)
20023 craig 36
INCLUDE(GNUInstallDirs)
21325 craig 37
#INCLUDE(FeatureSummary)
10215 cbradney 38
 
16856 craig 39
#ENABLE_TESTING()
40
 
9680 cbradney 41
#Set the custom CMake module directory where our include/lib finders are
5142 cbradney 42
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
9680 cbradney 43
 
10215 cbradney 44
##############################################################################################################
45
########## toplevel compiler flags                                                                  ##########
15099 cbradney 46
MESSAGE(STATUS "Shared Library Flags: ${CMAKE_SHARED_LIBRARY_C_FLAGS}")
10215 cbradney 47
 
9680 cbradney 48
#Project Setup
5142 cbradney 49
PROJECT(scribus)
9680 cbradney 50
#Set our version values
14911 cbradney 51
#Final version is ${VERSION} = ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_SUFFIX}
14373 cbradney 52
#where VERSION_SUFFIX is of the form "", "svn" or "Nsvn" (N being the minor patch level)
5396 cbradney 53
SET (VERSION_MAJOR "1")
13511 mrdocs 54
SET (VERSION_MINOR "5")
21334 craig 55
SET (VERSION_PATCH "3")
56
SET (VERSION_SUFFIX "svn")
14911 cbradney 57
SET (VERSION ${VERSION_MAJOR})
58
IF (VERSION_MINOR GREATER -1)
20014 craig 59
	SET (VERSION ${VERSION}.${VERSION_MINOR})
14911 cbradney 60
ENDIF (VERSION_MINOR GREATER -1)
61
IF (VERSION_PATCH GREATER -1)
20014 craig 62
	SET (VERSION ${VERSION}.${VERSION_PATCH})
14911 cbradney 63
ENDIF (VERSION_PATCH GREATER -1)
64
IF (VERSION_SUFFIX)
20014 craig 65
	SET (VERSION ${VERSION}.${VERSION_SUFFIX})
14911 cbradney 66
ENDIF (VERSION_SUFFIX)
20014 craig 67
MESSAGE(STATUS "Scribus ${VERSION} will be built and installed into ${CMAKE_INSTALL_PREFIX}")
5142 cbradney 68
 
9680 cbradney 69
#Set the permissions to be used when installing plugins
5142 cbradney 70
SET(PLUGIN_PERMISSIONS WORLD_EXECUTE GROUP_EXECUTE OWNER_EXECUTE WORLD_READ GROUP_READ OWNER_READ OWNER_WRITE)
71
 
9680 cbradney 72
#Our main directory is scribus
5379 cbradney 73
SET(MAIN_DIR_NAME "scribus")
9680 cbradney 74
 
10215 cbradney 75
##############################################################################################################
10238 cbradney 76
########## check for the CPU we build for                                                           ##########
77
 
78
EXECUTE_PROCESS(
20014 craig 79
	COMMAND ${CMAKE_C_COMPILER} -dumpmachine
80
	OUTPUT_VARIABLE MACHINE
81
	OUTPUT_STRIP_TRAILING_WHITESPACE
10238 cbradney 82
)
20014 craig 83
 
84
## Find out what machine/cpu we are running on
14373 cbradney 85
MESSAGE(STATUS  "Machine: ${MACHINE}, void pointer size: ${CMAKE_SIZEOF_VOID_P}")
19233 craig 86
STRING(REGEX MATCH "(i[0-9]86-*)|(athlon-*)|(pentium-*)" _machine_x86 "${MACHINE}")
10238 cbradney 87
IF (_machine_x86)
20014 craig 88
	MESSAGE(STATUS "Found target X86")
89
	SET(ARCH_X86 1)
10238 cbradney 90
ENDIF (_machine_x86)
91
 
92
STRING(REGEX MATCH "(x86_64-*)|(X86_64-*)|(AMD64-*)|(amd64-*)" _machine_x86_64 "${MACHINE}")
93
IF (_machine_x86_64)
19233 craig 94
	MESSAGE(STATUS "Found target X86_64")
95
	SET(ARCH_X86_64 1)
10238 cbradney 96
ENDIF (_machine_x86_64)
97
 
20014 craig 98
STRING(REGEX MATCH "(sparc64-*)|(SPARC64-*)" _machine_sparc_64 "${MACHINE}")
99
IF (_machine_sparc_64)
100
	MESSAGE(STATUS "Found target SPARC 64")
101
	SET(ARCH_SPARC_64 1)
102
ENDIF (_machine_sparc_64)
103
 
104
STRING(REGEX MATCH "(mips64-*)|(MIPS64-*)" _machine_mips_64 "${MACHINE}")
105
IF (_machine_mips_64)
106
	MESSAGE(STATUS "Found target MIPS 64")
107
	SET(ARCH_MIPS_64 1)
108
ENDIF (_machine_mips_64)
109
 
110
STRING(REGEX MATCH "(ppc-*)|(powerpc-*)" _machine_ppc "${MACHINE}")
111
IF (_machine_ppc)
112
	MESSAGE(STATUS "Found target PPC")
113
	SET(ARCH_PPC 1)
114
ENDIF (_machine_ppc)
115
 
116
STRING(REGEX MATCH "(ppc64-*)|(PPC64-*)|(powerpc64-*)" _machine_ppc_64 "${MACHINE}")
117
IF (_machine_ppc_64)
118
	MESSAGE(STATUS "Found target PPC64")
119
	SET(ARCH_PPC_64 1)
120
ENDIF (_machine_ppc_64)
121
 
122
STRING(REGEX MATCH "(sparc-*)" _machine_sparc "${MACHINE}")
123
IF (_machine_sparc)
124
	MESSAGE(STATUS "Found target Sparc")
125
	SET(ARCH_SPARC 1)
126
ENDIF (_machine_sparc)
127
 
128
STRING(REGEX MATCH "(sparcv9-*)" _machine_sparcv9 "${MACHINE}")
129
IF (_machine_sparcv9)
130
	MESSAGE(STATUS "Found target Sparc v9")
131
	SET(ARCH_SPARCV9 1)
132
ENDIF (_machine_sparcv9)
133
 
134
STRING(REGEX MATCH "(sparc64-*)" _machine_sparc64 "${MACHINE}")
135
IF (_machine_sparc64)
136
	MESSAGE(STATUS "Found target Sparc64")
137
	SET(ARCH_SPARC64 1)
138
	SET(ARCH64BIT 1)
139
ENDIF (_machine_sparc64)
140
 
20469 craig 141
STRING(REGEX MATCH "(hppa*)" _machine_hppa "${MACHINE}")
142
IF (_machine_hppa)
143
	MESSAGE(STATUS "Found target Hppa")
144
	SET(ARCH_HPPA 1)
145
ENDIF (_machine_hppa)
146
 
147
# We need to pass -fPIC to lib2geom on amd64, mips, mipsel, and hppa. See:
148
# http://www.gentoo.org/proj/en/base/amd64/howtos/index.xml?part=1&chap=3 and
149
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=559133
150
 
151
IF (ARCH_X86_64 EQUAL 1 OR ARCH_HPPA EQUAL 1 OR ARCH_MIPS EQUAL 1 OR ARCH_MIPS_64 EQUAL 1 OR ARCH_PPC_64 EQUAL 1)
152
	SET(CMAKE_CXX_FLAGS_FPIC "-fPIC")
153
ENDIF (ARCH_X86_64 EQUAL 1 OR ARCH_HPPA EQUAL 1 OR ARCH_MIPS EQUAL 1 OR ARCH_MIPS_64 EQUAL 1 OR ARCH_PPC_64 EQUAL 1)
154
 
20014 craig 155
## Do our Apple OSX version setup
19233 craig 156
IF (APPLE AND CMAKE_SIZEOF_VOID_P EQUAL 8 AND (ARCH_X86 EQUAL 1 OR ARCH_X86_64 EQUAL 1))
157
	STRING(REGEX REPLACE ".*-darwin([0-9]+).*" "\\1" _apple_ver "${MACHINE}")
20460 craig 158
	IF (_apple_ver EQUAL "15")
159
		MESSAGE(STATUS "Found OSX El Capitan Target: Apple, 64 bit, X86")
160
		SET(APPLE_10_11_X 1 CACHE TYPE BOOL)
161
	ENDIF (_apple_ver EQUAL "15")
19233 craig 162
	IF (_apple_ver EQUAL "14")
163
		MESSAGE(STATUS "Found OSX Yosemite Target: Apple, 64 bit, X86")
164
		SET(APPLE_10_10_X 1 CACHE TYPE BOOL)
165
	ENDIF (_apple_ver EQUAL "14")
166
	IF (_apple_ver EQUAL "13")
167
		MESSAGE(STATUS "Found OSX Mavericks Target: Apple, 64 bit, X86")
168
		SET(APPLE_10_9_X 1 CACHE TYPE BOOL)
169
	ENDIF (_apple_ver EQUAL "13")
170
	IF (_apple_ver EQUAL "12")
171
		MESSAGE(STATUS "Found OSX Mountain Lion Target: Apple, 64 bit, X86")
172
		SET(APPLE_10_8_X 1 CACHE TYPE BOOL)
173
	ENDIF (_apple_ver EQUAL "12")
174
	IF (_apple_ver EQUAL "11")
175
		MESSAGE(STATUS "Found OSX Lion Target: Apple, 64 bit, X86")
176
		SET(APPLE_10_7_X 1 CACHE TYPE BOOL)
177
	ENDIF (_apple_ver EQUAL "11")
178
	IF (_apple_ver EQUAL "10")
179
		MESSAGE(STATUS "Found OSX Snow Leopard Target: Apple, 64 bit, X86")
180
		SET(APPLE_10_6_X 1 CACHE TYPE BOOL)
181
	ENDIF (_apple_ver EQUAL "10")
182
	IF (_apple_ver EQUAL "9")
19353 craig 183
		MESSAGE(STATUS "Found OSX Leopard Target: Apple, 32 bit, X86")
19242 craig 184
		SET(APPLE_10_5_X 1 CACHE TYPE BOOL)
19233 craig 185
	ENDIF (_apple_ver EQUAL "9")
186
	UNSET(ARCH_X86)
187
ENDIF (APPLE AND CMAKE_SIZEOF_VOID_P EQUAL 8 AND (ARCH_X86 EQUAL 1 OR ARCH_X86_64 EQUAL 1))
188
 
189
 
11407 cbradney 190
#convert any 64 bit build into generic 64 tag for below
19222 fschmid 191
IF (ARCH_X86_64 OR ARCH_SPARC_64 OR ARCH_MIPS_64 OR ARCH_PPC_64)
20014 craig 192
	SET(ARCH64BIT 1)
19222 fschmid 193
ENDIF (ARCH_X86_64 OR ARCH_SPARC_64 OR ARCH_MIPS_64 OR ARCH_PPC_64)
11407 cbradney 194
 
195
MESSAGE(STATUS "Building for target ${MACHINE}")
196
 
10238 cbradney 197
##############################################################################################################
10215 cbradney 198
########## Versioning Setup                                                                         ##########
199
 
9409 cbradney 200
#On Apple, we ignore the versioning tag so all items are "scribus" not "scribus-version"
9508 cbradney 201
IF (NOT BUILD_OSX_BUNDLE)
20014 craig 202
	SET(BUILD_OSX_BUNDLE ${APPLE} CACHE TYPE BOOL)
9508 cbradney 203
ENDIF (NOT BUILD_OSX_BUNDLE)
204
 
9680 cbradney 205
#Simplify future conditionals for Apple
206
IF (APPLE AND BUILD_OSX_BUNDLE)
20014 craig 207
	SET(APPLEBUNDLE TRUE CACHE TYPE BOOL)
9680 cbradney 208
ENDIF (APPLE AND BUILD_OSX_BUNDLE)
209
 
210
#Announce we cached a version request before, overridden below for OSX
9508 cbradney 211
IF(TAG_VERSION)
20014 craig 212
	IF (NOT APPLEBUNDLE)
213
		MESSAGE(STATUS "Previously selected version tag: ${TAG_VERSION}")
214
	ENDIF (NOT APPLEBUNDLE)
215
	SET(WANT_VERSIONING 1)
216
	SET(CACHED_VERSIONING 1)
9508 cbradney 217
ENDIF(TAG_VERSION)
218
 
9680 cbradney 219
#Remove version tags on OSX so our bundle is Scribus.app
18766 craig 220
IF (APPLEBUNDLE OR WIN32)
221
	IF (WANT_VERSIONING OR CACHED_VERSIONING)
222
		MESSAGE(STATUS "Ignoring version tag on Win32 or OSX when building bundle")
223
		SET(WANT_VERSIONING 0)
224
		SET(CACHED_VERSIONING 0)
225
	ENDIF (WANT_VERSIONING OR CACHED_VERSIONING)
18770 jghali 226
ENDIF (APPLEBUNDLE OR WIN32)
9508 cbradney 227
 
20014 craig 228
#Store our version string if required
6891 cbradney 229
IF (WANT_VERSIONING AND NOT CACHED_VERSIONING)
20014 craig 230
	IF (NOT CUSTOM_VERSIONTAG)
231
		SET(TAG_VERSION "-${VERSION}" CACHE TYPE STRING)
232
	ELSE (NOT CUSTOM_VERSIONTAG)
233
		SET(TAG_VERSION ${CUSTOM_VERSIONTAG} CACHE TYPE STRING)
234
	ENDIF (NOT CUSTOM_VERSIONTAG)
6891 cbradney 235
ENDIF (WANT_VERSIONING AND NOT CACHED_VERSIONING)
5379 cbradney 236
 
10215 cbradney 237
##############################################################################################################
238
########## Install/Directory Setup                                                                  ##########
239
 
12457 avox 240
IF (APPLEBUNDLE)
19631 craig 241
SET (APPLE_APP_DIR "${CMAKE_INSTALL_PREFIX}")
20014 craig 242
	IF ("${CMAKE_INSTALL_PREFIX}" MATCHES "[.]app/Contents/?$")
243
		# all ok
244
	ELSE ("${CMAKE_INSTALL_PREFIX}" MATCHES "[.]app/Contents/?$")
245
		IF ("${CMAKE_INSTALL_PREFIX}" MATCHES "[.]app/?$")
246
			# add "/Contents" subpath
247
			SET(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/Contents")
248
		ELSE ("${CMAKE_INSTALL_PREFIX}" MATCHES "[.]app/?$")
249
			# no bundle name spcified, use appname and version
250
			SET(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/Scribus${VERSION}.app/Contents")
251
		ENDIF ("${CMAKE_INSTALL_PREFIX}" MATCHES "[.]app/?$")
252
	ENDIF ("${CMAKE_INSTALL_PREFIX}" MATCHES "[.]app/Contents/?$")
253
	MESSAGE(STATUS "APPLEBUNDLE install prefix: ${APPLE_APP_DIR}")
12457 avox 254
ENDIF (APPLEBUNDLE)
255
 
256
 
19353 craig 257
#Setup all the directories we will use
13271 fschmid 258
CMAKE_POLICY(SET CMP0005 OLD)
20023 craig 259
#SHARE
16347 malex 260
IF(WANT_VERSIONING)
20023 craig 261
	SET(SHAREDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}${TAG_VERSION}/")
16345 malex 262
ELSE(WANT_VERSIONING)
20023 craig 263
	SET(SHAREDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}/")
16345 malex 264
ENDIF(WANT_VERSIONING)
20023 craig 265
IF(NOT IS_ABSOLUTE ${SHAREDIR})
266
	ADD_DEFINITIONS("-DSHAREDIR=\\\"${CMAKE_INSTALL_PREFIX}/${SHAREDIR}\\\"")
267
ELSE()
268
	ADD_DEFINITIONS("-DSHAREDIR=\\\"${SHAREDIR}\\\"")
269
ENDIF()
9680 cbradney 270
 
9409 cbradney 271
#SHARE - use the default on Apple as TAG_VERSION is empty
14949 jghali 272
IF(WIN32 OR OS2)
20023 craig 273
	SET(DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/")
14949 jghali 274
ELSE (WIN32 OR OS2)
20014 craig 275
	IF(TAG_VERSION OR BUILD_OSX_BUNDLE)
20023 craig 276
		SET(DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${MAIN_DIR_NAME}${TAG_VERSION}/")
20014 craig 277
	ELSE(TAG_VERSION OR BUILD_OSX_BUNDLE)
278
		IF(NOT WANT_VERSIONING)
20023 craig 279
			SET(DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${MAIN_DIR_NAME}/")
20014 craig 280
		ELSE(NOT WANT_VERSIONING)
20023 craig 281
			SET(DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${MAIN_DIR_NAME}-${VERSION}/")
20014 craig 282
		ENDIF(NOT WANT_VERSIONING)
283
	ENDIF (TAG_VERSION OR BUILD_OSX_BUNDLE)
14949 jghali 284
ENDIF (WIN32 OR OS2)
20023 craig 285
IF(NOT IS_ABSOLUTE ${DOCDIR})
286
	ADD_DEFINITIONS("-DDOCDIR=\\\"${CMAKE_INSTALL_PREFIX}/${DOCDIR}\\\"")
287
ELSE()
288
	ADD_DEFINITIONS("-DDOCDIR=\\\"${DOCDIR}\\\"")
289
ENDIF()
9680 cbradney 290
 
18763 craig 291
#ICONS
10779 craig 292
IF(WIN32)
20023 craig 293
	SET(ICONDIR "${CMAKE_INSTALL_DATAROOTDIR}/icons/")
10779 craig 294
ELSE(WIN32)
20023 craig 295
	SET(ICONDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}${TAG_VERSION}/icons/")
10779 craig 296
ENDIF(WIN32)
20023 craig 297
IF(NOT IS_ABSOLUTE ${ICONDIR})
298
	ADD_DEFINITIONS("-DICONDIR=\\\"${CMAKE_INSTALL_PREFIX}/${ICONDIR}\\\"")
299
ELSE()
300
	ADD_DEFINITIONS("-DICONDIR=\\\"${ICONDIR}\\\"")
301
ENDIF()
9680 cbradney 302
 
7269 cbradney 303
#SAMPLES
20023 craig 304
SET(SAMPLESDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}${TAG_VERSION}/samples/")
305
IF(NOT IS_ABSOLUTE ${SAMPLESDIR})
306
	ADD_DEFINITIONS("-DSAMPLESDIR=\\\"${CMAKE_INSTALL_PREFIX}/${SAMPLESDIR}\\\"")
307
ELSE()
308
	ADD_DEFINITIONS("-DSAMPLESDIR=\\\"${SAMPLESDIR}\\\"")
309
ENDIF()
9680 cbradney 310
 
7269 cbradney 311
#SCRIPTS
20023 craig 312
SET(SCRIPTSDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}${TAG_VERSION}/scripts/")
313
IF(NOT IS_ABSOLUTE ${SCRIPTSDIR})
314
	ADD_DEFINITIONS("-DSCRIPTSDIR=\\\"${CMAKE_INSTALL_PREFIX}/${SCRIPTSDIR}\\\"")
315
ELSE()
316
	ADD_DEFINITIONS("-DSCRIPTSDIR=\\\"${SCRIPTSDIR}\\\"")
317
ENDIF()
9680 cbradney 318
 
7269 cbradney 319
#TEMPLATES
10779 craig 320
IF(WIN32)
20023 craig 321
	SET(TEMPLATEDIR "${CMAKE_INSTALL_DATAROOTDIR}/templates/")
10779 craig 322
ELSE(WIN32)
20023 craig 323
	SET(TEMPLATEDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}${TAG_VERSION}/templates/")
10779 craig 324
ENDIF(WIN32)
20023 craig 325
IF(NOT IS_ABSOLUTE ${TEMPLATEDIR})
326
	ADD_DEFINITIONS("-DTEMPLATEDIR=\\\"${CMAKE_INSTALL_PREFIX}/${TEMPLATEDIR}\\\"")
327
ELSE()
328
	ADD_DEFINITIONS("-DTEMPLATEDIR=\\\"${TEMPLATEDIR}\\\"")
329
ENDIF()
9680 cbradney 330
 
18763 craig 331
#QML
18764 jghali 332
IF(WIN32)
20023 craig 333
	SET(QMLDIR "${CMAKE_INSTALL_DATAROOTDIR}/qml/")
18764 jghali 334
ELSE(WIN32)
20023 craig 335
	SET(QMLDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}${TAG_VERSION}/qml/")
18764 jghali 336
ENDIF(WIN32)
18763 craig 337
ADD_DEFINITIONS("-DQMLDIR=\\\"${CMAKE_INSTALL_PREFIX}/${QMLDIR}\\\"")
338
 
9660 cbradney 339
#DESKTOP
20023 craig 340
SET(DESKTOPDIR "${CMAKE_INSTALL_DATAROOTDIR}/applications/")
341
IF(NOT IS_ABSOLUTE ${DESKTOPDIR})
342
	ADD_DEFINITIONS("-DDESKTOPDIR=\\\"${CMAKE_INSTALL_PREFIX}/${DESKTOPDIR}\\\"")
343
ELSE()
344
	ADD_DEFINITIONS("-DDESKTOPDIR=\\\"${DESKTOPDIR}\\\"")
345
ENDIF()
9680 cbradney 346
 
21230 mrdocs 347
#APPDATA
348
SET(APPDATADIR "${CMAKE_INSTALL_DATAROOTDIR}/appdata/")
349
IF(NOT IS_ABSOLUTE ${APPDATADIRR})
350
    ADD_DEFINITIONS("-DAPPDATADIR=\\\"${CMAKE_INSTALL_PREFIX}/${APPDATADIR}\\\"")
351
ELSE()
352
    ADD_DEFINITIONS("-DAPPDATADIR=\\\"${APPDATADIR}\\\"")
353
ENDIF()
354
 
355
 
13066 subik 356
# APPLICATION_DATA_DIR
357
# It allows specify the user configuration directory in the compile time.
358
# Example: I want to use special ~/.scribus135svn config directory for my trunk
359
#          cmake -DAPPLICATION_DATA_DIR=.scribus135svn ...
360
IF (APPLICATION_DATA_DIR)
13171 cbradney 361
	MESSAGE(STATUS "Using ApplicationDataDir ${APPLICATION_DATA_DIR} instead of the platform default.")
20014 craig 362
	ADD_DEFINITIONS("-DAPPLICATION_DATA_DIR=\\\"${APPLICATION_DATA_DIR}\\\"")
13066 subik 363
ELSE (APPLICATION_DATA_DIR)
20014 craig 364
	MESSAGE(STATUS "Using standard ApplicationDataDir. You can change it with -DAPPLICATION_DATA_DIR")
13066 subik 365
ENDIF (APPLICATION_DATA_DIR)
366
 
10161 cbradney 367
#LIB LOCATION - lib or lib64 normally
7269 cbradney 368
#LIB
10161 cbradney 369
IF(WANT_LIB64)
19631 craig 370
	IF(NOT ARCH_X86_64)
371
		MESSAGE(STATUS "WARNING: BUILDING 64 Bit build on non 64 bit architecture")
372
	ENDIF(NOT ARCH_X86_64)
373
	 SET(LIB_SUFFIX "64" CACHE TYPE STRING)
10161 cbradney 374
ENDIF(WANT_LIB64)
10239 cbradney 375
SET(LIB_DIR_NAME "lib${LIB_SUFFIX}")
19631 craig 376
IF (APPLEBUNDLE)
19676 craig 377
	SET(LIBDIR "lib/")
19631 craig 378
ELSE (APPLEBUNDLE)
379
	SET(LIBDIR "${LIB_DIR_NAME}/${MAIN_DIR_NAME}${TAG_VERSION}/")
380
ENDIF (APPLEBUNDLE)
5142 cbradney 381
ADD_DEFINITIONS("-DLIBDIR=\\\"${CMAKE_INSTALL_PREFIX}/${LIBDIR}\\\"")
9680 cbradney 382
 
18763 craig 383
#C++11 Support
384
IF(WANT_CPP11)
385
	MESSAGE(STATUS "Enabling C++11 compiler features")
21377 craig 386
	set(CMAKE_CXX_STANDARD 11)
18763 craig 387
	ADD_DEFINITIONS("-std=c++11")
388
ENDIF(WANT_CPP11)
389
 
7269 cbradney 390
#PLUGINS
10779 craig 391
IF(WIN32)
19631 craig 392
	SET(PLUGINDIR "plugins")
10781 craig 393
ELSE(WIN32)
19631 craig 394
	IF (APPLEBUNDLE)
395
		SET(PLUGINDIR "${LIBDIR}")
396
	ELSE (APPLEBUNDLE)
397
		SET(PLUGINDIR "${LIB_DIR_NAME}/${MAIN_DIR_NAME}${TAG_VERSION}/plugins/")
398
	ENDIF (APPLEBUNDLE)
10779 craig 399
ENDIF(WIN32)
5142 cbradney 400
ADD_DEFINITIONS("-DPLUGINDIR=\\\"${CMAKE_INSTALL_PREFIX}/${PLUGINDIR}\\\"")
9680 cbradney 401
 
18763 craig 402
 
9660 cbradney 403
#INCLUDE
404
SET(INCLUDEDIR "include/${MAIN_DIR_NAME}${TAG_VERSION}/")
405
#NO ADD DEFINITIONS, WE ONLY INSTALL WITH IT
9680 cbradney 406
 
7269 cbradney 407
#RPATH
10459 cbradney 408
IF (WANT_NORPATH OR WANT_DISTROBUILD)
20014 craig 409
	set(CMAKE_INSTALL_RPATH "")
10459 cbradney 410
ELSE (WANT_NORPATH OR WANT_DISTROBUILD)
20014 craig 411
	set(CMAKE_INSTALL_RPATH ${PLUGINDIR})
10459 cbradney 412
ENDIF (WANT_NORPATH OR WANT_DISTROBUILD)
5142 cbradney 413
 
6319 mrdocs 414
# Set the XDG mime stuff
20023 craig 415
SET(MIMEDIR "${CMAKE_INSTALL_DATAROOTDIR}/mime/packages/")
416
SET(MIMELNKDIR "${CMAKE_INSTALL_DATAROOTDIR}/mimelnk/application/")
6319 mrdocs 417
 
10215 cbradney 418
##############################################################################################################
419
########## Build Setup                                                                              ##########
6319 mrdocs 420
 
9680 cbradney 421
#Convert our simpler command line option to the CMake style
5142 cbradney 422
#None, Debug, Release, .. or custom ones
7943 cbradney 423
# SET(WANT_DEBUG 1)
5142 cbradney 424
IF(WANT_DEBUG)
20014 craig 425
	SET(CMAKE_BUILD_TYPE Debug)
13238 cbradney 426
ENDIF(WANT_DEBUG)
427
IF (WANT_RELEASEWITHDEBUG)
20014 craig 428
	SET(CMAKE_BUILD_TYPE RelWithDebInfo)
13238 cbradney 429
ENDIF (WANT_RELEASEWITHDEBUG)
430
IF(NOT WANT_DEBUG AND NOT WANT_RELEASEWITHDEBUG)
20014 craig 431
	SET(CMAKE_BUILD_TYPE RELEASE)
13238 cbradney 432
ENDIF(NOT WANT_DEBUG AND NOT WANT_RELEASEWITHDEBUG)
5142 cbradney 433
 
13238 cbradney 434
 
435
 
9680 cbradney 436
#Based on our build type, setup our build options
5468 avox 437
IF(APPLE)
20460 craig 438
	IF(APPLE_10_11_X)
439
		SET(OSXMINVER "10.11" CACHE TYPE STRING)
440
		IF (WANT_OSX_SDK)
441
			SET(CMAKE_OSX_SYSROOT "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk")
442
		ENDIF (WANT_OSX_SDK)
443
	ENDIF(APPLE_10_11_X)
19229 craig 444
	IF(APPLE_10_10_X)
445
		SET(OSXMINVER "10.10" CACHE TYPE STRING)
20681 craig 446
		SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.10")
19260 craig 447
		IF (WANT_OSX_SDK)
20681 craig 448
			IF(EXISTS("/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk"))
449
				SET(CMAKE_OSX_SYSROOT "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk")
450
			ELSEIF(EXISTS("/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk"))
451
				SET(CMAKE_OSX_SYSROOT "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk")
452
			ENDIF()
19260 craig 453
		ENDIF (WANT_OSX_SDK)
19229 craig 454
	ENDIF(APPLE_10_10_X)
455
	IF(APPLE_10_9_X)
456
		SET(OSXMINVER "10.9" CACHE TYPE STRING)
19260 craig 457
		IF (WANT_OSX_SDK)
458
			SET(CMAKE_OSX_SYSROOT "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk")
459
		ENDIF (WANT_OSX_SDK)
19229 craig 460
	ENDIF(APPLE_10_9_X)
461
	IF(APPLE_10_8_X)
462
		SET(OSXMINVER "10.8" CACHE TYPE STRING)
19260 craig 463
		IF (WANT_OSX_SDK)
464
			SET(CMAKE_OSX_SYSROOT "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk")
465
		ENDIF (WANT_OSX_SDK)
19229 craig 466
	ENDIF(APPLE_10_8_X)
467
	IF(APPLE_10_7_X)
468
		SET(OSXMINVER "10.7" CACHE TYPE STRING)
19260 craig 469
		IF (WANT_OSX_SDK)
470
			SET(CMAKE_OSX_SYSROOT "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk")
471
		ENDIF (WANT_OSX_SDK)
19229 craig 472
	ENDIF(APPLE_10_7_X)
473
	IF(APPLE_10_6_X)
474
		SET(OSXMINVER "10.6" CACHE TYPE STRING)
19260 craig 475
		IF (WANT_OSX_SDK)
476
			SET(CMAKE_OSX_SYSROOT "/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk")
477
		ENDIF (WANT_OSX_SDK)
19229 craig 478
	ENDIF(APPLE_10_6_X)
479
	IF(APPLE_10_5_X)
480
		SET(OSXMINVER "10.5" CACHE TYPE STRING)
19260 craig 481
		IF (WANT_OSX_SDK)
482
			SET(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.5.sdk")
483
		ENDIF (WANT_OSX_SDK)
19229 craig 484
	ENDIF(APPLE_10_5_X)
485
	IF(APPLE_10_4_X)
486
		SET(OSXMINVER "10.4" CACHE TYPE STRING)
19260 craig 487
		IF (WANT_OSX_SDK)
488
			SET(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk")
489
		ENDIF (WANT_OSX_SDK)
19229 craig 490
	ENDIF(APPLE_10_4_X)
19233 craig 491
	# gcc/mac
492
	IF(WANT_UNIVERSAL_BUNDLE)
493
		MESSAGE("Setting Universal (PPC/i386) Architecture for OSX Build/Bundle")
494
		SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" )
495
		SET(CMAKE_TRY_COMPILE_OSX_ARCHITECTURES "ppc;i386" )
19260 craig 496
		IF (WANT_OSX_SDK)
497
			SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.4")
498
		ENDIF (WANT_OSX_SDK)
19233 craig 499
	ELSE(WANT_UNIVERSAL_BUNDLE)
500
		IF(ARCH_PPC OR ARCH_PPC_64)
501
			MESSAGE("Setting PPC Architecture for OSX Build/Bundle")
502
			SET(CMAKE_OSX_ARCHITECTURES "ppc" )
503
			SET(CMAKE_TRY_COMPILE_OSX_ARCHITECTURES "ppc" )
504
		ELSE(ARCH_PPC OR ARCH_PPC_64)
19260 craig 505
			IF (WANT_OSX_SDK)
506
				SET(CMAKE_OSX_DEPLOYMENT_TARGET "${OSXMINVER}")
507
			ENDIF (WANT_OSX_SDK)
20460 craig 508
			IF(APPLE_10_6_X OR APPLE_10_7_X OR APPLE_10_8_X OR APPLE_10_9_X OR APPLE_10_10_X OR APPLE_10_11_X)
19233 craig 509
				MESSAGE("Setting x86_64 Architecture for OSX Build/Bundle")
510
				SET(CMAKE_OSX_ARCHITECTURES "x86_64" )
511
				SET(CMAKE_TRY_COMPILE_OSX_ARCHITECTURES "x86_64" )
20460 craig 512
			ELSE(APPLE_10_6_X OR APPLE_10_7_X OR APPLE_10_8_X OR APPLE_10_9_X OR APPLE_10_10_X OR APPLE_10_11_X)
19233 craig 513
				MESSAGE("Setting i386 Architecture for OSX Build/Bundle")
514
				SET(CMAKE_OSX_ARCHITECTURES "i386" )
515
				SET(CMAKE_TRY_COMPILE_OSX_ARCHITECTURES "i386" )
20460 craig 516
			ENDIF(APPLE_10_6_X OR APPLE_10_7_X OR APPLE_10_8_X OR APPLE_10_9_X OR APPLE_10_10_X OR APPLE_10_11_X)
19233 craig 517
		ENDIF(ARCH_PPC OR ARCH_PPC_64)
518
	ENDIF(WANT_UNIVERSAL_BUNDLE)
519
	MESSAGE(STATUS "${CMAKE_OSX_ARCHITECTURES} ${CMAKE_OSX_SYSROOT}")
520
	SET(ENV{MACOSX_DEPLOYMENT_TARGET} ${OSXMINVER} )
521
	SET(ENV{LD_PREBIND} 1 )
522
	SET(ENV{LD_PREBIND_ALLOW_OVERLAP} 1 )
523
	IF (WANT_DEBUG)
21377 craig 524
	    SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -fno-inline-functions -Wall -mmacosx-version-min=${OSXMINVER}")
20103 avox 525
		SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -fno-inline-functions -Wall -mmacosx-version-min=${OSXMINVER}")
19233 craig 526
	ENDIF (WANT_DEBUG)
527
	IF (WANT_RELEASEWITHDEBUG)
21377 craig 528
	    SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -fno-inline-functions -Wall -mmacosx-version-min=${OSXMINVER}")
20103 avox 529
		SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -fno-inline-functions -Wall -mmacosx-version-min=${OSXMINVER}")
19233 craig 530
	ENDIF (WANT_RELEASEWITHDEBUG)
531
	IF (NOT WANT_DEBUG AND NOT WANT_RELEASEWITHDEBUG)
21377 craig 532
	    SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -fno-inline-functions -Wall -mmacosx-version-min=${OSXMINVER}")
19233 craig 533
		SET(CMAKE_C_FLAGS_RELEASE "-O2 -fno-inline-functions -Wall -mmacosx-version-min=${OSXMINVER}")
534
	ENDIF (NOT WANT_DEBUG AND NOT WANT_RELEASEWITHDEBUG)
5468 avox 535
ELSE(APPLE)
19233 craig 536
	IF(${CMAKE_GENERATOR} MATCHES "^(Visual Studio|NMake).*")
537
		# Windows build with Visual Studio
538
		# Surely there's a better way to identify the compiler?
539
		SET(CMAKE_CXX_FLAGS_DEBUG)
540
		SET(CMAKE_C_FLAGS_DEBUG)
541
	ELSE(${CMAKE_GENERATOR} MATCHES "^(Visual Studio|NMake).*")
542
		# vanilla gcc
20103 avox 543
		SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -Wall -fstrict-aliasing")
544
		SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -Wall -fstrict-aliasing")
19233 craig 545
		IF (_machine_x86 OR _machine_x86_64)
546
			SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fPIC")
547
			SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fPIC")
548
		ENDIF (_machine_x86 OR _machine_x86_64)
549
	ENDIF(${CMAKE_GENERATOR} MATCHES "^(Visual Studio|NMake).*")
5468 avox 550
ENDIF(APPLE)
9680 cbradney 551
 
10750 craig 552
IF(${CMAKE_GENERATOR} MATCHES "^(Visual Studio|NMake).*")
19233 craig 553
	SET(CMAKE_CXX_FLAGS_RELEASE)
554
	SET(CMAKE_C_FLAGS_RELEASE)
10750 craig 555
ELSE(${CMAKE_GENERATOR} MATCHES "^(Visual Studio|NMake).*")
21377 craig 556
    SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -Wall -fPIC")
19233 craig 557
	SET(CMAKE_C_FLAGS_RELEASE "-O2 -Wall -fPIC")
20103 avox 558
#	ADD_DEFINITIONS(-DNDEBUG)
10750 craig 559
ENDIF(${CMAKE_GENERATOR} MATCHES "^(Visual Studio|NMake).*")
5142 cbradney 560
 
10750 craig 561
IF(WIN32)
20014 craig 562
	ADD_DEFINITIONS(-DWIN32_LEAN_AND_MEAN
563
					-DAVOID_WIN32_FILEIO
564
					-D_CRT_SECURE_NO_DEPRECATE
565
					-D_USE_MATH_DEFINES
566
					-DCOMPILE_PLUGIN_AS_DLL
567
					)
568
	SET(BUILD_WINDOWS_VERSION 1)
569
	SET(DLL_USE_NATIVE_API 1)
10750 craig 570
ENDIF(WIN32)
571
 
10215 cbradney 572
##############################################################################################################
573
########## Find Dependencies                                                                        ##########
5466 cbradney 574
 
9680 cbradney 575
#<< Qt
21180 jghali 576
SET (QT_MIN_VERSION "5.3.0")
20014 craig 577
SET(CMAKE_PREFIX_PATH "${QT_PREFIX}/lib/cmake")
578
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
579
FIND_PACKAGE(Qt5Core REQUIRED)
580
IF(Qt5Core_FOUND)
21377 craig 581
    MESSAGE(STATUS "----- USE QT 5-----")
20014 craig 582
ELSE(Qt5Core_FOUND)
21377 craig 583
    MESSAGE(FATAL_ERROR "ERROR: No QT 5 found")
20014 craig 584
ENDIF(Qt5Core_FOUND)
585
FIND_PACKAGE(Qt5Widgets REQUIRED)
586
IF(Qt5Widgets_FOUND)
21377 craig 587
    MESSAGE(STATUS "----- USE QT Widgets-----")
20014 craig 588
ELSE(Qt5Widgets_FOUND)
21377 craig 589
    MESSAGE(FATAL_ERROR "ERROR: No QT Widgets found")
20014 craig 590
ENDIF(Qt5Widgets_FOUND)
591
FIND_PACKAGE(Qt5Gui REQUIRED)
592
IF(Qt5Gui_FOUND)
21377 craig 593
    MESSAGE(STATUS "----- USE Qt5Gui -----")
20014 craig 594
ELSE(Qt5Gui_FOUND)
21377 craig 595
    MESSAGE(FATAL_ERROR "ERROR: Qt5Gui found")
20014 craig 596
ENDIF(Qt5Gui_FOUND)
597
FIND_PACKAGE(Qt5Xml REQUIRED)
598
IF(Qt5Xml_FOUND)
21377 craig 599
    MESSAGE(STATUS "----- USE QT 5 XML -----")
20014 craig 600
ELSE(Qt5Xml_FOUND)
21377 craig 601
    MESSAGE(FATAL_ERROR "ERROR: No QT 5 XML found")
20014 craig 602
ENDIF(Qt5Xml_FOUND)
603
FIND_PACKAGE(Qt5Network REQUIRED)
604
IF(Qt5Network_FOUND)
21377 craig 605
    MESSAGE(STATUS "----- USE Qt5Network -----")
20014 craig 606
ELSE(Qt5Network_FOUND)
21377 craig 607
    MESSAGE(FATAL_ERROR "ERROR: No Qt5Network found")
20014 craig 608
ENDIF(Qt5Network_FOUND)
609
FIND_PACKAGE(Qt5OpenGL REQUIRED)
610
IF(Qt5OpenGL_FOUND)
21377 craig 611
    MESSAGE(STATUS "----- USE Qt5OpenGL -----")
20014 craig 612
ELSE(Qt5OpenGL_FOUND)
21377 craig 613
    MESSAGE(FATAL_ERROR "ERROR: No Qt5OpenGL found")
20014 craig 614
ENDIF(Qt5OpenGL_FOUND)
615
FIND_PACKAGE(Qt5LinguistTools REQUIRED)
616
IF(Qt5LinguistTools_FOUND)
21377 craig 617
    MESSAGE(STATUS "----- USE Qt5LinguistTools -----")
20014 craig 618
ELSE(Qt5LinguistTools_FOUND)
21377 craig 619
    MESSAGE(FATAL_ERROR "ERROR: No Qt5LinguistTools found")
20014 craig 620
ENDIF(Qt5LinguistTools_FOUND)
621
FIND_PACKAGE(Qt5Quick REQUIRED)
622
IF(Qt5Quick_FOUND)
21377 craig 623
    MESSAGE(STATUS "----- USE Qt5Quick -----")
20014 craig 624
ELSE(Qt5Quick_FOUND)
21377 craig 625
    MESSAGE(FATAL_ERROR "ERROR: No Qt5Quick found")
20014 craig 626
ENDIF(Qt5Quick_FOUND)
627
FIND_PACKAGE(Qt5PrintSupport REQUIRED)
628
IF(Qt5PrintSupport_FOUND)
21377 craig 629
    MESSAGE(STATUS "----- USE Qt5PrintSupport -----")
20014 craig 630
ELSE(Qt5PrintSupport_FOUND)
21377 craig 631
    MESSAGE(FATAL_ERROR "ERROR: No Qt5PrintSupport found")
20014 craig 632
ENDIF(Qt5PrintSupport_FOUND)
633
INCLUDE_DIRECTORIES(${Qt5Core_INCLUDE_DIRS})
634
ADD_DEFINITIONS(${Qt5Core_DEFINITIONS})
635
INCLUDE_DIRECTORIES(${Qt5Widgets_INCLUDE_DIRS})
636
ADD_DEFINITIONS(${Qt5Widgets_DEFINITIONS})
637
INCLUDE_DIRECTORIES(${Qt5Gui_INCLUDE_DIRS})
638
ADD_DEFINITIONS(${Qt5Gui_DEFINITIONS})
639
INCLUDE_DIRECTORIES(${Qt5Xml_INCLUDE_DIRS})
640
ADD_DEFINITIONS(${Qt5Xml_DEFINITIONS})
641
INCLUDE_DIRECTORIES(${Qt5Network_INCLUDE_DIRS})
642
ADD_DEFINITIONS(${Qt5Network_DEFINITIONS})
643
INCLUDE_DIRECTORIES(${Qt5OpenGL_INCLUDE_DIRS})
644
ADD_DEFINITIONS(${Qt5OpenGL_DEFINITIONS})
645
INCLUDE_DIRECTORIES(${Qt5Quick_INCLUDE_DIRS})
646
ADD_DEFINITIONS(${Qt5Quick_DEFINITIONS})
647
INCLUDE_DIRECTORIES(${Qt5PrintSupport_INCLUDE_DIRS})
648
ADD_DEFINITIONS(${Qt5PrintSupport_DEFINITIONS})
21377 craig 649
 
650
MESSAGE(STATUS "Qt VERSION: ${Qt5Widgets_VERSION}")
9680 cbradney 651
#>> Qt
652
 
10818 craig 653
#<< ZLIB, PNG
654
IF (WIN32)
20014 craig 655
	# On win32 we can use Qt's zlib and libpng, so we use some
656
	# custom cmake includes. This permits us to honour the
657
	# USE_QT_ZLIB_PNGLIB flag if passed.
658
	SET(PNG_DIR ${CMAKE_MODULE_PATH})
659
	SET(ZLIB_DIR ${CMAKE_MODULE_PATH})
10818 craig 660
ENDIF (WIN32)
661
FIND_PACKAGE(ZLIB REQUIRED)
662
IF (ZLIB_FOUND)
20014 craig 663
	MESSAGE("ZLIB Library Found OK")
664
	SET(HAVE_LIBZ 1)
10818 craig 665
ENDIF(ZLIB_FOUND)
19112 craig 666
#FIND_PACKAGE(PNG REQUIRED)
667
#IF (PNG_FOUND)
20014 craig 668
#	MESSAGE("PNG Library Found OK")
19112 craig 669
#ENDIF(PNG_FOUND)
10818 craig 670
#>> ZLIB, PNG
671
 
13839 fschmid 672
IF (WANT_NOOSG)
20014 craig 673
	MESSAGE("Building without 3D Extension")
13839 fschmid 674
ELSE (WANT_NOOSG)
20014 craig 675
	FIND_PACKAGE(OSG)
676
	IF(OSG_FOUND)
677
		MESSAGE("OSG found OK")
678
		SET(HAVE_OSG 1)
679
		FIND_PACKAGE(OpenGL)
680
	ELSE(OSG_FOUND)
681
		MESSAGE("No OSG found, building without 3D Extension")
682
	ENDIF(OSG_FOUND)
13839 fschmid 683
ENDIF (WANT_NOOSG)
684
 
17954 jghali 685
#<< JPEG, TIFF
5142 cbradney 686
FIND_PACKAGE(JPEG REQUIRED)
687
IF (JPEG_FOUND)
20014 craig 688
	MESSAGE("JPEG Library Found OK")
5142 cbradney 689
ENDIF(JPEG_FOUND)
690
FIND_PACKAGE(TIFF REQUIRED)
691
IF (TIFF_FOUND)
20014 craig 692
	MESSAGE("TIFF Library Found OK")
693
	SET(HAVE_TIFF 1)
6211 cbradney 694
ELSE(TIFF_FOUND)
20014 craig 695
	MESSAGE(FATAL_ERROR "Could not find the TIFF Library")
5142 cbradney 696
ENDIF(TIFF_FOUND)
17954 jghali 697
#<< JPEG, TIFF
698
 
699
#<< PYTHON
18948 craig 700
#SET(PythonLibs_FIND_VERSION 2)
701
FIND_PACKAGE(PythonLibs 2 REQUIRED)
5142 cbradney 702
IF (PYTHON_LIBRARY)
20014 craig 703
	MESSAGE("Python Library Found OK")
704
	SET(HAVE_PYTHON 1)
705
	SET(COMPILE_PYTHON 1)
5142 cbradney 706
ENDIF(PYTHON_LIBRARY)
17954 jghali 707
#>> PYTHON
5142 cbradney 708
 
9680 cbradney 709
#<< FreeType2
20014 craig 710
FIND_PACKAGE(Freetype REQUIRED)
711
IF (FREETYPE_FOUND)
712
	MESSAGE(STATUS "FreeType2 Library Found OK")
713
	INCLUDE(CheckLibraryExists)
714
	CHECK_LIBRARY_EXISTS(${FREETYPE_LIBRARY} FT_Get_First_Char "" HAVE_FREETYPE_FIRST)
715
	CHECK_LIBRARY_EXISTS(${FREETYPE_LIBRARY} FT_Get_Next_Char "" HAVE_FREETYPE_NEXT)
716
	# here we have an alternative
717
	# a) Setup CFLAGS with the FREETYPE_INCLUDE_DIR_freetype2 provided by cmake
718
	# b) Insert ${FREETYPE_INCLUDE_DIRS} in include sections of CMakeLists that need it
719
	# I prefer (b) and at some point & from my opinion it should  be just needed in scribus/fonts/CmakeLists.txt - pm
720
ELSE (FREETYPE_FOUND)
721
	MESSAGE(FATAL_ERROR "No Freetype Found")
722
ENDIF(FREETYPE_FOUND)
9680 cbradney 723
#>> FreeType2
5142 cbradney 724
 
9680 cbradney 725
#<<Render Library
18496 jghali 726
IF (WANT_PRIVATE_CAIRO)
20014 craig 727
	MESSAGE("We no longer support the private cairo library as the latest public release is more up to date, setting WANT_SYSTEM_CAIRO=1")
17563 craig 728
ENDIF(WANT_PRIVATE_CAIRO)
7013 cbradney 729
 
18496 jghali 730
IF (RENDER_LIB)
20014 craig 731
	IF (RENDER_LIB STREQUAL "QTARTHUR")
732
		MESSAGE("Qt4's Arthur as renderer is not supported anymore, performing renderer detection again")
733
	ENDIF (RENDER_LIB STREQUAL "QTARTHUR")
18496 jghali 734
ENDIF(RENDER_LIB)
5142 cbradney 735
 
18496 jghali 736
SET(CAIRO_DIR ${CMAKE_MODULE_PATH})
737
FIND_PACKAGE(CAIRO REQUIRED)
738
IF(CAIRO_FOUND)
20014 craig 739
	MESSAGE("CAIRO Library Found OK")
740
	SET(RENDER_LIB "CAIRO_SYSTEM" CACHE TYPE STRING)
18496 jghali 741
ELSE(CAIRO_FOUND)
20014 craig 742
	MESSAGE(FATAL_ERROR "No Cairo Found")
18496 jghali 743
ENDIF(CAIRO_FOUND)
9680 cbradney 744
#>>Render Library
745
 
746
#<<CUPS
18186 craig 747
IF(NOT WIN32 AND NOT HAIKU)
20014 craig 748
	FIND_PACKAGE(Cups REQUIRED)
749
	IF(CUPS_FOUND)
750
		SET(HAVE_CUPS 1)
751
		MESSAGE("CUPS Library Found OK")
752
	ENDIF(CUPS_FOUND)
18186 craig 753
ELSE(NOT WIN32 AND NOT HAIKU)
20014 craig 754
	# Windows doesn't use CUPS
755
	SET(CUPS_INCLUDE_DIR)
18186 craig 756
ENDIF(NOT WIN32 AND NOT HAIKU)
9680 cbradney 757
#>>CUPS
5142 cbradney 758
 
9680 cbradney 759
#<<LibXML2
7203 cbradney 760
FIND_PACKAGE(LibXml2 REQUIRED)
5142 cbradney 761
IF(LIBXML2_FOUND)
20014 craig 762
	SET(HAVE_XML 1)
763
	MESSAGE("LIBXML2 Library Found OK")
5142 cbradney 764
ENDIF(LIBXML2_FOUND)
9680 cbradney 765
#>>LibXML2
5142 cbradney 766
 
9680 cbradney 767
#<<LittleCMS
5142 cbradney 768
SET(LCMS_DIR ${CMAKE_MODULE_PATH})
18497 jghali 769
FIND_PACKAGE(LCMS2 REQUIRED)
15143 fschmid 770
IF(LCMS2_FOUND)
20014 craig 771
	SET(HAVE_LCMS2 1)
772
	SET(HAVE_CMS 1)
773
	SET(CMS_INC "\"lcms2.h\"")
774
	MESSAGE("LittleCMS-2 Library Found OK")
15143 fschmid 775
ELSE(LCMS2_FOUND)
20014 craig 776
	MESSAGE(FATAL_ERROR "Could not find the LittleCMS 2 Library")
15143 fschmid 777
ENDIF(LCMS2_FOUND)
9680 cbradney 778
#>>LittleCMS
5142 cbradney 779
 
9680 cbradney 780
#<<FontConfig
10747 craig 781
IF(NOT WIN32)
20014 craig 782
	SET(FONTCONFIG_DIR ${CMAKE_MODULE_PATH})
783
	FIND_PACKAGE(FONTCONFIG)
784
	IF(FONTCONFIG_FOUND)
785
		MESSAGE("FontConfig Found OK")
786
		SET(HAVE_FONTCONFIG 1)
787
	ENDIF(FONTCONFIG_FOUND)
10747 craig 788
ELSE(NOT WIN32)
20014 craig 789
	# Windows builds neither use nor require fontconfig
790
	SET(FONTCONFIG_INCLUDE_DIR)
10747 craig 791
ENDIF(NOT WIN32)
9680 cbradney 792
#>>FontConfig
5142 cbradney 793
 
17501 craig 794
#<<HUNSPELL for Speelling support
18099 craig 795
OPTION(WANT_HUNSPELL "Enable support for spell checking with hunspell" ON)
17501 craig 796
IF (WANT_HUNSPELL)
20014 craig 797
	FIND_PACKAGE(HUNSPELL)
798
	IF (HUNSPELL_FOUND)
799
		MESSAGE("Hunspell Found OK")
800
		SET(HAVE_HUNSPELL 1)
801
	ELSE (HUNSPELL_FOUND)
802
		MESSAGE("Hunspell or its developer libraries NOT found - Disabling support for spell checking")
803
	ENDIF (HUNSPELL_FOUND)
17501 craig 804
ENDIF (WANT_HUNSPELL)
805
#>>HUNSPELL for Speelling support
11106 cbradney 806
 
10238 cbradney 807
#<<PoDoFo for AI PDF import
14968 cbradney 808
OPTION(WITH_PODOFO "Enable support for PDF embedded in AI" ON)
809
IF (WITH_PODOFO)
20014 craig 810
	FIND_PACKAGE(LIBPODOFO)
811
	IF (LIBPODOFO_FOUND)
812
		MESSAGE("PoDoFo found OK")
813
		SET(HAVE_PODOFO 1)
814
	ELSE (LIBPODOFO_FOUND)
815
		MESSAGE("PoDoFo NOT found - Disabling support for PDF embedded in AI")
816
	ENDIF (LIBPODOFO_FOUND)
14968 cbradney 817
ENDIF (WITH_PODOFO)
10238 cbradney 818
#>>PoDoFo for AI PDF import
10234 fschmid 819
 
14937 fschmid 820
#<<Boost for 2Geom Tools
14968 cbradney 821
OPTION(WITH_BOOST "Enable support for Boost based enhancements" ON)
822
IF (WITH_BOOST)
20014 craig 823
	FIND_PACKAGE(Boost)
824
	IF (Boost_FOUND)
825
		MESSAGE("Boost Library Found OK")
826
		SET(HAVE_BOOST 1)
827
	ELSE(Boost_FOUND)
828
		MESSAGE("Boost: NOT FOUND, not building 2geomtools")
829
	ENDIF (Boost_FOUND)
14968 cbradney 830
ENDIF (WITH_BOOST)
14937 fschmid 831
#>>Boost for 2Geom Tools
832
 
15714 christoph 833
#<<GraphicksMagick for image import
14516 cbradney 834
IF (WANT_GRAPHICSMAGICK)
20014 craig 835
	SET(GMAGICK_DIR ${CMAKE_MODULE_PATH})
836
	pkg_check_modules(GMAGICK GraphicsMagick)
837
	# FIND_PACKAGE(GMAGICK)
838
	IF(GMAGICK_FOUND)
839
		MESSAGE("GraphicksMagick Found OK")
840
	ELSE(GMAGICK_FOUND)
841
		MESSAGE("GraphicksMagick NOT found! Building without additional image format support!")
842
	ENDIF(GMAGICK_FOUND)
14516 cbradney 843
ELSE (WANT_GRAPHICSMAGICK)
20014 craig 844
	MESSAGE("Building without GraphicksMagick (use -DWANT_GRAPHICSMAGICK=1 to enable)")
14516 cbradney 845
ENDIF (WANT_GRAPHICSMAGICK)
15714 christoph 846
#>>GraphicksMagick for image import
13957 herm 847
 
16729 fschmid 848
#<<Poppler for PDF import
849
FIND_PACKAGE(POPPLER)
850
IF (POPPLER_FOUND)
851
	IF (FREETYPE_FOUND)
852
		SET( HAVE_POPPLER 1 )
853
		MESSAGE(STATUS "Found poppler")
854
		MESSAGE(STATUS "Found poppler libs: ${POPPLER_LIBRARY}")
855
		MESSAGE(STATUS "Found poppler includes: ${POPPLER_INCLUDE_DIR}")
856
	ELSE (FREETYPE_FOUND)
857
		MESSAGE("Poppler NOT found - Disabling support for native PDF import")
858
	ENDIF (FREETYPE_FOUND)
859
ELSE (POPPLER_FOUND)
860
	MESSAGE("Poppler NOT found - Disabling support for native PDF import")
861
ENDIF (POPPLER_FOUND)
862
#>>Poppler for PDF import
863
 
19222 fschmid 864
# librevenge for MsPub import
865
pkg_check_modules(LIBREVENGE librevenge-0.0)
866
IF (LIBREVENGE_FOUND)
867
	pkg_check_modules(LIBREVENGE_STREAM librevenge-stream-0.0)
868
	IF (LIBREVENGE_STREAM_FOUND)
869
		pkg_check_modules(LIBREVENGE_GENERATORS librevenge-generators-0.0)
870
		IF (LIBREVENGE_GENERATORS_FOUND)
871
			SET(HAVE_REVENGE 1)
872
		ENDIF (LIBREVENGE_GENERATORS_FOUND)
873
	ENDIF (LIBREVENGE_STREAM_FOUND)
874
ENDIF (LIBREVENGE_FOUND)
16729 fschmid 875
 
10215 cbradney 876
##############################################################################################################
877
########## Include Setup                                                                            ##########
8499 cbradney 878
 
10215 cbradney 879
TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
19222 fschmid 880
 
5142 cbradney 881
CHECK_INCLUDE_FILE("dlfcn.h" HAVE_DLFCN_H)
882
IF(HAVE_DLFCN_H)
20014 craig 883
	ADD_DEFINITIONS(-DHAVE_DLFCN_H)
5142 cbradney 884
ENDIF(HAVE_DLFCN_H)
885
 
886
CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
887
IF(HAVE_UNISTD_H)
20014 craig 888
	ADD_DEFINITIONS(-DHAVE_UNISTD_H)
5142 cbradney 889
ENDIF(HAVE_UNISTD_H)
890
 
891
CHECK_INCLUDE_FILE("sys/types.h" HAVE_SYS_TYPES_H)
892
# IF(HAVE_SYS_TYPES_H)
893
#   ADD_DEFINITIONS(-DHAVE_SYS_TYPES_H)
894
# ENDIF(HAVE_SYS_TYPES_H)
895
 
896
CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H)
897
# IF(HAVE_SYS_STAT_H)
898
#   ADD_DEFINITIONS(-DHAVE_SYS_STAT_H)
899
# ENDIF(HAVE_SYS_STAT_H)
9680 cbradney 900
#>>Test for existing include files
5142 cbradney 901
 
902
 
5150 cbradney 903
#Create configure files.. config.h and uninstall
904
#config.h
5142 cbradney 905
INCLUDE (ConfigureChecks.cmake)
20014 craig 906
	IF(WIN32)
907
		SET(CONFIG_NAME win-config.h)
908
	ELSE(WIN32)
909
		SET(CONFIG_NAME config.h)
910
	ENDIF(WIN32)
10779 craig 911
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})
5142 cbradney 912
ADD_DEFINITIONS("-DHAVE_CONFIG_H")
9680 cbradney 913
 
5142 cbradney 914
 
5150 cbradney 915
 
5157 cbradney 916
#Set up include dirs with all found packages
5142 cbradney 917
INCLUDE_DIRECTORIES(
20014 craig 918
	${CMAKE_BINARY_DIR}
919
	${CMAKE_BINARY_DIR}/scribus
920
	${QT_INCLUDES}
921
	${FREETYPE_INCLUDE_DIR}
922
	${FONTCONFIG_INCLUDE_DIR}
923
	${JPEG_INCLUDE_DIR}
924
	${LCMS2_INCLUDE_DIR}
925
	${LIBXML2_INCLUDE_DIR}
926
	${TIFF_INCLUDE_DIR}
927
	${ZLIB_INCLUDE_DIR}
928
	${OPENGL_INCLUDE_DIR}
929
	${OSG_INCLUDE_DIR}
930
	${GSL_INCLUDE_DIR}
5142 cbradney 931
)
932
 
18186 craig 933
IF (NOT WIN32 AND NOT HAIKU)
934
INCLUDE_DIRECTORIES(
20014 craig 935
	${CUPS_INCLUDE_DIR}
18186 craig 936
)
937
ENDIF (NOT WIN32 AND NOT HAIKU)
938
 
10215 cbradney 939
##############################################################################################################
940
########## Uninstall Setup                                                                          ##########
941
 
942
CONFIGURE_FILE(
20014 craig 943
	"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
944
	"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
945
	IMMEDIATE @ONLY
10215 cbradney 946
)
947
 
948
ADD_CUSTOM_TARGET(uninstall
20014 craig 949
	"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
950
)
19222 fschmid 951
 
952
 
10215 cbradney 953
##############################################################################################################
954
########## Add our subdirs                                                                          ##########
955
 
5157 cbradney 956
#Add our source subdirs
5142 cbradney 957
ADD_SUBDIRECTORY(scribus)
13527 cbradney 958
ADD_SUBDIRECTORY(doc)
14098 cbradney 959
ADD_SUBDIRECTORY(resources/dicts)
14097 cbradney 960
ADD_SUBDIRECTORY(resources/editorconfig)
20160 craig 961
ADD_SUBDIRECTORY(resources/iconsets)
14096 cbradney 962
ADD_SUBDIRECTORY(resources/keysets)
14097 cbradney 963
ADD_SUBDIRECTORY(resources/loremipsum)
14096 cbradney 964
ADD_SUBDIRECTORY(resources/profiles)
14047 cbradney 965
ADD_SUBDIRECTORY(resources/swatches)
14097 cbradney 966
ADD_SUBDIRECTORY(resources/templates)
18404 craig 967
ADD_SUBDIRECTORY(resources/translations)
5142 cbradney 968
 
5157 cbradney 969
#Install our READMEs etc.
5142 cbradney 970
INSTALL(FILES
19171 craig 971
	AUTHORS
972
	BUILDING
973
	ChangeLog
974
	COPYING
975
	LINKS
976
	NEWS
977
	PACKAGING
978
	README
979
	TODO
980
	TRANSLATION
981
	DESTINATION ${DOCDIR}
5142 cbradney 982
)
9386 cbradney 983
 
17500 craig 984
IF (APPLE)
20014 craig 985
	INSTALL(FILES
986
		README.MacOSX
987
		DESTINATION ${DOCDIR}
988
	)
18763 craig 989
 
20014 craig 990
	#	EXECUTE_PROCESS (COMMAND mkdir -p "${CMAKE_INSTALL_PREFIX}/PlugIns/imageformats")
991
	#	IF (NOT EXISTS "${CMAKE_INSTALL_PREFIX}/PlugIns/imageformats/libqjpeg.dylib")
992
	#MESSAGE(STATUS ${QT_PREFIX})
993
	#MESSAGE(STATUS "@QT_PREFIX@/plugins/imageformats/libqjpeg.dylib")
994
	#MESSAGE(STATUS "${CMAKE_INSTALL_PREFIX}/PlugIns/imageformats/libqjpeg.dylib")
995
	#		EXECUTE_PROCESS (COMMAND ditto "@QT_PREFIX@/plugins/imageformats/libqjpeg.dylib" "${CMAKE_INSTALL_PREFIX}/PlugIns/imageformats/libqjpeg.dylib")
996
	#	ENDIF()
18763 craig 997
 
17500 craig 998
ENDIF (APPLE)
999
 
9680 cbradney 1000
#Install our MIME data
6319 mrdocs 1001
INSTALL(FILES
20014 craig 1002
	scribus.xml
1003
	DESTINATION ${MIMEDIR}
6319 mrdocs 1004
)
11715 malex 1005
#KDE workaround until it starts supporting freedesktop spec
1006
INSTALL(FILES
20014 craig 1007
	vnd.scribus.desktop
1008
	DESTINATION ${MIMELNKDIR}
11715 malex 1009
)
5396 cbradney 1010
 
21230 mrdocs 1011
 
1012
#Install the appdata file
1013
INSTALL(FILES
1014
scribus.appdata.xml
1015
DESTINATION ${APPDATADIR}
1016
)
1017
 
1018
 
9680 cbradney 1019
#If building an Apple bundle, install these specific files
1020
IF(APPLEBUNDLE)
20014 craig 1021
	INSTALL(FILES
1022
		Scribus.app/Contents/Info.plist
1023
		DESTINATION ${CMAKE_INSTALL_PREFIX}
1024
	)
1025
	INSTALL(FILES
1026
		Scribus.app/Contents/Resources/Scribus.icns
1027
		Scribus.app/Contents/Resources/Scribus-doc.icns
1028
		DESTINATION ${CMAKE_INSTALL_PREFIX}/Resources
1029
	)
9680 cbradney 1030
ENDIF(APPLEBUNDLE)
9386 cbradney 1031
 
10215 cbradney 1032
##############################################################################################################
1033
########## Install/CPack Setup                                                                      ##########
1034
 
9680 cbradney 1035
# If the cmake version includes cpack, use it for tarball building
5396 cbradney 1036
IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
20014 craig 1037
	SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Scribus is an open source publishing application for Linux, Mac OSX and Windows")
1038
	SET(CPACK_PACKAGE_VENDOR "Scribus Team")
1039
	SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
1040
	SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/README")
1041
	SET(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}")
1042
	SET(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
1043
	SET(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}")
1044
	SET(CPACK_PACKAGE_INSTALL_DIRECTORY "Scribus ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
1045
	SET(CPACK_PACKAGE_EXECUTABLES "scribus${TAG_VERSION}")
1046
	SET(CPACK_SOURCE_PACKAGE_FILE_NAME "scribus-${VERSION}${VERSION_SUFFIX}")
1047
	SET(CPACK_SOURCE_GENERATOR TBZ2)
1048
	SET(CPACK_SYSTEM_NAME "")
1049
	SET(CPACK_TOPLEVEL_TAG "")
1050
	SET(CPACK_SOURCE_IGNORE_FILES
1051
		CMakeCache.txt
21325 craig 1052
		scribus-1.5.2.tar.bz2
1053
		scribus-1.5.2.tar.Z
1054
		scribus-1.5.2.tar.gz
21006 jghali 1055
		scribus-1.5.2.svn.tar.bz2
1056
		scribus-1.5.2.svn.tar.Z
1057
		scribus-1.5.2.svn.tar.gz
20014 craig 1058
		"~$"
1059
		"\\\\.cvsignore$"
1060
		"\\\\.o$"
1061
		"\\\\.svn-base$"
1062
		"\\\\.svn$"
1063
		"^${PROJECT_SOURCE_DIR}.*/CVS/"
1064
		"^${PROJECT_SOURCE_DIR}/debian/"
1065
		"^${PROJECT_SOURCE_DIR}/old/"
1066
		"^${PROJECT_SOURCE_DIR}.*/CVSROOT/"
1067
		"^${PROJECT_SOURCE_DIR}/admin/"
1068
	)
1069
	INCLUDE(CPack)
5463 avox 1070
ENDIF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
14097 cbradney 1071
 
20014 craig 1072
#include (cmakeconfigreport optional)
21325 craig 1073
 
1074
# Output everything we've found
1075
#feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES)