CMakeLists.txt 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. FIND_PATH(udebug_include_dir NAMES udebug.h)
  9. INCLUDE_DIRECTORIES(${ubox_include_dir} ${ubus_include_dir} ${udebug_include_dir})
  10. FIND_LIBRARY(ubox NAMES ubox)
  11. FIND_LIBRARY(ubus NAMES ubus)
  12. FIND_LIBRARY(blobmsg_json NAMES blobmsg_json)
  13. FIND_LIBRARY(json NAMES json json-c)
  14. FIND_LIBRARY(udebug NAMES udebug)
  15. SET(LIBS ${ubox} ${ubus} ${blobmsg_json} ${json} resolv ${udebug})
  16. IF(DEBUG)
  17. ADD_DEFINITIONS(-DDEBUG -g3)
  18. ENDIF()
  19. ADD_LIBRARY(umdns-lib STATIC ${SOURCES})
  20. TARGET_LINK_LIBRARIES(umdns-lib ${LIBS})
  21. ADD_EXECUTABLE(umdns main.c)
  22. TARGET_LINK_LIBRARIES(umdns umdns-lib)
  23. IF(UNIT_TESTING)
  24. ENABLE_TESTING()
  25. ADD_SUBDIRECTORY(tests)
  26. IF(CMAKE_C_COMPILER_ID STREQUAL "Clang")
  27. ADD_LIBRARY(umdns-lib-san STATIC ${SOURCES})
  28. TARGET_COMPILE_OPTIONS(umdns-lib-san PRIVATE -g -fno-omit-frame-pointer -fsanitize=undefined,address,leak -fno-sanitize-recover=all)
  29. TARGET_LINK_OPTIONS(umdns-lib-san PRIVATE -fsanitize=undefined,address,leak)
  30. TARGET_LINK_LIBRARIES(umdns-lib-san ${LIBS})
  31. ADD_EXECUTABLE(umdns-san main.c ${SOURCES})
  32. TARGET_COMPILE_OPTIONS(umdns-san PRIVATE -g -fno-omit-frame-pointer -fsanitize=undefined,address,leak -fno-sanitize-recover=all)
  33. TARGET_LINK_OPTIONS(umdns-san PRIVATE -fsanitize=undefined,address,leak)
  34. TARGET_LINK_LIBRARIES(umdns-san umdns-lib-san)
  35. ENDIF()
  36. ENDIF()
  37. INSTALL(TARGETS umdns
  38. RUNTIME DESTINATION sbin
  39. )