[OpenWrt-Devel] [PATCH] libubox: cmake: Add BUILD_EXAMPLES option

Nikolay Dimitrov picmaster at mail.bg
Sat Jun 6 11:04:19 EDT 2015


Add ability to skip building the examples. The default value is ON to follow
the original cmake behavior.

Signed-off-by: Nikolay Dimitrov <picmaster at mail.bg>
---
 CMakeLists.txt          |    1 +
 examples/CMakeLists.txt |   28 +++++++++++++++-------------
 2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 38709ec..ecca3e9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,6 +6,7 @@ PROJECT(ubox C)
 ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -Wmissing-declarations)
 
 OPTION(BUILD_LUA "build Lua plugin" ON)
+OPTION(BUILD_EXAMPLES "build examples" ON)
 
 INCLUDE(FindPkgConfig)
 PKG_SEARCH_MODULE(JSONC json-c)
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 6399c7a..a635535 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,21 +1,23 @@
 cmake_minimum_required(VERSION 2.6)
 
-PROJECT(ubox-examples C)
-ADD_DEFINITIONS(-O1 -Wall -Werror --std=gnu99 -g3)
+IF (BUILD_EXAMPLES)
+    PROJECT(ubox-examples C)
+    ADD_DEFINITIONS(-O1 -Wall -Werror --std=gnu99 -g3)
 
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..)
-LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..)
+    INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..)
+    LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..)
 
-FIND_LIBRARY(json NAMES json-c json)
+    FIND_LIBRARY(json NAMES json-c json)
 
-ADD_EXECUTABLE(blobmsg-example blobmsg-example.c)
-TARGET_LINK_LIBRARIES(blobmsg-example ubox blobmsg_json  ${json})
+    ADD_EXECUTABLE(blobmsg-example blobmsg-example.c)
+    TARGET_LINK_LIBRARIES(blobmsg-example ubox blobmsg_json  ${json})
 
-ADD_EXECUTABLE(ustream-example ustream-example.c)
-TARGET_LINK_LIBRARIES(ustream-example ubox)
+    ADD_EXECUTABLE(ustream-example ustream-example.c)
+    TARGET_LINK_LIBRARIES(ustream-example ubox)
 
-ADD_EXECUTABLE(runqueue-example runqueue-example.c)
-TARGET_LINK_LIBRARIES(runqueue-example ubox)
+    ADD_EXECUTABLE(runqueue-example runqueue-example.c)
+    TARGET_LINK_LIBRARIES(runqueue-example ubox)
 
-ADD_EXECUTABLE(json_script-example json_script-example.c)
-TARGET_LINK_LIBRARIES(json_script-example ubox blobmsg_json json_script ${json})
+    ADD_EXECUTABLE(json_script-example json_script-example.c)
+    TARGET_LINK_LIBRARIES(json_script-example ubox blobmsg_json json_script ${json})
+ENDIF()
-- 
1.7.10.4
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list