-project(dbus-lib)
-
SET(DBUS_DIR ${CMAKE_SOURCE_DIR}/../dbus)
configure_file(${DBUS_DIR}/dbus-arch-deps.h.in ${CMAKE_CURRENT_BINARY_DIR}/dbus-arch-deps.h )
${DBUS_DIR}/dbus-syntax.h
${DBUS_DIR}/dbus-threads.h
${DBUS_DIR}/dbus-types.h
- dbus-arch-deps.h
+)
+set (dbusinclude_ARCH_HEADERS
+ ${CMAKE_CURRENT_BINARY_DIR}/dbus-arch-deps.h
)
### source code that goes in the installed client library
set (DBUS_UTIL_SOURCES
${DBUS_UTIL_SOURCES}
${DBUS_DIR}/dbus-test.c
+ ${DBUS_DIR}/dbus-spawn-test.c
)
endif (DBUS_ENABLE_EMBEDDED_TESTS)
${DBUS_DIR}/dbus-sysdeps-unix.c
${DBUS_DIR}/dbus-sysdeps-pthread.c
${DBUS_DIR}/dbus-userdb.c
- ${DBUS_DIR}/sd-daemon.c
)
set (DBUS_SHARED_HEADERS ${DBUS_SHARED_HEADERS}
${DBUS_DIR}/dbus-server-unix.h
${DBUS_DIR}/dbus-transport-unix.h
${DBUS_DIR}/dbus-sysdeps-unix.h
${DBUS_DIR}/dbus-userdb.h
- ${DBUS_DIR}/sd-daemon.h
)
set (DBUS_UTIL_SOURCES ${DBUS_UTIL_SOURCES}
${DBUS_DIR}/dbus-spawn.c
${DBUS_LIB_HEADERS}
${DBUS_SHARED_HEADERS}
)
-if (MSVC)
- set (BUILD_FILEVERSION ${DBUS_MAJOR_VERSION},${DBUS_MINOR_VERSION},${DBUS_MICRO_VERSION},${DBUS_PATCH_VERSION})
- set (BUILD_TIMESTAMP ${DBUS_BUILD_TIMESTAMP})
-
- 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)
+
+set (BUILD_FILEVERSION ${DBUS_MAJOR_VERSION},${DBUS_MINOR_VERSION},${DBUS_MICRO_VERSION},${DBUS_PATCH_VERSION})
+set (BUILD_TIMESTAMP ${DBUS_BUILD_TIMESTAMP})
+
+configure_file(${DBUS_DIR}/versioninfo.rc.in ${CMAKE_CURRENT_BINARY_DIR}/versioninfo.rc)
+list(APPEND libdbus_SOURCES versioninfo.rc)
if(MSVC_IDE)
project_source_group(${GROUP_CODE} DBUS_LIB_SOURCES DBUS_LIB_HEADERS)
project_source_group(${GROUP_CODE} DBUS_UTIL_SOURCES DBUS_UTIL_SOURCES)
endif(MSVC_IDE)
-### Client library
+# for clock_getres() on e.g. GNU/Linux (but not Android)
+find_library(LIBRT rt)
+# for socket() on QNX
+find_library(LIBSOCKET socket)
+
+### Client library
add_library(dbus-1 SHARED
${libdbus_SOURCES}
${libdbus_HEADERS}
)
+if(DEFINED DBUS_LIBRARY_REVISION)
+ math(EXPR DBUS_LIBRARY_MAJOR "${DBUS_LIBRARY_CURRENT} - ${DBUS_LIBRARY_AGE}")
+endif()
+
if(WIN32)
+ if(DEFINED DBUS_LIBRARY_REVISION)
+ set_target_properties(dbus-1 PROPERTIES SUFFIX "-${DBUS_LIBRARY_MAJOR}${CMAKE_SHARED_LIBRARY_SUFFIX}")
+ add_custom_command(TARGET dbus-1 POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:dbus-1>" "$<TARGET_FILE_DIR:dbus-1>/${CMAKE_SHARED_LIBRARY_PREFIX}dbus-1${CMAKE_SHARED_LIBRARY_SUFFIX}"
+ COMMENT "Create non versioned dbus-1 library for legacy applications"
+ )
+ install(FILES ${LEGACY_FILE_NAME} DESTINATION bin)
+ endif()
if(WINCE)
target_link_libraries(dbus-1 ws2)
else(WINCE)
- target_link_libraries(dbus-1 ws2_32 advapi32 netapi32 iphlpapi)
+ target_link_libraries(dbus-1 ws2_32 advapi32 netapi32 iphlpapi dbghelp)
endif(WINCE)
else(WIN32)
- target_link_libraries(dbus-1 ${CMAKE_THREAD_LIBS_INIT} rt)
+ if(DEFINED DBUS_LIBRARY_REVISION)
+ set_target_properties(dbus-1 PROPERTIES VERSION ${DBUS_LIBRARY_MAJOR}.${DBUS_LIBRARY_AGE}.${DBUS_LIBRARY_REVISION} SOVERSION ${DBUS_LIBRARY_MAJOR})
+ endif()
+ target_link_libraries(dbus-1 ${CMAKE_THREAD_LIBS_INIT})
+ if(LIBRT)
+ target_link_libraries(dbus-1 ${LIBRT})
+ endif()
+ if(LIBSOCKET)
+ target_link_libraries(dbus-1 ${LIBSOCKET})
+ endif()
endif(WIN32)
+# Assume that Linux has -Wl,--version-script and other platforms do not
+if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
+ set(SOVERSION ${DBUS_LIBRARY_MAJOR})
+ configure_file(${DBUS_DIR}/Version.in ${CMAKE_CURRENT_BINARY_DIR}/Version)
+ set_target_properties(dbus-1 PROPERTIES LINK_FLAGS -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/Version)
+endif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
+
install(TARGETS dbus-1 ${INSTALL_TARGETS_DEFAULT_ARGS})
-install_files(/include/dbus FILES ${dbusinclude_HEADERS})
+install(FILES ${dbusinclude_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dbus-1.0/dbus)
+install(FILES ${dbusinclude_ARCH_HEADERS} DESTINATION ${CMAKE_INSTALL_LIBDIR}/dbus-1.0/include/dbus)
### Internal library, used for the daemon, tools and tests, compiled statically.
add_library(dbus-internal ${DBUS_INTERNAL_ADD_LIBRARY_OPTIONS}
- ${DBUS_LIB_SOURCES}
- ${DBUS_LIB_HEADERS}
- ${DBUS_SHARED_SOURCES}
- ${DBUS_SHARED_HEADERS}
${DBUS_UTIL_SOURCES}
${DBUS_UTIL_HEADERS}
)
-target_link_libraries(dbus-internal)
-set_target_properties(dbus-internal PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_LIBRARY_DEFINITIONS})
+target_link_libraries(dbus-internal dbus-1)
if(WIN32)
if(WINCE)
target_link_libraries(dbus-internal ws2)
target_link_libraries(dbus-internal ws2_32 advapi32 netapi32 iphlpapi)
endif(WINCE)
else(WIN32)
- target_link_libraries(dbus-internal ${CMAKE_THREAD_LIBS_INIT} rt)
+ target_link_libraries(dbus-internal ${CMAKE_THREAD_LIBS_INIT})
+ if(LIBRT)
+ target_link_libraries(dbus-internal ${LIBRT})
+ endif()
+ if(LIBSOCKET)
+ target_link_libraries(dbus-internal ${LIBSOCKET})
+ endif()
endif(WIN32)
if (DBUS_ENABLE_EMBEDDED_TESTS)
- set (TESTS_ENVIRONMENT "DBUS_TEST_DATA=${CMAKE_SOURCE_DIR}/test/data DBUS_TEST_HOMEDIR=${CMAKE_BUILD_DIR}/dbus")
- ADD_EXECUTABLE(dbus-test ${CMAKE_SOURCE_DIR}/../dbus/dbus-test-main.c)
- target_link_libraries(dbus-test ${DBUS_INTERNAL_LIBRARIES})
- add_test(dbus-test ${EXECUTABLE_OUTPUT_PATH}/dbus-test ${CMAKE_SOURCE_DIR}/../test/data)
- set_target_properties(dbus-test PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
+ add_test_executable(test-dbus ${CMAKE_SOURCE_DIR}/../dbus/dbus-test-main.c ${DBUS_INTERNAL_LIBRARIES})
+ set_target_properties(test-dbus PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
ENDIF (DBUS_ENABLE_EMBEDDED_TESTS)
if (UNIX)