Subversion Repositories Scribus

Rev

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