From 8eb19d936d6320a018c75ab9718f3d645ab46e55 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Wed, 17 Aug 2016 00:03:54 +0200 Subject: [PATCH] Do not link dbus-1 and dbus-internal against librt and libsocket if not present. This fixes a cross link issue on windows for android. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=94096 --- cmake/dbus/CMakeLists.txt | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/cmake/dbus/CMakeLists.txt b/cmake/dbus/CMakeLists.txt index c5c5ebd..86c4058 100644 --- a/cmake/dbus/CMakeLists.txt +++ b/cmake/dbus/CMakeLists.txt @@ -254,8 +254,13 @@ if(MSVC_IDE) 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} @@ -282,7 +287,13 @@ else(WIN32) 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} rt) + 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 @@ -309,7 +320,13 @@ if(WIN32) 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) -- 2.6.6