cmake: Add ubox library and include dir lookup
[project/uci.git] / CMakeLists.txt
index e3968c8..a900a15 100644 (file)
@@ -9,11 +9,22 @@ OPTION(UCI_DEBUG "debugging support" OFF)
 OPTION(UCI_DEBUG_TYPECAST "typecast debugging support" OFF)
 OPTION(BUILD_LUA "build Lua binding" ON)
 
+IF(BUILD_STATIC)
+  FIND_LIBRARY(ubox_library NAMES ubox.a)
+ELSE(BUILD_STATIC)
+  FIND_LIBRARY(ubox_library NAMES ubox)
+ENDIF(BUILD_STATIC)
+
+FIND_PATH(ubox_include_dir libubox/usock.h)
+
 CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/uci_config.h.in ${CMAKE_SOURCE_DIR}/uci_config.h )
 
-SET(LIB_SOURCES libuci.c file.c util.c delta.c parse.c)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${ubox_include_dir})
+
+SET(LIB_SOURCES libuci.c file.c util.c delta.c parse.c blob.c)
 
 ADD_LIBRARY(uci SHARED ${LIB_SOURCES})
+TARGET_LINK_LIBRARIES(uci ${ubox_library})
 SET_TARGET_PROPERTIES(uci PROPERTIES OUTPUT_NAME uci)
 
 ADD_EXECUTABLE(cli cli.c)
@@ -22,12 +33,9 @@ TARGET_LINK_LIBRARIES(cli uci)
 
 ADD_LIBRARY(ucimap STATIC ucimap.c)
 
-ADD_EXECUTABLE(ucimap-example ucimap-example.c)
-TARGET_LINK_LIBRARIES(ucimap-example uci ucimap)
-
 ADD_SUBDIRECTORY(lua)
 
-INSTALL(FILES uci.h uci_config.h ucimap.h
+INSTALL(FILES uci.h uci_config.h uci_blob.h ucimap.h
        DESTINATION include
 )