fix libvlc linking when UPDATE_CHECK is on
[vlc.git] / extras / buildsystem / cmake / CMakeLists / src_CMakeLists.txt
1
2 add_definitions(-Dasm=__asm__ -D_INTL_REDIRECT_MACROS)
3 add_definitions(-DLOCALEDIR=\\"${CMAKE_INSTALL_PREFIX}/locale\\")
4 add_definitions(-DPLUGIN_PATH=\\"${CMAKE_INSTALL_PREFIX}/lib/vlc\\")
5 add_definitions(-DDATA_PATH=\\"${CMAKE_INSTALL_PREFIX}/share/vlc\\")
6
7 # vlc
8 add_executable(vlc vlc.c)
9 target_link_libraries(vlc libvlc)
10
11 # libvlc
12
13 set( SOURCES_libvlc_beos misc/beos_specific.cpp )
14 set( SOURCES_libvlc_darwin misc/darwin_specific.c )
15 set( SOURCES_libvlc_win32 misc/win32_specific.c )
16 set( SOURCES_libvlc_dirent extras/dirent.c )
17 set( SOURCES_libvlc_getopt misc/getopt.c misc/getopt.h misc/getopt1.c )
18 set( SOURCES_libvlc_common
19     libvlc.c
20     libvlc-common.c
21     libvlc.h
22     libvlc-module.c
23     interface/interface.h
24     interface/interface.c
25     interface/intf_eject.c
26     interface/interaction.c
27     playlist/playlist_internal.h
28     playlist/thread.c
29     playlist/control.c
30     playlist/engine.c
31     playlist/sort.c
32     playlist/loadsave.c
33     playlist/tree.c
34     playlist/item.c
35     playlist/search.c
36     playlist/services_discovery.c
37     input/item.c
38     input/access.c
39     input/clock.c
40     input/control.c
41     input/decoder.c
42     input/decoder_synchro.c
43     input/demux.c
44     input/es_out.c
45     input/input.c
46     input/meta.c
47     input/input_internal.h
48     input/vlm_internal.h
49     input/stream.c
50     input/mem_stream.c
51     input/subtitles.c
52     input/var.c
53     video_output/video_output.c
54     video_output/vout_pictures.c
55     video_output/vout_pictures.h
56     video_output/video_text.c
57     video_output/video_widgets.c
58     video_output/vout_subpictures.c
59     video_output/vout_intf.c
60     audio_output/aout_internal.h
61     audio_output/common.c
62     audio_output/dec.c
63     audio_output/filters.c
64     audio_output/input.c
65     audio_output/mixer.c
66     audio_output/output.c
67     audio_output/intf.c
68     stream_output/stream_output.c
69     stream_output/stream_output.h
70     stream_output/announce.c
71     stream_output/profiles.c
72     stream_output/sap.c
73     stream_output/sdp.c
74     osd/osd.c
75     osd/osd_text.c
76     osd/osd_widgets.c
77     network/acl.c
78     network/getaddrinfo.c
79     network/io.c
80     network/error.c
81     network/tcp.c
82     network/udp.c
83     network/httpd.c
84     network/rootwrap.c
85     network/tls.c
86     network/poll.c
87     text/charset.c
88     text/strings.c
89     text/unicode.c
90     text/wincp.c
91     text/iso_lang.c
92     text/iso-639_def.h
93     misc/md5.c
94     misc/rand.c
95     misc/mtime.c
96     misc/block.c
97     ${CMAKE_BINARY_DIR}/src/modules/builtin.h
98     modules/modules.h
99     modules/modules.c
100     modules/cache.c
101     modules/entry.c
102     modules/os.c
103     misc/threads.c
104     misc/stats.c
105     misc/cpu.c
106     config/configuration.h
107     config/core.c
108     config/chain.c
109     config/file.c
110     config/intf.c
111     config/cmdline.c
112     misc/events.c
113     misc/image.c
114     misc/messages.c
115     misc/objects.c
116     misc/variables.h
117     misc/variables.c
118     misc/error.c
119     misc/update.c
120     ${CMAKE_BINARY_DIR}/src/misc/revision.c
121     input/vlm.c
122     misc/xml.c
123     misc/devices.c
124     extras/libc.c
125     ${CMAKE_BINARY_DIR}/include/vlc_about.h )
126
127 set( SOURCES_libvlc ${SOURCES_libvlc_common} )
128
129 if(SYS_DARWIN)
130     set( SOURCES_libvlc ${SOURCES_libvlc} ${SOURCES_libvlc_darwin} )
131 endif(SYS_DARWIN)
132
133 add_library(libvlc SHARED ${SOURCES_libvlc})
134
135 set_target_properties(libvlc PROPERTIES
136         OUTPUT_NAME vlc
137         SOVERSION 1 VERSION 1.0.0)
138
139 if(UPDATE_CHECK)
140 target_link_libraries(libvlc ${LIBM} ${LIBRT} ${LIBICONV} ${Dlopen_LIBRARIES} "-lgcrypt")
141 else(UPDATE_CHECK)
142 target_link_libraries(libvlc ${LIBM} ${LIBRT} ${LIBICONV} ${Dlopen_LIBRARIES})
143 endif(UPDATE_CHECK)
144
145 # libvlc-control
146 set( SOURCES_libvlc_control
147      control/libvlc_internal.h
148      control/core.c
149      control/log.c
150      control/playlist.c
151      control/vlm.c
152      control/video.c
153      control/audio.c
154      control/dynamic_media_list.c
155      control/event.c
156      control/flat_media_list_view.c
157      control/hierarchical_media_list_view.c
158      control/hierarchical_node_media_list_view.c
159      control/media_descriptor.c
160      control/media_instance.c
161      control/media_list.c
162      control/media_list_path.h
163      control/media_list_player.c
164      control/media_list_view.c
165      control/media_library.c
166      control/mediacontrol_internal.h
167      control/mediacontrol_core.c
168      control/mediacontrol_util.c
169      control/mediacontrol_audio_video.c
170      control/media_discoverer.c
171      control/tag_query.c )
172
173 add_library(libvlc-control SHARED ${SOURCES_libvlc_control})
174
175 set_target_properties(libvlc-control PROPERTIES OUTPUT_NAME vlc-control)
176 set_target_properties(libvlc-control PROPERTIES SOVERSION 0)
177 set_target_properties(libvlc PROPERTIES VERSION 0.0.0)
178
179 target_link_libraries(libvlc-control libvlc)
180
181 ##########################################################
182 # Install
183
184 install(TARGETS libvlc libvlc-control DESTINATION lib)
185 install(TARGETS vlc DESTINATION bin)
186
187 ##########################################################
188 # Libraries
189
190 # Carbon
191 if(APPLE)
192   find_library(CARBON_FRAMEWORK Carbon)
193   target_link_libraries(libvlc ${CARBON_FRAMEWORK})
194 endif(APPLE)
195
196 ##########################################################
197 # revision.c
198
199 set(rev "${CMAKE_BINARY_DIR}/src/misc/revision.c")
200 exec_program(dirname ARGS ${rev} OUTPUT_VARIABLE rev_dir)
201
202 add_custom_command(
203 OUTPUT ${rev}
204 COMMAND    rm -f ${rev} ${rev}.tmp
205 COMMAND    mkdir -p ${rev_dir}
206 COMMAND    sh -c "echo '/* AUTOGENERATED FILE - DO NOT EDIT */' > ${rev}.tmp"
207 COMMAND    sh -c "printf 'const char psz_vlc_changeset[] = \"' >> ${rev}.tmp"
208 COMMAND    sh -c "printf `LANG=C svnversion ${CMAKE_SOURCE_DIR} || printf \"exported\"` >> ${rev}.tmp"
209 COMMAND    sh -c "echo '\";' >> ${rev}.tmp"
210 COMMAND    mv -f ${rev}.tmp ${rev}
211 VERBATIM
212 )
213 set(rev)
214
215 ##########################################################
216 # builtin.h
217 # No real use for this one, we just used to need it.
218 # We should really remove that.
219 set(builtin "${CMAKE_BINARY_DIR}/src/modules/builtin.h")
220 exec_program(dirname ARGS ${builtin} OUTPUT_VARIABLE builtin_dir)
221
222 add_custom_command(
223 OUTPUT ${builtin}
224 COMMAND    mkdir -p ${builtin_dir}
225 COMMAND    sh -c "echo '/* Auto generated by ${CMAKE_CURRENT_BUILD_DIR}/CMakeLists.txt */' > ${builtin}"
226 COMMAND    sh -c "echo 'int vlc_entry__main( module_t* );' >> ${builtin}"
227 COMMAND    sh -c "echo '#define ALLOCATE_ALL_BUILTINS() do {} while(0)' >> ${builtin}"
228 VERBATIM
229 )
230 set(should)
231
232 ##########################################################
233 # vlc_about.h
234 set(about "${CMAKE_BINARY_DIR}/include/vlc_about.h")
235 exec_program(dirname ARGS ${about} OUTPUT_VARIABLE about_dir)
236
237 add_custom_command(
238 OUTPUT ${about}
239 COMMAND rm -f "${about}.tmp"
240 COMMAND mkdir -p ${about_dir}
241 COMMAND sh -c "echo '/* Automatically generated file - DO NOT EDIT */' > ${about}.tmp"
242 COMMAND sh -c "echo 'static const char psz_license[] =' >> ${about}.tmp"
243 COMMAND sh -c "cat ${CMAKE_SOURCE_DIR}/COPYING | sed s/\\\"/''/g | awk '{ print \"\\\"\"$0\"\\\\n\\\"\" }' >> ${about}.tmp"
244 COMMAND sh -c "echo ';' >> ${about}.tmp"
245 COMMAND sh -c "echo 'static const char psz_thanks[] =' >> ${about}.tmp"
246 COMMAND sh -c "grep -v '$$Id:'  ${CMAKE_SOURCE_DIR}/THANKS | sed 's/\"/''/g' | awk '{ print  \"\\\"\"$0\"\\\\n\\\"\" }'|sed 's/\"<.*.> \"//' >> ${about}.tmp"
247 COMMAND sh -c "echo ';' >> ${about}.tmp"
248 COMMAND sh -c "echo 'static const char psz_authors[] =' >> ${about}.tmp"
249 COMMAND sh -c "grep N: ${CMAKE_SOURCE_DIR}/AUTHORS | cut -d '\ ' -f 2- | sed 's/\"/''/g' | awk '{ print  \"\\\"\"$0\"\\\\n\\\"\" }' >> ${about}.tmp"
250 COMMAND sh -c "echo ';' >> ${about}.tmp"
251 COMMAND sh -c "mv -f -- ${about}.tmp ${about}"
252 DEPENDS ${CMAKE_SOURCE_DIR}/AUTHORS ${CMAKE_SOURCE_DIR}/THANKS ${CMAKE_SOURCE_DIR}/COPYING
253 VERBATIM
254 )
255 set(about)
256
257
258 ##########################################################
259 # SET_TARGET_PROPERTIES
260
261 # FIXME: Should probably be autodetected in configure?
262 if(NOT APPLE)
263    set(LINK_FLAGS "-z defs --as-needed")
264 endif(NOT APPLE)
265
266 target_link_libraries(libvlc "${CMAKE_THREAD_LIBS_INIT}")
267 target_link_libraries(libvlc-control "${CMAKE_THREAD_LIBS_INIT}")
268
269 set_target_properties(libvlc libvlc-control vlc PROPERTIES COMPILE_FLAGS
270     "-Wall -Wextra -Wsign-compare -Wundef -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Wmissing-prototypes -I${CMAKE_BINARY_DIR}/src -I${CMAKE_BINARY_DIR}/include" )
271
272 ##########################################################
273 # Tests
274
275 add_executable(test_testapi    control/testapi.c)
276 add_executable(test_i18n_atof  test/i18n_atof.c)
277 add_executable(test_url        test/url.c)
278 add_executable(test_utf8       test/utf8.c)
279 add_executable(test_dictionary test/dictionary.c)
280
281 target_link_libraries(test_testapi    libvlc-control)
282 target_link_libraries(test_i18n_atof  libvlc)
283 target_link_libraries(test_url        libvlc)
284 target_link_libraries(test_utf8       libvlc)
285 target_link_libraries(test_dictionary libvlc)
286
287 add_test(test_control    ${CMAKE_CURRENT_BINARY_DIR}/test_testapi)
288 add_test(test_i18n_atof  ${CMAKE_CURRENT_BINARY_DIR}/test_i18n_atof)
289 add_test(test_url        ${CMAKE_CURRENT_BINARY_DIR}/test_url)
290 add_test(test_utf8       ${CMAKE_CURRENT_BINARY_DIR}/test_utf8)
291 add_test(test_dictionary ${CMAKE_CURRENT_BINARY_DIR}/test_dictionary)
292