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