CMakeLists.txt 1.8 KB

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