Skip to content

Commit

Permalink
replace the existing build system with cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Fietkau committed Mar 26, 2011
1 parent 9080634 commit b298632
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 179 deletions.
15 changes: 10 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
Makefile
CMakeCache.txt
CMakeFiles
*.cmake
*.o
*.a
*.so
*.dylib
install_manifest.txt

uci
uci-static
ucimap-example
*.[oa]
*.so*
*.dylib*
.*.swp
.gdb*
uci_config.h
test/save
46 changes: 46 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
cmake_minimum_required(VERSION 2.6)

PROJECT(uci C)

SET(CMAKE_INSTALL_PREFIX /usr)

ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -DUCI_PREFIX="${CMAKE_INSTALL_PREFIX}")

OPTION(UCI_PLUGIN_SUPPORT "plugin support" ON)
OPTION(UCI_DEBUG "debugging support" OFF)
OPTION(UCI_DEBUG_TYPECAST "typecast debugging support" OFF)
OPTION(BUILD_LUA "build Lua plugin" ON)

CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/uci_config.h.in ${CMAKE_SOURCE_DIR}/uci_config.h )

SET(LIB_SOURCES libuci.c file.c ucimap.c util.c delta.c)

ADD_LIBRARY(uci-shared SHARED ${LIB_SOURCES})
SET_TARGET_PROPERTIES(uci-shared PROPERTIES OUTPUT_NAME uci)

ADD_LIBRARY(uci-static STATIC ${LIB_SOURCES})
SET_TARGET_PROPERTIES(uci-static PROPERTIES OUTPUT_NAME uci)

ADD_EXECUTABLE(cli cli.c)
SET_TARGET_PROPERTIES(cli PROPERTIES OUTPUT_NAME uci)
TARGET_LINK_LIBRARIES(cli uci-shared)

ADD_EXECUTABLE(cli-static cli.c)
SET_TARGET_PROPERTIES(cli-static PROPERTIES OUTPUT_NAME uci-static)
TARGET_LINK_LIBRARIES(cli-static uci-static)

ADD_EXECUTABLE(ucimap-example ucimap-example.c)
TARGET_LINK_LIBRARIES(ucimap-example uci-static)

ADD_SUBDIRECTORY(lua)

INSTALL(FILES uci.h uci_config.h ucimap.h
DESTINATION include/libubox
)

INSTALL(TARGETS uci-shared uci-static cli cli-static
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)

95 changes: 0 additions & 95 deletions Makefile

This file was deleted.

35 changes: 0 additions & 35 deletions Makefile.inc

This file was deleted.

33 changes: 33 additions & 0 deletions lua/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
cmake_minimum_required(VERSION 2.6)

PROJECT(uci C)

SET(CMAKE_INSTALL_PREFIX /)

ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3)

IF(APPLE)
SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -undefined dynamic_lookup")
ENDIF(APPLE)

EXECUTE_PROCESS(
COMMAND lua -e "for k in string.gmatch(package.cpath .. \";\", \"([^;]+)/..so;\") do if k:sub(1,1) == \"/\" then print(k) break end end"
OUTPUT_VARIABLE LUAPATH
RESULT_VARIABLE LUA_CHECK_RES
OUTPUT_STRIP_TRAILING_WHITESPACE
)

IF(NOT ${LUA_CHECK_RES} EQUAL 0 OR ${LUAPATH} EQUAL "")
MESSAGE(SEND_ERROR "Lua was not found on your system")
ENDIF()

ADD_LIBRARY(uci_lua MODULE uci.c)
SET_TARGET_PROPERTIES(uci_lua PROPERTIES
OUTPUT_NAME uci
PREFIX ""
)
TARGET_LINK_LIBRARIES(uci_lua uci)

INSTALL(TARGETS uci_lua
LIBRARY DESTINATION ${LUAPATH}
)
44 changes: 0 additions & 44 deletions lua/Makefile

This file was deleted.

3 changes: 3 additions & 0 deletions uci_config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#cmakedefine UCI_PLUGIN_SUPPORT 1
#cmakedefine UCI_DEBUG 1
#cmakedefine UCI_DEBUG_TYPECAST 1

0 comments on commit b298632

Please sign in to comment.