Subversion Repositories Scribus

Rev

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