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