forked from lightspark/lightspark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
484 lines (433 loc) · 18.7 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
#**************************************************************************
# Lightspark, a free flash player implementation
#
# Copyright (C) 2010-2011 Alessandro Pignotti <[email protected]>
# Copyright (C) 2010 Giacomo Spigler <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#**************************************************************************
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
# Name & Version
PROJECT(LIGHTSPARK)
SET(MAJOR_VERSION "0")
SET(MINOR_VERSION "6")
SET(PATCH_VERSION "0")
SET(SUBPATCH_VERSION "0")
IF(EXISTS "${CMAKE_SOURCE_DIR}/.git/")
SET(GIT_VERSION "-git")
#Find out if we are exactly at a tag. Then the version
#is enough. Only consider the official release tags like
#'lightspark-0.5.3'
EXECUTE_PROCESS(COMMAND git describe --match "lightspark-*" --tags
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_DESC
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
#Check if that command failed (maybe git is not installed at all)
IF(GIT_DESC)
EXECUTE_PROCESS(COMMAND git describe --match "lightspark-*" --tags --abbrev=0
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_DESC_ABBREV
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
IF(${GIT_DESC} STREQUAL ${GIT_DESC_ABBREV})
#We are exactly at a tag
SET(GIT_VERSION "")
ELSE()
#Append to GIT_VERSION
#GIT_DESC_ABBREV is of the form lightspark-0.5.3 (the name of the previous tag)
#GIT_DESC is of the form lightspark-0.5.3-69-gf49ec56 (tag-numberOfCommits-currentHash)
#We want GIT_REVISION to be 69-gf49ec56
#which denotes the number of commits since the last tag (=release)
#and the current commit's hash
STRING(REPLACE "${GIT_DESC_ABBREV}-" "" GIT_REVISION "${GIT_DESC}")
SET(GIT_VERSION "-${GIT_REVISION}")
ENDIF()
ENDIF()
ELSE(EXISTS "${CMAKE_SOURCE_DIR}/.git/")
SET(GIT_VERSION "")
ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/.git/")
IF(SUBPATCH_VERSION EQUAL "0")
SET(FULLVERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}${GIT_VERSION}")
ELSE(SUBPATCH_VERSION EQUAL "0")
SET(FULLVERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}.${SUBPATCH_VERSION}${GIT_VERSION}")
ENDIF(SUBPATCH_VERSION EQUAL "0")
SET(SHORTVERSION "${MINOR_VERSION}${PATCH_VERSION}${SUBPATCH_VERSION}")
CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/src/version.h.in" "${CMAKE_CURRENT_BINARY_DIR}/version.h" @ONLY)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
# GCC 4.4+ is required, GCC_VERSION macro taken from GCC manual
INCLUDE(CheckCSourceCompiles)
IF(CMAKE_COMPILER_IS_GNUCC)
CHECK_C_SOURCE_COMPILES("
#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#if GCC_VERSION < 40400
#error
#endif
int main() { return 0; }" GCC_IS_4_4)
IF(NOT GCC_IS_4_4)
MESSAGE(FATAL_ERROR "GCC 4.4+ is required.")
ENDIF(NOT GCC_IS_4_4)
ENDIF(CMAKE_COMPILER_IS_GNUCC)
# Find put the path of the gnash executable, if available
FIND_PROGRAM(GNASH_EXE_PATH NAMES gnash)
IF(GNASH_EXE_PATH)
MESSAGE(STATUS "Found gnash path: ${GNASH_EXE_PATH}")
ELSE(GNASH_EXE_PATH)
# Set a default path
MESSAGE(STATUS "Gnash not found")
SET(GNASH_EXE_PATH "/usr/bin/gnash")
ENDIF(GNASH_EXE_PATH)
# Find out CPU architecture ...
# we could also use IF(CMAKE_SIZEOF_VOID_P EQUAL 4) to determine if it's a 32 or a 64bit arch
#
# Setting the value of LIB_SUFFIX if not specified (We could build 32bit version on 64bit)
# However, some distro don't implement FHS the same way
# Suse, Redhat put 64bit libs in /lib64; Debian use /lib for 64bit, but specifies /lib32 for 32bit libs
# See FHS 2.3 for Lib directories under each architecture
# Some directory shortcuts
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/conf)
INCLUDE(Pack)
# If we're gcc, then use nasm to get fastpath. If MSVC, just use inline asm to get around
# CMake issues
IF(CMAKE_COMPILER_IS_GNUCC)
INCLUDE(CMakeASM-NASMCompiler)
ENDIF(CMAKE_COMPILER_IS_GNUCC)
IF(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^i[3-6]86$|^x86$")
SET(i386 1)
SET(LIB_SUFFIX "" CACHE STRING "Choose the suffix of the lib folder (if any) : None 32")
# nasm for assembly optimizations
IF(CMAKE_COMPILER_IS_GNUCC)
ENABLE_LANGUAGE(ASM-NASM)
ENDIF(CMAKE_COMPILER_IS_GNUCC)
ELSEIF(${CMAKE_SYSTEM_PROCESSOR} MATCHES "unknown" AND ${CMAKE_SYSTEM} MATCHES "GNU-0.3")
# GNU Hurd is i386
SET(i386 1)
SET(LIB_SUFFIX "" CACHE STRING "Choose the suffix of the lib folder (if any) : None 32")
# nasm for assembly optimizations
IF(CMAKE_COMPILER_IS_GNUCC)
ENABLE_LANGUAGE(ASM-NASM)
ENDIF ()
ELSEIF(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^x86_64$|^amd64$")
SET(x86_64 1)
SET(LIB_SUFFIX "" CACHE STRING "Choose the suffix of the lib folder (if any) : None 64")
# nasm for assembly optimizations
IF(CMAKE_COMPILER_IS_GNUCC)
ENABLE_LANGUAGE(ASM-NASM)
ENDIF(CMAKE_COMPILER_IS_GNUCC)
ELSEIF(${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc")
SET(ppc 1)
SET(LIB_SUFFIX "" CACHE STRING "Choose the suffix of the lib folder (if any) : None ppc")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maltivec -D__STDC_CONSTANT_MACROS -fPIC")
ELSE(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^i[3-6]86$|^x86$")
# All non-x86 non-ppc architectures.
SET(LIB_SUFFIX "" CACHE STRING "Choose the suffix of the lib folder (if any) : None")
ENDIF(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^i[3-6]86$|^x86$")
IF(CMAKE_SYSTEM_NAME STREQUAL CMAKE_HOST_SYSTEM_NAME)
SET(CROSSCOMPILING FALSE)
ELSE()
SET(CROSSCOMPILING TRUE)
ENDIF()
#On mingw-cross-env, all depedencies are static libs
IF(CROSSCOMPILING AND MINGW)
SET(STATICDEPS TRUE)
ELSE()
SET(STATICDEPS FALSE)
ENDIF()
# Using relative folders, cmake happens by itself CMAKE_INSTALL_PREFIX
IF(UNIX)
SET(ETCDIR "/etc") #Using absolute folder
SET(BINDIR "bin")
SET(DATADIR "share")
# Absolute path, because this path is embedded in the binary
SET(LSDATADIR "${CMAKE_INSTALL_PREFIX}/${DATADIR}/lightspark")
SET(LIBDIR "lib${LIB_SUFFIX}")
#We need a absolute path here because we use it for rpath
#later on
SET(PRIVATELIBDIR "${CMAKE_INSTALL_PREFIX}/${LIBDIR}/lightspark")
SET(CMAKE_INSTALL_RPATH "${PRIVATELIBDIR}")
SET(PLUGINSDIR "${PRIVATELIBDIR}/plugins")
ELSE()
SET(ETCDIR ".")
SET(BINDIR ".")
SET(DATADIR ".")
SET(LSDATADIR ".")
SET(LIBDIR ".")
SET(PRIVATELIBDIR ".")
SET(PLUGINSDIR ".")
ENDIF(UNIX)
# Setting variables
IF(WIN32)
SET(AUDIO_BACKEND "winmm" CACHE STRING "Which audio backends should be built?")
ELSE()
SET(AUDIO_BACKEND "pulseaudio" CACHE STRING "Which audio backends should be built?")
ENDIF()
SET(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Install prefix, default is /usr/local (UNIX) and C:\\Program Files (Windows)")
SET(COMPILE_LIGHTSPARK TRUE CACHE BOOL "Compile Lightspark?")
SET(COMPILE_TIGHTSPARK TRUE CACHE BOOL "Compile Tightspark?")
SET(COMPILE_PLUGIN TRUE CACHE BOOL "Compile the browser plugin?")
SET(ENABLE_CURL TRUE CACHE BOOL "Enable CURL? (Required for Downloader functionality)")
SET(ENABLE_GLES2 FALSE CACHE BOOL "Build with OpenGLES 2.0 support instead of OpenGL")
SET(ENABLE_LIBAVCODEC TRUE CACHE BOOL "Enable libavcodec and dependent functionality?")
SET(ENABLE_RTMP TRUE CACHE BOOL "Enable librtmp and dependent functionality?")
SET(ENABLE_PROFILING FALSE CACHE BOOL "Enable profiling support? (Causes performance issues)")
SET(ENABLE_MEMORY_USAGE_PROFILING FALSE CACHE BOOL "Enable profiling of memory usage? (Causes performance issues)")
SET(PLUGIN_DIRECTORY "${LIBDIR}/mozilla/plugins" CACHE STRING "Directory to install Firefox plugin to")
IF(ENABLE_DEBIAN_ALTERNATIVES OR WIN32)
SET(PLUGIN_DIRECTORY ${PRIVATELIBDIR})
ENDIF()
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo Profile" FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)
# The library is searched in its private library directory
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH "${PRIVATELIBDIR}")
# Libraries we need
INCLUDE(FindPkgConfig REQUIRED)
INCLUDE(FindGettext REQUIRED)
INCLUDE(FindLLVM REQUIRED)
IF(${LLVM_STRING_VERSION} VERSION_LESS 2.8)
MESSAGE(FATAL_ERROR "LLVM >=2.8 is required!")
ENDIF(${LLVM_STRING_VERSION} VERSION_LESS 2.8)
IF(${LLVM_STRING_VERSION} VERSION_EQUAL 2.9)
MESSAGE(FATAL_ERROR "LLVM !=2.9 is required!")
ENDIF(${LLVM_STRING_VERSION} VERSION_EQUAL 2.9)
IF(${LLVM_STRING_VERSION} VERSION_EQUAL 2.8)
ADD_DEFINITIONS(-DLLVM_28)
ENDIF(${LLVM_STRING_VERSION} VERSION_EQUAL 2.8)
IF(${LLVM_STRING_VERSION} VERSION_EQUAL 3.0)
ADD_DEFINITIONS(-DLLVM_30)
ENDIF(${LLVM_STRING_VERSION} VERSION_EQUAL 3.0)
IF(${LLVM_STRING_VERSION} VERSION_GREATER 3.0)
ADD_DEFINITIONS(-DLLVM_31)
ENDIF(${LLVM_STRING_VERSION} VERSION_GREATER 3.0)
INCLUDE(FindZLIB REQUIRED)
INCLUDE(FindFreetype REQUIRED)
IF(NOT(ENABLE_GLES2))
INCLUDE(FindOpenGL REQUIRED)
INCLUDE(FindGLEW REQUIRED)
ENDIF(NOT(ENABLE_GLES2))
INCLUDE(FindPCRE REQUIRED)
INCLUDE(FindJPEG REQUIRED)
INCLUDE(FindPNG REQUIRED)
pkg_check_modules(XMLPP REQUIRED libxml++-2.6>=2.33.1)
IF(XMLPP_FOUND AND NOT(XMLPP_VERSION VERSION_LESS 2.35.1))
ADD_DEFINITIONS(-DXMLPP_2_35_1)
ENDIF(XMLPP_FOUND AND NOT(XMLPP_VERSION VERSION_LESS 2.35.1))
find_package(Boost COMPONENTS filesystem system REQUIRED)
if(Boost_FOUND)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
ENDIF(Boost_FOUND)
pkg_check_modules(CAIRO REQUIRED cairo pangocairo)
IF(UNIX)
pkg_check_modules(X11 REQUIRED x11)
INCLUDE_DIRECTORIES(${X11_INCLUDE_DIRS})
ENDIF(UNIX)
IF(ENABLE_GLES2)
pkg_check_modules(GLES2 REQUIRED egl glesv2)
ADD_DEFINITIONS(-DENABLE_GLES2)
ENDIF(ENABLE_GLES2)
IF(WIN32)
SET(EXTRA_LIBS_LIBRARIES ${EXTRA_LIBS_LIBRARIES} ws2_32.lib imagehlp.lib)
ENDIF(WIN32)
IF(AUDIO_BACKEND)
ADD_DEFINITIONS(-DAUDIO_BACKEND="${AUDIO_BACKEND}")
ENDIF(AUDIO_BACKEND)
IF(ENABLE_LIBAVCODEC)
pkg_check_modules(FFMPEG libavcodec libavutil libavformat)
IF(NOT(FFMPEG_FOUND))
INCLUDE(FindFFMpeg REQUIRED)
ENDIF(NOT(FFMPEG_FOUND))
# Compatibility checks for ffmpeg deprecated functions
INCLUDE(CheckFunctionExists REQUIRED)
SET(CMAKE_REQUIRED_FLAGS ${LIBAVCODEC_CFLAGS})
SET(CMAKE_REQUIRED_INCLUDES ${FFMPEG_INCLUDE_DIRS})
SET(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES})
CHECK_FUNCTION_EXISTS(avcodec_decode_video2 HAVE_AVCODEC_DECODE_VIDEO2)
CHECK_FUNCTION_EXISTS(avcodec_decode_audio3 HAVE_AVCODEC_DECODE_AUDIO3)
CHECK_FUNCTION_EXISTS(avcodec_decode_audio4 HAVE_AVCODEC_DECODE_AUDIO4)
CHECK_FUNCTION_EXISTS(avio_alloc_context HAVE_AVIO_ALLOC_CONTEXT)
SET(CMAKE_REQUIRED_FLAGS)
SET(CMAKE_REQUIRED_INCLUDES)
SET(CMAKE_REQUIRED_LIBRARIES)
IF(HAVE_AVCODEC_DECODE_VIDEO2)
ADD_DEFINITIONS(-DHAVE_AVCODEC_DECODE_VIDEO2)
ENDIF(HAVE_AVCODEC_DECODE_VIDEO2)
IF(HAVE_AVCODEC_DECODE_AUDIO3)
ADD_DEFINITIONS(-DHAVE_AVCODEC_DECODE_AUDIO3)
ENDIF(HAVE_AVCODEC_DECODE_AUDIO3)
IF(HAVE_AVCODEC_DECODE_AUDIO4)
ADD_DEFINITIONS(-DHAVE_AVCODEC_DECODE_AUDIO4)
ENDIF(HAVE_AVCODEC_DECODE_AUDIO4)
IF(HAVE_AVIO_ALLOC_CONTEXT)
ADD_DEFINITIONS(-DHAVE_AVIO_ALLOC_CONTEXT)
ENDIF(HAVE_AVIO_ALLOC_CONTEXT)
ADD_DEFINITIONS(-DENABLE_LIBAVCODEC)
ENDIF(ENABLE_LIBAVCODEC)
pkg_check_modules(GLIB REQUIRED glib-2.0)
pkg_check_modules(GTHREAD REQUIRED gthread-2.0)
pkg_check_modules(GMODULE REQUIRED gmodule-2.0)
pkg_check_modules(GLIBMM REQUIRED glibmm-2.4)
INCLUDE_DIRECTORIES(${GLIBMM_INCLUDE_DIRS})
pkg_check_modules(GTK REQUIRED gtk+-2.0)
IF(GLIBMM_FOUND AND NOT(GLIBMM_VERSION VERSION_LESS 2.31.0))
ADD_DEFINITIONS(-DHAVE_NEW_GLIBMM_THREAD_API)
ENDIF(GLIBMM_FOUND AND NOT(GLIBMM_VERSION VERSION_LESS 2.31.0))
INCLUDE_DIRECTORIES(${LLVM_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${FREETYPE_INCLUDE_DIRS})
IF(ENABLE_GLES2)
INCLUDE_DIRECTORIES(${GLES2_INCLUDE_DIRS})
ELSE()
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${GLEW_INCLUDE_DIR})
ENDIF(ENABLE_GLES2)
INCLUDE_DIRECTORIES(${PCRE_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${PNG_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${XMLPP_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${CAIRO_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${GLIB_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${GTK_INCLUDE_DIRS})
IF(ENABLE_LIBAVCODEC)
INCLUDE_DIRECTORIES(${FFMPEG_INCLUDE_DIRS})
SET(OPTIONAL_LIBRARIES ${OPTIONAL_LIBRARIES} ${FFMPEG_LIBRARIES})
ENDIF(ENABLE_LIBAVCODEC)
IF(CMAKE_COMPILER_IS_GNUCC)
IF(MINGW)
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed,--no-undefined -mthreads ${CMAKE_EXE_LINKER_FLAGS}")
SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed,--no-undefined,--enable-stdcall-fixup -mthreads ${CMAKE_SHARED_LINKER_FLAGS}")
ELSE()
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--no-undefined ${CMAKE_EXE_LINKER_FLAGS}")
SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed,-z,noexecstack,--no-undefined ${CMAKE_SHARED_LINKER_FLAGS}")
ENDIF()
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "-s")
SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "-s")
ENDIF(CMAKE_COMPILER_IS_GNUCC)
LINK_DIRECTORIES(${LLVM_LIB_DIR})
IF(ENABLE_CURL)
pkg_check_modules(CURL REQUIRED libcurl)
INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR})
IF(STATICDEPS)
SET(OPTIONAL_LIBRARIES ${OPTIONAL_LIBRARIES} ${CURL_STATIC_LIBRARIES})
ELSE()
SET(OPTIONAL_LIBRARIES ${OPTIONAL_LIBRARIES} ${CURL_LIBRARIES})
ENDIF()
ADD_DEFINITIONS(-DENABLE_CURL)
ENDIF(ENABLE_CURL)
IF(ENABLE_RTMP)
pkg_check_modules(RTMP REQUIRED librtmp)
SET(OPTIONAL_LIBRARIES ${OPTIONAL_LIBRARIES} ${RTMP_LIBRARIES})
ADD_DEFINITIONS(-DENABLE_RTMP)
ENDIF(ENABLE_RTMP)
IF(ENABLE_PROFILING)
ADD_DEFINITIONS(-DPROFILING_SUPPORT)
ENDIF(ENABLE_PROFILING)
IF(ENABLE_MEMORY_USAGE_PROFILING)
ADD_DEFINITIONS(-DMEMORY_USAGE_PROFILING)
ENDIF(ENABLE_MEMORY_USAGE_PROFILING)
# Compiler defaults flags for different profiles
IF(CMAKE_COMPILER_IS_GNUCC)
IF(MINGW)
SET(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -mms-bitfields -mthreads -fexceptions -Wall -Wnon-virtual-dtor -Woverloaded-virtual -pipe -std=c++0x -Wdisabled-optimization -Wextra -Wno-unused-parameter -Wno-invalid-offsetof")
ELSE()
SET(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wall -Wnon-virtual-dtor -Woverloaded-virtual -pipe -fvisibility=hidden -fvisibility-inlines-hidden -std=c++0x -Wdisabled-optimization -Wextra -Wno-unused-parameter -Wno-invalid-offsetof")
ENDIF()
SET(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -DEXPENSIVE_DEBUG")
SET(CMAKE_CXX_FLAGS_PROFILE "-g -pg -O2")
SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O2 -DNDEBUG")
SET(CMAKE_CXX_FLAGS_LEANDEBUG "-g -O2")
ADD_DEFINITIONS(-DLS_DATADIR="${LSDATADIR}" -DGNASH_PATH="${GNASH_EXE_PATH}" -DPRIVATELIBDIR="${PRIVATELIBDIR}")
ENDIF(CMAKE_COMPILER_IS_GNUCC)
IF(MSVC)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -DVPCOMPAT -DPTW32_STATIC_LIB -DPCRE_STATIC)
ENDIF(MSVC)
IF(STATICDEPS)
ADD_DEFINITIONS(-DLIBXML_STATIC -DGLEW_STATIC)
ENDIF()
# Check if the system have atomic header ( gcc >= 4.6 )
INCLUDE (CheckIncludeFileCXX)
CHECK_INCLUDE_FILE_CXX (atomic HAVE_ATOMIC)
IF(HAVE_ATOMIC)
ADD_DEFINITIONS(-DHAVE_ATOMIC)
ENDIF(HAVE_ATOMIC)
# Setting the output directories, so we can build all profiles without mixmatching
IF(CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${CMAKE_SYSTEM_PROCESSOR}/${CMAKE_BUILD_TYPE}/bin")
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${CMAKE_SYSTEM_PROCESSOR}/${CMAKE_BUILD_TYPE}/lib${LIB_SUFFIX}")
#SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/objs/${CMAKE_SYSTEM_PROCESSOR}/${CMAKE_BUILD_TYPE}/lib${LIB_SUFFIX}" CACHE PATH "Static libraries output directory")
ENDIF(CMAKE_COMPILER_IS_GNUCC)
#Install icons and desktop file
if(UNIX)
FOREACH(i 16 22 24 32 36 48 64 72 96 128 192 256 )
INSTALL(FILES media/lightspark-ico-${i}x${i}.png
DESTINATION ${DATADIR}/icons/hicolor/${i}x${i}/apps
RENAME lightspark.png
)
ENDFOREACH(i)
INSTALL(FILES media/lightspark-ico.svg
DESTINATION ${DATADIR}/icons/hicolor/scalable/apps
RENAME lightspark.svg
)
INSTALL(FILES media/lightspark.desktop DESTINATION ${DATADIR}/applications )
endif(UNIX)
# generate locales for gettext
GETTEXT_CREATE_TRANSLATIONS(i18n/lightspark.pot ALL i18n/pl.po i18n/fr.po
i18n/zh_CN.po)
if(UNIX)
INSTALL(FILES etc/xdg/lightspark.conf
DESTINATION ${ETCDIR}/xdg/)
ELSE()
INSTALL(FILES COPYING DESTINATION "." RENAME COPYING.txt)
INSTALL(FILES COPYING.LESSER DESTINATION "." RENAME COPYING.LESSER.txt)
endif(UNIX)
SUBDIRS(src)
#-- CPack setup - use 'make package' to build
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Lightspark is an LGPLv3 licensed cross-platform Flash player and browser plugin")
SET(CPACK_PACKAGE_VENDOR "Lightspark Team")
SET(CPACK_PACKAGE_NAME "Lightspark")
SET(CPACK_PACKAGE_VERSION_MAJOR "${MAJOR_VERSION}")
SET(CPACK_PACKAGE_VERSION_MINOR "${MINOR_VERSION}")
IF(SUBPATCH_VERSION EQUAL "0")
SET(CPACK_PACKAGE_VERSION_PATCH "${PATCH_VERSION}${GIT_VERSION}")
ELSE()
SET(CPACK_PACKAGE_VERSION_PATCH "${PATCH_VERSION}.${SUBPATCH_VERSION}${GIT_VERSION}")
ENDIF()
SET(CPACK_NSIS_MENU_LINKS "")
#In release builds, we already strip symbols (see LDFLAGS), and compress by upx
#Therefore we cannot strip afterwards
SET(CPACK_STRIP_FILES FALSE)
SET(CPACK_RESOURCE_FILE_LICENSE ${PROJECT_SOURCE_DIR}/COPYING)
SET(CPACK_NSIS_HELP_LINK "http:////www.lightspark.org")
SET(CPACK_NSIS_URL_INFO_ABOUT "http:////www.lightspark.org")
SET(CPACK_PACKAGE_ICON ${PROJECT_SOURCE_DIR}/media/lightspark-logo.svg)
IF(WIN32)
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "Lightspark")
SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
WriteRegStr HKCU 'Software\\\\MozillaPlugins\\\\@lightspark.github.com/Lightspark;version=1' 'Description' 'Lightspark'
WriteRegStr HKCU 'Software\\\\MozillaPlugins\\\\@lightspark.github.com/Lightspark;version=1' 'ProductName' 'Lightspark'
WriteRegStr HKCU 'Software\\\\MozillaPlugins\\\\@lightspark.github.com/Lightspark;version=1' 'Vendor' 'Lightspark Team'
WriteRegStr HKCU 'Software\\\\MozillaPlugins\\\\@lightspark.github.com/Lightspark;version=1' 'Version' '1'
WriteRegStr HKCU 'Software\\\\MozillaPlugins\\\\@lightspark.github.com/Lightspark;version=1' 'Path' '$INSTDIR\\\\nplightsparkplugin.dll'
WriteRegStr HKCU 'Software\\\\MozillaPlugins\\\\@lightspark.github.com/Lightspark;version=1\\\\MimeTypes\\\\application/x-shockwave-flash' '' ''
")
SET(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "
DeleteRegKey HKLM 'Software\\\\MozillaPlugins\\\\@lightspark.github.com/Lightspark;version=1'
")
ENDIF(WIN32)
#Must come after the definitions
INCLUDE(CPack)