]> git.sesse.net Git - vlc/blob - extras/buildsystem/cmake/include/config.cmake
7b59fe28ff4532797fa49631c92ef5cdb7ee0063
[vlc] / extras / buildsystem / cmake / include / config.cmake
1 include( CheckIncludeFile )
2 include (CheckTypeSize)
3 include (CheckCSourceCompiles)
4 include (CheckSymbolExists)
5 include (CheckLibraryExists)
6 include (FindThreads)
7
8 include( ${CMAKE_SOURCE_DIR}/cmake/vlc_check_include_files.cmake )
9 include( ${CMAKE_SOURCE_DIR}/cmake/vlc_check_functions_exist.cmake )
10 include( ${CMAKE_SOURCE_DIR}/cmake/vlc_add_compile_flag.cmake )
11 include( ${CMAKE_SOURCE_DIR}/cmake/vlc_check_type.cmake )
12 include( ${CMAKE_SOURCE_DIR}/cmake/pkg_check_modules.cmake )
13
14 ###########################################################
15 # Headers checks
16 ###########################################################
17
18 vlc_check_include_files (malloc.h stdbool.h locale.h)
19 vlc_check_include_files (stddef.h stdlib.h sys/stat.h)
20 vlc_check_include_files (stdio.h stdint.h inttypes.h)
21 vlc_check_include_files (signal.h unistd.h dirent.h)
22 vlc_check_include_files (netinet/in.h netinet/udplite.h)
23 vlc_check_include_files (arpa/inet.h net/if.h)
24 vlc_check_include_files (netdb.h fcntl.h sys/time.h poll.h)
25 vlc_check_include_files (errno.h time.h)
26
27 vlc_check_include_files (dlfcn.h dl.h)
28
29 vlc_check_include_files (kernel/OS.h)
30 vlc_check_include_files (mach-o/dyld.h)
31
32
33 ###########################################################
34 # Functions/structures checks
35 ###########################################################
36
37 set(CMAKE_EXTRA_INCLUDE_FILES string.h)
38 vlc_check_functions_exist(strcpy strcasecmp)
39 vlc_check_functions_exist(strcasestr strdup)
40 vlc_check_functions_exist(strndup stricmp strnicmp)
41 vlc_check_functions_exist(atof strtoll atoll lldiv)
42 vlc_check_functions_exist(strlcpy)
43 set(CMAKE_EXTRA_INCLUDE_FILES)
44
45 set(CMAKE_EXTRA_INCLUDE_FILES stdio.h)
46 vlc_check_functions_exist(vasprintf)
47 set(CMAKE_EXTRA_INCLUDE_FILES)
48
49 set(CMAKE_EXTRA_INCLUDE_FILES libc.h)
50 vlc_check_functions_exist(fork)
51 set(CMAKE_EXTRA_INCLUDE_FILES)
52
53 check_c_source_compiles(
54 "#include <langinfo.h>
55 int main() { char* cs = nl_langinfo(CODESET); }"
56 HAVE_LANGINFO_CODESET)
57
58 vlc_check_type("struct addrinfo" "sys/socket.h;netdb.h")
59 if(HAVE_STRUCT_ADDRINFO)
60   set(HAVE_ADDRINFO ON)
61 endif(HAVE_STRUCT_ADDRINFO)
62 vlc_check_type("struct timespec" "time.h")
63
64 check_c_source_compiles (
65 "#include <stdint.h> \n #ifdef UINTMAX \n #error no uintmax
66  #endif
67  int main() { return 0;}" HAVE_STDINT_H_WITH_UINTMAX)
68
69 check_symbol_exists(ntohl "sys/param.h" NTOHL_IN_SYS_PARAM_H)
70 check_symbol_exists(scandir "dirent.h" HAVE_SCANDIR)
71 check_symbol_exists(scandir "dirent.h" HAVE_SCANDIR)
72 check_symbol_exists(localtime_r "time.h" HAVE_LOCALTIME_R)
73
74 check_symbol_exists(getnameinfo "sys/types.h;sys/socket.h;netdb.h" HAVE_GETNAMEINFO)
75 check_symbol_exists(getaddrinfo "sys/types.h;sys/socket.h;netdb.h" HAVE_GETADDRINFO)
76 if(NOT HAVE_GETADDRINFO)
77     check_library_exists(getaddrinfo nsl "" HAVE_GETADDRINFO)
78 endif(NOT HAVE_GETADDRINFO)
79
80 set(LIBICONV "")
81 vlc_check_functions_exist(iconv)
82
83 if(NOT HAVE_ICONV)
84     set(LIBICONV "iconv")
85     check_library_exists(iconv iconv "" HAVE_ICONV)
86 endif(NOT HAVE_ICONV)
87 # FIXME: this will break on *BSD:
88 set( ICONV_CONST "" )
89
90 check_library_exists(rt clock_nanosleep "" HAVE_CLOCK_NANOSLEEP)
91 if (HAVE_CLOCK_NANOSLEEP)
92     set(LIBRT "rt")
93 endif (HAVE_CLOCK_NANOSLEEP)
94
95 check_library_exists(m pow "" HAVE_LIBM)
96 if (HAVE_LIBM)
97     set (LIBM "m")
98 endif (HAVE_LIBM)
99
100 ###########################################################
101 # Other check
102 ###########################################################
103 include( ${CMAKE_SOURCE_DIR}/cmake/vlc_test_inline.cmake )
104
105 ###########################################################
106 # Platform check
107 ###########################################################
108 if(APPLE)
109     include( ${CMAKE_SOURCE_DIR}/cmake/vlc_find_frameworks.cmake )
110
111     set(CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS
112             "${CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS} -undefined dynamic_lookup")
113         set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS
114             "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -undefined dynamic_lookup")
115
116     set(SYS_DARWIN 1)
117     add_definitions(-std=gnu99) # Hack for obj-c files to be compiled with gnu99
118     vlc_enable_modules(macosx minimal_macosx access_eyetv quartztext)
119
120     vlc_find_frameworks(Cocoa Carbon OpenGL AGL IOKit Quicktime
121                         WebKit QuartzCore Foundation ApplicationServices)
122     vlc_module_add_link_libraries(macosx
123         ${Cocoa_FRAMEWORKS}
124         ${IOKit_FRAMEWORKS}
125         ${OpenGL_FRAMEWORKS}
126         ${AGL_FRAMEWORKS}
127         ${Quicktime_FRAMEWORKS}
128         ${WebKit_FRAMEWORKS})
129     vlc_module_add_link_libraries(minimal_macosx
130         ${Cocoa_FRAMEWORKS}
131         ${Carbon_FRAMEWORKS}
132         ${OpenGL_FRAMEWORKS}
133         ${AGL_FRAMEWORKS})
134     vlc_module_add_link_libraries(access_eyetv
135         ${Foundation_FRAMEWORKS})
136     vlc_module_add_link_libraries(opengllayer
137          ${Cocoa_FRAMEWORKS}
138          ${QuartzCore_FRAMEWORKS}
139          ${OpenGL_FRAMEWORKS} )
140     vlc_module_add_link_libraries(quartztext
141          ${Carbon_FRAMEWORKS}
142          ${ApplicationServices_FRAMEWORKS} )
143     vlc_module_add_link_libraries(mp4
144          ${IOKit_FRAMEWORKS} )
145
146     add_executable(VLC MACOSX_BUNDLE src/vlc.c)
147     target_link_libraries(VLC libvlc)
148     add_custom_command(
149         TARGET VLC
150         POST_BUILD
151         COMMAND rm -Rf ${CMAKE_CURRENT_BINARY_DIR}/tmp
152         COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/tmp/modules/gui/macosx
153         COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/tmp/extras/package/macosx
154         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
155         COMMAND for i in AUTHORS COPYING THANKS\;do cp ${CMAKE_CURRENT_SOURCE_DIR}/$$i ${CMAKE_CURRENT_BINARY_DIR}/tmp\; done
156         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
157         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
158         COMMAND cp -r ${CMAKE_CURRENT_SOURCE_DIR}/extras/package/macosx/Resources ${CMAKE_CURRENT_BINARY_DIR}/VLC.app/Contents
159         COMMAND find -d ${CMAKE_CURRENT_BINARY_DIR}/VLC.app/Contents/Resources -type d -name \\.svn -exec rm -rf {} "\;"
160         COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/VLC.app/Contents/MacOS/modules
161         COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/VLC.app/Contents/MacOS/modules
162         COMMAND rm -f ${CMAKE_CURRENT_BINARY_DIR}/VLC.app/Contents/MacOS/share #remove the link if it exists
163         COMMAND ln -s ${CMAKE_CURRENT_SOURCE_DIR}/share ${CMAKE_CURRENT_BINARY_DIR}/VLC.app/Contents/MacOS/share
164         COMMAND find ${CMAKE_CURRENT_BINARY_DIR}/modules -name *.so -exec sh -c \"ln -s {} ${CMAKE_CURRENT_BINARY_DIR}/VLC.app/Contents/MacOS/modules/\\`basename {}\\`\" "\;"
165         COMMAND ln -sf VLC ${CMAKE_CURRENT_BINARY_DIR}/VLC.app/Contents/MacOS/clivlc #useless?
166         COMMAND printf "APPLVLC#" > ${CMAKE_CURRENT_BINARY_DIR}/VLC.app/Contents/PkgInfo
167         #TODO: po/ > VLC.app/locale
168     )
169
170 endif(APPLE)
171
172 ###########################################################
173 # version and info setup
174 ###########################################################
175
176 macro(command_to_configvar command var)
177  execute_process(
178   COMMAND sh -c "${command}"
179   OUTPUT_VARIABLE ${var}
180   OUTPUT_STRIP_TRAILING_WHITESPACE)
181  string( REPLACE "\n" "\\n" ${var} ${${var}})
182 endmacro(command_to_configvar)
183
184 command_to_configvar( "whoami" VLC_COMPILE_BY )
185 command_to_configvar( "hostname" VLC_COMPILE_HOST )
186 command_to_configvar( "hostname" VLC_COMPILE_DOMAIN )
187 command_to_configvar( "${CMAKE_C_COMPILER} --version" VLC_COMPILER )
188 # FIXME: WTF? this is not the configure line!
189 command_to_configvar( "${CMAKE_C_COMPILER} --version" CONFIGURE_LINE )
190 set( VLC_COMPILER "${CMAKE_C_COMPILER}" )
191
192 set(PACKAGE "vlc")
193 set(PACKAGE_STRING "vlc")
194 set(VERSION_MESSAGE "vlc-0.9.0-svn")
195 set(COPYRIGHT_MESSAGE "Copyright VLC Team")
196 set(COPYRIGHT_YEARS "2001-2007")
197
198 ###########################################################
199 # Options
200 ###########################################################
201
202 OPTION( ENABLE_HTTPD           "Enable httpd server" ON )
203 OPTION( ENABLE_VLM             "Enable vlm" ON )
204 OPTION( ENABLE_DYNAMIC_PLUGINS "Enable dynamic plugin" ON )
205 OPTION( ENABLE_NO_SYMBOL_CHECK "Don't check symbols of modules against libvlc. (Enabling this option speeds up compilation)" ON )
206
207 set( HAVE_DYNAMIC_PLUGINS ${ENABLE_DYNAMIC_PLUGINS})
208 set( LIBEXT ${CMAKE_SHARED_MODULE_SUFFIX})
209
210 ###########################################################
211 # Modules: Following are all listed in options
212 ###########################################################
213
214 # This module will be enabled but user could disabled it
215 vlc_enable_modules(dummy logger memcpy)
216 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)
217 vlc_enable_modules(cvdsub svcdsub spudec subsdec subsusf t140 dvbsub cc mpeg_audio lpcm a52 dts cinepak flac)
218 vlc_enable_modules(deinterlace invert adjust transform wave ripple psychedelic gradient motionblur rv32 rotate noise grain extract sharpen seamcarving)
219 vlc_enable_modules(converter_fixed mono)
220 vlc_enable_modules(trivial_resampler ugly_resampler)
221 vlc_enable_modules(trivial_channel_mixer trivial_mixer)
222 vlc_enable_modules(playlist export nsc xtag)
223 vlc_enable_modules(i420_rgb grey_yuv rawvideo blend scale image logo magnify puzzle colorthres)
224 vlc_enable_modules(wav araw subtitle vobsub adpcm a52sys dtssys au ty voc xa nuv smf)
225 vlc_enable_modules(access_directory access_file access_udp access_tcp)
226 vlc_enable_modules(access_http access_mms access_ftp)
227 vlc_enable_modules(access_filter_bandwidth)
228 vlc_enable_modules(packetizer_mpegvideo packetizer_h264)
229 vlc_enable_modules(packetizer_mpeg4video packetizer_mpeg4audio)
230 vlc_enable_modules(packetizer_vc1)
231 vlc_enable_modules(spatializer)
232
233 if(NOT mingwce)
234    set(enabled ON)
235 endif(NOT mingwce)
236 vlc_register_modules(${enabled} access_fake access_filter_timeshift access_filter_record access_filter_dump)
237 vlc_register_modules(${enabled} gestures rc telnet hotkeys showintf marq podcast shout sap fake folder)
238 vlc_register_modules(${enabled} rss mosaic wall motiondetect clone crop erase bluescreen alphamask gaussianblur)
239 vlc_register_modules(${enabled} i420_yuy2 i422_yuy2 i420_ymga i422_i420 yuy2_i422 yuy2_i420 chroma_chain)
240 vlc_register_modules(${enabled} aout_file linear_resampler bandlimited_resampler)
241 vlc_register_modules(${enabled} float32_mixer spdif_mixer simple_channel_mixer)
242 vlc_register_modules(${enabled} dolby_surround_decoder headphone_channel_mixer normvol equalizer param_eq)
243 vlc_register_modules(${enabled} converter_float a52tospdif dtstospdif audio_format)
244 set(enabled)
245
246 if(NOT WIN32)
247    vlc_enable_modules(screensaver)
248 endif(NOT WIN32)
249
250 # Following modules will be disabled but listed in options
251
252 vlc_disable_modules(asf)
253
254 # This module is disabled because the CMakeList.txt which
255 # is generated isn't correct. We'll put that back
256 # when cmake will be accepted as default build system
257 vlc_disable_modules(motion)
258
259 ###########################################################
260 # libraries
261 ###########################################################
262
263 pkg_check_modules(LIBCDDB libcddb>=0.9.5)
264 if(${LIBCDDB_FOUND})
265   vlc_module_add_link_libraries(cdda ${LIBCDDB_LIBRARIES})
266   vlc_add_module_compile_flag(cdda ${LIBCDDB_CFLAGS} )
267 endif(${LIBCDDB_FOUND})
268
269 include (FindDlopen)
270 set(HAVE_DL_DLOPEN ${Dlopen_FOUND})
271
272 ###########################################################
273 # Final configuration
274 ###########################################################
275 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/include/config.h)
276