libubus: fix passing the return code of the subscriber callback to the notifier
[project/ubus.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.6)
2
3 PROJECT(ubus C)
4 ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -Wmissing-declarations)
5
6 OPTION(BUILD_LUA "build Lua plugin" ON)
7 OPTION(BUILD_EXAMPLES "build examples" ON)
8 OPTION(ENABLE_SYSTEMD "systemd support" ON)
9
10 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
11 SET(UBUS_UNIX_SOCKET "/var/run/ubus.sock")
12
13 ADD_DEFINITIONS( -DUBUS_UNIX_SOCKET="${UBUS_UNIX_SOCKET}")
14
15 IF(APPLE)
16   INCLUDE_DIRECTORIES(/opt/local/include)
17   LINK_DIRECTORIES(/opt/local/lib)
18 ENDIF()
19
20 ADD_LIBRARY(ubus SHARED libubus.c libubus-io.c libubus-obj.c libubus-sub.c libubus-req.c)
21 TARGET_LINK_LIBRARIES(ubus ubox)
22
23 ADD_EXECUTABLE(ubusd ubusd.c ubusd_id.c ubusd_obj.c ubusd_proto.c ubusd_event.c)
24 TARGET_LINK_LIBRARIES(ubusd ubox)
25
26 ADD_EXECUTABLE(cli cli.c)
27 SET_TARGET_PROPERTIES(cli PROPERTIES OUTPUT_NAME ubus)
28 TARGET_LINK_LIBRARIES(cli ubus ubox blobmsg_json json)
29
30 ADD_SUBDIRECTORY(lua)
31 ADD_SUBDIRECTORY(examples)
32
33 INSTALL(TARGETS ubus cli
34         LIBRARY DESTINATION lib
35         RUNTIME DESTINATION bin
36 )
37 INSTALL(TARGETS ubusd
38         RUNTIME DESTINATION sbin
39 )
40
41 INSTALL(FILES ubusmsg.h ubus_common.h libubus.h DESTINATION include)
42
43 # FIXME: this works but certainly can be done better:
44 SET(UBUSD_BINARY "${CMAKE_INSTALL_PREFIX}/sbin/ubusd")
45
46 # do this after the installs so we have the proper paths
47 IF(ENABLE_SYSTEMD)
48   INCLUDE(FindPkgConfig)
49   PKG_CHECK_MODULES(SYSTEMD systemd)
50   IF(SYSTEMD_FOUND)
51     ADD_SUBDIRECTORY(systemd)
52   ENDIF()
53 ENDIF()