Commit ed6e4256 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

buildsystem/cmake: Add an embryonary CMake support. Files are constrained into...

buildsystem/cmake: Add an embryonary CMake support. Files are constrained into the buildsystem directory so you need to populate them prior using it, using:
cd vlc && sh ./extras/buildsystem/cmake/scripts/convert_vlc_to_cmake.sh
parent a82cb9cd
PROJECT(vlc)
# Our own include
include( ${CMAKE_SOURCE_DIR}/cmake/vlc_module_funcs.cmake )
# Config
include( ${CMAKE_SOURCE_DIR}/cmake/config.cmake )
add_definitions(-DHAVE_CONFIG_H)
add_definitions(-D__LIBVLC__)
add_definitions(-I.) # Hack
add_definitions(-std=c99) # Hack
include_directories(${CMAKE_SOURCE_DIR}/include)
# Sources
add_subdirectory(src)
add_subdirectory(modules)
include_directories( . )
add_definitions(-Dasm=__asm__ -D_INTL_REDIRECT_MACROS -DMACOSX_DEPLOYMENT_TARGET=10.4 -mmacosx-version-min=10.4)
# vlc
add_executable(vlc vlc.c)
target_link_libraries(vlc libvlc)
install_programs(/bin FILES vlc)
# libvlc
set( SOURCES_libvlc_beos misc/beos_specific.cpp )
set( SOURCES_libvlc_darwin misc/darwin_specific.c )
set( SOURCES_libvlc_win32 misc/win32_specific.c )
set( SOURCES_libvlc_dirent extras/dirent.c )
set( SOURCES_libvlc_getopt misc/getopt.c misc/getopt.h misc/getopt1.c )
set( SOURCES_libvlc_common
libvlc.c
libvlc-common.c
libvlc.h
libvlc-module.c
interface/interface.h
interface/interface.c
interface/intf_eject.c
interface/interaction.c
playlist/playlist_internal.h
playlist/thread.c
playlist/control.c
playlist/engine.c
playlist/sort.c
playlist/loadsave.c
playlist/tree.c
playlist/item.c
playlist/search.c
playlist/services_discovery.c
input/item.c
input/access.c
input/clock.c
input/control.c
input/decoder.c
input/decoder_synchro.c
input/demux.c
input/es_out.c
input/input.c
input/meta.c
input/input_internal.h
input/vlm_internal.h
input/stream.c
input/mem_stream.c
input/subtitles.c
input/var.c
video_output/video_output.c
video_output/vout_pictures.c
video_output/vout_pictures.h
video_output/video_text.c
video_output/video_widgets.c
video_output/vout_subpictures.c
video_output/vout_intf.c
audio_output/aout_internal.h
audio_output/common.c
audio_output/dec.c
audio_output/filters.c
audio_output/input.c
audio_output/mixer.c
audio_output/output.c
audio_output/intf.c
stream_output/stream_output.c
stream_output/stream_output.h
stream_output/announce.c
stream_output/profiles.c
stream_output/sap.c
stream_output/sdp.c
osd/osd.c
osd/osd_text.c
osd/osd_widgets.c
network/acl.c
network/getaddrinfo.c
network/io.c
network/error.c
network/tcp.c
network/udp.c
network/httpd.c
network/rootwrap.c
network/tls.c
network/poll.c
text/charset.c
text/strings.c
text/unicode.c
text/wincp.c
text/iso_lang.c
text/iso-639_def.h
misc/md5.c
misc/rand.c
misc/mtime.c
misc/block.c
modules/modules.h
modules/modules.c
modules/cache.c
modules/entry.c
modules/os.c
misc/threads.c
misc/stats.c
misc/cpu.c
config/configuration.h
config/core.c
config/chain.c
config/file.c
config/cmdline.c
misc/events.c
misc/image.c
misc/messages.c
misc/objects.c
misc/variables.h
misc/variables.c
misc/error.c
misc/update.c
misc/revision.c
input/vlm.c
misc/xml.c
misc/devices.c
extras/libc.c )
set( SOURCES_libvlc ${SOURCES_libvlc_common} )
if(SYS_DARWIN)
set( SOURCES_libvlc ${SOURCES_libvlc} ${SOURCES_libvlc_darwin} )
endif(SYS_DARWIN)
add_library(libvlc SHARED ${SOURCES_libvlc})
install_targets(/lib libvlc)
##########################################################
# Libraries
# iconv
target_link_libraries(libvlc ${HAVE_ICONV})
# Carbon
find_library(CARBON_FRAMEWORK Carbon)
target_link_libraries(libvlc ${CARBON_FRAMEWORK})
##########################################################
# version.c
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/foo.c
COMMAND sh "rm -f misc/revision.c misc/revision.c.tmp &&
echo '/* AUTOGENERATED FILE - DO NOT EDIT */' > misc/revision.c.tmp &&
REVISION=\"$$\(LANG=C svnversion \\\"$\(top_srcdir)\\\" 2>/dev/null || echo exported)\" ; &&
echo \"const char psz_vlc_changeset[] = \\\"$$REVISION\\\";\" >> misc/revision.c.tmp &&
mv -f misc/revision.c.tmp misc/revision.c"
)
##########################################################
# SET_TARGET_PROPERTIES
set_target_properties(libvlc vlc PROPERTIES COMPILE_FLAGS
"-std=c99 -I. -Wall -Wextra -Wsign-compare -Wundef -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Wmissing-prototypes" )
To use CMake:
First, as CMake isn't the default on vlc populate its CMakeLists files:
$ cd vlc && sh ./extras/buildsystem/cmake/scripts/convert_vlc_to_cmake.sh
Now you can use CMake as usual:
$ cd vlc && cmake . (or ccmake . if you want a graphical view of the settings)
$ make [VERBOSE=1 if you want more details]
$ make install
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 )
###########################################################
###########################################################
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)
vlc_check_include_files (netdb.h fcntl.h sys/time.h poll.h)
vlc_check_include_files (errno.h time.h)
vlc_check_include_files (kernel/OS.h)
vlc_check_include_files (mach-o/dyld.h)
check_symbol_exists(ntohl "sys/param.h" NTOHL_IN_SYS_PARAM_H)
check_symbol_exists(scandir "dirent.h" HAVE_SCANDIR)
check_symbol_exists(scandir "dirent.h" HAVE_SCANDIR)
check_symbol_exists(localtime_r "time.h" HAVE_LOCALTIME_R)
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)
find_library(HAVE_ICONV iconv)
set( ICONV_CONST " " )
###########################################################
###########################################################
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)
vlc_check_functions_exist(strlcpy)
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)
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")
###########################################################
#include (CheckVariableExists)
###########################################################
###########################################################
###########################################################
check_c_source_compiles (
"#include <stdint.h> \n #ifdef UINTMAX \n #error no uintmax
#endif
int main() { return 0;}" HAVE_STDINT_H_WITH_UINTMAX)
###########################################################
# Other check
###########################################################
include( ${CMAKE_SOURCE_DIR}/cmake/vlc_test_inline.cmake )
###########################################################
# Platform check
###########################################################
if(APPLE)
include( ${CMAKE_SOURCE_DIR}/cmake/vlc_find_frameworks.cmake )
set(HAVE_DL_DYLD ON INTERNAL)
set(SYS_DARWIN 1)
vlc_enable_modules(macosx minimal_macosx access_eyetv quartztext)
vlc_find_frameworks(Cocoa Carbon OpenGL AGL IOKit Quicktime
WebKit QuartzCore Foundation ApplicationServices)
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} )
vlc_module_add_link_libraries(mp4
${IOKit_FRAMEWORKS} )
add_executable(VLC MACOSX_BUNDLE src/vlc.c)
target_link_libraries(VLC libvlc)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/VLC.app/Contents/MacOS/modules
COMMAND ln -s ${CMAKE_CURRENT_BINARY_DIR}/modules ${CMAKE_CURRENT_BINARY_DIR}/VLC.app/Contents/MacOS/lib
)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/VLC.app/Contents/MacOS/lib
COMMAND ln -s ${CMAKE_CURRENT_BINARY_DIR}/modules ${CMAKE_CURRENT_BINARY_DIR}/VLC.app/Contents/MacOS/lib
)
endif(APPLE)
###########################################################
# version and info setup
###########################################################
macro(command_to_configvar command var)
execute_process(
COMMAND sh -c "${command}"
OUTPUT_VARIABLE ${var}
OUTPUT_STRIP_TRAILING_WHITESPACE)
string( REPLACE "\n" "\\n" ${var} ${${var}})
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 )
command_to_configvar( "${CMAKE_C_COMPILER} --version" CONFIGURE_LINE )
set( VLC_COMPILER "${CMAKE_C_COMPILER}" )
set(PACKAGE "vlc")
set(PACKAGE_STRING "vlc")
set(VERSION_MESSAGE "vlc-0.9.0-svn")
set(COPYRIGHT_MESSAGE "Copyright VLC Team")
set(COPYRIGHT_YEARS "2001-2007")
###########################################################
# Options
###########################################################
OPTION( ENABLE_HTTPD "Enable httpd server" ON )
OPTION( ENABLE_VLM "Enable vlm" ON )
###########################################################
# 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)
vlc_disable_modules(asf)
# This module will be disabled but listed in options
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)
vlc_register_modules(${enabled} screensaver motion)
endif(NOT WIN32)
# vlc_disable_module()
pkg_check_modules(LIBCDDB libcddb>=0.9.5)
if(${LIBCDDB_FOUND})
#vlc_add_library(cdda ${LIBCDDB_LIBRARIES})
vlc_add_compile_flag(cdda ${LIBCDDB_CFLAGS} )
endif(${LIBCDDB_FOUND})
set( MODULES_CFLAGS, "-std=c99" )
###########################################################
# Final configuration
###########################################################
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/include/config.h)
# From KDELibs - BSD Licence
# - a pkg-config module for CMake
#
# Usage:
# pkg_check_modules(<PREFIX> [REQUIRED] <MODULE> [<MODULE>]*)
# checks for all the given modules
#
# pkg_search_module(<PREFIX> [REQUIRED] <MODULE> [<MODULE>]*)
# checks for given modules and uses the first working one
#
# When the 'REQUIRED' argument was set, macros will fail with an error
# when module(s) could not be found
#
# It sets the following variables:
# PKG_CONFIG_FOUND ... true if pkg-config works on the system
# PKG_CONFIG_EXECUTABLE ... pathname of the pkg-config program
# <PREFIX>_FOUND ... set to 1 if module(s) exist
#
# For the following variables two sets of values exist; first one is the
# common one and has the given PREFIX. The second set contains flags
# which are given out when pkgconfig was called with the '--static'
# option.
# <XPREFIX>_LIBRARIES ... only the libraries (w/o the '-l')
# <XPREFIX>_LIBRARY_DIRS ... the paths of the libraries (w/o the '-L')
# <XPREFIX>_LDFLAGS ... all required linker flags
# <XPREFIX>_LDFLAGS_OTHERS ... all other linker flags
# <XPREFIX>_INCLUDE_DIRS ... the '-I' preprocessor flags (w/o the '-I')
# <XPREFIX>_CFLAGS ... all required cflags
# <XPREFIX>_CFLAGS_OTHERS ... the other compiler flags
#
# <XPREFIX> = <PREFIX> for common case
# <XPREFIX> = <PREFIX>_STATIC for static linking
#
# There are some special variables whose prefix depends on the count
# of given modules. When there is only one module, <PREFIX> stays
# unchanged. When there are multiple modules, the prefix will be
# changed to <PREFIX>_<MODNAME>:
# <XPREFIX>_VERSION ... version of the module
# <XPREFIX>_PREFIX ... prefix-directory of the module
# <XPREFIX>_INCLUDEDIR ... include-dir of the module
# <XPREFIX>_LIBDIR ... lib-dir of the module
#
# <XPREFIX> = <PREFIX> when |MODULES| == 1, else
# <XPREFIX> = <PREFIX>_<MODNAME>
#
# A <MODULE> parameter can have the following formats:
# {MODNAME} ... matches any version
# {MODNAME}>={VERSION} ... at least version <VERSION> is required
# {MODNAME}={VERSION} ... exactly version <VERSION> is required
# {MODNAME}<={VERSION} ... modules must not be newer than <VERSION>
#
# Examples
# pkg_check_modules (GLIB2 glib-2.0)
#
# pkg_check_modules (GLIB2 glib-2.0>=2.10)
# requires at least version 2.10 of glib2 and defines e.g.
# GLIB2_VERSION=2.10.3
#
# pkg_check_modules (FOO glib-2.0>=2.10 gtk+-2.0)
# requires both glib2 and gtk2, and defines e.g.
# FOO_glib-2.0_VERSION=2.10.3
# FOO_gtk+-2.0_VERSION=2.8.20
#
# pkg_check_modules (XRENDER REQUIRED xrender)
# defines e.g.:
# XRENDER_LIBRARIES=Xrender;X11
# XRENDER_STATIC_LIBRARIES=Xrender;X11;pthread;Xau;Xdmcp
#
# pkg_search_module (BAR libxml-2.0 libxml2 libxml>=2)
# Copyright (C) 2006 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
#
# Redistribution and use, with or without modification, are permitted
# provided that the following conditions are met:
#
# 1. Redistributions must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. The name of the author may not be used to endorse or promote
# products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
### Common stuff ####
set(PKG_CONFIG_VERSION 1)
set(PKG_CONFIG_FOUND 0)
find_program(PKG_CONFIG_EXECUTABLE NAMES pkg-config DOC "pkg-config executable")
mark_as_advanced(PKG_CONFIG_EXECUTABLE)
if(PKG_CONFIG_EXECUTABLE)
set(PKG_CONFIG_FOUND 1)
endif(PKG_CONFIG_EXECUTABLE)
# Unsets the given variables
macro(_pkgconfig_unset var)
set(${var} "" CACHE INTERNAL "")
endmacro(_pkgconfig_unset)
macro(_pkgconfig_set var value)
set(${var} ${value} CACHE INTERNAL "")
endmacro(_pkgconfig_set)
# Invokes pkgconfig, cleans up the result and sets variables
macro(_pkgconfig_invoke _pkglist _prefix _varname _regexp)
set(_pkgconfig_invoke_result)
execute_process(
COMMAND ${PKG_CONFIG_EXECUTABLE} ${ARGN} ${_pkglist}
OUTPUT_VARIABLE _pkgconfig_invoke_result
RESULT_VARIABLE _pkgconfig_failed)
if (_pkgconfig_failed)
set(_pkgconfig_${_varname} "")
_pkgconfig_unset(${_prefix}_${_varname})
else(_pkgconfig_failed)
string(REGEX REPLACE "[\r\n]" " " _pkgconfig_invoke_result "${_pkgconfig_invoke_result}")
string(REGEX REPLACE " +$" "" _pkgconfig_invoke_result "${_pkgconfig_invoke_result}")
if (NOT ${_regexp} STREQUAL "")
string(REGEX REPLACE "${_regexp}" " " _pkgconfig_invoke_result "${_pkgconfig_invoke_result}")
endif(NOT ${_regexp} STREQUAL "")
separate_arguments(_pkgconfig_invoke_result)
#message(STATUS " ${_varname} ... ${_pkgconfig_invoke_result}")
set(_pkgconfig_${_varname} ${_pkgconfig_invoke_result})
_pkgconfig_set(${_prefix}_${_varname} "${_pkgconfig_invoke_result}")
endif(_pkgconfig_failed)
endmacro(_pkgconfig_invoke)
# Invokes pkgconfig two times; once without '--static' and once with
# '--static'
macro(_pkgconfig_invoke_dyn _pkglist _prefix _varname cleanup_regexp)
_pkgconfig_invoke("${_pkglist}" ${_prefix} ${_varname} "${cleanup_regexp}" ${ARGN})
_pkgconfig_invoke("${_pkglist}" ${_prefix} STATIC_${_varname} "${cleanup_regexp}" --static ${ARGN})
endmacro(_pkgconfig_invoke_dyn)
# Splits given arguments into options and a package list
macro(_pkgconfig_parse_options _result _is_req)
set(${_is_req} 0)
foreach(_pkg ${ARGN})
if (_pkg STREQUAL "REQUIRED")
set(${_is_req} 1)
endif (_pkg STREQUAL "REQUIRED")
endforeach(_pkg ${ARGN})
set(${_result} ${ARGN})
list(REMOVE_ITEM ${_result} "REQUIRED")
endmacro(_pkgconfig_parse_options)
###
macro(_pkg_check_modules_internal _is_required _is_silent _prefix)
_pkgconfig_unset(${_prefix}_FOUND)
_pkgconfig_unset(${_prefix}_VERSION)
_pkgconfig_unset(${_prefix}_PREFIX)
_pkgconfig_unset(${_prefix}_INCLUDEDIR)
_pkgconfig_unset(${_prefix}_LIBDIR)
_pkgconfig_unset(${_prefix}_LIBS)
_pkgconfig_unset(${_prefix}_LIBS_L)
_pkgconfig_unset(${_prefix}_LIBS_PATHS)
_pkgconfig_unset(${_prefix}_LIBS_OTHER)
_pkgconfig_unset(${_prefix}_CFLAGS)
_pkgconfig_unset(${_prefix}_CFLAGS_I)
_pkgconfig_unset(${_prefix}_CFLAGS_OTHER)
_pkgconfig_unset(${_prefix}_STATIC_LIBDIR)
_pkgconfig_unset(${_prefix}_STATIC_LIBS)
_pkgconfig_unset(${_prefix}_STATIC_LIBS_L)
_pkgconfig_unset(${_prefix}_STATIC_LIBS_PATHS)
_pkgconfig_unset(${_prefix}_STATIC_LIBS_OTHER)
_pkgconfig_unset(${_prefix}_STATIC_CFLAGS)
_pkgconfig_unset(${_prefix}_STATIC_CFLAGS_I)
_pkgconfig_unset(${_prefix}_STATIC_CFLAGS_OTHER)
# create a better addressable variable of the modules and calculate its size
set(_pkg_check_modules_list ${ARGN})
list(LENGTH _pkg_check_modules_list _pkg_check_modules_cnt)
if(PKG_CONFIG_EXECUTABLE)
# give out status message telling checked module
if (NOT ${_is_silent})
if (_pkg_check_modules_cnt EQUAL 1)
message(STATUS "checking for module '${_pkg_check_modules_list}'")
else(_pkg_check_modules_cnt EQUAL 1)
message(STATUS "checking for modules '${_pkg_check_modules_list}'")
endif(_pkg_check_modules_cnt EQUAL 1)
endif(NOT ${_is_silent})
set(_pkg_check_modules_packages)
set(_pkg_check_modules_failed)
# iterate through module list and check whether they exist and match the required version
foreach (_pkg_check_modules_pkg ${_pkg_check_modules_list})
set(_pkg_check_modules_exist_query)
# check whether version is given
if (_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*")
string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\1" _pkg_check_modules_pkg_name "${_pkg_check_modules_pkg}")
string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\2" _pkg_check_modules_pkg_op "${_pkg_check_modules_pkg}")
string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\3" _pkg_check_modules_pkg_ver "${_pkg_check_modules_pkg}")
else(_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*")
set(_pkg_check_modules_pkg_name "${_pkg_check_modules_pkg}")
set(_pkg_check_modules_pkg_op)
set(_pkg_check_modules_pkg_ver)
endif(_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*")
# handle the operands
if (_pkg_check_modules_pkg_op STREQUAL ">=")
list(APPEND _pkg_check_modules_exist_query --atleast-version)
endif(_pkg_check_modules_pkg_op STREQUAL ">=")
if (_pkg_check_modules_pkg_op STREQUAL "=")
list(APPEND _pkg_check_modules_exist_query --exact-version)
endif(_pkg_check_modules_pkg_op STREQUAL "=")
if (_pkg_check_modules_pkg_op STREQUAL "<=")
list(APPEND _pkg_check_modules_exist_query --max-version)
endif(_pkg_check_modules_pkg_op STREQUAL "<=")
# create the final query which is of the format:
# * --atleast-version <version> <pkg-name>
# * --exact-version <version> <pkg-name>
# * --max-version <version> <pkg-name>
# * --exists <pkg-name>
if (_pkg_check_modules_pkg_op)
list(APPEND _pkg_check_modules_exist_query "${_pkg_check_modules_pkg_ver}")
else(_pkg_check_modules_pkg_op)
list(APPEND _pkg_check_modules_exist_query --exists)
endif(_pkg_check_modules_pkg_op)
_pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_VERSION)
_pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_PREFIX)
_pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_INCLUDEDIR)
_pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_LIBDIR)
list(APPEND _pkg_check_modules_exist_query "${_pkg_check_modules_pkg_name}")
list(APPEND _pkg_check_modules_packages "${_pkg_check_modules_pkg_name}")
# execute the query
execute_process(
COMMAND ${PKG_CONFIG_EXECUTABLE} ${_pkg_check_modules_exist_query}
RESULT_VARIABLE _pkgconfig_retval)
# evaluate result and tell failures
if (_pkgconfig_retval)
if(NOT ${_is_silent})
message(STATUS " package '${_pkg_check_modules_pkg}' not found")
endif(NOT ${_is_silent})
set(_pkg_check_modules_failed 1)
endif(_pkgconfig_retval)
endforeach(_pkg_check_modules_pkg)
if(_pkg_check_modules_failed)
# fail when requested
if (${_is_required})
message(SEND_ERROR "A required package was not found")
endif (${_is_required})
else(_pkg_check_modules_failed)
# when we are here, we checked whether requested modules
# exist. Now, go through them and set variables
_pkgconfig_set(${_prefix}_FOUND 1)
list(LENGTH _pkg_check_modules_packages pkg_count)
# iterate through all modules again and set individual variables
foreach (_pkg_check_modules_pkg ${_pkg_check_modules_packages})
# handle case when there is only one package required
if (pkg_count EQUAL 1)
set(_pkg_check_prefix "${_prefix}")
else(pkg_count EQUAL 1)
set(_pkg_check_prefix "${_prefix}_${_pkg_check_modules_pkg}")
endif(pkg_count EQUAL 1)
_pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" VERSION "" --modversion )
_pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" PREFIX "" --variable=prefix )
_pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" INCLUDEDIR "" --variable=includedir )
_pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" LIBDIR "" --variable=libdir )
message(STATUS " found ${_pkg_check_modules_pkg}, version ${_pkgconfig_VERSION}")
endforeach(_pkg_check_modules_pkg)
# set variables which are combined for multiple modules
_pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LIBRARIES "(^| )-l" --libs-only-l )
_pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LIBRARY_DIRS "(^| )-L" --libs-only-L )
_pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LDFLAGS "" --libs )
_pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LDFLAGS_OTHER "" --libs-only-other )
_pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" INCLUDE_DIRS "(^| )-I" --cflags-only-I )
_pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS "" --cflags )
_pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS_OTHER "" --cflags-only-other )
endif(_pkg_check_modules_failed)
else(PKG_CONFIG_EXECUTABLE)
if (${_is_required})
message(SEND_ERROR "pkg-config tool not found")
endif (${_is_required})
endif(PKG_CONFIG_EXECUTABLE)
endmacro(_pkg_check_modules_internal)
###
### User visible macros start here
###
###
macro(pkg_check_modules _prefix _module0)
# check cached value
if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION})
_pkgconfig_parse_options (_pkg_modules _pkg_is_required "${_module0}" ${ARGN})
_pkg_check_modules_internal("${_pkg_is_required}" 0 "${_prefix}" ${_pkg_modules})
_pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION})
endif(NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION})
endmacro(pkg_check_modules)
###
macro(pkg_search_module _prefix _module0)
# check cached value
if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION})
set(_pkg_modules_found 0)
_pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required "${_module0}" ${ARGN})
message(STATUS "checking for one of the modules '${_pkg_modules_alt}'")
# iterate through all modules and stop at the first working one.
foreach(_pkg_alt ${_pkg_modules_alt})
if(NOT _pkg_modules_found)
_pkg_check_modules_internal(0 1 "${_prefix}" "${_pkg_alt}")
endif(NOT _pkg_modules_found)
if (${_prefix}_FOUND)
set(_pkg_modules_found 1)
endif(${_prefix}_FOUND)
endforeach(_pkg_alt)
if (NOT ${_prefix}_FOUND)
if(${_pkg_is_required})
message(SEND_ERROR "None of the required '${_pkg_modules_alt}' found")
endif(${_pkg_is_required})
endif(NOT ${_prefix}_FOUND)
_pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION})
endif(NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION})
endmacro(pkg_search_module)
### Local Variables:
### mode: cmake
### End:
# - vlc_add_compile_flag(<_target> "flags...")
# From KDELibs
# Copyright (c) 2006, Oswald Buddenhagen, <ossi@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
MACRO (vlc_add_compile_flag _target _flg)
GET_TARGET_PROPERTY(_flags ${_target} COMPILE_FLAGS)
if (_flags)
set(_flags "${_flags} ${_flg}")
else (_flags)
set(_flags "${_flg}")
endif (_flags)
SET_TARGET_PROPERTIES(${_target} PROPERTIES COMPILE_FLAGS "${_flags}")
ENDMACRO (vlc_add_compile_flag)
include (CheckFunctionExists)
MACRO(vlc_check_functions_exist functions)
foreach(function ${ARGV})
# Construct the HAVE_ var
string(REGEX REPLACE "[-./:;,?=+\\]" "_" function_escaped ${function})
string(TOUPPER ${function_escaped} function_escaped)
check_function_exists( ${function} HAVE_${function_escaped} )
endforeach(function)
ENDMACRO(vlc_check_functions_exist)
include (CheckIncludeFiles)
MACRO(vlc_check_include_files files)
foreach(filepath ${ARGV})
# Construct the HAVE_ var
string(REGEX REPLACE "[-./:;,?=+\\]" "_" filepath_escaped ${filepath})
string(TOUPPER ${filepath_escaped} filepath_escaped)
check_include_files( ${filepath} HAVE_${filepath_escaped} )
endforeach(filepath)
ENDMACRO(vlc_check_include_files)
include (CheckTypeSize)
MACRO(vlc_check_type type header)
# Construct the HAVE_ var
string(REGEX REPLACE "[ -./:;,?=+\\]" "_" type_escaped ${type})
string(TOUPPER ${type_escaped} type_escaped)
set(CMAKE_EXTRA_INCLUDE_FILES ${header})
check_type_size( ${type} HAVE_${type_escaped} )
set(CMAKE_EXTRA_INCLUDE_FILES)
ENDMACRO(vlc_check_type)
include(CMakeFindFrameworks)
MACRO(vlc_find_frameworks frameworks)
foreach(framework ${ARGV})
cmake_find_frameworks(${framework})
endforeach(framework)
ENDMACRO(vlc_find_frameworks)
\ No newline at end of file
include( ${CMAKE_SOURCE_DIR}/cmake/vlc_add_compile_flag.cmake )
MACRO(vlc_add_module module_name)
if(ENABLE_VLC_MODULE_${module_name})
add_library( vlc_${module_name} MODULE ${ARGN} )
set_target_properties( vlc_${module_name} PROPERTIES COMPILE_FLAGS "-D__PLUGIN__ -DMODULE_NAME=${module_name} -DMODULE_NAME_IS_${module_name} -I${CMAKE_CURRENT_SOURCE_DIR}" )
if (VLC_${module_name}_LINK_LIBRARIES)
target_link_libraries( vlc_${module_name} libvlc ${VLC_${module_name}_LINK_LIBRARIES})
else (VLC_${module_name}_LINK_LIBRARIES)
target_link_libraries( vlc_${module_name} libvlc )
endif (VLC_${module_name}_LINK_LIBRARIES)
endif(ENABLE_VLC_MODULE_${module_name})
ENDMACRO(vlc_add_module)
MACRO(vlc_register_modules state)
foreach( module_name ${ARGN} )
OPTION( ENABLE_VLC_MODULE_${module_name} "Enable the ${module_name} module" ${state} )
endforeach( module_name )
ENDMACRO(vlc_register_modules)
MACRO(vlc_enable_modules module_names)
vlc_register_modules( ON ${ARGV} )
ENDMACRO(vlc_enable_modules)
MACRO(vlc_disable_modules module_names)
vlc_register_modules( OFF ${ARGV} )
ENDMACRO(vlc_disable_modules)
MACRO(vlc_set_module_properties module_name)
set_target_properties(vlc_${module_name} ${ARGN})
ENDMACRO(vlc_set_module_properties)
MACRO(vlc_set_module_properties module_name)
set_target_properties(vlc_${module_name} ${ARGN})
ENDMACRO(vlc_set_module_properties)
MACRO(vlc_module_add_link_libraries module_name)
set(VLC_${module_name}_LINK_LIBRARIES ${VLC_${module_name}_LINK_LIBRARIES} ${ARGN})
ENDMACRO(vlc_module_add_link_libraries)
# This handy test is from Jack Kelly on the cmake email list.
# Here is a minimal working example. It tests the inline keyword,
# then __inline__ and then __inline. When it finds one that works,
# it will ADD_DEFINITIONS(-Dinline=${KEYWORD}) and if none work, it
# will ADD_DEFINITIONS(-Dinline=).
# Inspired from /usr/share/autoconf/autoconf/c.m4
include (CheckCSourceCompiles)
FOREACH(KEYWORD "inline" "__inline__" "__inline")
IF(NOT DEFINED C_INLINE)
check_c_source_compiles(
"typedef int foo_t; static inline foo_t static_foo(){return 0;}
foo_t foo(){return 0;} int main(int argc, char *argv[]){return 0;}"
C_HAS_${KEYWORD})
IF(C_HAS_${KEYWORD})
SET(C_INLINE TRUE)
ADD_DEFINITIONS("-Dinline=${KEYWORD}")
ENDIF(C_HAS_${KEYWORD})
ENDIF(NOT DEFINED C_INLINE)
ENDFOREACH(KEYWORD)
IF(NOT DEFINED C_INLINE)
ADD_DEFINITIONS("-Dinline=")
ENDIF(NOT DEFINED C_INLINE)
#!/bin/sh
echo "Searching $1"
for file in `find $1 -name "Modules.am"`; do
cmake_file=`dirname $file`/CMakeLists.txt
echo "Creating $cmake_file"
cat $file | perl -ne 's/\\\n/ /g; print' | sed -n -e "s/^SOURCES_\(.*\)[ ]*=\(.*\)$/vlc_add_module( \1 \2 )/p" | tr '\t' ' ' | sed 's/ */ /g' | sed 's/\$(NULL)//g' > $cmake_file
dir=`dirname $file`
echo "" >> $cmake_file
for subdirfile in `find $dir -name "Modules.am"`; do
if [ "$subdirfile" != "$file" ]; then
subdir=`echo \`dirname $subdirfile\` | sed -e "s:$dir::" | sed -e "s:^/::"`
echo "add_subdirectory( $subdir )" >> $cmake_file
fi
done
done
#!/bin/sh
cmake_dir=extras/buildsystem/cmake
if ! test -e configure.ac
then
echo "***"
echo "*** Error: You must run that script from the root vlc source tree"
echo "***"
exit -1
fi
echo "Installing CMakeLists.txt"
ln -s $cmake_dir/CMakeLists/root_CMakeLists.txt CMakeLists.txt
echo "Installing src/CMakeLists.txt"
ln -s ../$cmake_dir/CMakeLists/src_CMakeLists.txt src/CMakeLists.txt
echo "Installing cmake/"
ln -s $cmake_dir/include cmake
echo "Generating CMakeLists for modules/"
sh $cmake_dir/scripts/convert_modules_to_cmake.sh modules
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment