Bug 28460 - Refactored dbus configuration access.
[platform/upstream/dbus.git] / cmake / dbus / CMakeLists.txt
1 project(dbus-lib)
2
3 SET(DBUS_DIR ${CMAKE_SOURCE_DIR}/../dbus)
4
5 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dbus-arch-deps.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/dbus-arch-deps.h )
6
7 add_definitions(-DDBUS_COMPILATION)
8
9 set (dbusinclude_HEADERS
10         ${DBUS_DIR}/dbus.h
11         ${DBUS_DIR}/dbus-address.h
12         ${DBUS_DIR}/dbus-bus.h
13         ${DBUS_DIR}/dbus-connection.h
14         ${DBUS_DIR}/dbus-errors.h
15         ${DBUS_DIR}/dbus-macros.h
16         ${DBUS_DIR}/dbus-memory.h
17         ${DBUS_DIR}/dbus-message.h
18         ${DBUS_DIR}/dbus-misc.h
19         ${DBUS_DIR}/dbus-pending-call.h
20         ${DBUS_DIR}/dbus-protocol.h
21         ${DBUS_DIR}/dbus-server.h
22         ${DBUS_DIR}/dbus-shared.h
23         ${DBUS_DIR}/dbus-signature.h
24         ${DBUS_DIR}/dbus-threads.h
25         ${DBUS_DIR}/dbus-types.h
26         dbus-arch-deps.h
27 )
28
29 ### source code that goes in the installed client library
30 ### and is specific to library functionality
31 set (DBUS_LIB_SOURCES
32         ${DBUS_DIR}/dbus-address.c
33         ${DBUS_DIR}/dbus-auth.c
34         ${DBUS_DIR}/dbus-auth-script.c
35         ${DBUS_DIR}/dbus-bus.c
36         ${DBUS_DIR}/dbus-connection.c
37         ${DBUS_DIR}/dbus-credentials.c
38         ${DBUS_DIR}/dbus-errors.c
39         ${DBUS_DIR}/dbus-keyring.c
40         ${DBUS_DIR}/dbus-marshal-header.c
41         ${DBUS_DIR}/dbus-marshal-byteswap.c
42         ${DBUS_DIR}/dbus-marshal-recursive.c
43         ${DBUS_DIR}/dbus-marshal-validate.c
44         ${DBUS_DIR}/dbus-message.c
45         ${DBUS_DIR}/dbus-misc.c
46         ${DBUS_DIR}/dbus-nonce.c
47         ${DBUS_DIR}/dbus-object-tree.c
48         ${DBUS_DIR}/dbus-pending-call.c
49         ${DBUS_DIR}/dbus-resources.c
50         ${DBUS_DIR}/dbus-server.c
51         ${DBUS_DIR}/dbus-server-socket.c
52         ${DBUS_DIR}/dbus-server-debug-pipe.c
53         ${DBUS_DIR}/dbus-sha.c
54         ${DBUS_DIR}/dbus-signature.c
55         ${DBUS_DIR}/dbus-timeout.c
56         ${DBUS_DIR}/dbus-threads.c
57         ${DBUS_DIR}/dbus-transport.c
58         ${DBUS_DIR}/dbus-transport-socket.c
59         ${DBUS_DIR}/dbus-watch.c
60 #dbus-md5.c
61 #
62 #  find a clean Windows implementation
63 #  and move code to a *-win.c file
64 )
65
66
67 if(UNIX)
68         set (DBUS_LIB_SOURCES ${DBUS_LIB_SOURCES} 
69                 ${DBUS_DIR}/dbus-transport-unix.c
70                 ${DBUS_DIR}/dbus-server-unix.c
71         )
72 else(UNIX)
73         set (DBUS_LIB_SOURCES ${DBUS_LIB_SOURCES} 
74                 ${DBUS_DIR}/dbus-transport-win.c
75                 ${DBUS_DIR}/dbus-server-win.c
76         )
77 endif(UNIX)
78
79 set (DBUS_LIB_HEADERS
80         ${DBUS_DIR}/dbus-auth.h
81         ${DBUS_DIR}/dbus-auth-script.h
82         ${DBUS_DIR}/dbus-connection-internal.h
83         ${DBUS_DIR}/dbus-credentials.h
84         ${DBUS_DIR}/dbus-keyring.h
85         ${DBUS_DIR}/dbus-marshal-header.h
86         ${DBUS_DIR}/dbus-marshal-byteswap.h
87         ${DBUS_DIR}/dbus-marshal-recursive.h
88         ${DBUS_DIR}/dbus-marshal-validate.h
89         ${DBUS_DIR}/dbus-message-internal.h
90         ${DBUS_DIR}/dbus-message-private.h
91         ${DBUS_DIR}/dbus-misc.h
92         ${DBUS_DIR}/dbus-object-tree.h
93         ${DBUS_DIR}/dbus-protocol.h
94         ${DBUS_DIR}/dbus-resources.h
95         ${DBUS_DIR}/dbus-server-debug-pipe.h
96         ${DBUS_DIR}/dbus-server-protected.h
97         ${DBUS_DIR}/dbus-server-unix.h
98         ${DBUS_DIR}/dbus-sha.h
99         ${DBUS_DIR}/dbus-timeout.h
100         ${DBUS_DIR}/dbus-threads.h
101         ${DBUS_DIR}/dbus-threads-internal.h
102         ${DBUS_DIR}/dbus-transport.h
103         ${DBUS_DIR}/dbus-transport-protected.h
104         ${DBUS_DIR}/dbus-watch.h
105         ${CMAKE_BINARY_DIR}/config.h
106 ##dbus-md5.h
107 )
108 if(UNIX)
109         set (DBUS_LIB_HEADERS ${DBUS_LIB_HEADERS} 
110                 ${DBUS_DIR}/dbus-transport-unix.h
111         )
112 else(UNIX)
113         set (DBUS_LIB_HEADERS ${DBUS_LIB_HEADERS} 
114                 ${DBUS_DIR}/dbus-transport-win.h
115         )
116 endif(UNIX)
117
118
119 ### source code that goes in the installed client library
120 ### AND is generic utility functionality used by the 
121 ### daemon or test programs (all symbols in here should 
122 ### be underscore-prefixed)
123 set (DBUS_SHARED_SOURCES
124         ${DBUS_DIR}/dbus-config.c
125         ${DBUS_DIR}/dbus-dataslot.c
126         ${DBUS_DIR}/dbus-file.c
127         ${DBUS_DIR}/dbus-hash.c
128         ${DBUS_DIR}/dbus-internals.c
129         ${DBUS_DIR}/dbus-list.c
130         ${DBUS_DIR}/dbus-marshal-basic.c
131         ${DBUS_DIR}/dbus-memory.c
132         ${DBUS_DIR}/dbus-mempool.c
133         ${DBUS_DIR}/dbus-string.c
134         ${DBUS_DIR}/dbus-sysdeps.c
135         ${DBUS_DIR}/dbus-pipe.c
136 )
137
138 set (DBUS_SHARED_HEADERS
139         ${DBUS_DIR}/dbus-dataslot.h
140         ${DBUS_DIR}/dbus-file.h
141         ${DBUS_DIR}/dbus-hash.h
142         ${DBUS_DIR}/dbus-internals.h
143         ${DBUS_DIR}/dbus-list.h
144         ${DBUS_DIR}/dbus-marshal-basic.h
145         ${DBUS_DIR}/dbus-mempool.h
146         ${DBUS_DIR}/dbus-string.h
147         ${DBUS_DIR}/dbus-string-private.h
148         ${DBUS_DIR}/dbus-pipe.h
149         ${DBUS_DIR}/dbus-sysdeps.h
150 )
151
152 ### source code that is generic utility functionality used
153 ### by the bus daemon or test apps, but is NOT included
154 ### in the D-BUS client library (all symbols in here 
155 ### should be underscore-prefixed but don't really need 
156 ### to be unless they move to DBUS_SHARED_SOURCES later)
157 set (DBUS_UTIL_SOURCES
158         ${DBUS_DIR}/dbus-auth-util.c
159         ${DBUS_DIR}/dbus-config.h
160         ${DBUS_DIR}/dbus-credentials-util.c
161         ${DBUS_DIR}/dbus-mainloop.c
162         ${DBUS_DIR}/dbus-marshal-byteswap-util.c
163         ${DBUS_DIR}/dbus-marshal-recursive-util.c
164         ${DBUS_DIR}/dbus-marshal-validate-util.c
165         ${DBUS_DIR}/dbus-message-factory.c
166         ${DBUS_DIR}/dbus-message-util.c
167         ${DBUS_DIR}/dbus-shell.c
168         ${DBUS_DIR}/dbus-string-util.c
169         ${DBUS_DIR}/dbus-sysdeps-util.c
170 )
171
172 if (DBUS_BUILD_TESTS)
173         set (DBUS_UTIL_SOURCES 
174                 ${DBUS_UTIL_SOURCES}
175                 ${DBUS_DIR}/dbus-test.c
176         )
177 endif (DBUS_BUILD_TESTS)
178
179 set (DBUS_UTIL_HEADERS
180         ${DBUS_DIR}/dbus-mainloop.h
181         ${DBUS_DIR}/dbus-message-factory.h
182         ${DBUS_DIR}/dbus-shell.h
183         ${DBUS_DIR}/dbus-spawn.h
184         ${DBUS_DIR}/dbus-test.h
185 )
186
187 ### platform specific settings
188 if (WIN32)
189         set (DBUS_SHARED_SOURCES ${DBUS_SHARED_SOURCES} 
190                 ${DBUS_DIR}/dbus-file-win.c
191                 ${DBUS_DIR}/dbus-sysdeps-win.c
192                 ${DBUS_DIR}/dbus-pipe-win.c
193                 ${DBUS_DIR}/dbus-sysdeps-thread-win.c
194         )
195         set (DBUS_SHARED_HEADERS ${DBUS_SHARED_HEADERS} 
196                 ${DBUS_DIR}/dbus-sockets-win.h
197                 ${DBUS_DIR}/dbus-sysdeps-win.h
198         )
199         set (DBUS_UTIL_SOURCES ${DBUS_UTIL_SOURCES}
200                 ${DBUS_DIR}/dbus-spawn-win.c
201                 ${DBUS_DIR}/dbus-sysdeps-util-win.c
202         )
203         if(WINCE)
204         set (DBUS_SHARED_SOURCES ${DBUS_SHARED_SOURCES}
205                 ${DBUS_DIR}/dbus-sysdeps-wince-glue.c
206         )
207         set (DBUS_SHARED_HEADERS ${DBUS_SHARED_HEADERS}
208                 ${DBUS_DIR}/dbus-sysdeps-wince-glue.h
209         )
210         endif(WINCE)
211 else (WIN32)
212         set (DBUS_SHARED_SOURCES ${DBUS_SHARED_SOURCES} 
213                 ${DBUS_DIR}/dbus-file-unix.c
214                 ${DBUS_DIR}/dbus-pipe-unix.c
215                 ${DBUS_DIR}/dbus-sysdeps-unix.c
216                 ${DBUS_DIR}/dbus-sysdeps-pthread.c
217                 ${DBUS_DIR}/dbus-userdb.c
218         )
219         set (DBUS_SHARED_HEADERS ${DBUS_SHARED_HEADERS} 
220                 ${DBUS_DIR}/dbus-server-unix.h
221                 ${DBUS_DIR}/dbus-transport-unix.h
222                 ${DBUS_DIR}/dbus-sysdeps-unix.h
223                 ${DBUS_DIR}/dbus-userdb.h
224         )
225         set (DBUS_UTIL_SOURCES ${DBUS_UTIL_SOURCES}
226                 ${DBUS_DIR}/dbus-spawn.c
227                 ${DBUS_DIR}/dbus-userdb-util.c
228                 ${DBUS_DIR}/dbus-sysdeps-util-unix.c
229         )
230 endif (WIN32)
231
232 set(libdbus_SOURCES
233         ${DBUS_LIB_SOURCES}
234         ${DBUS_SHARED_SOURCES}
235         # for debugging
236         ${DBUS_UTIL_SOURCES}
237 )
238
239 set(libdbus_HEADERS 
240         ${DBUS_LIB_HEADERS}
241         ${DBUS_SHARED_HEADERS}
242         # for debugging
243         ${DBUS_UTIL_HEADERS}
244 )
245 if (MSVC)
246     set (BUILD_FILEVERSION ${DBUS_MAJOR_VERSION},${DBUS_MINOR_VERSION},${DBUS_MICRO_VERSION},${DBUS_PATCH_VERSION})
247     set (BUILD_TIMESTAMP ${DBUS_BUILD_TIMESTAMP})
248     
249     configure_file(${DBUS_DIR}/versioninfo.rc.in ${CMAKE_CURRENT_BINARY_DIR}/versioninfo.rc)
250     file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/afxres.h "")
251     list(APPEND libdbus_SOURCES versioninfo.rc)
252     set_source_files_properties(versioninfo.rc COMPILE_FLAGS "-D__LINE__=1")
253 endif (MSVC)
254
255 if(MSVC_IDE)
256         project_source_group(${GROUP_CODE} DBUS_LIB_SOURCES DBUS_LIB_HEADERS)
257         project_source_group(${GROUP_CODE} DBUS_SHARED_SOURCES DBUS_SHARED_HEADERS)
258         project_source_group(${GROUP_CODE} DBUS_UTIL_SOURCES DBUS_UTIL_SOURCES)
259 endif(MSVC_IDE)
260
261 ### Client library
262
263 add_library(dbus-1 SHARED
264                         ${DBUS_LIB_SOURCES}
265                         ${DBUS_SHARED_SOURCES}
266                         ${DBUS_LIB_HEADERS}
267                         ${DBUS_SHARED_HEADERS})
268 if(WIN32)
269     if(WINCE)
270         target_link_libraries(dbus-1 ws2)
271     else(WINCE)
272         target_link_libraries(dbus-1 ws2_32 advapi32 netapi32)
273     endif(WINCE)
274 endif(WIN32)
275
276 install_targets(/lib dbus-1 )
277 install_files(/include/dbus FILES ${dbusinclude_HEADERS})
278
279 ### Internal library, used for the daemon, tools and tests, compiled statically.
280
281 add_library(dbus-internal ${DBUS_INTERNAL_ADD_LIBRARY_OPTIONS}
282                         ${DBUS_LIB_SOURCES}
283                         ${DBUS_LIB_HEADERS}
284                         ${DBUS_SHARED_SOURCES}
285                         ${DBUS_SHARED_HEADERS}
286                         ${DBUS_UTIL_SOURCES}
287                         ${DBUS_UTIL_HEADERS}
288 )
289 target_link_libraries(dbus-internal)
290 set_target_properties(dbus-internal PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_LIBRARY_DEFINITIONS})
291 if(WIN32)
292     if(WINCE)
293         target_link_libraries(dbus-internal ws2)
294     else(WINCE)
295         target_link_libraries(dbus-internal ws2_32 advapi32 netapi32)
296     endif(WINCE)
297 endif(WIN32)
298
299 if (DBUS_BUILD_TESTS)
300         set (TESTS_ENVIRONMENT "DBUS_TEST_DATA=${CMAKE_SOURCE_DIR}/test/data DBUS_TEST_HOMEDIR=${CMAKE_BUILD_DIR}/dbus")
301         ADD_EXECUTABLE(dbus-test ${CMAKE_SOURCE_DIR}/../dbus/dbus-test-main.c)
302         target_link_libraries(dbus-test ${DBUS_INTERNAL_LIBRARIES})
303         add_test(dbus-test ${EXECUTABLE_OUTPUT_PATH}/dbus-test ${CMAKE_SOURCE_DIR}/../test/data)
304         set_target_properties(dbus-test PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
305 ENDIF (DBUS_BUILD_TESTS)
306
307 if (UNIX)
308 # set version info
309 ENDIF (UNIX)
310
311
312 ## mop up the gcov files
313 #clean-local:
314 #/bin/rm *.bb *.bbg *.da *.gcov .libs/*.da .libs/*.bbg || true