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