source: trunk/debian/packages/libubox/trunk/CMakeLists.txt @ 857

Last change on this file since 857 was 857, checked in by amain, 4 years ago

libubox: initial import / part 4

File size: 1.8 KB
Line 
1cmake_minimum_required(VERSION 2.6)
2INCLUDE(CheckLibraryExists)
3INCLUDE(CheckFunctionExists)
4
5PROJECT(ubox C)
6ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -Wmissing-declarations)
7
8OPTION(BUILD_LUA "build Lua plugin" ON)
9OPTION(BUILD_EXAMPLES "build examples" ON)
10
11INCLUDE(FindPkgConfig)
12PKG_SEARCH_MODULE(JSONC json-c)
13IF(JSONC_FOUND)
14  ADD_DEFINITIONS(-DJSONC)
15  INCLUDE_DIRECTORIES(${JSONC_INCLUDE_DIRS})
16ENDIF()
17
18SET(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 ulog.c base64.c)
19
20ADD_LIBRARY(ubox SHARED ${SOURCES})
21ADD_LIBRARY(ubox-static STATIC ${SOURCES})
22SET_TARGET_PROPERTIES(ubox-static PROPERTIES OUTPUT_NAME ubox)
23
24SET(LIBS)
25CHECK_FUNCTION_EXISTS(clock_gettime HAVE_GETTIME)
26IF(NOT HAVE_GETTIME)
27        CHECK_LIBRARY_EXISTS(rt clock_gettime "" NEED_GETTIME)
28        IF(NEED_GETTIME)
29                TARGET_LINK_LIBRARIES(ubox rt)
30        ENDIF()
31ENDIF()
32
33FILE(GLOB headers *.h)
34INSTALL(FILES ${headers}
35        DESTINATION include/libubox
36)
37INSTALL(TARGETS ubox ubox-static
38        ARCHIVE DESTINATION lib
39        LIBRARY DESTINATION lib
40)
41
42ADD_SUBDIRECTORY(lua)
43ADD_SUBDIRECTORY(examples)
44
45find_library(json NAMES json-c)
46IF(EXISTS ${json})
47        ADD_LIBRARY(blobmsg_json SHARED blobmsg_json.c)
48        TARGET_LINK_LIBRARIES(blobmsg_json ubox ${json})
49
50        ADD_LIBRARY(blobmsg_json-static STATIC blobmsg_json.c)
51        SET_TARGET_PROPERTIES(blobmsg_json-static
52                              PROPERTIES OUTPUT_NAME blobmsg_json)
53
54        ADD_EXECUTABLE(jshn jshn.c)
55        TARGET_LINK_LIBRARIES(jshn blobmsg_json ${json})
56
57        ADD_LIBRARY(json_script SHARED json_script.c)
58        TARGET_LINK_LIBRARIES(json_script ubox)
59
60        INSTALL(TARGETS blobmsg_json blobmsg_json-static jshn json_script
61                ARCHIVE DESTINATION lib
62                LIBRARY DESTINATION lib
63                RUNTIME DESTINATION bin
64        )
65
66        FILE(GLOB scripts sh/*.sh)
67        INSTALL(FILES ${scripts}
68                DESTINATION share/libubox
69        )
70
71ENDIF()
Note: See TracBrowser for help on using the repository browser.