CMakeLists.txt 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. cmake_minimum_required(VERSION 2.6)
  2. PROJECT(umdns C)
  3. ADD_DEFINITIONS(-Os -ggdb -Wall -Werror --std=gnu99 -Wmissing-declarations)
  4. SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
  5. SET(SOURCES dns.c announce.c cache.c service.c util.c ubus.c interface.c)
  6. FIND_PATH(ubox_include_dir NAMES libubox/usock.h)
  7. FIND_PATH(ubus_include_dir NAMES libubus.h)
  8. INCLUDE_DIRECTORIES(${ubox_include_dir} ${ubus_include_dir})
  9. FIND_LIBRARY(ubox NAMES ubox)
  10. FIND_LIBRARY(ubus NAMES ubus)
  11. FIND_LIBRARY(blobmsg_json NAMES blobmsg_json)
  12. FIND_LIBRARY(json NAMES json json-c)
  13. SET(LIBS ${ubox} ${ubus} ${blobmsg_json} ${json} resolv)
  14. IF(DEBUG)
  15. ADD_DEFINITIONS(-DDEBUG -g3)
  16. ENDIF()
  17. ADD_LIBRARY(umdns-lib STATIC ${SOURCES})
  18. TARGET_LINK_LIBRARIES(umdns-lib ${LIBS})
  19. ADD_EXECUTABLE(umdns main.c)
  20. TARGET_LINK_LIBRARIES(umdns umdns-lib)
  21. IF(UNIT_TESTING)
  22. ENABLE_TESTING()
  23. ADD_SUBDIRECTORY(tests)
  24. IF(CMAKE_C_COMPILER_ID STREQUAL "Clang")
  25. ADD_LIBRARY(umdns-lib-san STATIC ${SOURCES})
  26. TARGET_COMPILE_OPTIONS(umdns-lib-san PRIVATE -g -fno-omit-frame-pointer -fsanitize=undefined,address,leak -fno-sanitize-recover=all)
  27. TARGET_LINK_OPTIONS(umdns-lib-san PRIVATE -fsanitize=undefined,address,leak)
  28. TARGET_LINK_LIBRARIES(umdns-lib-san ${LIBS})
  29. ADD_EXECUTABLE(umdns-san main.c ${SOURCES})
  30. TARGET_COMPILE_OPTIONS(umdns-san PRIVATE -g -fno-omit-frame-pointer -fsanitize=undefined,address,leak -fno-sanitize-recover=all)
  31. TARGET_LINK_OPTIONS(umdns-san PRIVATE -fsanitize=undefined,address,leak)
  32. TARGET_LINK_LIBRARIES(umdns-san umdns-lib-san)
  33. ENDIF()
  34. ENDIF()
  35. INSTALL(TARGETS umdns
  36. RUNTIME DESTINATION sbin
  37. )