1 cmake_minimum_required(VERSION 2.6)
4 ADD_DEFINITIONS(-Os -ggdb -Wall -Werror --std=gnu99 -Wmissing-declarations)
6 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
8 SET(SOURCES dns.c announce.c cache.c service.c util.c ubus.c interface.c)
10 FIND_PATH(ubox_include_dir NAMES libubox/usock.h)
11 FIND_PATH(ubus_include_dir NAMES libubus.h)
12 FIND_PATH(udebug_include_dir NAMES udebug.h)
13 INCLUDE_DIRECTORIES(${ubox_include_dir} ${ubus_include_dir} ${udebug_include_dir})
15 FIND_LIBRARY(ubox NAMES ubox)
16 FIND_LIBRARY(ubus NAMES ubus)
17 FIND_LIBRARY(blobmsg_json NAMES blobmsg_json)
18 FIND_LIBRARY(json NAMES json json-c)
19 FIND_LIBRARY(udebug NAMES udebug)
21 SET(LIBS ${ubox} ${ubus} ${blobmsg_json} ${json} resolv ${udebug})
24 ADD_DEFINITIONS(-DDEBUG -g3)
27 ADD_LIBRARY(umdns-lib STATIC ${SOURCES})
28 TARGET_LINK_LIBRARIES(umdns-lib ${LIBS})
30 ADD_EXECUTABLE(umdns main.c)
31 TARGET_LINK_LIBRARIES(umdns umdns-lib)
35 ADD_SUBDIRECTORY(tests)
37 IF(CMAKE_C_COMPILER_ID STREQUAL "Clang")
38 ADD_LIBRARY(umdns-lib-san STATIC ${SOURCES})
39 TARGET_COMPILE_OPTIONS(umdns-lib-san PRIVATE -g -fno-omit-frame-pointer -fsanitize=undefined,address,leak -fno-sanitize-recover=all)
40 TARGET_LINK_OPTIONS(umdns-lib-san PRIVATE -fsanitize=undefined,address,leak)
41 TARGET_LINK_LIBRARIES(umdns-lib-san ${LIBS})
43 ADD_EXECUTABLE(umdns-san main.c ${SOURCES})
44 TARGET_COMPILE_OPTIONS(umdns-san PRIVATE -g -fno-omit-frame-pointer -fsanitize=undefined,address,leak -fno-sanitize-recover=all)
45 TARGET_LINK_OPTIONS(umdns-san PRIVATE -fsanitize=undefined,address,leak)
46 TARGET_LINK_LIBRARIES(umdns-san umdns-lib-san)
52 RUNTIME DESTINATION sbin