-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
86 lines (68 loc) · 3.48 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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}")
include (CheckTypeSize)
#DBUS
find_package(DBUS REQUIRED)
set(CMAKE_REQUIRED_INCLUDES ${DBUS_INCLUDES})
set(CMAKE_EXTRA_INCLUDE_FILES dbus/dbus.h)
check_type_size(DBusBasicValue DBUSBASICVALUE)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
#GLIB
find_package(GLIB REQUIRED)
# Find Python executable
find_package(PythonInterp REQUIRED)
find_package(PythonLibs 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(list(filter(lambda s : s[1] == 'rb' and s[0][0] == '.', imp.get_suffixes()))[0][0])")
find_file(stdint stdint.h)
if(NOT stdint)
message(SEND_ERROR "You need a C99 compliant stdint.h for windows, use e.g. http://msinttypes.googlecode.com/svn/trunk/stdint.h")
endif(NOT stdint)
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})
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} ${DBUS_LIBRARY})
include_directories(_dbus_glib_bindings/ ${GLIB_INCLUDE_DIR} ${GLIB_CONFIG_INCLUDE_DIR} ${DBUS_INCLUDES})
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} ${DBUS_LIBRARY} ${DBUS_GLIB_LIBRARY} ${GLIB_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_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)