-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
46 lines (34 loc) · 1.46 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
cmake_minimum_required(VERSION 2.6)
PROJECT(cgi-io C)
INCLUDE(CheckFunctionExists)
FIND_PATH(ubus_include_dir libubus.h)
FIND_LIBRARY(ubox NAMES ubox)
FIND_LIBRARY(ubus NAMES ubus)
INCLUDE_DIRECTORIES(${ubus_include_dir})
ADD_DEFINITIONS(-Os -Wall -Werror -Wextra --std=gnu99 -g3)
ADD_DEFINITIONS(-Wno-unused-parameter -Wmissing-declarations)
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
IF(APPLE)
INCLUDE_DIRECTORIES(/opt/local/include)
LINK_DIRECTORIES(/opt/local/lib)
ENDIF()
SET(LIB_SOURCES multipart_parser.c util.c)
ADD_LIBRARY(cgi-lib STATIC ${LIB_SOURCES})
ADD_EXECUTABLE(cgi-io main.c)
TARGET_LINK_LIBRARIES(cgi-io cgi-lib ${ubox} ${ubus})
IF(UNIT_TESTING)
ADD_DEFINITIONS(-DUNIT_TESTING)
ENABLE_TESTING()
ADD_SUBDIRECTORY(tests)
IF(CMAKE_C_COMPILER_ID STREQUAL "Clang")
ADD_LIBRARY(cgi-lib-san SHARED ${LIB_SOURCES})
TARGET_COMPILE_OPTIONS(cgi-lib-san PRIVATE -g -fno-omit-frame-pointer -fsanitize=undefined,address,leak -fno-sanitize-recover=all)
TARGET_LINK_OPTIONS(cgi-lib-san PRIVATE -fsanitize=undefined,address,leak)
TARGET_LINK_LIBRARIES(cgi-lib-san ${ubox} ${ubus})
ADD_EXECUTABLE(cgi-io-san main.c)
TARGET_COMPILE_OPTIONS(cgi-io-san PRIVATE -g -fno-omit-frame-pointer -fsanitize=undefined,address,leak -fno-sanitize-recover=all)
TARGET_LINK_OPTIONS(cgi-io-san PRIVATE -fsanitize=undefined,address,leak)
TARGET_LINK_LIBRARIES(cgi-io-san cgi-lib-san ${ubox})
ENDIF()
ENDIF()
INSTALL(TARGETS cgi-io RUNTIME DESTINATION sbin)