Merge branch 'dbus-1.2'
[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-dataslot.c
125         ${DBUS_DIR}/dbus-file.c
126         ${DBUS_DIR}/dbus-hash.c
127         ${DBUS_DIR}/dbus-internals.c
128         ${DBUS_DIR}/dbus-list.c
129         ${DBUS_DIR}/dbus-marshal-basic.c
130         ${DBUS_DIR}/dbus-memory.c
131         ${DBUS_DIR}/dbus-mempool.c
132         ${DBUS_DIR}/dbus-string.c
133         ${DBUS_DIR}/dbus-sysdeps.c
134         ${DBUS_DIR}/dbus-pipe.c
135 )
136
137 set (DBUS_SHARED_HEADERS
138         ${DBUS_DIR}/dbus-dataslot.h
139         ${DBUS_DIR}/dbus-file.h
140         ${DBUS_DIR}/dbus-hash.h
141         ${DBUS_DIR}/dbus-internals.h
142         ${DBUS_DIR}/dbus-list.h
143         ${DBUS_DIR}/dbus-marshal-basic.h
144         ${DBUS_DIR}/dbus-mempool.h
145         ${DBUS_DIR}/dbus-string.h
146         ${DBUS_DIR}/dbus-string-private.h
147         ${DBUS_DIR}/dbus-pipe.h
148         ${DBUS_DIR}/dbus-sysdeps.h
149 )
150
151 ### source code that is generic utility functionality used
152 ### by the bus daemon or test apps, but is NOT included
153 ### in the D-BUS client library (all symbols in here 
154 ### should be underscore-prefixed but don't really need 
155 ### to be unless they move to DBUS_SHARED_SOURCES later)
156 set (DBUS_UTIL_SOURCES
157         ${DBUS_DIR}/dbus-auth-util.c
158         ${DBUS_DIR}/dbus-credentials-util.c
159         ${DBUS_DIR}/dbus-mainloop.c
160         ${DBUS_DIR}/dbus-marshal-byteswap-util.c
161         ${DBUS_DIR}/dbus-marshal-recursive-util.c
162         ${DBUS_DIR}/dbus-marshal-validate-util.c
163         ${DBUS_DIR}/dbus-message-factory.c
164         ${DBUS_DIR}/dbus-message-util.c
165         ${DBUS_DIR}/dbus-shell.c
166         ${DBUS_DIR}/dbus-string-util.c
167         ${DBUS_DIR}/dbus-sysdeps-util.c
168 )
169
170 if (DBUS_BUILD_TESTS)
171         set (DBUS_UTIL_SOURCES 
172                 ${DBUS_UTIL_SOURCES}
173                 ${DBUS_DIR}/dbus-test.c
174         )
175 endif (DBUS_BUILD_TESTS)
176
177 set (DBUS_UTIL_HEADERS
178         ${DBUS_DIR}/dbus-mainloop.h
179         ${DBUS_DIR}/dbus-message-factory.h
180         ${DBUS_DIR}/dbus-shell.h
181         ${DBUS_DIR}/dbus-spawn.h
182         ${DBUS_DIR}/dbus-test.h
183 )
184
185 ### platform specific settings
186 if (WIN32)
187         set (DBUS_SHARED_SOURCES ${DBUS_SHARED_SOURCES} 
188                 ${DBUS_DIR}/dbus-file-win.c
189                 ${DBUS_DIR}/dbus-sysdeps-win.c
190                 ${DBUS_DIR}/dbus-pipe-win.c
191                 ${DBUS_DIR}/dbus-sysdeps-thread-win.c
192         )
193         set (DBUS_SHARED_HEADERS ${DBUS_SHARED_HEADERS} 
194                 ${DBUS_DIR}/dbus-sockets-win.h
195                 ${DBUS_DIR}/dbus-sysdeps-win.h
196         )
197         set (DBUS_UTIL_SOURCES ${DBUS_UTIL_SOURCES}
198                 ${DBUS_DIR}/dbus-spawn-win.c
199                 ${DBUS_DIR}/dbus-sysdeps-util-win.c
200         )
201         if(WINCE)
202         set (DBUS_SHARED_SOURCES ${DBUS_SHARED_SOURCES}
203                 ${DBUS_DIR}/dbus-sysdeps-wince-glue.c
204         )
205         set (DBUS_SHARED_HEADERS ${DBUS_SHARED_HEADERS}
206                 ${DBUS_DIR}/dbus-sysdeps-wince-glue.h
207         )
208         endif(WINCE)
209 else (WIN32)
210         set (DBUS_SHARED_SOURCES ${DBUS_SHARED_SOURCES} 
211                 ${DBUS_DIR}/dbus-file-unix.c
212                 ${DBUS_DIR}/dbus-pipe-unix.c
213                 ${DBUS_DIR}/dbus-sysdeps-unix.c
214                 ${DBUS_DIR}/dbus-sysdeps-pthread.c
215                 ${DBUS_DIR}/dbus-userdb.c
216         )
217         set (DBUS_SHARED_HEADERS ${DBUS_SHARED_HEADERS} 
218                 ${DBUS_DIR}/dbus-server-unix.h
219                 ${DBUS_DIR}/dbus-transport-unix.h
220                 ${DBUS_DIR}/dbus-sysdeps-unix.h
221                 ${DBUS_DIR}/dbus-userdb.h
222         )
223         set (DBUS_UTIL_SOURCES ${DBUS_UTIL_SOURCES}
224                 ${DBUS_DIR}/dbus-spawn.c
225                 ${DBUS_DIR}/dbus-userdb-util.c
226                 ${DBUS_DIR}/dbus-sysdeps-util-unix.c
227         )
228 endif (WIN32)
229
230 set(libdbus_SOURCES
231         ${DBUS_LIB_SOURCES}
232         ${DBUS_SHARED_SOURCES}
233         # for debugging
234         ${DBUS_UTIL_SOURCES}
235 )
236
237 set(libdbus_HEADERS 
238         ${DBUS_LIB_HEADERS}
239         ${DBUS_SHARED_HEADERS}
240         # for debugging
241         ${DBUS_UTIL_HEADERS}
242 )
243 if (MSVC)
244     set (BUILD_FILEVERSION ${DBUS_MAJOR_VERSION},${DBUS_MINOR_VERSION},${DBUS_MICRO_VERSION},${DBUS_PATCH_VERSION})
245     set (BUILD_TIMESTAMP ${DBUS_BUILD_TIMESTAMP})
246     
247     configure_file(${DBUS_DIR}/versioninfo.rc.in ${CMAKE_CURRENT_BINARY_DIR}/versioninfo.rc)
248     file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/afxres.h "")
249     list(APPEND libdbus_SOURCES versioninfo.rc)
250     set_source_files_properties(versioninfo.rc COMPILE_FLAGS "-D__LINE__=1")
251 endif (MSVC)
252
253 if(MSVC_IDE)
254         project_source_group(${GROUP_CODE} DBUS_LIB_SOURCES DBUS_LIB_HEADERS)
255         project_source_group(${GROUP_CODE} DBUS_SHARED_SOURCES DBUS_SHARED_HEADERS)
256         project_source_group(${GROUP_CODE} DBUS_UTIL_SOURCES DBUS_UTIL_SOURCES)
257 endif(MSVC_IDE)
258
259 ### Client library
260
261 add_library(dbus-1 SHARED
262                         ${DBUS_LIB_SOURCES}
263                         ${DBUS_SHARED_SOURCES}
264                         ${DBUS_LIB_HEADERS}
265                         ${DBUS_SHARED_HEADERS})
266 if(WIN32)
267     if(WINCE)
268         target_link_libraries(dbus-1 ws2)
269     else(WINCE)
270         target_link_libraries(dbus-1 ws2_32 advapi32 netapi32)
271     endif(WINCE)
272 endif(WIN32)
273
274 install_targets(/lib dbus-1 )
275 install_files(/include/dbus FILES ${dbusinclude_HEADERS})
276
277 ### Internal library, used for the daemon, tools and tests, compiled statically.
278
279 add_library(dbus-internal ${DBUS_INTERNAL_ADD_LIBRARY_OPTIONS}
280                         ${DBUS_LIB_SOURCES}
281                         ${DBUS_LIB_HEADERS}
282                         ${DBUS_SHARED_SOURCES}
283                         ${DBUS_SHARED_HEADERS}
284                         ${DBUS_UTIL_SOURCES}
285                         ${DBUS_UTIL_HEADERS}
286 )
287 target_link_libraries(dbus-internal)
288 set_target_properties(dbus-internal PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_LIBRARY_DEFINITIONS})
289 if(WIN32)
290     if(WINCE)
291         target_link_libraries(dbus-internal ws2)
292     else(WINCE)
293         target_link_libraries(dbus-internal ws2_32 advapi32 netapi32)
294     endif(WINCE)
295 endif(WIN32)
296
297 if (DBUS_BUILD_TESTS)
298         set (TESTS_ENVIRONMENT "DBUS_TEST_DATA=${CMAKE_SOURCE_DIR}/test/data DBUS_TEST_HOMEDIR=${CMAKE_BUILD_DIR}/dbus")
299         ADD_EXECUTABLE(dbus-test ${CMAKE_SOURCE_DIR}/../dbus/dbus-test-main.c)
300         target_link_libraries(dbus-test ${DBUS_INTERNAL_LIBRARIES})
301         add_test(dbus-test ${EXECUTABLE_OUTPUT_PATH}/dbus-test ${CMAKE_SOURCE_DIR}/../test/data)
302         set_target_properties(dbus-test PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
303 ENDIF (DBUS_BUILD_TESTS)
304
305 if (UNIX)
306 # set version info
307 ENDIF (UNIX)
308
309
310 ## mop up the gcov files
311 #clean-local:
312 #/bin/rm *.bb *.bbg *.da *.gcov .libs/*.da .libs/*.bbg || true