ubus: Remove unnecessary memset calls.
[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
9 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
10 SET(UBUS_UNIX_SOCKET "/var/run/ubus.sock")
11 SET(UBUS_MAX_MSGLEN 1048576)
12
13 ADD_DEFINITIONS( -DUBUS_UNIX_SOCKET="${UBUS_UNIX_SOCKET}")
14 ADD_DEFINITIONS( -DUBUS_MAX_MSGLEN=${UBUS_MAX_MSGLEN})
15
16 IF(BUILD_STATIC)
17   FIND_LIBRARY(ubox_library NAMES ubox.a)
18   FIND_LIBRARY(blob_library NAMES blobmsg_json.a)
19 ELSE(BUILD_STATIC)
20   FIND_LIBRARY(ubox_library NAMES ubox)
21   FIND_LIBRARY(blob_library NAMES blobmsg_json)
22 ENDIF(BUILD_STATIC)
23
24 FIND_PATH(ubox_include_dir libubox/usock.h)
25 INCLUDE_DIRECTORIES(${ubox_include_dir})
26
27 ADD_LIBRARY(ubus SHARED libubus.c libubus-io.c libubus-obj.c libubus-sub.c libubus-req.c libubus-acl.c)
28 TARGET_LINK_LIBRARIES(ubus ${ubox_library})
29
30 find_library(json NAMES json-c json)
31
32 ADD_EXECUTABLE(ubusd ubusd.c ubusd_id.c ubusd_obj.c ubusd_proto.c ubusd_event.c ubusd_acl.c ubusd_monitor.c)
33 TARGET_LINK_LIBRARIES(ubusd ${ubox_library} ${blob_library} ${json})
34
35 ADD_EXECUTABLE(cli cli.c)
36 SET_TARGET_PROPERTIES(cli PROPERTIES OUTPUT_NAME ubus)
37 TARGET_LINK_LIBRARIES(cli ubus ${ubox_library} ${blob_library} ${json})
38
39 ADD_SUBDIRECTORY(lua)
40 ADD_SUBDIRECTORY(examples)
41
42 INSTALL(TARGETS ubus cli
43         LIBRARY DESTINATION lib
44         RUNTIME DESTINATION bin
45 )
46 INSTALL(TARGETS ubusd
47         RUNTIME DESTINATION sbin
48 )
49
50 INSTALL(FILES ubusmsg.h ubus_common.h libubus.h DESTINATION include)