+# 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
+
+find_package(FFmpeg)
+if(FFmpeg_FOUND)
+ string(REPLACE ";" " " FFmpeg_CFLAGS "${FFmpeg_CFLAGS}")
+ set( CMAKE_REQUIRED_FLAGS_saved ${CMAKE_REQUIRED_FLAGS} )
+ set( CMAKE_REQUIRED_FLAGS ${FFmpeg_CFLAGS} )
+
+ vlc_check_include_files (ffmpeg/avcodec.h libavcodec/avcodec.h)
+ vlc_check_include_files (ffmpeg/avutil.h libavutil/avutil.h)
+ vlc_check_include_files (ffmpeg/swscale.h libswscale/swscale.h)
+ check_c_source_compiles( "#include <stdint.h>\n#include <postproc/postprocess.h>\nint main(){return 0;}" HAVE_POSTPROC_POSTPROCESS_H )
+ vlc_check_include_files (libpostproc/postprocess.h)
+
+ message( STATUS "avcodec found ${HAVE_FFMPEG_AVCODEC_H} || ${HAVE_LIBAVCODEC_AVCODEC_H}")
+ message( STATUS "avutil found ${HAVE_FFMPEG_AVUTIL_H} || ${HAVE_LIBAVUTIL_AVUTIL_H}")
+ message( STATUS "swscale found ${HAVE_FFMPEG_SWSCALE_H} || ${HAVE_LIBSWSCALE_SWSCALE_H}")
+ message( STATUS "postprocess found ${HAVE_POSTPROC_POSTPROCESS_H} || ${HAVE_LIBPOSTPROC_POSTPROCESS_H}")
+
+ vlc_enable_modules(ffmpeg)
+ vlc_add_module_compile_flag(ffmpeg ${FFmpeg_CFLAGS})
+ vlc_module_add_link_libraries(ffmpeg ${FFmpeg_LIBRARIES})
+
+ set( CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_saved} )
+ set( CMAKE_REQUIRED_FLAGS_saved )
+endif(FFmpeg_FOUND)
+
+find_package(Lua)
+if(Lua_FOUND)
+ set(HAVE_LUA TRUE)
+ vlc_enable_modules(lua)
+ vlc_check_include_files (lua.h lualib.h)
+ vlc_add_module_compile_flag(lua ${Lua_CFLAGS} )
+ vlc_module_add_link_libraries(lua ${Lua_LIBRARIES})
+endif(Lua_FOUND)
+
+find_package(Qt4)
+if(QT4_FOUND)
+ set(HAVE_QT4 TRUE)
+ include_directories(${QT_INCLUDES})
+ vlc_check_include_files (qt.h)
+ vlc_enable_modules(qt4)
+ #execute_process leaves the trailing newline appended to the variable, unlike exec_program
+ #execute_process( COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=prefix QtCore OUTPUT_VARIABLE QT4LOCALEDIR)
+ exec_program( ${PKG_CONFIG_EXECUTABLE} ARGS --variable=prefix QtCore OUTPUT_VARIABLE QT4LOCALEDIR)
+ set(QT4LOCALEDIR ${QT4LOCALEDIR}/share/qt4/translations )
+ vlc_add_module_compile_flag(qt4 ${QT_CFLAGS})
+ vlc_add_module_compile_flag(qt4 -DQT4LOCALEDIR=\\\\"${QT4LOCALEDIR}\\\\" )
+ vlc_module_add_link_libraries(qt4 ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY})
+
+ # 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)
+
+ MACRO (VLC_QT4_GENERATE_MOC outfiles flags )
+ string(REGEX MATCHALL "[^\\ ]+" flags_list ${flags})
+ FOREACH (it ${ARGN})
+ string(REPLACE ".hpp" ".moc.cpp" 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_MOC_EXECUTABLE}
+ ARGS ${flags_list}
+ ARGS -I ${CMAKE_BINARY_DIR}/include
+ ARGS -o ${outfile} ${infile}
+ MAIN_DEPENDENCY ${it}
+ )
+ SET(${outfiles} ${${outfiles}} ${outfile})
+ ENDFOREACH (it)
+ ENDMACRO (VLC_QT4_GENERATE_MOC)
+
+
+endif(QT4_FOUND)
+
+find_package(OpenGL)
+if(OPENGL_FOUND)
+ vlc_enable_modules(opengl)
+ vlc_check_include_files (gl/gl.h)
+ vlc_check_include_files (gl/glu.h)
+ vlc_check_include_files (gl/glx.h)
+ vlc_add_module_compile_flag(opengl ${OPENGL_CFLAGS})
+ vlc_module_add_link_libraries(opengl ${OPENGL_LIBRARIES})
+endif(OPENGL_FOUND)
+
+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)
+
+find_package(Live555)
+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)
+
+set(CURSES_NEED_NCURSES TRUE)
+find_package(Curses)
+if(CURSES_LIBRARIES)
+ vlc_enable_modules(ncurses)
+ vlc_module_add_link_libraries(ncurses ${CURSES_LIBRARIES})
+endif(CURSES_LIBRARIES)
+
+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)
+
+vlc_check_include_files (linux/fb.h)
+if(HAVE_LINUX_FB_H)
+ vlc_enable_modules(fb)
+endif(HAVE_LINUX_FB_H)
+
+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_register_modules(${ENABLE_STREAM_OUT} mux_ts)
+ vlc_enable_modules(ts)
+ 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})
+ vlc_module_add_link_libraries(mux_ts ${Dvbpsi_LIBRARIES})
+ vlc_module_add_link_libraries(dvb ${Dvbpsi_LIBRARIES})
+endif(Dvbpsi_FOUND)
+
+vlc_check_include_files (id3tag.h zlib.h)
+if(HAVE_ID3TAG_H AND HAVE_ZLIB_H)
+ vlc_enable_modules(id3tag)
+ vlc_module_add_link_libraries(id3tag "id3tag;z")
+endif(HAVE_ID3TAG_H AND HAVE_ZLIB_H)
+
+find_package(Taglib)
+if(Taglib_FOUND)
+ set(HAVE_TAGLIB 1)
+ vlc_enable_modules(taglib)
+ vlc_module_add_link_libraries(taglib "${Taglib_LIBRARIES};z")
+ vlc_add_module_compile_flag(taglib "${Taglib_CFLAGS}")
+endif(Taglib_FOUND)
+
+vlc_check_include_files (zlib.h)
+if(HAVE_ZLIB_H)
+ vlc_module_add_link_libraries(access_http z)
+ vlc_module_add_link_libraries(mkv z)
+ vlc_module_add_link_libraries(mp4 z)
+ vlc_module_add_link_libraries(stream_out_bridge z)
+ vlc_module_add_link_libraries(sap z)
+endif(HAVE_ZLIB_H)
+
+set(CMAKE_REQUIRED_INCLUDES)
+