From bdd7f432daddac793cab30f091777bfab14bf1bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20H=C3=B6ger?= Date: Thu, 24 May 2012 11:02:49 +0200 Subject: [PATCH 01/14] Start cmake integration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With this additions, I can build dbus-python under linux with cmake. TODO: install / test Signed-off-by: Christoph Höger --- CMakeLists.txt | 69 ++++++++++++++++++++++++++++++++++++++++++++++ cmake/FindDBUS.cmake | 22 +++++++++++++++ config.h.cmake | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 165 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 cmake/FindDBUS.cmake create mode 100644 config.h.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..34c658b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,69 @@ +project(dbus_python CXX C) +cmake_minimum_required(VERSION 2.8) + +set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") + +set(PACKAGE "dbus-python") +set(PACKAGE_BUGREPORT "http://bugs.freedesktop.org/enter_bug.cgi?product=dbus&component=python") +set(PACKAGE_NAME "dbus-python") +set(PACKAGE_URL "") +set(PACKAGE_VERSION "1.1.0") +set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") +set(PACKAGE_TARNAME "${PACKAGE_NAME}") + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +#DBUS +find_package(DBUS REQUIRED) + +# Find Python executable +find_package(PythonLibs REQUIRED) +find_package(PythonInterp REQUIRED) +if(NOT PYTHONLIBS_FOUND OR NOT PYTHON_EXECUTABLE) + message(SEND_ERROR "You need Python to build the dbus python bindings") +endif(NOT PYTHONLIBS_FOUND OR NOT PYTHON_EXECUTABLE) + +# The code below prints the Python extension for the current system +set(get_python_suffix "import imp ; print(filter(lambda s : s[1] == 'rb' and s[0][0] == '.', imp.get_suffixes())[0][0])") + +execute_process( + COMMAND ${PYTHON_EXECUTABLE} -c "${get_python_suffix}" + OUTPUT_VARIABLE _modsuffix +) +string(REPLACE "\n" "" _modsuffix ${_modsuffix}) +message(STATUS "Python module suffix is: ${_modsuffix}") + +# The code below returns the site-packages directory for the current system +set(get_site_package_dir "from distutils.sysconfig import get_python_lib; print get_python_lib()") +execute_process( + COMMAND ${PYTHON_EXECUTABLE} -c "${get_site_package_dir}" + OUTPUT_VARIABLE site_pkg +) +string(REPLACE "\n" "" site_pkg ${site_pkg}) +message(STATUS "Python module path is: ${site_pkg}") + +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}) + +include_directories(_dbus_glib_bindings/) +file(GLOB dbus_glib_binding_sources _dbus_bindings/*.c) +add_library(_dbus_glib_bindings SHARED ${dbus_glib_binding_sources}) +target_link_libraries(_dbus_glib_bindings ${PYTHON_LIBRARIES}) + +set_target_properties(_dbus_bindings + PROPERTIES + PREFIX "" # There is no prefix even on UNIXes + SUFFIX "${_modsuffix}" # The extension got from Python libraries +) + +set_target_properties(_dbus_glib_bindings + PROPERTIES + PREFIX "" # There is no prefix even on UNIXes + SUFFIX "${_modsuffix}" # The extension got from Python libraries +) + diff --git a/cmake/FindDBUS.cmake b/cmake/FindDBUS.cmake new file mode 100644 index 0000000..96fb42b --- /dev/null +++ b/cmake/FindDBUS.cmake @@ -0,0 +1,22 @@ +FIND_PATH( DBUS_INCLUDE_DIR dbus/dbus.h PATHS ${CMAKE_INCLUDE_PATH}/dbus-1.0 /usr/include/dbus-1.0) +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) + +IF( DBUS_INCLUDE_DIR AND DBUS_INCLUDE_LIB_DIR AND DBUS_LIBRARY ) +SET( DBUS_FOUND TRUE ) +ENDIF( DBUS_INCLUDE_DIR AND DBUS_INCLUDE_LIB_DIR AND DBUS_LIBRARY ) + +IF( DBUS_INCLUDE_DIR AND DBUS_INCLUDE_LIB_DIR ) +SET( DBUS_INCLUDES ${DBUS_INCLUDE_DIR} ${DBUS_INCLUDE_LIB_DIR} ) +ENDIF( DBUS_INCLUDE_DIR AND DBUS_INCLUDE_LIB_DIR ) + +IF( DBUS_FOUND ) + MESSAGE( STATUS "Found dbus: ${DBUS_LIBRARY}" ) + ELSE( DBUS_FOUND ) + IF( DBUS_FIND_REQUIRED ) + MESSAGE( FATAL_ERROR "Could not find dbus" ) + ENDIF( DBUS_FIND_REQUIRED ) +ENDIF( DBUS_FOUND ) + + diff --git a/config.h.cmake b/config.h.cmake new file mode 100644 index 0000000..2eeefd1 --- /dev/null +++ b/config.h.cmake @@ -0,0 +1,74 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* dbus-python major version */ +#cmakedefine DBUS_PYTHON_MAJOR_VERSION + +/* dbus-python micro version */ +#cmakedefine DBUS_PYTHON_MICRO_VERSION + +/* dbus-python minor version */ +#cmakedefine DBUS_PYTHON_MINOR_VERSION + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_MEMORY_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_UNISTD_H + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#cmakedefine LT_OBJDIR + +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +#cmakedefine NO_MINUS_C_MINUS_O + +/* Name of package */ +#cmakedefine PACKAGE "@PACKAGE@" + +/* Define to the address where bug reports for this package should be sent. */ +#cmakedefine PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@" + +/* Define to the full name of this package. */ +#cmakedefine PACKAGE_NAME "@PACKAGE_NAME@" + +/* Define to the full name and version of this package. */ +#cmakedefine PACKAGE_STRING "@PACKAGE_STRING@" + +/* Define to the one symbol short name of this package. */ +#cmakedefine PACKAGE_TARNAME "@PACKAGE_TARNAME@" + +/* Define to the home page for this package. */ +#cmakedefine PACKAGE_URL "@PACKAGE_URL@" + +/* Define to the version of this package. */ +#cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@" + +/* Define to 1 if you have the ANSI C header files. */ +#cmakedefine STDC_HEADERS 1 + +/* Version number of package */ +#cmakedefine VERSION "@VERSION@" -- 1.7.10