CMakeLists.txt 9.28 KB
Newer Older
1
project(dbus-lib)
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

#INCLUDES=-I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) -DDBUS_COMPILATION

SET(DBUS_DIR ${CMAKE_SOURCE_DIR}/../dbus)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dbus-arch-deps.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/dbus-arch-deps.h )

add_definitions(-DDBUS_COMPILATION)

set (dbusinclude_HEADERS
	${DBUS_DIR}/dbus.h
	${DBUS_DIR}/dbus-address.h
	${DBUS_DIR}/dbus-bus.h
	${DBUS_DIR}/dbus-connection.h
	${DBUS_DIR}/dbus-errors.h
	${DBUS_DIR}/dbus-macros.h
	${DBUS_DIR}/dbus-memory.h
	${DBUS_DIR}/dbus-message.h
	${DBUS_DIR}/dbus-misc.h
	${DBUS_DIR}/dbus-pending-call.h
	${DBUS_DIR}/dbus-protocol.h
	${DBUS_DIR}/dbus-server.h
	${DBUS_DIR}/dbus-shared.h
	${DBUS_DIR}/dbus-signature.h
26
	${DBUS_DIR}/dbus-spawn.h
27 28 29 30 31 32 33 34 35 36 37 38 39
	${DBUS_DIR}/dbus-threads.h
	${DBUS_DIR}/dbus-types.h
	dbus-arch-deps.h
)

### source code that goes in the installed client library
### and is specific to library functionality
set (DBUS_LIB_SOURCES
	${DBUS_DIR}/dbus-address.c
	${DBUS_DIR}/dbus-auth.c
	${DBUS_DIR}/dbus-auth-script.c
	${DBUS_DIR}/dbus-bus.c
	${DBUS_DIR}/dbus-connection.c
40
	${DBUS_DIR}/dbus-credentials.c
41 42 43 44 45 46 47 48
	${DBUS_DIR}/dbus-errors.c
	${DBUS_DIR}/dbus-keyring.c
	${DBUS_DIR}/dbus-marshal-header.c
	${DBUS_DIR}/dbus-marshal-byteswap.c
	${DBUS_DIR}/dbus-marshal-recursive.c
	${DBUS_DIR}/dbus-marshal-validate.c
	${DBUS_DIR}/dbus-message.c
	${DBUS_DIR}/dbus-misc.c
49
	${DBUS_DIR}/dbus-nonce.c
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
	${DBUS_DIR}/dbus-object-tree.c
	${DBUS_DIR}/dbus-pending-call.c
	${DBUS_DIR}/dbus-resources.c
	${DBUS_DIR}/dbus-server.c
	${DBUS_DIR}/dbus-server-socket.c
	${DBUS_DIR}/dbus-server-debug-pipe.c
	${DBUS_DIR}/dbus-sha.c
	${DBUS_DIR}/dbus-signature.c
	${DBUS_DIR}/dbus-timeout.c
	${DBUS_DIR}/dbus-threads.c
	${DBUS_DIR}/dbus-transport.c
	${DBUS_DIR}/dbus-transport-socket.c
	${DBUS_DIR}/dbus-watch.c
#dbus-md5.c
#
#  find a clean Windows implementation
#  and move code to a *-win.c file
)
68 69


70
if(UNIX)
71 72 73
	set (DBUS_LIB_SOURCES ${DBUS_LIB_SOURCES} 
		${DBUS_DIR}/dbus-transport-unix.c
		${DBUS_DIR}/dbus-server-unix.c
74
	)
75
else(UNIX)
76 77 78
	set (DBUS_LIB_SOURCES ${DBUS_LIB_SOURCES} 
		${DBUS_DIR}/dbus-transport-win.c
		${DBUS_DIR}/dbus-server-win.c
79
	)
80 81
endif(UNIX)

82 83 84 85
set (DBUS_LIB_HEADERS
	${DBUS_DIR}/dbus-auth.h
	${DBUS_DIR}/dbus-auth-script.h
	${DBUS_DIR}/dbus-connection-internal.h
86
	${DBUS_DIR}/dbus-credentials.h
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
	${DBUS_DIR}/dbus-keyring.h
	${DBUS_DIR}/dbus-marshal-header.h
	${DBUS_DIR}/dbus-marshal-byteswap.h
	${DBUS_DIR}/dbus-marshal-recursive.h
	${DBUS_DIR}/dbus-marshal-validate.h
	${DBUS_DIR}/dbus-message-internal.h
	${DBUS_DIR}/dbus-message-private.h
	${DBUS_DIR}/dbus-misc.h
	${DBUS_DIR}/dbus-object-tree.h
	${DBUS_DIR}/dbus-protocol.h
	${DBUS_DIR}/dbus-resources.h
	${DBUS_DIR}/dbus-server-debug-pipe.h
	${DBUS_DIR}/dbus-server-protected.h
	${DBUS_DIR}/dbus-server-unix.h
	${DBUS_DIR}/dbus-sha.h
	${DBUS_DIR}/dbus-timeout.h
	${DBUS_DIR}/dbus-threads.h
	${DBUS_DIR}/dbus-threads-internal.h
	${DBUS_DIR}/dbus-transport.h
	${DBUS_DIR}/dbus-transport-protected.h
	${DBUS_DIR}/dbus-watch.h
	${CMAKE_BINARY_DIR}/config.h
##dbus-md5.h
)
111 112 113 114 115 116 117 118 119 120 121
if(UNIX)
	set (DBUS_LIB_HEADERS ${DBUS_LIB_HEADERS} 
		${DBUS_DIR}/dbus-transport-unix.h
	)
else(UNIX)
	set (DBUS_LIB_HEADERS ${DBUS_LIB_HEADERS} 
		${DBUS_DIR}/dbus-transport-win.h
	)
endif(UNIX)


122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
### source code that goes in the installed client library
### AND is generic utility functionality used by the 
### daemon or test programs (all symbols in here should 
### be underscore-prefixed)
set (DBUS_SHARED_SOURCES
	${DBUS_DIR}/dbus-dataslot.c
	${DBUS_DIR}/dbus-hash.c
	${DBUS_DIR}/dbus-internals.c
	${DBUS_DIR}/dbus-list.c
	${DBUS_DIR}/dbus-marshal-basic.c
	${DBUS_DIR}/dbus-memory.c
	${DBUS_DIR}/dbus-mempool.c
	${DBUS_DIR}/dbus-string.c
	${DBUS_DIR}/dbus-sysdeps.c
)

set (DBUS_SHARED_HEADERS
	${DBUS_DIR}/dbus-dataslot.h
	${DBUS_DIR}/dbus-hash.h
	${DBUS_DIR}/dbus-internals.h
	${DBUS_DIR}/dbus-list.h
	${DBUS_DIR}/dbus-marshal-basic.h
	${DBUS_DIR}/dbus-mempool.h
	${DBUS_DIR}/dbus-string.h
	${DBUS_DIR}/dbus-string-private.h
	${DBUS_DIR}/dbus-sysdeps.h
)

### source code that is generic utility functionality used
### by the bus daemon or test apps, but is NOT included
### in the D-BUS client library (all symbols in here 
### should be underscore-prefixed but don't really need 
### to be unless they move to DBUS_SHARED_SOURCES later)
set (DBUS_UTIL_SOURCES
	${DBUS_DIR}/dbus-auth-util.c
157
	${DBUS_DIR}/dbus-credentials-util.c
158 159 160 161 162 163 164 165
	${DBUS_DIR}/dbus-mainloop.c
	${DBUS_DIR}/dbus-marshal-byteswap-util.c
	${DBUS_DIR}/dbus-marshal-recursive-util.c
	${DBUS_DIR}/dbus-marshal-validate-util.c
	${DBUS_DIR}/dbus-message-factory.c
	${DBUS_DIR}/dbus-message-util.c
	${DBUS_DIR}/dbus-shell.c
	${DBUS_DIR}/dbus-string-util.c
166
        ${DBUS_DIR}/dbus-sysdeps-util.c
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
)

if (DBUS_BUILD_TESTS)
	set (DBUS_UTIL_SOURCES 
		${DBUS_UTIL_SOURCES}
		${DBUS_DIR}/dbus-test.c
	)
endif (DBUS_BUILD_TESTS)

set (DBUS_UTIL_HEADERS
	${DBUS_DIR}/dbus-mainloop.h
	${DBUS_DIR}/dbus-message-factory.h
	${DBUS_DIR}/dbus-shell.h
	${DBUS_DIR}/dbus-spawn.h
	${DBUS_DIR}/dbus-test.h
)

### platform specific settings
if (WIN32)
	set (DBUS_SHARED_SOURCES ${DBUS_SHARED_SOURCES} 
		${DBUS_DIR}/dbus-sysdeps-win.c
188
		${DBUS_DIR}/dbus-sysdeps-thread-win.c
189 190 191
		${DBUS_DIR}/dbus-spawn-win.c
	)
	set (DBUS_SHARED_HEADERS ${DBUS_SHARED_HEADERS} 
192 193 194
		${DBUS_DIR}/dbus-sockets-win.h
		${DBUS_DIR}/dbus-sysdeps-win.h
	)
Frank Osterfeld's avatar
Frank Osterfeld committed
195 196 197
	set (DBUS_UTIL_SOURCES ${DBUS_UTIL_SOURCES}
		${DBUS_DIR}/dbus-sysdeps-util-win.c
	)
198 199 200 201 202 203
	set (LIBS ${LIBS} ws2_32 advapi32 netapi32)
else (WIN32)
	set (DBUS_SHARED_SOURCES ${DBUS_SHARED_SOURCES} 
		${DBUS_DIR}/dbus-sysdeps-unix.c
		${DBUS_DIR}/dbus-sysdeps-pthread.c
		${DBUS_DIR}/dbus-spawn.c
204
		${DBUS_DIR}/dbus-userdb.c
205 206
	)
	set (DBUS_SHARED_HEADERS ${DBUS_SHARED_HEADERS} 
207 208 209
		${DBUS_DIR}/dbus-server-unix.h
		${DBUS_DIR}/dbus-transport-unix.h
		${DBUS_DIR}/dbus-sysdeps-unix.h
210 211 212 213
		${DBUS_DIR}/dbus-userdb.h
	)
	set (DBUS_UTIL_SOURCES ${DBUS_UTIL_SOURCES}
		${DBUS_DIR}/dbus-userdb-util.c
Frank Osterfeld's avatar
Frank Osterfeld committed
214
		${DBUS_DIR}/dbus-sysdeps-util-unix.c
215
	)
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
endif (WIN32)

set(libdbus_SOURCES
	${DBUS_LIB_SOURCES}
	${DBUS_SHARED_SOURCES}
	# for debugging
	${DBUS_UTIL_SOURCES}
)

set(libdbus_HEADERS 
	${DBUS_LIB_HEADERS}
	${DBUS_SHARED_HEADERS}
	# for debugging
	${DBUS_UTIL_HEADERS}
)
231 232 233 234 235 236 237 238 239 240 241 242
if (MSVC)
    set (BUILD_FILEVERSION ${DBUS_MAJOR_VERSION},${DBUS_MINOR_VERSION},${DBUS_MICRO_VERSION},${DBUS_PATCH_VERSION})

    # no idea how to create the current date as string
    message(STATUS "FIXME create the current date as string in dbus/CMakeLists.txt")
    set (BUILD_TIMESTAMP 20091205)

    configure_file(${DBUS_DIR}/versioninfo.rc.in ${CMAKE_CURRENT_BINARY_DIR}/versioninfo.rc)
    file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/afxres.h "")
    list(APPEND libdbus_SOURCES versioninfo.rc)
    set_source_files_properties(versioninfo.rc COMPILE_FLAGS "-D__LINE__=1")
endif (MSVC)
243

244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
if(MSVC AND splitlib)
	set(DBUS_LIB_TYPE STATIC)
elseif(MSVC AND splitlib)
	set(DBUS_LIB_TYPE SHARED)
endif(MSVC AND splitlib)


if(splitlib AND MSVC)
	# code for the client library and daemon/tests
	add_library(dbus-lib-generic ${DBUS_LIB_TYPE} ${DBUS_SHARED_SOURCES} ${DBUS_SHARED_HEADERS})
	
	# code only for daemon/tests
	add_library(dbus-lib-util ${DBUS_LIB_TYPE} ${DBUS_UTIL_SOURCES} ${DBUS_UTIL_HEADERS})
	
	# code for the client library
	add_library(dbus-lib-client ${DBUS_LIB_TYPE} ${DBUS_LIB_SOURCES} ${DBUS_LIB_HEADERS})
	
	target_link_libraries(dbus-lib-generic ${LIBS})
	target_link_libraries(dbus-lib-util ${LIBS})
	target_link_libraries(dbus-lib-client ${LIBS})
	
	if(MSVC_IDE)
		project_source_group(${GROUP_CODE} DBUS_LIB_SOURCES DBUS_LIB_HEADERS)
		project_source_group(${GROUP_CODE} DBUS_SHARED_SOURCES DBUS_SHARED_HEADERS)
		project_source_group(${GROUP_CODE} DBUS_UTIL_SOURCES DBUS_UTIL_SOURCES)
	endif(MSVC_IDE)
else(splitlib AND MSVC)
	# all code into one library
	add_library(dbus-1 ${DBUS_LIB_TYPE} ${libdbus_SOURCES} ${libdbus_HEADERS} )
	target_link_libraries(dbus-1 ${LIBS})
	
	if(MSVC)
276 277 278 279
		set_target_properties(dbus-1  PROPERTIES LINK_FLAGS_RELWITHDEBINFO /def:"${DBUS_DIR}/dbus-1.def")
		set_target_properties(dbus-1  PROPERTIES LINK_FLAGS_RELEASE /def:"${DBUS_DIR}/dbus-1.def")
		set_target_properties(dbus-1  PROPERTIES LINK_FLAGS_MINSIZEREL /def:"${DBUS_DIR}/dbus-1.def")
		set_target_properties(dbus-1  PROPERTIES LINK_FLAGS_DEBUG /def:"${DBUS_DIR}/dbus-1.def")
280 281 282 283 284
	endif(MSVC)
	if(MSVC_IDE)	
		project_source_group(${GROUP_CODE} libdbus_SOURCES libdbus_HEADERS)
	endif(MSVC_IDE)
endif(splitlib AND MSVC)
285 286


287 288 289 290
if(NOT splitlib)
	install_targets(/lib dbus-1 )
	install_files(/include/dbus FILES ${dbusinclude_HEADERS})
endif(NOT splitlib)
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307

#ADD_EXECUTABLE(dbus-example dbus-example.c)
#target_link_libraries(${CMAKE_SOURCE_DIR}/../dbus/dbus-example dbus-1)
#install_targets(/bin dbus-example )

## note that TESTS has special meaning (stuff to use in make check)
## so if adding tests not to be run in make check, don't add them to 
## TESTS
#if DBUS_BUILD_TESTS
#TESTS_ENVIRONMENT=DBUS_TEST_DATA=$(top_builddir)/test/data DBUS_TEST_HOMEDIR=$(top_builddir)/dbus
#TESTS=dbus-test
#else
#TESTS=
#endif

if (DBUS_BUILD_TESTS)
	set (TESTS_ENVIRONMENT "DBUS_TEST_DATA=${CMAKE_SOURCE_DIR}/test/data DBUS_TEST_HOMEDIR=${CMAKE_BUILD_DIR}/dbus")
308
	ADD_EXECUTABLE(dbus-test ${CMAKE_SOURCE_DIR}/../dbus/dbus-test-main.c)
309
	target_link_libraries(dbus-test ${DBUS_1} ${LIBS})
310 311
	add_test(dbus-test ${EXECUTABLE_OUTPUT_PATH}/dbus-test ${CMAKE_SOURCE_DIR}/../test/data)
	#install_targets(/bin dbus-test)
312 313 314 315 316 317 318 319 320 321
ENDIF (DBUS_BUILD_TESTS)

if (UNIX)
# set version info
ENDIF (UNIX)


## mop up the gcov files
#clean-local:
#/bin/rm *.bb *.bbg *.da *.gcov .libs/*.da .libs/*.bbg || true