config.cmake 21.5 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
include( CheckIncludeFile )
include (CheckTypeSize)
include (CheckCSourceCompiles)
include (CheckSymbolExists)
include (CheckLibraryExists)

include( ${CMAKE_SOURCE_DIR}/cmake/vlc_check_include_files.cmake )
include( ${CMAKE_SOURCE_DIR}/cmake/vlc_check_functions_exist.cmake )
include( ${CMAKE_SOURCE_DIR}/cmake/vlc_add_compile_flag.cmake )
include( ${CMAKE_SOURCE_DIR}/cmake/vlc_check_type.cmake )
include( ${CMAKE_SOURCE_DIR}/cmake/pkg_check_modules.cmake )

13
14
15
16
17
18
19
20
###########################################################
# VERSION
###########################################################

set(VLC_VERSION_MAJOR 0)
set(VLC_VERSION_MINOR 9)
set(VLC_VERSION_PATCH 0)
set(VLC_VERSION_EXTRA "-svn")
Pierre d'Herbemont's avatar
Pierre d'Herbemont committed
21
set(VLC_VERSION ${VLC_VERSION_MAJOR}.${VLC_VERSION_MINOR}.${VLC_VERSION_PATCH}${VLC_VERSION_EXTRA})
22
23

set(PACKAGE "vlc")
Pierre d'Herbemont's avatar
Pierre d'Herbemont committed
24
set(PACKAGE_VERSION "${VLC_VERSION}")
25
set(PACKAGE_STRING "vlc")
Pierre d'Herbemont's avatar
Pierre d'Herbemont committed
26
set(VERSION_MESSAGE "vlc-${VLC_VERSION}")
27
28
set(COPYRIGHT_MESSAGE "Copyright © the VideoLAN team")
set(COPYRIGHT_YEARS "2001-2008")
29
30
31
32
set(PACKAGE_VERSION_EXTRA "${VLC_VERSION_EXTRA}")
set(PACKAGE_VERSION_MAJOR "${VLC_VERSION_MAJOR}")
set(PACKAGE_VERSION_MINOR "${VLC_VERSION_MINOR}")
set(PACKAGE_VERSION_REVISION "${VLC_VERSION_PATCH}")
33

Pierre d'Herbemont's avatar
Pierre d'Herbemont committed
34
###########################################################
35
# Options
Pierre d'Herbemont's avatar
Pierre d'Herbemont committed
36
37
###########################################################

38
39
40
OPTION( ENABLE_HTTPD           "Enable httpd server" ON )
OPTION( ENABLE_VLM             "Enable vlm" ON )
OPTION( ENABLE_DYNAMIC_PLUGINS "Enable dynamic plugin" ON )
41
OPTION( UPDATE_CHECK           "Enable automatic new version checking" OFF )
42
OPTION( ENABLE_NO_SYMBOL_CHECK "Don't check symbols of modules against libvlc. (Enabling this option speeds up compilation)" OFF )
43

44
IF (NOT CMAKE_BUILD_TYPE)
45
    set(CMAKE_BUILD_TYPE "Debug" CACHE STRING  "build type determining compiler flags" FORCE )
46
47
endif(NOT CMAKE_BUILD_TYPE )

48
49
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
    set(DEBUG ON)
50
    add_definitions(-DDEBUG=1)
51
    set(NDEBUG OFF)
52
53
endif(CMAKE_BUILD_TYPE STREQUAL "Debug")

54
55
set( HAVE_DYNAMIC_PLUGINS ${ENABLE_DYNAMIC_PLUGINS})
set( LIBEXT ${CMAKE_SHARED_MODULE_SUFFIX})
Pierre d'Herbemont's avatar
Pierre d'Herbemont committed
56

57
###########################################################
58
# Headers checks
59
60
61
62
63
64
65
###########################################################

vlc_check_include_files (malloc.h stdbool.h locale.h)
vlc_check_include_files (stddef.h stdlib.h sys/stat.h)
vlc_check_include_files (stdio.h stdint.h inttypes.h)
vlc_check_include_files (signal.h unistd.h dirent.h)
vlc_check_include_files (netinet/in.h netinet/udplite.h)
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
66
vlc_check_include_files (arpa/inet.h net/if.h)
67
vlc_check_include_files (netdb.h fcntl.h sys/time.h poll.h)
68
69
70
71
vlc_check_include_files (errno.h time.h alloca.h)
vlc_check_include_files (limits.h)

vlc_check_include_files (string.h strings.h getopt.h)
72

73
74
vlc_check_include_files (dlfcn.h dl.h)

75
vlc_check_include_files (kernel/OS.h)
76
vlc_check_include_files (memory.h)
77
78
vlc_check_include_files (mach-o/dyld.h)

79
80
81
vlc_check_include_files (pthread.h)

find_package (Threads)
82
83

###########################################################
84
# Functions/structures checks
85
###########################################################
86
set(CMAKE_REQUIRED_LIBRARIES c)
87
88
89
90
91
set(CMAKE_EXTRA_INCLUDE_FILES string.h)
vlc_check_functions_exist(strcpy strcasecmp)
vlc_check_functions_exist(strcasestr strdup)
vlc_check_functions_exist(strndup stricmp strnicmp)
vlc_check_functions_exist(atof strtoll atoll lldiv)
92
93
94
vlc_check_functions_exist(strlcpy stristr strnlen strsep)
vlc_check_functions_exist(strtod strtof strtol stroul)
vlc_check_functions_exist(stroull)
95
96
97
98
99
100
101
102
103
104
set(CMAKE_EXTRA_INCLUDE_FILES)

set(CMAKE_EXTRA_INCLUDE_FILES stdio.h)
vlc_check_functions_exist(vasprintf)
set(CMAKE_EXTRA_INCLUDE_FILES)

set(CMAKE_EXTRA_INCLUDE_FILES libc.h)
vlc_check_functions_exist(fork)
set(CMAKE_EXTRA_INCLUDE_FILES)

105
106
107
108
109
110
111
112
113
114
115
set(CMAKE_EXTRA_INCLUDE_FILES stdlib.h)
vlc_check_functions_exist(putenv getenv setenv)
vlc_check_functions_exist(putenv getenv setenv)
set(CMAKE_EXTRA_INCLUDE_FILES)

set(CMAKE_EXTRA_INCLUDE_FILES stdio.h)
vlc_check_functions_exist(snprintf asprintf)
vlc_check_functions_exist(putenv getenv setenv)
set(CMAKE_EXTRA_INCLUDE_FILES)

set(CMAKE_EXTRA_INCLUDE_FILES unistd.h)
Pierre d'Herbemont's avatar
Pierre d'Herbemont committed
116
vlc_check_functions_exist(isatty getcwd getuid swab)
117
118
119
120
121
122
set(CMAKE_EXTRA_INCLUDE_FILES)

set(CMAKE_EXTRA_INCLUDE_FILES sys/stat.h)
vlc_check_functions_exist(lstat fstat stat)
set(CMAKE_EXTRA_INCLUDE_FILES)

123
set(CMAKE_EXTRA_INCLUDE_FILES arpa/inet.h)
124
vlc_check_functions_exist(inet_aton inet_ntop inet_pton)
125
126
set(CMAKE_EXTRA_INCLUDE_FILES)

127
128
129
130
set(CMAKE_EXTRA_INCLUDE_FILES sys/mman.h)
vlc_check_functions_exist(mmap)
set(CMAKE_EXTRA_INCLUDE_FILES)

131
132
set(CMAKE_REQUIRED_LIBRARIES)

133
134
check_library_exists(poll poll "" HAVE_POLL)

135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
check_c_source_compiles(
"#include <langinfo.h>
int main() { char* cs = nl_langinfo(CODESET); }"
HAVE_LANGINFO_CODESET)

vlc_check_type("struct addrinfo" "sys/socket.h;netdb.h")
if(HAVE_STRUCT_ADDRINFO)
  set(HAVE_ADDRINFO ON)
endif(HAVE_STRUCT_ADDRINFO)
vlc_check_type("struct timespec" "time.h")

check_c_source_compiles (
"#include <stdint.h> \n #ifdef UINTMAX \n #error no uintmax
 #endif
 int main() { return 0;}" HAVE_STDINT_H_WITH_UINTMAX)

151
152
check_symbol_exists(ntohl "sys/param.h"  NTOHL_IN_SYS_PARAM_H)
check_symbol_exists(scandir "dirent.h"   HAVE_SCANDIR)
153
check_symbol_exists(localtime_r "time.h" HAVE_LOCALTIME_R)
154
155
156
157
158
check_symbol_exists(alloca "alloca.h"    HAVE_ALLOCA)

check_symbol_exists(va_copy "stdarg.h"   HAVE_VACOPY)
check_symbol_exists(__va_copy "stdarg.h" HAVE___VA_COPY)

159
160
161
162
163
164
165

check_symbol_exists(getnameinfo "sys/types.h;sys/socket.h;netdb.h" HAVE_GETNAMEINFO)
check_symbol_exists(getaddrinfo "sys/types.h;sys/socket.h;netdb.h" HAVE_GETADDRINFO)
if(NOT HAVE_GETADDRINFO)
    check_library_exists(getaddrinfo nsl "" HAVE_GETADDRINFO)
endif(NOT HAVE_GETADDRINFO)

166
167
vlc_check_functions_exist(iconv)
if(NOT HAVE_ICONV)
168
    set(LIBICONV "iconv")
169
170
    check_library_exists(iconv iconv "" HAVE_ICONV)
endif(NOT HAVE_ICONV)
171
set(CMAKE_REQUIRED_LIBRARIES ${LIBICONV})
172
173
174
175
176
177
178
CHECK_C_SOURCE_COMPILES(" #include <iconv.h>
 int main() { return iconv(0, (char **)0, 0, (char**)0, 0); }" ICONV_NO_CONST)
if( ICONV_NO_CONST )
  set( ICONV_CONST "const" )
else( ICONV_NO_CONST )
  set( ICONV_CONST " ")
endif( ICONV_NO_CONST )
179
set(CMAKE_REQUIRED_LIBRARIES)
180

181
check_library_exists(rt clock_nanosleep "" HAVE_CLOCK_NANOSLEEP)
182
if (HAVE_CLOCK_NANOSLEEP)
183
    set(LIBRT "rt")
184
endif (HAVE_CLOCK_NANOSLEEP)
185

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
186
187
188
189
190
check_library_exists(m pow "" HAVE_LIBM)
if (HAVE_LIBM)
    set (LIBM "m")
endif (HAVE_LIBM)

191
192
check_symbol_exists(connect "sys/types.h;sys/socket.h" HAVE_CONNECT)
if(NOT HAVE_CONNECT)
193
    check_library_exists(connect socket "" HAVE_CONNECT)
194
195
196
197
    if(NOT HAVE_CONNECT)
        vlc_module_add_link_libraries(libvlc connect)
        vlc_module_add_link_libraries(cdda   connect)
        vlc_module_add_link_libraries(cddax  connect)
198
    endif(NOT HAVE_CONNECT)
199
200
endif(NOT HAVE_CONNECT)

201
202
203
204
205
206
207
208
209
210
211
###########################################################
# Other check
###########################################################
include( ${CMAKE_SOURCE_DIR}/cmake/vlc_test_inline.cmake )

###########################################################
# Platform check
###########################################################
if(APPLE)
    include( ${CMAKE_SOURCE_DIR}/cmake/vlc_find_frameworks.cmake )

212
213
214
215
    # Mac OS X (10.4 and 10.5)  can't poll a tty properly
    # So we deactivate its uses
    set(HAVE_POLL OFF)

216
    if(ENABLE_NO_SYMBOL_CHECK)
217
218
219
        set(DYNAMIC_LOOKUP "-undefined dynamic_lookup")
    else(ENABLE_NO_SYMBOL_CHECK)
        set(DYNAMIC_LOOKUP)
220
    endif(ENABLE_NO_SYMBOL_CHECK)
221
    set(CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS
222
223
224
     "${CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS} ${DYNAMIC_LOOKUP}")
    set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS
     "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} ${DYNAMIC_LOOKUP}")
225

226
227
228
    # For pre-10.5
    set( CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_C_FLAGS} -fno-common")

229
    set(SYS_DARWIN 1)
230
    add_definitions(-std=gnu99) # Hack for obj-c files to be compiled with gnu99
231
232
    vlc_enable_modules(macosx minimal_macosx opengllayer
                       access_eyetv quartztext auhal)
233

234
235
236
    # On Pre-10.5
    vlc_module_add_link_flags (ffmpeg "-read_only_relocs warning")

237
238
239
   # vlc_check_include_files (ApplicationServices/ApplicationServices.h)
   # vlc_check_include_files (Carbon/Carbon.h)
   # vlc_check_include_files (CoreAudio/CoreAudio.h)
240
241
242
243

   # check_symbol_exists (CFLocaleCopyCurrent "CoreFoundation/CoreFoundation.h" "" HAVE_CFLOCALECOPYCURRENT)
   # check_symbol_exists (CFPreferencesCopyAppValue "CoreFoundation/CoreFoundation.h" "" HAVE_CFPREFERENCESCOPYAPPVALUE)

244
    vlc_find_frameworks(Cocoa Carbon OpenGL AGL IOKit Quicktime
245
246
                        WebKit QuartzCore Foundation ApplicationServices
                        CoreAudio AudioUnit AudioToolbox)
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
    vlc_module_add_link_libraries(macosx
        ${Cocoa_FRAMEWORKS}
        ${IOKit_FRAMEWORKS}
        ${OpenGL_FRAMEWORKS}
        ${AGL_FRAMEWORKS}
        ${Quicktime_FRAMEWORKS}
        ${WebKit_FRAMEWORKS})
    vlc_module_add_link_libraries(minimal_macosx
        ${Cocoa_FRAMEWORKS}
        ${Carbon_FRAMEWORKS}
        ${OpenGL_FRAMEWORKS}
        ${AGL_FRAMEWORKS})
    vlc_module_add_link_libraries(access_eyetv
        ${Foundation_FRAMEWORKS})
    vlc_module_add_link_libraries(opengllayer
         ${Cocoa_FRAMEWORKS}
         ${QuartzCore_FRAMEWORKS}
         ${OpenGL_FRAMEWORKS} )
    vlc_module_add_link_libraries(quartztext
         ${Carbon_FRAMEWORKS}
         ${ApplicationServices_FRAMEWORKS} )
268
269
270
271
272
    vlc_module_add_link_libraries(auhal
         ${Carbon_FRAMEWORKS}
         ${CoreAudio_FRAMEWORKS}
         ${AudioUnit_FRAMEWORKS}
         ${AudioToolbox_FRAMEWORKS} )
Pierre d'Herbemont's avatar
Pierre d'Herbemont committed
273
274
    vlc_module_add_link_libraries(mp4 ${IOKit_FRAMEWORKS} )
    vlc_module_add_link_libraries(mkv ${IOKit_FRAMEWORKS} )
275
276
277

    add_executable(VLC MACOSX_BUNDLE src/vlc.c)
    target_link_libraries(VLC libvlc)
278
    set( MacOS ${CMAKE_CURRENT_BINARY_DIR}/VLC.app/Contents/MacOS )
279
    add_custom_command(
280
281
282
283
284
        TARGET VLC
        POST_BUILD
        COMMAND rm -Rf ${CMAKE_CURRENT_BINARY_DIR}/tmp
        COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/tmp/modules/gui/macosx
        COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/tmp/extras/package/macosx
285
286
        COMMAND for i in vlc.xcodeproj Resources README.MacOSX.rtf\; do cp -R ${CMAKE_CURRENT_SOURCE_DIR}/extras/package/macosx/$$i ${CMAKE_CURRENT_BINARY_DIR}/tmp/extras/package/macosx\; done
        COMMAND for i in AUTHORS COPYING THANKS\;do cp ${CMAKE_CURRENT_SOURCE_DIR}/$$i ${CMAKE_CURRENT_BINARY_DIR}/tmp\; done
287
288
289
290
        COMMAND for i in AppleRemote.h AppleRemote.m about.h about.m applescript.h applescript.m controls.h controls.m equalizer.h equalizer.m intf.h intf.m macosx.m misc.h misc.m open.h open.m output.h output.m playlist.h playlist.m playlistinfo.h playlistinfo.m prefs_widgets.h prefs_widgets.m prefs.h prefs.m vout.h voutqt.m voutgl.m wizard.h wizard.m extended.h extended.m bookmarks.h bookmarks.m sfilters.h sfilters.m update.h update.m interaction.h interaction.m embeddedwindow.h embeddedwindow.m fspanel.h fspanel.m vout.m\; do cp ${CMAKE_CURRENT_SOURCE_DIR}/modules/gui/macosx/$$i ${CMAKE_CURRENT_BINARY_DIR}/tmp/modules/gui/macosx\; done
        COMMAND cd ${CMAKE_CURRENT_BINARY_DIR}/tmp/extras/package/macosx && xcodebuild -target vlc | grep -vE '^\([ \\t]|$$\)' && cd ../../../../ && cp ${CMAKE_CURRENT_BINARY_DIR}/tmp/extras/package/macosx/build/Default/VLC.bundle/Contents/Info.plist ${CMAKE_CURRENT_BINARY_DIR}/VLC.app/Contents && cp -R ${CMAKE_CURRENT_BINARY_DIR}/tmp/extras/package/macosx/build/Default/VLC.bundle/Contents/Resources/English.lproj ${CMAKE_CURRENT_BINARY_DIR}/VLC.app/Contents/Resources
        COMMAND cp -r ${CMAKE_CURRENT_SOURCE_DIR}/extras/package/macosx/Resources ${CMAKE_CURRENT_BINARY_DIR}/VLC.app/Contents
        COMMAND find -d ${CMAKE_CURRENT_BINARY_DIR}/VLC.app/Contents/Resources -type d -name \\.svn -exec rm -rf {} "\;"
291
        COMMAND rm -rf ${MacOS}/modules ${MacOS}/locale ${MacOS}/share
292
        COMMAND ln -s ${CMAKE_CURRENT_SOURCE_DIR}/share ${MacOS}/share
293
        COMMAND ln -s ${CMAKE_CURRENT_BINARY_DIR}/modules ${MacOS}/modules
294
295
        COMMAND find ${CMAKE_BINARY_DIR}/po -name *.gmo -exec sh -c \"mkdir -p ${MacOS}/locale/\\`basename {}|sed s/\\.gmo//\\`/LC_MESSAGES\; ln -s {} ${MacOS}/locale/\\`basename {}|sed s/\\.gmo//\\`/LC_MESSAGES/vlc.mo\" "\;"
        COMMAND ln -sf VLC ${MacOS}/clivlc #useless?
296
        COMMAND printf "APPLVLC#" > ${CMAKE_CURRENT_BINARY_DIR}/VLC.app/Contents/PkgInfo
297
    )
298
    set( MacOS )
299
300
301
302

endif(APPLE)

###########################################################
303
# info
304
305
306
307
308
309
310
###########################################################

macro(command_to_configvar command var)
 execute_process(
  COMMAND sh -c "${command}"
  OUTPUT_VARIABLE ${var}
  OUTPUT_STRIP_TRAILING_WHITESPACE)
311
 string( REPLACE "\n" "\\n" ${var} "${${var}}")
312
313
314
315
316
317
endmacro(command_to_configvar)

command_to_configvar( "whoami" VLC_COMPILE_BY )
command_to_configvar( "hostname" VLC_COMPILE_HOST )
command_to_configvar( "hostname" VLC_COMPILE_DOMAIN )
command_to_configvar( "${CMAKE_C_COMPILER} --version" VLC_COMPILER )
318
# FIXME: WTF? this is not the configure line!
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
command_to_configvar( "${CMAKE_C_COMPILER} --version" CONFIGURE_LINE )
set( VLC_COMPILER "${CMAKE_C_COMPILER}" )


###########################################################
# Modules: Following are all listed in options
###########################################################

# This module will be enabled but user could disabled it
vlc_enable_modules(dummy logger memcpy)
vlc_enable_modules(mpgv mpga m4v m4a h264 vc1 demux_cdg cdg ps pva avi mp4 rawdv rawvid nsv real aiff mjpeg demuxdump flacsys tta)
vlc_enable_modules(cvdsub svcdsub spudec subsdec subsusf t140 dvbsub cc mpeg_audio lpcm a52 dts cinepak flac)
vlc_enable_modules(deinterlace invert adjust transform wave ripple psychedelic gradient motionblur rv32 rotate noise grain extract sharpen seamcarving)
vlc_enable_modules(converter_fixed mono)
vlc_enable_modules(trivial_resampler ugly_resampler)
vlc_enable_modules(trivial_channel_mixer trivial_mixer)
vlc_enable_modules(playlist export nsc xtag)
vlc_enable_modules(i420_rgb grey_yuv rawvideo blend scale image logo magnify puzzle colorthres)
vlc_enable_modules(wav araw subtitle vobsub adpcm a52sys dtssys au ty voc xa nuv smf)
vlc_enable_modules(access_directory access_file access_udp access_tcp)
vlc_enable_modules(access_http access_mms access_ftp)
vlc_enable_modules(access_filter_bandwidth)
vlc_enable_modules(packetizer_mpegvideo packetizer_h264)
vlc_enable_modules(packetizer_mpeg4video packetizer_mpeg4audio)
vlc_enable_modules(packetizer_vc1)
vlc_enable_modules(spatializer)
345
vlc_enable_modules(asf)
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360

if(NOT mingwce)
   set(enabled ON)
endif(NOT mingwce)
vlc_register_modules(${enabled} access_fake access_filter_timeshift access_filter_record access_filter_dump)
vlc_register_modules(${enabled} gestures rc telnet hotkeys showintf marq podcast shout sap fake folder)
vlc_register_modules(${enabled} rss mosaic wall motiondetect clone crop erase bluescreen alphamask gaussianblur)
vlc_register_modules(${enabled} i420_yuy2 i422_yuy2 i420_ymga i422_i420 yuy2_i422 yuy2_i420 chroma_chain)
vlc_register_modules(${enabled} aout_file linear_resampler bandlimited_resampler)
vlc_register_modules(${enabled} float32_mixer spdif_mixer simple_channel_mixer)
vlc_register_modules(${enabled} dolby_surround_decoder headphone_channel_mixer normvol equalizer param_eq)
vlc_register_modules(${enabled} converter_float a52tospdif dtstospdif audio_format)
set(enabled)

if(NOT WIN32)
361
   vlc_enable_modules(screensaver)
362
363
endif(NOT WIN32)

364
365
366
367
# This module is disabled because the CMakeList.txt which
# is generated isn't correct. We'll put that back
# when cmake will be accepted as default build system
vlc_disable_modules(motion)
368

369
370
371
###########################################################
# libraries
###########################################################
372
373
374
375
376
377
378
379
380
381
382
OPTION( ENABLE_CONTRIB "Attempt to use VLC contrib system to get the third-party libraries" ON )
if(ENABLE_CONTRIB)
  set( CONTRIB_INCLUDE ${CMAKE_SOURCE_DIR}/extras/contrib/include)
  set( CONTRIB_LIB ${CMAKE_SOURCE_DIR}/extras/contrib/lib)
  set( CONTRIB_PROGRAM ${CMAKE_SOURCE_DIR}/extras/contrib/bin)
  set( CMAKE_LIBRARY_PATH ${CONTRIB_LIB} ${CMAKE_LIBRARY_PATH} )
  set( CMAKE_PROGRAM_PATH ${CONTRIB_PROGRAM} ${CMAKE_PROGRAM_PATH} )
  set( CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -L${CONTRIB_LIB}" )
  set( CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -L${CONTRIB_LIB}" )
  set( CMAKE_SHARED_MODULE_CREATE_C_FLAGS "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -L${CONTRIB_LIB}" )
  set( CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS "${CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS} -L${CONTRIB_LIB}" )
383
384
  set( CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -L${CONTRIB_LIB}" )
  set( CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -L${CONTRIB_LIB}" )
385
386
  add_definitions(-I${CONTRIB_INCLUDE})
endif(ENABLE_CONTRIB)
387

388
389
390
set(CMAKE_REQUIRED_INCLUDES ${CONTRIB_INCLUDE})

#fixme: use find_package(cddb 0.9.5)
391
392
pkg_check_modules(LIBCDDB libcddb>=0.9.5)
if(${LIBCDDB_FOUND})
393
394
  vlc_module_add_link_libraries(cdda ${LIBCDDB_LIBRARIES})
  vlc_add_module_compile_flag(cdda ${LIBCDDB_CFLAGS} )
395
396
endif(${LIBCDDB_FOUND})

397
find_package(Dlopen)
398
399
set(HAVE_DL_DLOPEN ${Dlopen_FOUND})

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
# Advanced Linux Sound Architecture (ALSA)
pkg_check_modules(ALSA alsa>=1.0.0-rc4)
if (${ALSA_FOUND})
  set (HAVE_ALSA_NEW_API "1")
else (${ALSA_FOUND})
  pkg_check_modules(ALSA alsa)
endif (${ALSA_FOUND})

if (${ALSA_FOUND})
  set (HAVE_ALSA "1")
  vlc_enable_modules(alsa)
  vlc_add_module_compile_flag(alsa ${ALSA_CFLAGS})
  vlc_module_add_link_libraries(alsa ${ALSA_LIBRARIES})
endif (${ALSA_FOUND})

# Open Sound System (OSS)
# TODO

418
find_package(FFmpeg)
419
420
if(FFmpeg_FOUND)
  vlc_check_include_files (ffmpeg/avcodec.h)
421
422
  vlc_check_include_files (ffmpeg/avutil.h)
  vlc_check_include_files (ffmpeg/swscale.h)
423
  check_include_files ("stdint.h;postproc/postprocess.h" HAVE_POSTPROC_POSTPROCESS_H)
424
425
426
427
428
429
430
431
432
  vlc_enable_modules(ffmpeg)
  vlc_add_module_compile_flag(ffmpeg ${FFmpeg_CFLAGS} )
  vlc_module_add_link_libraries(ffmpeg ${FFmpeg_LIBRARIES})
endif(FFmpeg_FOUND)

find_package(Lua)
if(Lua_FOUND)
  set(HAVE_LUA TRUE)
  vlc_enable_modules(lua)
433
  vlc_check_include_files (lua.h lualib.h)
434
435
436
  vlc_add_module_compile_flag(lua ${Lua_CFLAGS} )
  vlc_module_add_link_libraries(lua ${Lua_LIBRARIES})
endif(Lua_FOUND)
437

438
find_package(Qt4)
Pierre d'Herbemont's avatar
Pierre d'Herbemont committed
439
if(QT4_FOUND)
440
  set(HAVE_QT4 TRUE)
441
  include_directories(${QT_INCLUDES})
442
443
  vlc_check_include_files (qt.h)
  vlc_enable_modules(qt4)
Pierre d'Herbemont's avatar
Pierre d'Herbemont committed
444
  vlc_add_module_compile_flag(qt4 ${QT_CFLAGS} )
445
  vlc_module_add_link_libraries(qt4 ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY})
Pierre d'Herbemont's avatar
Pierre d'Herbemont committed
446

447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
  # Define our own qt4_wrap_ui macro to match wanted behaviour
  MACRO (VLC_QT4_WRAP_UI outfiles )
    FOREACH (it ${ARGN})
     string(REPLACE ".ui" ".h" outfile "${it}")
      GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
      SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/${outfile})
      ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
        COMMAND mkdir -p `dirname ${outfile}`
        COMMAND ${QT_UIC_EXECUTABLE}
        ARGS -o ${outfile} ${infile}
        MAIN_DEPENDENCY ${infile})
      SET(${outfiles} ${${outfiles}} ${outfile})
    ENDFOREACH (it)
  ENDMACRO (VLC_QT4_WRAP_UI)

462
  MACRO (VLC_QT4_GENERATE_MOC outfiles flags )
463
    string(REGEX MATCHALL "[^\\ ]+" flags_list ${flags})
464
    FOREACH (it ${ARGN})
465
      string(REPLACE ".hpp" ".moc.cpp" outfile "${it}")
466
467
468
469
      GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
      SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/${outfile})
      ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
        COMMAND mkdir -p `dirname ${outfile}`
470
471
472
473
474
475
        COMMAND ${QT_MOC_EXECUTABLE} 
        ARGS ${flags_list}
        ARGS -I ${CMAKE_BINARY_DIR}/include
        ARGS -o ${outfile} ${infile}
        MAIN_DEPENDENCY ${it}
        )
476
477
478
479
480
      SET(${outfiles} ${${outfiles}} ${outfile})
    ENDFOREACH (it)
  ENDMACRO (VLC_QT4_GENERATE_MOC)


Pierre d'Herbemont's avatar
Pierre d'Herbemont committed
481
endif(QT4_FOUND)
482

Pierre d'Herbemont's avatar
Pierre d'Herbemont committed
483
484
485
find_package(OpenGL)
if(OPENGL_FOUND)
  vlc_enable_modules(opengl)
486
487
488
  vlc_check_include_files (gl/gl.h)
  vlc_check_include_files (gl/glu.h)
  vlc_check_include_files (gl/glx.h)
Pierre d'Herbemont's avatar
Pierre d'Herbemont committed
489
490
491
492
  vlc_add_module_compile_flag(opengl ${OPENGL_CFLAGS})
  vlc_module_add_link_libraries(opengl ${OPENGL_LIBRARIES})
endif(OPENGL_FOUND)

Pierre d'Herbemont's avatar
Pierre d'Herbemont committed
493
494
495
496
497
498
499
500
find_package(Matroska 0.7.7)
if(Matroska_FOUND)
  vlc_enable_modules(mkv)
  vlc_check_include_files (matroska/KaxAttachments.h)
  vlc_check_include_files (matroska/KaxVersion.h)
  vlc_module_add_link_libraries(mkv ${Matroska_LIBRARIES})
endif(Matroska_FOUND)

Pierre d'Herbemont's avatar
Pierre d'Herbemont committed
501
find_package(Live555)
Pierre d'Herbemont's avatar
Pierre d'Herbemont committed
502
503
504
505
506
507
if(Live555_FOUND)
  vlc_enable_modules(live555)
  vlc_add_module_compile_flag(live555 ${Live555_CFLAGS})
  vlc_module_add_link_libraries(live555 ${Live555_LIBRARIES})
endif(Live555_FOUND)

Pierre d'Herbemont's avatar
Pierre d'Herbemont committed
508
509
510
511
512
513
find_package(Curses)
if(CURSES_LIBRARIES)
  vlc_enable_modules(ncurses)
  vlc_module_add_link_libraries(ncurses ${CURSES_LIBRARIES})
endif(CURSES_LIBRARIES)

Pierre d'Herbemont's avatar
Pierre d'Herbemont committed
514
515
516
517
518
519
520
521
find_package(X11)
if(X11_FOUND)
  vlc_enable_modules(x11 panoramix)
  vlc_check_include_files (X11/Xlib.h)
  vlc_module_add_link_libraries(x11       ${X11_LIBRARIES})
  vlc_module_add_link_libraries(panoramix ${X11_LIBRARIES})
endif(X11_FOUND)

522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
find_package(Mpeg2)
if(Mpeg2_FOUND)
  vlc_enable_modules(libmpeg2)
  check_include_files ("stdint.h;mpeg2dec/mpeg2.h" HAVE_MPEG2DEC_MPEG2_H)
  vlc_module_add_link_libraries(libmpeg2 ${Mpeg2_LIBRARIES})
endif(Mpeg2_FOUND)

find_package(Dvbpsi)
if(Dvbpsi_FOUND)
  vlc_enable_modules(ts)
  set(CMAKE_REQUIRED_INCLUDES ${CONTRIB_INCLUDE})
  check_include_files ("stdint.h;dvbpsi/dvbpsi.h;dvbpsi/demux.h;dvbpsi/descriptor.h;dvbpsi/pat.h;dvbpsi/pmt.h;dvbpsi/sdt.h;dvbpsi/dr.h" HAVE_DVBPSI_DR_H)
  vlc_module_add_link_libraries(ts ${Dvbpsi_LIBRARIES})
endif(Dvbpsi_FOUND)



539
540
set(CMAKE_REQUIRED_INCLUDES)

541
542
543
###########################################################
# Final configuration
###########################################################
Pierre d'Herbemont's avatar
cmake:    
Pierre d'Herbemont committed
544
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/include/config.h)