]> git.sesse.net Git - vlc/blob - extras/buildsystem/cmake/include/config.cmake
f658ce53f46298d2060d6f9bdbe0017191b0f6bd
[vlc] / extras / buildsystem / cmake / include / config.cmake
1 include( CheckIncludeFile )
2 include (CheckTypeSize)
3 include (CheckCSourceCompiles)
4 include (CheckSymbolExists)
5 include (CheckLibraryExists)
6
7 include( ${CMAKE_SOURCE_DIR}/cmake/vlc_check_include_files.cmake )
8 include( ${CMAKE_SOURCE_DIR}/cmake/vlc_check_functions_exist.cmake )
9 include( ${CMAKE_SOURCE_DIR}/cmake/vlc_add_compile_flag.cmake )
10 include( ${CMAKE_SOURCE_DIR}/cmake/vlc_check_type.cmake )
11 include( ${CMAKE_SOURCE_DIR}/cmake/pkg_check_modules.cmake )
12
13 ###########################################################
14 # VERSION
15 ###########################################################
16
17 set(VLC_VERSION_MAJOR 0)
18 set(VLC_VERSION_MINOR 9)
19 set(VLC_VERSION_PATCH 0)
20 set(VLC_VERSION_EXTRA "-svn")
21 set(VLC_VERSION ${VLC_VERSION_MAJOR}.${VLC_VERSION_MINOR}.${VLC_VERSION_PATCH}${VLC_VERSION_EXTRA})
22
23 set(PACKAGE "vlc")
24 set(PACKAGE_VERSION "${VLC_VERSION}")
25 set(PACKAGE_STRING "vlc")
26 set(VERSION_MESSAGE "vlc-${VLC_VERSION}")
27 set(COPYRIGHT_MESSAGE "Copyright © the VideoLAN team")
28 set(COPYRIGHT_YEARS "2001-2008")
29
30 ###########################################################
31 # Options
32 ###########################################################
33
34 OPTION( ENABLE_HTTPD           "Enable httpd server" ON )
35 OPTION( ENABLE_VLM             "Enable vlm" ON )
36 OPTION( ENABLE_DYNAMIC_PLUGINS "Enable dynamic plugin" ON )
37 OPTION( UPDATE_CHECK           "Enable automatic new version checking" OFF )
38 OPTION( ENABLE_NO_SYMBOL_CHECK "Don't check symbols of modules against libvlc. (Enabling this option speeds up compilation)" OFF )
39
40 IF (NOT CMAKE_BUILD_TYPE)
41     set(CMAKE_BUILD_TYPE "Debug" CACHE STRING  "build type determining compiler flags" FORCE )
42 endif(NOT CMAKE_BUILD_TYPE )
43
44 if(CMAKE_BUILD_TYPE STREQUAL "Debug")
45     set(DEBUG ON)
46     add_definitions(-DDEBUG=1)
47     set(NDEBUG OFF)
48 endif(CMAKE_BUILD_TYPE STREQUAL "Debug")
49
50 set( HAVE_DYNAMIC_PLUGINS ${ENABLE_DYNAMIC_PLUGINS})
51 set( LIBEXT ${CMAKE_SHARED_MODULE_SUFFIX})
52
53 ###########################################################
54 # Headers checks
55 ###########################################################
56
57 vlc_check_include_files (malloc.h stdbool.h locale.h)
58 vlc_check_include_files (stddef.h stdlib.h sys/stat.h)
59 vlc_check_include_files (stdio.h stdint.h inttypes.h)
60 vlc_check_include_files (signal.h unistd.h dirent.h)
61 vlc_check_include_files (netinet/in.h netinet/udplite.h)
62 vlc_check_include_files (arpa/inet.h net/if.h)
63 vlc_check_include_files (netdb.h fcntl.h sys/time.h poll.h)
64 vlc_check_include_files (errno.h time.h alloca.h)
65 vlc_check_include_files (limits.h)
66
67 vlc_check_include_files (string.h strings.h getopt.h)
68
69 vlc_check_include_files (dlfcn.h dl.h)
70
71 vlc_check_include_files (kernel/OS.h)
72 vlc_check_include_files (memory.h)
73 vlc_check_include_files (mach-o/dyld.h)
74
75 vlc_check_include_files (pthread.h)
76
77 find_package (Threads)
78
79 ###########################################################
80 # Functions/structures checks
81 ###########################################################
82 set(CMAKE_REQUIRED_LIBRARIES c)
83 set(CMAKE_EXTRA_INCLUDE_FILES string.h)
84 vlc_check_functions_exist(strcpy strcasecmp)
85 vlc_check_functions_exist(strcasestr strdup)
86 vlc_check_functions_exist(strndup stricmp strnicmp)
87 vlc_check_functions_exist(atof strtoll atoll lldiv)
88 vlc_check_functions_exist(strlcpy stristr strnlen strsep)
89 vlc_check_functions_exist(strtod strtof strtol stroul)
90 vlc_check_functions_exist(stroull)
91 set(CMAKE_EXTRA_INCLUDE_FILES)
92
93 set(CMAKE_EXTRA_INCLUDE_FILES stdio.h)
94 vlc_check_functions_exist(vasprintf)
95 set(CMAKE_EXTRA_INCLUDE_FILES)
96
97 set(CMAKE_EXTRA_INCLUDE_FILES libc.h)
98 vlc_check_functions_exist(fork)
99 set(CMAKE_EXTRA_INCLUDE_FILES)
100
101 set(CMAKE_EXTRA_INCLUDE_FILES stdlib.h)
102 vlc_check_functions_exist(putenv getenv setenv)
103 vlc_check_functions_exist(putenv getenv setenv)
104 set(CMAKE_EXTRA_INCLUDE_FILES)
105
106 set(CMAKE_EXTRA_INCLUDE_FILES stdio.h)
107 vlc_check_functions_exist(snprintf asprintf)
108 vlc_check_functions_exist(putenv getenv setenv)
109 set(CMAKE_EXTRA_INCLUDE_FILES)
110
111 set(CMAKE_EXTRA_INCLUDE_FILES unistd.h)
112 vlc_check_functions_exist(isatty getcwd getuid swab)
113 set(CMAKE_EXTRA_INCLUDE_FILES)
114
115 set(CMAKE_EXTRA_INCLUDE_FILES sys/stat.h)
116 vlc_check_functions_exist(lstat fstat stat)
117 set(CMAKE_EXTRA_INCLUDE_FILES)
118
119 set(CMAKE_EXTRA_INCLUDE_FILES arpa/inet.h)
120 vlc_check_functions_exist(inet_aton inet_ntop inet_pton)
121 set(CMAKE_EXTRA_INCLUDE_FILES)
122
123 set(CMAKE_EXTRA_INCLUDE_FILES sys/mman.h)
124 vlc_check_functions_exist(mmap)
125 set(CMAKE_EXTRA_INCLUDE_FILES)
126
127 set(CMAKE_REQUIRED_LIBRARIES)
128
129 check_library_exists(poll poll "" HAVE_POLL)
130
131 check_c_source_compiles(
132 "#include <langinfo.h>
133 int main() { char* cs = nl_langinfo(CODESET); }"
134 HAVE_LANGINFO_CODESET)
135
136 vlc_check_type("struct addrinfo" "sys/socket.h;netdb.h")
137 if(HAVE_STRUCT_ADDRINFO)
138   set(HAVE_ADDRINFO ON)
139 endif(HAVE_STRUCT_ADDRINFO)
140 vlc_check_type("struct timespec" "time.h")
141
142 check_c_source_compiles (
143 "#include <stdint.h> \n #ifdef UINTMAX \n #error no uintmax
144  #endif
145  int main() { return 0;}" HAVE_STDINT_H_WITH_UINTMAX)
146
147 check_symbol_exists(ntohl "sys/param.h"  NTOHL_IN_SYS_PARAM_H)
148 check_symbol_exists(scandir "dirent.h"   HAVE_SCANDIR)
149 check_symbol_exists(localtime_r "time.h" HAVE_LOCALTIME_R)
150 check_symbol_exists(alloca "alloca.h"    HAVE_ALLOCA)
151
152 check_symbol_exists(va_copy "stdarg.h"   HAVE_VACOPY)
153 check_symbol_exists(__va_copy "stdarg.h" HAVE___VA_COPY)
154
155
156 check_symbol_exists(getnameinfo "sys/types.h;sys/socket.h;netdb.h" HAVE_GETNAMEINFO)
157 check_symbol_exists(getaddrinfo "sys/types.h;sys/socket.h;netdb.h" HAVE_GETADDRINFO)
158 if(NOT HAVE_GETADDRINFO)
159     check_library_exists(getaddrinfo nsl "" HAVE_GETADDRINFO)
160 endif(NOT HAVE_GETADDRINFO)
161
162 vlc_check_functions_exist(iconv)
163 if(NOT HAVE_ICONV)
164     set(LIBICONV "iconv")
165     check_library_exists(iconv iconv "" HAVE_ICONV)
166 endif(NOT HAVE_ICONV)
167 set(CMAKE_REQUIRED_LIBRARIES ${LIBICONV})
168 CHECK_C_SOURCE_COMPILES(" #include <iconv.h>
169  int main() { return iconv(0, (char **)0, 0, (char**)0, 0); }" ICONV_NO_CONST)
170 if( ICONV_NO_CONST )
171   set( ICONV_CONST "const" )
172 else( ICONV_NO_CONST )
173   set( ICONV_CONST " ")
174 endif( ICONV_NO_CONST )
175 set(CMAKE_REQUIRED_LIBRARIES)
176
177 check_library_exists(rt clock_nanosleep "" HAVE_CLOCK_NANOSLEEP)
178 if (HAVE_CLOCK_NANOSLEEP)
179     set(LIBRT "rt")
180 endif (HAVE_CLOCK_NANOSLEEP)
181
182 check_library_exists(m pow "" HAVE_LIBM)
183 if (HAVE_LIBM)
184     set (LIBM "m")
185 endif (HAVE_LIBM)
186
187 check_symbol_exists(connect "sys/types.h;sys/socket.h" HAVE_CONNECT)
188 if(NOT HAVE_CONNECT)
189     check_library_exists(connect socket "" HAVE_CONNECT)
190     if(NOT HAVE_CONNECT)
191         vlc_module_add_link_libraries(libvlc connect)
192         vlc_module_add_link_libraries(cdda   connect)
193         vlc_module_add_link_libraries(cddax  connect)
194     endif(NOT HAVE_CONNECT)
195 endif(NOT HAVE_CONNECT)
196
197 ###########################################################
198 # Other check
199 ###########################################################
200 include( ${CMAKE_SOURCE_DIR}/cmake/vlc_test_inline.cmake )
201
202 ###########################################################
203 # Platform check
204 ###########################################################
205 if(APPLE)
206     include( ${CMAKE_SOURCE_DIR}/cmake/vlc_find_frameworks.cmake )
207
208     if(ENABLE_NO_SYMBOL_CHECK)
209         set(DYNAMIC_LOOKUP "-undefined dynamic_lookup")
210     else(ENABLE_NO_SYMBOL_CHECK)
211         set(DYNAMIC_LOOKUP)
212     endif(ENABLE_NO_SYMBOL_CHECK)
213     set(CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS
214      "${CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS} ${DYNAMIC_LOOKUP}")
215     set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS
216      "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} ${DYNAMIC_LOOKUP}")
217
218     # For pre-10.5
219     set( CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_C_FLAGS} -fno-common")
220
221     set(SYS_DARWIN 1)
222     add_definitions(-std=gnu99) # Hack for obj-c files to be compiled with gnu99
223     vlc_enable_modules(macosx minimal_macosx opengllayer
224                        access_eyetv quartztext auhal)
225
226     # On Pre-10.5
227     vlc_module_add_link_flags (ffmpeg "-read_only_relocs warning")
228
229    # vlc_check_include_files (ApplicationServices/ApplicationServices.h)
230    # vlc_check_include_files (Carbon/Carbon.h)
231    # vlc_check_include_files (CoreAudio/CoreAudio.h)
232
233    # check_symbol_exists (CFLocaleCopyCurrent "CoreFoundation/CoreFoundation.h" "" HAVE_CFLOCALECOPYCURRENT)
234    # check_symbol_exists (CFPreferencesCopyAppValue "CoreFoundation/CoreFoundation.h" "" HAVE_CFPREFERENCESCOPYAPPVALUE)
235
236     vlc_find_frameworks(Cocoa Carbon OpenGL AGL IOKit Quicktime
237                         WebKit QuartzCore Foundation ApplicationServices
238                         CoreAudio AudioUnit AudioToolbox)
239     vlc_module_add_link_libraries(macosx
240         ${Cocoa_FRAMEWORKS}
241         ${IOKit_FRAMEWORKS}
242         ${OpenGL_FRAMEWORKS}
243         ${AGL_FRAMEWORKS}
244         ${Quicktime_FRAMEWORKS}
245         ${WebKit_FRAMEWORKS})
246     vlc_module_add_link_libraries(minimal_macosx
247         ${Cocoa_FRAMEWORKS}
248         ${Carbon_FRAMEWORKS}
249         ${OpenGL_FRAMEWORKS}
250         ${AGL_FRAMEWORKS})
251     vlc_module_add_link_libraries(access_eyetv
252         ${Foundation_FRAMEWORKS})
253     vlc_module_add_link_libraries(opengllayer
254          ${Cocoa_FRAMEWORKS}
255          ${QuartzCore_FRAMEWORKS}
256          ${OpenGL_FRAMEWORKS} )
257     vlc_module_add_link_libraries(quartztext
258          ${Carbon_FRAMEWORKS}
259          ${ApplicationServices_FRAMEWORKS} )
260     vlc_module_add_link_libraries(auhal
261          ${Carbon_FRAMEWORKS}
262          ${CoreAudio_FRAMEWORKS}
263          ${AudioUnit_FRAMEWORKS}
264          ${AudioToolbox_FRAMEWORKS} )
265     vlc_module_add_link_libraries(mp4 ${IOKit_FRAMEWORKS} )
266     vlc_module_add_link_libraries(mkv ${IOKit_FRAMEWORKS} )
267
268     add_executable(VLC MACOSX_BUNDLE src/vlc.c)
269     target_link_libraries(VLC libvlc)
270     set( MacOS ${CMAKE_CURRENT_BINARY_DIR}/VLC.app/Contents/MacOS )
271     add_custom_command(
272         TARGET VLC
273         POST_BUILD
274         COMMAND rm -Rf ${CMAKE_CURRENT_BINARY_DIR}/tmp
275         COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/tmp/modules/gui/macosx
276         COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/tmp/extras/package/macosx
277         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
278         COMMAND for i in AUTHORS COPYING THANKS\;do cp ${CMAKE_CURRENT_SOURCE_DIR}/$$i ${CMAKE_CURRENT_BINARY_DIR}/tmp\; done
279         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
280         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
281         COMMAND cp -r ${CMAKE_CURRENT_SOURCE_DIR}/extras/package/macosx/Resources ${CMAKE_CURRENT_BINARY_DIR}/VLC.app/Contents
282         COMMAND find -d ${CMAKE_CURRENT_BINARY_DIR}/VLC.app/Contents/Resources -type d -name \\.svn -exec rm -rf {} "\;"
283         COMMAND rm -rf ${MacOS}/modules ${MacOS}/locale ${MacOS}/share
284         COMMAND ln -s ${CMAKE_CURRENT_SOURCE_DIR}/share ${MacOS}/share
285         COMMAND ln -s ${CMAKE_CURRENT_BINARY_DIR}/modules ${MacOS}/modules
286         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\" "\;"
287         COMMAND ln -sf VLC ${MacOS}/clivlc #useless?
288         COMMAND printf "APPLVLC#" > ${CMAKE_CURRENT_BINARY_DIR}/VLC.app/Contents/PkgInfo
289     )
290     set( MacOS )
291
292 endif(APPLE)
293
294 ###########################################################
295 # info
296 ###########################################################
297
298 macro(command_to_configvar command var)
299  execute_process(
300   COMMAND sh -c "${command}"
301   OUTPUT_VARIABLE ${var}
302   OUTPUT_STRIP_TRAILING_WHITESPACE)
303  string( REPLACE "\n" "\\n" ${var} "${${var}}")
304 endmacro(command_to_configvar)
305
306 command_to_configvar( "whoami" VLC_COMPILE_BY )
307 command_to_configvar( "hostname" VLC_COMPILE_HOST )
308 command_to_configvar( "hostname" VLC_COMPILE_DOMAIN )
309 command_to_configvar( "${CMAKE_C_COMPILER} --version" VLC_COMPILER )
310 # FIXME: WTF? this is not the configure line!
311 command_to_configvar( "${CMAKE_C_COMPILER} --version" CONFIGURE_LINE )
312 set( VLC_COMPILER "${CMAKE_C_COMPILER}" )
313
314
315 ###########################################################
316 # Modules: Following are all listed in options
317 ###########################################################
318
319 # This module will be enabled but user could disabled it
320 vlc_enable_modules(dummy logger memcpy)
321 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)
322 vlc_enable_modules(cvdsub svcdsub spudec subsdec subsusf t140 dvbsub cc mpeg_audio lpcm a52 dts cinepak flac)
323 vlc_enable_modules(deinterlace invert adjust transform wave ripple psychedelic gradient motionblur rv32 rotate noise grain extract sharpen seamcarving)
324 vlc_enable_modules(converter_fixed mono)
325 vlc_enable_modules(trivial_resampler ugly_resampler)
326 vlc_enable_modules(trivial_channel_mixer trivial_mixer)
327 vlc_enable_modules(playlist export nsc xtag)
328 vlc_enable_modules(i420_rgb grey_yuv rawvideo blend scale image logo magnify puzzle colorthres)
329 vlc_enable_modules(wav araw subtitle vobsub adpcm a52sys dtssys au ty voc xa nuv smf)
330 vlc_enable_modules(access_directory access_file access_udp access_tcp)
331 vlc_enable_modules(access_http access_mms access_ftp)
332 vlc_enable_modules(access_filter_bandwidth)
333 vlc_enable_modules(packetizer_mpegvideo packetizer_h264)
334 vlc_enable_modules(packetizer_mpeg4video packetizer_mpeg4audio)
335 vlc_enable_modules(packetizer_vc1)
336 vlc_enable_modules(spatializer)
337 vlc_enable_modules(asf)
338
339 if(NOT mingwce)
340    set(enabled ON)
341 endif(NOT mingwce)
342 vlc_register_modules(${enabled} access_fake access_filter_timeshift access_filter_record access_filter_dump)
343 vlc_register_modules(${enabled} gestures rc telnet hotkeys showintf marq podcast shout sap fake folder)
344 vlc_register_modules(${enabled} rss mosaic wall motiondetect clone crop erase bluescreen alphamask gaussianblur)
345 vlc_register_modules(${enabled} i420_yuy2 i422_yuy2 i420_ymga i422_i420 yuy2_i422 yuy2_i420 chroma_chain)
346 vlc_register_modules(${enabled} aout_file linear_resampler bandlimited_resampler)
347 vlc_register_modules(${enabled} float32_mixer spdif_mixer simple_channel_mixer)
348 vlc_register_modules(${enabled} dolby_surround_decoder headphone_channel_mixer normvol equalizer param_eq)
349 vlc_register_modules(${enabled} converter_float a52tospdif dtstospdif audio_format)
350 set(enabled)
351
352 if(NOT WIN32)
353    vlc_enable_modules(screensaver)
354 endif(NOT WIN32)
355
356 # This module is disabled because the CMakeList.txt which
357 # is generated isn't correct. We'll put that back
358 # when cmake will be accepted as default build system
359 vlc_disable_modules(motion)
360
361 ###########################################################
362 # libraries
363 ###########################################################
364 OPTION( ENABLE_CONTRIB "Attempt to use VLC contrib system to get the third-party libraries" ON )
365 if(ENABLE_CONTRIB)
366   set( CONTRIB_INCLUDE ${CMAKE_SOURCE_DIR}/extras/contrib/include)
367   set( CONTRIB_LIB ${CMAKE_SOURCE_DIR}/extras/contrib/lib)
368   set( CONTRIB_PROGRAM ${CMAKE_SOURCE_DIR}/extras/contrib/bin)
369   set( CMAKE_LIBRARY_PATH ${CONTRIB_LIB} ${CMAKE_LIBRARY_PATH} )
370   set( CMAKE_PROGRAM_PATH ${CONTRIB_PROGRAM} ${CMAKE_PROGRAM_PATH} )
371   set( CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -L${CONTRIB_LIB}" )
372   set( CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -L${CONTRIB_LIB}" )
373   set( CMAKE_SHARED_MODULE_CREATE_C_FLAGS "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -L${CONTRIB_LIB}" )
374   set( CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS "${CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS} -L${CONTRIB_LIB}" )
375   set( CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -L${CONTRIB_LIB}" )
376   set( CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -L${CONTRIB_LIB}" )
377   add_definitions(-I${CONTRIB_INCLUDE})
378 endif(ENABLE_CONTRIB)
379
380 set(CMAKE_REQUIRED_INCLUDES ${CONTRIB_INCLUDE})
381
382 #fixme: use find_package(cddb 0.9.5)
383 pkg_check_modules(LIBCDDB libcddb>=0.9.5)
384 if(${LIBCDDB_FOUND})
385   vlc_module_add_link_libraries(cdda ${LIBCDDB_LIBRARIES})
386   vlc_add_module_compile_flag(cdda ${LIBCDDB_CFLAGS} )
387 endif(${LIBCDDB_FOUND})
388
389 find_package(Dlopen)
390 set(HAVE_DL_DLOPEN ${Dlopen_FOUND})
391
392 # Advanced Linux Sound Architecture (ALSA)
393 pkg_check_modules(ALSA alsa>=1.0.0-rc4)
394 if (${ALSA_FOUND})
395   set (HAVE_ALSA_NEW_API "1")
396 else (${ALSA_FOUND})
397   pkg_check_modules(ALSA alsa)
398 endif (${ALSA_FOUND})
399
400 if (${ALSA_FOUND})
401   set (HAVE_ALSA "1")
402   vlc_enable_modules(alsa)
403   vlc_add_module_compile_flag(alsa ${ALSA_CFLAGS})
404   vlc_module_add_link_libraries(alsa ${ALSA_LIBRARIES})
405 endif (${ALSA_FOUND})
406
407 # Open Sound System (OSS)
408 # TODO
409
410 find_package(FFmpeg)
411 if(FFmpeg_FOUND)
412   vlc_check_include_files (ffmpeg/avcodec.h)
413   vlc_check_include_files (ffmpeg/avutil.h)
414   vlc_check_include_files (ffmpeg/swscale.h)
415   check_include_files ("stdint.h;postproc/postprocess.h" HAVE_POSTPROC_POSTPROCESS_H)
416   vlc_enable_modules(ffmpeg)
417   vlc_add_module_compile_flag(ffmpeg ${FFmpeg_CFLAGS} )
418   vlc_module_add_link_libraries(ffmpeg ${FFmpeg_LIBRARIES})
419 endif(FFmpeg_FOUND)
420
421 find_package(Lua)
422 if(Lua_FOUND)
423   set(HAVE_LUA TRUE)
424   vlc_enable_modules(lua)
425   vlc_check_include_files (lua.h lualib.h)
426   vlc_add_module_compile_flag(lua ${Lua_CFLAGS} )
427   vlc_module_add_link_libraries(lua ${Lua_LIBRARIES})
428 endif(Lua_FOUND)
429
430 find_package(Qt4)
431 if(QT4_FOUND)
432   set(HAVE_QT4 TRUE)
433   include_directories(${QT_INCLUDES})
434   vlc_check_include_files (qt.h)
435   vlc_enable_modules(qt4)
436   vlc_add_module_compile_flag(qt4 ${QT_CFLAGS} )
437   vlc_module_add_link_libraries(qt4 ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY})
438
439   # Define our own qt4_wrap_ui macro to match wanted behaviour
440   MACRO (VLC_QT4_WRAP_UI outfiles )
441     FOREACH (it ${ARGN})
442      string(REPLACE ".ui" ".h" outfile "${it}")
443       GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
444       SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/${outfile})
445       ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
446         COMMAND mkdir -p `dirname ${outfile}`
447         COMMAND ${QT_UIC_EXECUTABLE}
448         ARGS -o ${outfile} ${infile}
449         MAIN_DEPENDENCY ${infile})
450       SET(${outfiles} ${${outfiles}} ${outfile})
451     ENDFOREACH (it)
452   ENDMACRO (VLC_QT4_WRAP_UI)
453
454   MACRO (VLC_QT4_GENERATE_MOC outfiles flags )
455     FOREACH (it ${ARGN})
456      string(REPLACE ".hpp" ".moc.cpp" outfile "${it}")
457       GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
458       SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/${outfile})
459       ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
460         COMMAND mkdir -p `dirname ${outfile}`
461         COMMAND ${QT_MOC_EXECUTABLE}
462         ARGS ${flags} -f -o ${outfile} ${infile}
463         MAIN_DEPENDENCY ${infile}
464         VERBATIM)
465       SET(${outfiles} ${${outfiles}} ${outfile})
466     ENDFOREACH (it)
467   ENDMACRO (VLC_QT4_GENERATE_MOC)
468
469
470 endif(QT4_FOUND)
471
472 find_package(OpenGL)
473 if(OPENGL_FOUND)
474   vlc_enable_modules(opengl)
475   vlc_check_include_files (gl/gl.h)
476   vlc_check_include_files (gl/glu.h)
477   vlc_check_include_files (gl/glx.h)
478   vlc_add_module_compile_flag(opengl ${OPENGL_CFLAGS})
479   vlc_module_add_link_libraries(opengl ${OPENGL_LIBRARIES})
480 endif(OPENGL_FOUND)
481
482 find_package(Matroska 0.7.7)
483 if(Matroska_FOUND)
484   vlc_enable_modules(mkv)
485   vlc_check_include_files (matroska/KaxAttachments.h)
486   vlc_check_include_files (matroska/KaxVersion.h)
487   vlc_module_add_link_libraries(mkv ${Matroska_LIBRARIES})
488 endif(Matroska_FOUND)
489
490 find_package(Live555)
491 if(Live555_FOUND)
492   vlc_enable_modules(live555)
493   vlc_add_module_compile_flag(live555 ${Live555_CFLAGS})
494   vlc_module_add_link_libraries(live555 ${Live555_LIBRARIES})
495 endif(Live555_FOUND)
496
497 find_package(Curses)
498 if(CURSES_LIBRARIES)
499   vlc_enable_modules(ncurses)
500   vlc_module_add_link_libraries(ncurses ${CURSES_LIBRARIES})
501 endif(CURSES_LIBRARIES)
502
503 find_package(X11)
504 if(X11_FOUND)
505   vlc_enable_modules(x11 panoramix)
506   vlc_check_include_files (X11/Xlib.h)
507   vlc_module_add_link_libraries(x11       ${X11_LIBRARIES})
508   vlc_module_add_link_libraries(panoramix ${X11_LIBRARIES})
509 endif(X11_FOUND)
510
511 find_package(Mpeg2)
512 if(Mpeg2_FOUND)
513   vlc_enable_modules(libmpeg2)
514   check_include_files ("stdint.h;mpeg2dec/mpeg2.h" HAVE_MPEG2DEC_MPEG2_H)
515   vlc_module_add_link_libraries(libmpeg2 ${Mpeg2_LIBRARIES})
516 endif(Mpeg2_FOUND)
517
518 find_package(Dvbpsi)
519 if(Dvbpsi_FOUND)
520   vlc_enable_modules(ts)
521   set(CMAKE_REQUIRED_INCLUDES ${CONTRIB_INCLUDE})
522   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)
523   vlc_module_add_link_libraries(ts ${Dvbpsi_LIBRARIES})
524 endif(Dvbpsi_FOUND)
525
526
527
528 set(CMAKE_REQUIRED_INCLUDES)
529
530 ###########################################################
531 # Final configuration
532 ###########################################################
533 add_definitions(-DHAVE_CONFIG_H)
534 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/include/config.h)