CMakeLists.txt 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. cmake_minimum_required(VERSION 2.6)
  2. INCLUDE(CheckFunctionExists)
  3. PROJECT(rpcd C)
  4. ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -Wmissing-declarations -DINSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}")
  5. INCLUDE_DIRECTORIES(include)
  6. OPTION(FILE_SUPPORT "File plugin support" ON)
  7. OPTION(IWINFO_SUPPORT "libiwinfo plugin support" ON)
  8. OPTION(RPCSYS_SUPPORT "rpc-sys plugin support" ON)
  9. OPTION(UCODE_SUPPORT "ucode plugin support" ON)
  10. SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
  11. IF(APPLE)
  12. INCLUDE_DIRECTORIES(/opt/local/include)
  13. LINK_DIRECTORIES(/opt/local/lib)
  14. ENDIF()
  15. CHECK_FUNCTION_EXISTS(getspnam HAVE_SHADOW)
  16. IF(HAVE_SHADOW)
  17. ADD_DEFINITIONS(-DHAVE_SHADOW)
  18. ENDIF()
  19. FIND_LIBRARY(uci NAMES uci)
  20. FIND_LIBRARY(ubus NAMES ubus)
  21. FIND_LIBRARY(ubox NAMES ubox)
  22. FIND_LIBRARY(blobmsg_json NAMES blobmsg_json)
  23. FIND_LIBRARY(json NAMES json-c json)
  24. FIND_LIBRARY(crypt NAMES crypt)
  25. IF(crypt STREQUAL "crypt-NOTFOUND")
  26. SET(crypt "")
  27. ENDIF()
  28. FIND_PATH(ubus_include_dir libubus.h)
  29. INCLUDE_DIRECTORIES(${ubus_include_dir})
  30. FIND_PATH(ubox_include_dir libubox/blobmsg_json.h)
  31. INCLUDE_DIRECTORIES(${ubox_include_dir})
  32. ADD_EXECUTABLE(rpcd main.c exec.c session.c uci.c rc.c plugin.c)
  33. TARGET_LINK_LIBRARIES(rpcd ${ubox} ${ubus} ${uci} ${blobmsg_json} ${json} ${crypt} dl)
  34. SET(PLUGINS "")
  35. IF(FILE_SUPPORT)
  36. SET(PLUGINS ${PLUGINS} file_plugin)
  37. ADD_LIBRARY(file_plugin MODULE file.c)
  38. TARGET_LINK_LIBRARIES(file_plugin ${ubox} ${ubus})
  39. SET_TARGET_PROPERTIES(file_plugin PROPERTIES OUTPUT_NAME file PREFIX "")
  40. ENDIF()
  41. IF(RPCSYS_SUPPORT)
  42. SET(PLUGINS ${PLUGINS} rpcsys_plugin)
  43. ADD_LIBRARY(rpcsys_plugin MODULE sys.c)
  44. TARGET_LINK_LIBRARIES(rpcsys_plugin ${ubox} ${ubus})
  45. SET_TARGET_PROPERTIES(rpcsys_plugin PROPERTIES OUTPUT_NAME rpcsys PREFIX "")
  46. ENDIF()
  47. IF(IWINFO_SUPPORT)
  48. FIND_LIBRARY(iwinfo NAMES iwinfo)
  49. SET(PLUGINS ${PLUGINS} iwinfo_plugin)
  50. ADD_LIBRARY(iwinfo_plugin MODULE iwinfo.c)
  51. TARGET_LINK_LIBRARIES(iwinfo_plugin ${ubox} ${ubus} ${iwinfo})
  52. SET_TARGET_PROPERTIES(iwinfo_plugin PROPERTIES OUTPUT_NAME iwinfo PREFIX "")
  53. ENDIF()
  54. IF(UCODE_SUPPORT)
  55. FIND_LIBRARY(ucode NAMES ucode)
  56. SET(PLUGINS ${PLUGINS} ucode_plugin)
  57. ADD_LIBRARY(ucode_plugin MODULE ucode.c)
  58. TARGET_LINK_LIBRARIES(ucode_plugin ${ucode})
  59. SET_TARGET_PROPERTIES(ucode_plugin PROPERTIES OUTPUT_NAME ucode PREFIX "")
  60. ENDIF()
  61. INSTALL(TARGETS rpcd ${PLUGINS}
  62. RUNTIME DESTINATION sbin
  63. LIBRARY DESTINATION lib/rpcd
  64. )