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