• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/libubox/CMakeLists.txt

  1 cmake_minimum_required(VERSION 2.6)
  2 INCLUDE(CheckLibraryExists)
  3 INCLUDE(CheckFunctionExists)
  4 
  5 PROJECT(ubox C)
  6 
  7 ADD_DEFINITIONS(-Wall -Werror)
  8 IF(CMAKE_C_COMPILER_VERSION VERSION_GREATER 6)
  9         ADD_DEFINITIONS(-Wextra -Werror=implicit-function-declaration)
 10         ADD_DEFINITIONS(-Wformat -Werror=format-security -Werror=format-nonliteral)
 11 ENDIF()
 12 ADD_DEFINITIONS(-Os -std=gnu99 -g3 -Wmissing-declarations -Wno-unused-parameter)
 13 
 14 OPTION(BUILD_LUA "build Lua plugin" ON)
 15 OPTION(BUILD_EXAMPLES "build examples" ON)
 16 
 17 INCLUDE(FindPkgConfig)
 18 PKG_SEARCH_MODULE(JSONC json-c)
 19 IF(JSONC_FOUND)
 20   ADD_DEFINITIONS(-DJSONC)
 21   INCLUDE_DIRECTORIES(${JSONC_INCLUDE_DIRS})
 22 ENDIF()
 23 
 24 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 ulog.c base64.c)
 25 
 26 ADD_LIBRARY(ubox SHARED ${SOURCES})
 27 ADD_LIBRARY(ubox-static STATIC ${SOURCES})
 28 SET_TARGET_PROPERTIES(ubox-static PROPERTIES OUTPUT_NAME ubox)
 29 
 30 SET(LIBS)
 31 CHECK_FUNCTION_EXISTS(clock_gettime HAVE_GETTIME)
 32 IF(NOT HAVE_GETTIME)
 33         CHECK_LIBRARY_EXISTS(rt clock_gettime "" NEED_GETTIME)
 34         IF(NEED_GETTIME)
 35                 TARGET_LINK_LIBRARIES(ubox rt)
 36         ENDIF()
 37 ENDIF()
 38 
 39 FILE(GLOB headers *.h)
 40 INSTALL(FILES ${headers}
 41         DESTINATION include/libubox
 42 )
 43 INSTALL(TARGETS ubox ubox-static
 44         ARCHIVE DESTINATION lib
 45         LIBRARY DESTINATION lib
 46 )
 47 
 48 ADD_SUBDIRECTORY(lua)
 49 ADD_SUBDIRECTORY(examples)
 50 
 51 MACRO(ADD_UNIT_TEST_SAN name)
 52   ADD_EXECUTABLE(${name}-san ${name}.c)
 53   TARGET_COMPILE_OPTIONS(${name}-san PRIVATE -g -fno-omit-frame-pointer -fsanitize=undefined,address,leak -fno-sanitize-recover=all)
 54   TARGET_LINK_OPTIONS(${name}-san PRIVATE -fsanitize=undefined,address,leak)
 55   TARGET_LINK_LIBRARIES(${name}-san ubox blobmsg_json json_script ${json})
 56   TARGET_INCLUDE_DIRECTORIES(${name}-san PRIVATE ${PROJECT_SOURCE_DIR})
 57 ENDMACRO(ADD_UNIT_TEST_SAN)
 58 
 59 IF(UNIT_TESTING)
 60   ENABLE_TESTING()
 61   ADD_SUBDIRECTORY(tests)
 62 ENDIF()
 63 
 64 find_library(json NAMES json-c)
 65 IF(EXISTS ${json})
 66         ADD_LIBRARY(blobmsg_json SHARED blobmsg_json.c)
 67         TARGET_LINK_LIBRARIES(blobmsg_json ubox ${json})
 68 
 69         ADD_LIBRARY(blobmsg_json-static STATIC blobmsg_json.c)
 70         SET_TARGET_PROPERTIES(blobmsg_json-static
 71                               PROPERTIES OUTPUT_NAME blobmsg_json)
 72 
 73         IF(UNIT_TESTING)
 74                 ADD_UNIT_TEST_SAN(jshn)
 75         ENDIF(UNIT_TESTING)
 76 
 77         ADD_EXECUTABLE(jshn jshn.c)
 78         TARGET_LINK_LIBRARIES(jshn blobmsg_json ${json})
 79 
 80         ADD_LIBRARY(json_script SHARED json_script.c)
 81         TARGET_LINK_LIBRARIES(json_script ubox)
 82 
 83         INSTALL(TARGETS blobmsg_json blobmsg_json-static jshn json_script
 84                 ARCHIVE DESTINATION lib
 85                 LIBRARY DESTINATION lib
 86                 RUNTIME DESTINATION bin
 87         )
 88 
 89         FILE(GLOB scripts sh/*.sh)
 90         INSTALL(FILES ${scripts}
 91                 DESTINATION share/libubox
 92         )
 93 
 94 ENDIF()
 95 
 96 IF(ABIVERSION)
 97         SET_TARGET_PROPERTIES(ubox PROPERTIES VERSION ${ABIVERSION})
 98         SET_TARGET_PROPERTIES(json_script PROPERTIES VERSION ${ABIVERSION})
 99         SET_TARGET_PROPERTIES(blobmsg_json PROPERTIES VERSION ${ABIVERSION})
100 ENDIF()

This page was automatically generated by LXR 0.3.1.  •  OpenWrt