CMakeLists.txt 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. cmake_minimum_required(VERSION 2.6)
  2. PROJECT(ubus C)
  3. ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -Wmissing-declarations)
  4. OPTION(BUILD_LUA "build Lua plugin" ON)
  5. OPTION(BUILD_EXAMPLES "build examples" ON)
  6. SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
  7. SET(UBUS_UNIX_SOCKET "/var/run/ubus.sock")
  8. SET(UBUS_MAX_MSGLEN 1048576)
  9. ADD_DEFINITIONS( -DUBUS_UNIX_SOCKET="${UBUS_UNIX_SOCKET}")
  10. ADD_DEFINITIONS( -DUBUS_MAX_MSGLEN=${UBUS_MAX_MSGLEN})
  11. IF(BUILD_STATIC)
  12. FIND_LIBRARY(ubox_library NAMES ubox.a)
  13. FIND_LIBRARY(blob_library NAMES blobmsg_json.a)
  14. ELSE(BUILD_STATIC)
  15. FIND_LIBRARY(ubox_library NAMES ubox)
  16. FIND_LIBRARY(blob_library NAMES blobmsg_json)
  17. ENDIF(BUILD_STATIC)
  18. FIND_PATH(ubox_include_dir libubox/usock.h)
  19. INCLUDE_DIRECTORIES(${ubox_include_dir})
  20. ADD_LIBRARY(ubus SHARED libubus.c libubus-io.c libubus-obj.c libubus-sub.c libubus-req.c libubus-acl.c)
  21. TARGET_LINK_LIBRARIES(ubus ${ubox_library})
  22. find_library(json NAMES json-c json)
  23. ADD_EXECUTABLE(ubusd ubusd.c ubusd_id.c ubusd_obj.c ubusd_proto.c ubusd_event.c ubusd_acl.c ubusd_monitor.c)
  24. TARGET_LINK_LIBRARIES(ubusd ${ubox_library} ${blob_library} ${json})
  25. ADD_EXECUTABLE(cli cli.c)
  26. SET_TARGET_PROPERTIES(cli PROPERTIES OUTPUT_NAME ubus)
  27. TARGET_LINK_LIBRARIES(cli ubus ${ubox_library} ${blob_library} ${json})
  28. ADD_SUBDIRECTORY(lua)
  29. ADD_SUBDIRECTORY(examples)
  30. INSTALL(TARGETS ubus cli
  31. LIBRARY DESTINATION lib
  32. RUNTIME DESTINATION bin
  33. )
  34. INSTALL(TARGETS ubusd
  35. RUNTIME DESTINATION sbin
  36. )
  37. INSTALL(FILES ubusmsg.h ubus_common.h libubus.h DESTINATION include)