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