libubus: refactor ubus_context msgbuf data to be dynamically allocated
[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 find_library(json NAMES json-c json)
27 ADD_EXECUTABLE(cli cli.c)
28 SET_TARGET_PROPERTIES(cli PROPERTIES OUTPUT_NAME ubus)
29 TARGET_LINK_LIBRARIES(cli ubus ubox blobmsg_json ${json})
30
31 ADD_SUBDIRECTORY(lua)
32 ADD_SUBDIRECTORY(examples)
33
34 INSTALL(TARGETS ubus cli
35         LIBRARY DESTINATION lib
36         RUNTIME DESTINATION bin
37 )
38 INSTALL(TARGETS ubusd
39         RUNTIME DESTINATION sbin
40 )
41
42 INSTALL(FILES ubusmsg.h ubus_common.h libubus.h DESTINATION include)
43
44 # FIXME: this works but certainly can be done better:
45 SET(UBUSD_BINARY "${CMAKE_INSTALL_PREFIX}/sbin/ubusd")
46
47 # do this after the installs so we have the proper paths
48 IF(ENABLE_SYSTEMD)
49   INCLUDE(FindPkgConfig)
50   PKG_CHECK_MODULES(SYSTEMD systemd)
51   IF(SYSTEMD_FOUND)
52     ADD_SUBDIRECTORY(systemd)
53   ENDIF()
54 ENDIF()