fix a bug in blobmsg_parse
[project/libubox.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.6)
2
3 PROJECT(ubox C)
4 ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3)
5
6 IF(APPLE)
7   INCLUDE_DIRECTORIES(/opt/local/include)
8   LINK_DIRECTORIES(/opt/local/lib)
9 ENDIF()
10
11 SET(SOURCES avl.c blob.c blobmsg.c uloop.c usock.c)
12
13 ADD_LIBRARY(ubox SHARED ${SOURCES})
14
15 SET(CMAKE_INSTALL_PREFIX /usr)
16
17 FILE(GLOB headers *.h)
18 INSTALL(FILES ${headers}
19         DESTINATION include/libubox
20 )
21 INSTALL(TARGETS ubox
22         LIBRARY DESTINATION lib
23 )
24
25 find_library(json json)
26 IF(EXISTS ${json})
27         ADD_LIBRARY(blobmsg_json SHARED blobmsg_json.c)
28         TARGET_LINK_LIBRARIES(blobmsg_json ubox json)
29
30         ADD_EXECUTABLE(jshn jshn.c)
31         TARGET_LINK_LIBRARIES(jshn json)
32
33         INSTALL(TARGETS blobmsg_json jshn
34                 LIBRARY DESTINATION lib
35                 RUNTIME DESTINATION bin
36         )
37
38         FILE(GLOB scripts sh/*.sh)
39         INSTALL(FILES ${scripts}
40                 DESTINATION share/libubox
41         )
42
43 ENDIF()