usock: add helper waiting for socket to be ready
[project/libubox.git] / CMakeLists.txt
index c339e02..ddd5533 100644 (file)
@@ -7,13 +7,8 @@ ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -Wmissing-declarations)
 
 OPTION(BUILD_LUA "build Lua plugin" ON)
 
-IF(APPLE)
-  INCLUDE_DIRECTORIES(/opt/local/include)
-  LINK_DIRECTORIES(/opt/local/lib)
-ENDIF()
-
 INCLUDE(FindPkgConfig)
-PKG_CHECK_MODULES(JSONC json-c json)
+PKG_CHECK_MODULES(JSONC json-c)
 IF(JSONC_FOUND)
   ADD_DEFINITIONS(-DJSONC)
   INCLUDE_DIRECTORIES(${JSONC_INCLUDE_DIRS})
@@ -22,6 +17,8 @@ ENDIF()
 SET(SOURCES avl.c avl-cmp.c blob.c blobmsg.c uloop.c usock.c ustream.c ustream-fd.c vlist.c utils.c safe_list.c runqueue.c md5.c kvlist.c)
 
 ADD_LIBRARY(ubox SHARED ${SOURCES})
+ADD_LIBRARY(ubox-static STATIC ${SOURCES})
+SET_TARGET_PROPERTIES(ubox-static PROPERTIES OUTPUT_NAME ubox)
 
 SET(LIBS)
 CHECK_FUNCTION_EXISTS(clock_gettime HAVE_GETTIME)
@@ -36,19 +33,21 @@ FILE(GLOB headers *.h)
 INSTALL(FILES ${headers}
        DESTINATION include/libubox
 )
-INSTALL(TARGETS ubox
+INSTALL(TARGETS ubox ubox-static
+       ARCHIVE DESTINATION lib
        LIBRARY DESTINATION lib
 )
 
 ADD_SUBDIRECTORY(lua)
+ADD_SUBDIRECTORY(examples)
 
-find_library(json NAMES json-c json)
+find_library(json NAMES json-c)
 IF(EXISTS ${json})
        ADD_LIBRARY(blobmsg_json SHARED blobmsg_json.c)
        TARGET_LINK_LIBRARIES(blobmsg_json ubox ${json})
 
        ADD_EXECUTABLE(jshn jshn.c)
-       TARGET_LINK_LIBRARIES(jshn ${json})
+       TARGET_LINK_LIBRARIES(jshn blobmsg_json ${json})
 
        ADD_LIBRARY(json_script SHARED json_script.c)
        TARGET_LINK_LIBRARIES(json_script ubox)