projects/uci: lua: use built in pkg-config support for alternatives
[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 ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -I. -DUCI_PREFIX="${CMAKE_INSTALL_PREFIX}")
7
8 OPTION(UCI_DEBUG "debugging support" OFF)
9 OPTION(UCI_DEBUG_TYPECAST "typecast debugging support" OFF)
10 OPTION(BUILD_LUA "build Lua binding" ON)
11
12 IF(BUILD_STATIC)
13   FIND_LIBRARY(ubox_library NAMES ubox.a)
14 ELSE(BUILD_STATIC)
15   FIND_LIBRARY(ubox_library NAMES ubox)
16 ENDIF(BUILD_STATIC)
17
18 FIND_PATH(ubox_include_dir libubox/usock.h)
19
20 CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/uci_config.h.in ${CMAKE_SOURCE_DIR}/uci_config.h )
21
22 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${ubox_include_dir})
23
24 SET(LIB_SOURCES libuci.c file.c util.c delta.c parse.c blob.c)
25
26 ADD_LIBRARY(uci SHARED ${LIB_SOURCES})
27 TARGET_LINK_LIBRARIES(uci ${ubox_library})
28 SET_TARGET_PROPERTIES(uci PROPERTIES OUTPUT_NAME uci)
29
30 ADD_EXECUTABLE(cli cli.c)
31 SET_TARGET_PROPERTIES(cli PROPERTIES OUTPUT_NAME uci)
32 TARGET_LINK_LIBRARIES(cli uci)
33
34 ADD_LIBRARY(ucimap STATIC ucimap.c)
35
36 ADD_SUBDIRECTORY(lua)
37
38 INSTALL(FILES uci.h uci_config.h uci_blob.h ucimap.h
39         DESTINATION include
40 )
41
42 INSTALL(TARGETS uci cli
43         ARCHIVE DESTINATION lib
44         LIBRARY DESTINATION lib
45         RUNTIME DESTINATION bin
46 )
47