1 cmake_minimum_required(VERSION 2.6)
2 INCLUDE(CheckLibraryExists)
3 INCLUDE(CheckFunctionExists)
6 ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -Wmissing-declarations)
8 OPTION(BUILD_LUA "build Lua plugin" ON)
10 INCLUDE(FindPkgConfig)
11 PKG_CHECK_MODULES(JSONC json-c)
13 ADD_DEFINITIONS(-DJSONC)
14 INCLUDE_DIRECTORIES(${JSONC_INCLUDE_DIRS})
17 SET(SOURCES avl.c avl-cmp.c blob.c blobmsg.c uloop.c usock.c ustream.c ustream-fd.c vlist.c utils.c safe_list.c runqueue.c md5.c kvlist.c)
19 ADD_LIBRARY(ubox SHARED ${SOURCES})
20 ADD_LIBRARY(ubox-static STATIC ${SOURCES})
21 SET_TARGET_PROPERTIES(ubox-static PROPERTIES OUTPUT_NAME ubox)
24 CHECK_FUNCTION_EXISTS(clock_gettime HAVE_GETTIME)
26 CHECK_LIBRARY_EXISTS(rt clock_gettime "" NEED_GETTIME)
28 TARGET_LINK_LIBRARIES(ubox rt)
32 FILE(GLOB headers *.h)
33 INSTALL(FILES ${headers}
34 DESTINATION include/libubox
36 INSTALL(TARGETS ubox ubox-static
37 ARCHIVE DESTINATION lib
38 LIBRARY DESTINATION lib
42 ADD_SUBDIRECTORY(examples)
44 find_library(json NAMES json-c)
46 ADD_LIBRARY(blobmsg_json SHARED blobmsg_json.c)
47 TARGET_LINK_LIBRARIES(blobmsg_json ubox ${json})
49 ADD_EXECUTABLE(jshn jshn.c)
50 TARGET_LINK_LIBRARIES(jshn blobmsg_json ${json})
52 ADD_LIBRARY(json_script SHARED json_script.c)
53 TARGET_LINK_LIBRARIES(json_script ubox)
55 INSTALL(TARGETS blobmsg_json jshn json_script
56 LIBRARY DESTINATION lib
57 RUNTIME DESTINATION bin
60 FILE(GLOB scripts sh/*.sh)
61 INSTALL(FILES ${scripts}
62 DESTINATION share/libubox