Add CMake definitions for plugins
authorJo-Philipp Wich <jow@openwrt.org>
Mon, 2 Sep 2013 13:14:33 +0000 (15:14 +0200)
committerJo-Philipp Wich <jow@openwrt.org>
Mon, 2 Sep 2013 13:24:00 +0000 (15:24 +0200)
CMakeLists.txt

index e9f158659b8a405f00643eab73324dc03c23947d..6f42902eb53e9269f2b12d976ac32cd6bca10f16 100644 (file)
@@ -3,6 +3,10 @@ cmake_minimum_required(VERSION 2.6)
 PROJECT(luci-rpcd C)
 ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -Wmissing-declarations)
 
+OPTION(FILE_SUPPORT "File plugin support" ON)
+OPTION(LUCI2_SUPPORT "LuCI2 plugin support" ON)
+OPTION(IWINFO_SUPPORT "libiwinfo plugin support" ON)
+
 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
 
 IF(APPLE)
@@ -10,14 +14,35 @@ IF(APPLE)
   LINK_DIRECTORIES(/opt/local/lib)
 ENDIF()
 
-ADD_EXECUTABLE(luci-rpcd main.c exec.c session.c file.c uci.c iwinfo.c luci2.c plugin.c)
-
 FIND_LIBRARY(json NAMES json-c json)
 
-TARGET_LINK_LIBRARIES(luci-rpcd ubox ubus uci iwinfo blobmsg_json ${json})
+ADD_EXECUTABLE(luci-rpcd main.c exec.c session.c uci.c plugin.c)
+TARGET_LINK_LIBRARIES(luci-rpcd ubox ubus uci dl blobmsg_json ${json})
+
+SET(PLUGINS "")
+
+IF(FILE_SUPPORT)
+  SET(PLUGINS ${PLUGINS} file_plugin)
+  ADD_LIBRARY(file_plugin MODULE file.c)
+  TARGET_LINK_LIBRARIES(file_plugin ubox ubus)
+  SET_TARGET_PROPERTIES(file_plugin PROPERTIES OUTPUT_NAME file PREFIX "")
+ENDIF()
+
+IF(LUCI2_SUPPORT)
+  SET(PLUGINS ${PLUGINS} luci2_plugin)
+  ADD_LIBRARY(luci2_plugin MODULE luci2.c)
+  TARGET_LINK_LIBRARIES(luci2_plugin ubox ubus)
+  SET_TARGET_PROPERTIES(luci2_plugin PROPERTIES OUTPUT_NAME luci2 PREFIX "")
+ENDIF()
 
-SET(CMAKE_INSTALL_PREFIX /usr)
+IF (IWINFO_SUPPORT)
+  SET(PLUGINS ${PLUGINS} iwinfo_plugin)
+  ADD_LIBRARY(iwinfo_plugin MODULE iwinfo.c)
+  TARGET_LINK_LIBRARIES(iwinfo_plugin ubox ubus iwinfo)
+  SET_TARGET_PROPERTIES(iwinfo_plugin PROPERTIES OUTPUT_NAME iwinfo PREFIX "")
+ENDIF()
 
-INSTALL(TARGETS luci-rpcd
+INSTALL(TARGETS luci-rpcd ${PLUGINS}
        RUNTIME DESTINATION sbin
+       LIBRARY DESTINATION lib
 )