replace the existing build system with cmake
[project/uci.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.6)
2
3 PROJECT(uci C)
4
5 SET(CMAKE_INSTALL_PREFIX /usr)
6
7 ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -DUCI_PREFIX="${CMAKE_INSTALL_PREFIX}")
8
9 OPTION(UCI_PLUGIN_SUPPORT "plugin support" ON)
10 OPTION(UCI_DEBUG "debugging support" OFF)
11 OPTION(UCI_DEBUG_TYPECAST "typecast debugging support" OFF)
12 OPTION(BUILD_LUA "build Lua plugin" ON)
13
14 CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/uci_config.h.in ${CMAKE_SOURCE_DIR}/uci_config.h )
15
16 SET(LIB_SOURCES libuci.c file.c ucimap.c util.c delta.c)
17
18 ADD_LIBRARY(uci-shared SHARED ${LIB_SOURCES})
19 SET_TARGET_PROPERTIES(uci-shared PROPERTIES OUTPUT_NAME uci)
20
21 ADD_LIBRARY(uci-static STATIC ${LIB_SOURCES})
22 SET_TARGET_PROPERTIES(uci-static PROPERTIES OUTPUT_NAME uci)
23
24 ADD_EXECUTABLE(cli cli.c)
25 SET_TARGET_PROPERTIES(cli PROPERTIES OUTPUT_NAME uci)
26 TARGET_LINK_LIBRARIES(cli uci-shared)
27
28 ADD_EXECUTABLE(cli-static cli.c)
29 SET_TARGET_PROPERTIES(cli-static PROPERTIES OUTPUT_NAME uci-static)
30 TARGET_LINK_LIBRARIES(cli-static uci-static)
31
32 ADD_EXECUTABLE(ucimap-example ucimap-example.c)
33 TARGET_LINK_LIBRARIES(ucimap-example uci-static)
34
35 ADD_SUBDIRECTORY(lua)
36
37 INSTALL(FILES uci.h uci_config.h ucimap.h
38         DESTINATION include/libubox
39 )
40
41 INSTALL(TARGETS uci-shared uci-static cli cli-static
42         ARCHIVE DESTINATION lib
43         LIBRARY DESTINATION lib
44         RUNTIME DESTINATION bin
45 )
46