8c0a4ef4f78d18bdcec0f7ae43fc047017844dce
[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 -Iinclude)
7
8 OPTION(FILE_SUPPORT "File plugin support" ON)
9 OPTION(IWINFO_SUPPORT "libiwinfo plugin support" ON)
10
11 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
12
13 IF(APPLE)
14   INCLUDE_DIRECTORIES(/opt/local/include)
15   LINK_DIRECTORIES(/opt/local/lib)
16 ENDIF()
17
18 CHECK_FUNCTION_EXISTS(getspnam HAVE_SHADOW)
19 IF(HAVE_SHADOW)
20   ADD_DEFINITIONS(-DHAVE_SHADOW)
21 ENDIF()
22
23 FIND_LIBRARY(json NAMES json-c json)
24 FIND_LIBRARY(crypt NAMES crypt)
25 IF(crypt STREQUAL "LIBS-NOTFOUND")
26   SET(crypt "")
27 ENDIF()
28
29 ADD_EXECUTABLE(rpcd main.c exec.c session.c uci.c plugin.c)
30 TARGET_LINK_LIBRARIES(rpcd ubox ubus uci dl blobmsg_json ${json} ${crypt})
31
32 SET(PLUGINS "")
33
34 IF(FILE_SUPPORT)
35   SET(PLUGINS ${PLUGINS} file_plugin)
36   ADD_LIBRARY(file_plugin MODULE file.c)
37   TARGET_LINK_LIBRARIES(file_plugin ubox ubus)
38   SET_TARGET_PROPERTIES(file_plugin PROPERTIES OUTPUT_NAME file PREFIX "")
39 ENDIF()
40
41 IF (IWINFO_SUPPORT)
42   SET(PLUGINS ${PLUGINS} iwinfo_plugin)
43   ADD_LIBRARY(iwinfo_plugin MODULE iwinfo.c)
44   TARGET_LINK_LIBRARIES(iwinfo_plugin ubox ubus iwinfo)
45   SET_TARGET_PROPERTIES(iwinfo_plugin PROPERTIES OUTPUT_NAME iwinfo PREFIX "")
46 ENDIF()
47
48 INSTALL(TARGETS rpcd ${PLUGINS}
49         RUNTIME DESTINATION sbin
50         LIBRARY DESTINATION lib
51 )