uci: add state call to retrieve uci state variables
[project/rpcd.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.6)
2
3 INCLUDE(CheckFunctionExists)
4
5 PROJECT(rpcd C)
6 ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -Wmissing-declarations)
7 INCLUDE_DIRECTORIES(include)
8
9 OPTION(FILE_SUPPORT "File plugin support" ON)
10 OPTION(IWINFO_SUPPORT "libiwinfo plugin support" ON)
11
12 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
13
14 IF(APPLE)
15   INCLUDE_DIRECTORIES(/opt/local/include)
16   LINK_DIRECTORIES(/opt/local/lib)
17 ENDIF()
18
19 CHECK_FUNCTION_EXISTS(getspnam HAVE_SHADOW)
20 IF(HAVE_SHADOW)
21   ADD_DEFINITIONS(-DHAVE_SHADOW)
22 ENDIF()
23
24 FIND_LIBRARY(json NAMES json-c json)
25 FIND_LIBRARY(crypt NAMES crypt)
26 IF(crypt STREQUAL "LIBS-NOTFOUND")
27   SET(crypt "")
28 ENDIF()
29
30 ADD_EXECUTABLE(rpcd main.c exec.c session.c uci.c plugin.c)
31 TARGET_LINK_LIBRARIES(rpcd ubox ubus uci dl blobmsg_json ${json} ${crypt})
32
33 SET(PLUGINS "")
34
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
42 IF (IWINFO_SUPPORT)
43   SET(PLUGINS ${PLUGINS} iwinfo_plugin)
44   ADD_LIBRARY(iwinfo_plugin MODULE iwinfo.c)
45   TARGET_LINK_LIBRARIES(iwinfo_plugin ubox ubus iwinfo)
46   SET_TARGET_PROPERTIES(iwinfo_plugin PROPERTIES OUTPUT_NAME iwinfo PREFIX "")
47 ENDIF()
48
49 INSTALL(TARGETS rpcd ${PLUGINS}
50         RUNTIME DESTINATION sbin
51         LIBRARY DESTINATION lib
52 )