file: fix segfault in uci_parse_option
[project/uci.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.6)
2
3 PROJECT(uci C)
4
5 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
6
7 ADD_DEFINITIONS(-Wall -Werror)
8 IF(CMAKE_C_COMPILER_VERSION VERSION_GREATER 6)
9 ADD_DEFINITIONS(-Wextra -Werror=implicit-function-declaration)
10 ADD_DEFINITIONS(-Wformat -Werror=format-security -Werror=format-nonliteral)
11 ENDIF()
12 ADD_DEFINITIONS(-Os -std=gnu99 -g3 -Wmissing-declarations -Wno-unused-parameter)
13 ADD_DEFINITIONS(-DUCI_PREFIX="${CMAKE_INSTALL_PREFIX}")
14
15
16 OPTION(UCI_DEBUG "debugging support" OFF)
17 OPTION(UCI_DEBUG_TYPECAST "typecast debugging support" OFF)
18 OPTION(BUILD_LUA "build Lua binding" ON)
19 OPTION(BUILD_STATIC "statically linking uci" OFF)
20
21 FIND_PATH(ubox_include_dir libubox/usock.h)
22
23 CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/uci_config.h.in ${CMAKE_SOURCE_DIR}/uci_config.h )
24
25 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${ubox_include_dir})
26
27 SET(LIB_SOURCES libuci.c file.c util.c delta.c parse.c blob.c)
28
29 FIND_LIBRARY(ubox NAMES ubox)
30 IF(BUILD_STATIC)
31 FIND_LIBRARY(ubox-static NAMES libubox.a)
32 ENDIF(BUILD_STATIC)
33
34 ADD_LIBRARY(uci SHARED ${LIB_SOURCES})
35 SET_TARGET_PROPERTIES(uci PROPERTIES OUTPUT_NAME uci)
36 TARGET_LINK_LIBRARIES(uci ${ubox})
37
38 ADD_LIBRARY(uci-static STATIC ${LIB_SOURCES})
39 SET_TARGET_PROPERTIES(uci-static PROPERTIES OUTPUT_NAME uci)
40 TARGET_LINK_LIBRARIES(uci-static ${ubox-static})
41
42 ADD_EXECUTABLE(cli cli.c)
43 SET_TARGET_PROPERTIES(cli PROPERTIES OUTPUT_NAME uci)
44 IF(BUILD_STATIC)
45 TARGET_LINK_LIBRARIES(cli uci-static ${ubox-static})
46 ELSE(BUILD_STATIC)
47 TARGET_LINK_LIBRARIES(cli uci ${ubox})
48 ENDIF(BUILD_STATIC)
49
50 ADD_LIBRARY(ucimap STATIC ucimap.c)
51
52 IF(BUILD_LUA)
53 ADD_SUBDIRECTORY(lua)
54 ENDIF()
55
56 IF(UNIT_TESTING)
57 ENABLE_TESTING()
58 ADD_SUBDIRECTORY(tests)
59 ENDIF()
60
61 INSTALL(FILES uci.h uci_config.h uci_blob.h ucimap.h
62 DESTINATION include
63 )
64
65 INSTALL(TARGETS uci cli
66 ARCHIVE DESTINATION lib
67 LIBRARY DESTINATION lib
68 RUNTIME DESTINATION bin
69 )
70