]> git.sesse.net Git - vlc/blob - extras/buildsystem/cmake/include/config.cmake
cmake: Don't have modules to depend on libvlc on non-win32 platform.
[vlc] / 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(CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS
98             "${CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS} -undefined dynamic_lookup")
99         set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS
100             "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -undefined dynamic_lookup")
101     MESSAGE( "Using ${CMAKE_SHARED_MODULE_LINK_C_FLAGS}" )
102
103     set(HAVE_DL_DYLD ON INTERNAL)
104     set(SYS_DARWIN 1)
105
106     vlc_enable_modules(macosx minimal_macosx access_eyetv quartztext)
107
108     vlc_find_frameworks(Cocoa Carbon OpenGL AGL IOKit Quicktime
109                         WebKit QuartzCore Foundation ApplicationServices)
110     vlc_module_add_link_libraries(macosx
111         ${Cocoa_FRAMEWORKS}
112         ${IOKit_FRAMEWORKS}
113         ${OpenGL_FRAMEWORKS}
114         ${AGL_FRAMEWORKS}
115         ${Quicktime_FRAMEWORKS}
116         ${WebKit_FRAMEWORKS})
117     vlc_module_add_link_libraries(minimal_macosx
118         ${Cocoa_FRAMEWORKS}
119         ${Carbon_FRAMEWORKS}
120         ${OpenGL_FRAMEWORKS}
121         ${AGL_FRAMEWORKS})
122     vlc_module_add_link_libraries(access_eyetv
123         ${Foundation_FRAMEWORKS})
124     vlc_module_add_link_libraries(opengllayer
125          ${Cocoa_FRAMEWORKS}
126          ${QuartzCore_FRAMEWORKS}
127          ${OpenGL_FRAMEWORKS} )
128     vlc_module_add_link_libraries(quartztext
129          ${Carbon_FRAMEWORKS}
130          ${ApplicationServices_FRAMEWORKS} )
131     vlc_module_add_link_libraries(mp4
132          ${IOKit_FRAMEWORKS} )
133
134     add_executable(VLC MACOSX_BUNDLE src/vlc.c)
135     target_link_libraries(VLC libvlc)
136     add_custom_command(
137         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/VLC.app/Contents/MacOS/modules
138         COMMAND ln -s ${CMAKE_CURRENT_BINARY_DIR}/modules ${CMAKE_CURRENT_BINARY_DIR}/VLC.app/Contents/MacOS/lib
139     )
140     add_custom_command(
141         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/VLC.app/Contents/MacOS/lib
142         COMMAND ln -s ${CMAKE_CURRENT_BINARY_DIR}/modules ${CMAKE_CURRENT_BINARY_DIR}/VLC.app/Contents/MacOS/lib
143     )
144
145 endif(APPLE)
146
147 ###########################################################
148 # version and info setup
149 ###########################################################
150
151 macro(command_to_configvar command var)
152  execute_process(
153   COMMAND sh -c "${command}"
154   OUTPUT_VARIABLE ${var}
155   OUTPUT_STRIP_TRAILING_WHITESPACE)
156  string( REPLACE "\n" "\\n" ${var} ${${var}})
157 endmacro(command_to_configvar)
158
159 command_to_configvar( "whoami" VLC_COMPILE_BY )
160 command_to_configvar( "hostname" VLC_COMPILE_HOST )
161 command_to_configvar( "hostname" VLC_COMPILE_DOMAIN )
162 command_to_configvar( "${CMAKE_C_COMPILER} --version" VLC_COMPILER )
163 command_to_configvar( "${CMAKE_C_COMPILER} --version" CONFIGURE_LINE )
164 set( VLC_COMPILER "${CMAKE_C_COMPILER}" )
165
166 set(PACKAGE "vlc")
167 set(PACKAGE_STRING "vlc")
168 set(VERSION_MESSAGE "vlc-0.9.0-svn")
169 set(COPYRIGHT_MESSAGE "Copyright VLC Team")
170 set(COPYRIGHT_YEARS "2001-2007")
171
172 ###########################################################
173 # Options
174 ###########################################################
175
176 OPTION( ENABLE_HTTPD "Enable httpd server" ON )
177 OPTION( ENABLE_VLM   "Enable vlm" ON )
178
179 ###########################################################
180 # Modules: Following are all listed in options
181 ###########################################################
182
183 # This module will be enabled but user could disabled it
184 vlc_enable_modules(dummy logger memcpy)
185 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)
186 vlc_enable_modules(cvdsub svcdsub spudec subsdec subsusf t140 dvbsub cc mpeg_audio lpcm a52 dts cinepak flac)
187 vlc_enable_modules(deinterlace invert adjust transform wave ripple psychedelic gradient motionblur rv32 rotate noise grain extract sharpen seamcarving)
188 vlc_enable_modules(converter_fixed mono)
189 vlc_enable_modules(trivial_resampler ugly_resampler)
190 vlc_enable_modules(trivial_channel_mixer trivial_mixer)
191 vlc_enable_modules(playlist export nsc xtag)
192 vlc_enable_modules(i420_rgb grey_yuv rawvideo blend scale image logo magnify puzzle colorthres)
193 vlc_enable_modules(wav araw subtitle vobsub adpcm a52sys dtssys au ty voc xa nuv smf)
194 vlc_enable_modules(access_directory access_file access_udp access_tcp)
195 vlc_enable_modules(access_http access_mms access_ftp)
196 vlc_enable_modules(access_filter_bandwidth)
197 vlc_enable_modules(packetizer_mpegvideo packetizer_h264)
198 vlc_enable_modules(packetizer_mpeg4video packetizer_mpeg4audio)
199 vlc_enable_modules(packetizer_vc1)
200 vlc_enable_modules(spatializer)
201
202 vlc_disable_modules(asf)
203
204 # This module will be disabled but listed in options
205 if(NOT mingwce)
206    set(enabled ON)
207 endif(NOT mingwce)
208 vlc_register_modules(${enabled} access_fake access_filter_timeshift access_filter_record access_filter_dump)
209 vlc_register_modules(${enabled} gestures rc telnet hotkeys showintf marq podcast shout sap fake folder)
210 vlc_register_modules(${enabled} rss mosaic wall motiondetect clone crop erase bluescreen alphamask gaussianblur)
211 vlc_register_modules(${enabled} i420_yuy2 i422_yuy2 i420_ymga i422_i420 yuy2_i422 yuy2_i420 chroma_chain)
212 vlc_register_modules(${enabled} aout_file linear_resampler bandlimited_resampler)
213 vlc_register_modules(${enabled} float32_mixer spdif_mixer simple_channel_mixer)
214 vlc_register_modules(${enabled} dolby_surround_decoder headphone_channel_mixer normvol equalizer param_eq)
215 vlc_register_modules(${enabled} converter_float a52tospdif dtstospdif audio_format)
216 set(enabled)
217
218 if(NOT WIN32)
219    vlc_register_modules(${enabled} screensaver motion)
220 endif(NOT WIN32)
221
222
223 # vlc_disable_module()
224
225
226 pkg_check_modules(LIBCDDB libcddb>=0.9.5)
227 if(${LIBCDDB_FOUND})
228   #vlc_add_library(cdda ${LIBCDDB_LIBRARIES})
229   vlc_add_compile_flag(cdda ${LIBCDDB_CFLAGS} )
230 endif(${LIBCDDB_FOUND})
231
232 set( MODULES_CFLAGS, "-std=c99" )
233
234 ###########################################################
235 # Final configuration
236 ###########################################################
237 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/include/config.h)