From 5c659aa04a6e2e7cc6d1ef9dee7a5cc014099d5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20H=C3=B6ger?= Date: Thu, 24 May 2012 12:29:06 +0200 Subject: [PATCH 02/14] Made tests work MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is not really platform independent yet, but at least the cmake build seems to work. Signed-off-by: Christoph Höger --- CMakeLists.txt | 27 +++++++++++++++++---------- cmake/FindDBUS.cmake | 1 + cmake/FindGLIB.cmake | 45 +++++++++++++++++++++++++++++++++++++++++++++ test/run-test.sh | 6 ++++-- 4 files changed, 67 insertions(+), 12 deletions(-) create mode 100644 cmake/FindGLIB.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 34c658b..2750170 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,9 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) #DBUS find_package(DBUS REQUIRED) +#GLIB +find_package(GLIB REQUIRED) + # Find Python executable find_package(PythonLibs REQUIRED) find_package(PythonInterp REQUIRED) @@ -48,22 +51,26 @@ include_directories(include/ ${PYTHON_INCLUDE_DIRS} ${DBUS_INCLUDES}) include_directories(_dbus_bindings/) file(GLOB dbus_binding_sources _dbus_bindings/*.c) add_library(_dbus_bindings SHARED ${dbus_binding_sources}) -target_link_libraries(_dbus_bindings ${PYTHON_LIBRARIES}) +target_link_libraries(_dbus_bindings ${PYTHON_LIBRARIES} ${DBUS_LIBRARY}) -include_directories(_dbus_glib_bindings/) -file(GLOB dbus_glib_binding_sources _dbus_bindings/*.c) +include_directories(_dbus_glib_bindings/ ${GLIB_INCLUDE_DIR} ${GLIB_CONFIG_INCLUDE_DIR}) +file(GLOB dbus_glib_binding_sources _dbus_glib_bindings/*.c) add_library(_dbus_glib_bindings SHARED ${dbus_glib_binding_sources}) -target_link_libraries(_dbus_glib_bindings ${PYTHON_LIBRARIES}) +target_link_libraries(_dbus_glib_bindings ${PYTHON_LIBRARIES} ${DBUS_LIBRARY} ${DBUS_GLIB_LIBRARY} ${GLIB_LIBRARIES}) -set_target_properties(_dbus_bindings - PROPERTIES - PREFIX "" # There is no prefix even on UNIXes - SUFFIX "${_modsuffix}" # The extension got from Python libraries -) +file(GLOB dbus_py_test_sources test/*.c) +add_library(dbus_py_test SHARED ${dbus_py_test_sources}) +target_link_libraries(dbus_py_test ${PYTHON_LIBRARIES} ${DBUS_LIBRARY}) -set_target_properties(_dbus_glib_bindings +set_target_properties(_dbus_bindings _dbus_glib_bindings dbus_py_test PROPERTIES PREFIX "" # There is no prefix even on UNIXes SUFFIX "${_modsuffix}" # The extension got from Python libraries ) +set(PYTHON ${PYTHON_EXECUTABLE}) +set(abs_top_srcdir ${CMAKE_CURRENT_SOURCE_DIR}) +set(abs_top_builddir ${CMAKE_CURRENT_BINARY_DIR}) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test/tmp-session-bus.conf.in ${CMAKE_CURRENT_BINARY_DIR}/test/tmp-session-bus.conf) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test/TestSuitePythonService.service.in ${CMAKE_CURRENT_BINARY_DIR}/test/TestSuitePythonService.service) diff --git a/cmake/FindDBUS.cmake b/cmake/FindDBUS.cmake index 96fb42b..96e0305 100644 --- a/cmake/FindDBUS.cmake +++ b/cmake/FindDBUS.cmake @@ -2,6 +2,7 @@ FIND_PATH( DBUS_INCLUDE_DIR dbus/dbus.h PATHS ${CMAKE_INCLUDE_PATH}/dbus-1.0 /us FIND_PATH( DBUS_INCLUDE_LIB_DIR dbus/dbus-arch-deps.h PATHS ${CMAKE_LIBRARY_PATH}/dbus-1.0/include /usr/lib/dbus-1.0/include /usr/lib64/dbus-1.0/include) FIND_LIBRARY(DBUS_LIBRARY NAME dbus-1 PATHS /lib) +FIND_LIBRARY(DBUS_GLIB_LIBRARY NAME dbus-glib-1 PATHS /lib) IF( DBUS_INCLUDE_DIR AND DBUS_INCLUDE_LIB_DIR AND DBUS_LIBRARY ) SET( DBUS_FOUND TRUE ) diff --git a/cmake/FindGLIB.cmake b/cmake/FindGLIB.cmake new file mode 100644 index 0000000..67cd1cb --- /dev/null +++ b/cmake/FindGLIB.cmake @@ -0,0 +1,45 @@ +find_package(PkgConfig) +if (PKG_CONFIG_FOUND) + pkg_check_modules(GLIB_PKG glib-2.0) +endif (PKG_CONFIG_FOUND) + +if (GLIB_PKG_FOUND) + find_path(GLIB_INCLUDE_DIR NAMES glib.h PATH_SUFFIXES glib-2.0 + PATHS + ${GLIB_PKG_INCLUDE_DIRS} + /usr/include/glib-2.0 + /usr/include + /usr/local/include + ) + find_path(GLIB_CONFIG_INCLUDE_DIR NAMES glibconfig.h PATHS ${GLIB_PKG_LIBDIR} PATH_SUFFIXES glib-2.0/include) + + find_library(GLIB_LIBRARIES NAMES glib-2.0 + PATHS + ${GLIB_PKG_LIBRARY_DIRS} + /usr/lib + /usr/local/lib + ) + +else (GLIB_PKG_FOUND) + # Find Glib even if pkg-config is not working (eg. cross compiling to Windows) + find_library(GLIB_LIBRARIES NAMES glib-2.0) + string (REGEX REPLACE "/[^/]*$" "" GLIB_LIBRARIES_DIR ${GLIB_LIBRARIES}) + + find_path(GLIB_INCLUDE_DIR NAMES glib.h PATH_SUFFIXES glib-2.0) + find_path(GLIB_CONFIG_INCLUDE_DIR NAMES glibconfig.h PATHS ${GLIB_LIBRARIES_DIR} PATH_SUFFIXES glib-2.0/include) + +endif (GLIB_PKG_FOUND) + +if (GLIB_INCLUDE_DIR AND GLIB_CONFIG_INCLUDE_DIR AND GLIB_LIBRARIES) + set(GLIB_INCLUDE_DIRS ${GLIB_INCLUDE_DIR} ${GLIB_CONFIG_INCLUDE_DIR}) +endif (GLIB_INCLUDE_DIR AND GLIB_CONFIG_INCLUDE_DIR AND GLIB_LIBRARIES) + +if(GLIB_INCLUDE_DIRS AND GLIB_LIBRARIES) + set(GLIB_FOUND TRUE CACHE INTERNAL "glib-2.0 found") + message(STATUS "Found glib-2.0: ${GLIB_INCLUDE_DIR}, ${GLIB_LIBRARIES}") +else(GLIB_INCLUDE_DIRS AND GLIB_LIBRARIES) + set(GLIB_FOUND FALSE CACHE INTERNAL "glib-2.0 found") + message(STATUS "glib-2.0 not found.") +endif(GLIB_INCLUDE_DIRS AND GLIB_LIBRARIES) + +mark_as_advanced(GLIB_INCLUDE_DIR GLIB_CONFIG_INCLUDE_DIR GLIB_INCLUDE_DIRS GLIB_LIBRARIES) diff --git a/test/run-test.sh b/test/run-test.sh index 79efaff..fdb7bc9 100755 --- a/test/run-test.sh +++ b/test/run-test.sh @@ -87,10 +87,12 @@ $PYTHON "$DBUS_TOP_SRCDIR"/test/test-unusable-main-loop.py || die "... failed" # die "example-signal-recipient failed!" echo "running cross-test (for better diagnostics use mjj29's dbus-test)" +$PYTHON "$DBUS_TOP_SRCDIR"/test/cross-test-server.py > "$DBUS_TOP_BUILDDIR"/test/cross-server.log& -${MAKE:-make} -s cross-test-server > "$DBUS_TOP_BUILDDIR"/test/cross-server.log& +#${MAKE:-make} -s cross-test-server > "$DBUS_TOP_BUILDDIR"/test/cross-server.log& sleep 1 -${MAKE:-make} -s cross-test-client > "$DBUS_TOP_BUILDDIR"/test/cross-client.log +#${MAKE:-make} -s cross-test-client > "$DBUS_TOP_BUILDDIR"/test/cross-client.log +$PYTHON "$DBUS_TOP_SRCDIR"/test/cross-test-client.py > "$DBUS_TOP_BUILDDIR"/test/cross-client.log if grep . "$DBUS_TOP_BUILDDIR"/test/cross-client.log >/dev/null; then : # OK -- 1.7.10