-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
72 lines (58 loc) · 2.37 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
cmake_minimum_required(VERSION 2.6)
INCLUDE(CheckIncludeFiles)
PROJECT(uclient C)
ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3)
IF(CMAKE_C_COMPILER_VERSION VERSION_GREATER 6)
ADD_DEFINITIONS(-Wextra -Werror=implicit-function-declaration)
ADD_DEFINITIONS(-Wformat -Werror=format-security -Werror=format-nonliteral)
ENDIF()
ADD_DEFINITIONS(-Wno-unused-parameter -Wmissing-declarations)
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
FIND_PATH(ubox_include_dir libubox/ustream-ssl.h)
INCLUDE_DIRECTORIES(${ubox_include_dir})
OPTION(BUILD_UCODE "build ucode plugin" ON)
IF(BUILD_STATIC)
FIND_LIBRARY(ubox_library NAMES ubox.a)
ELSE(BUILD_STATIC)
FIND_LIBRARY(ubox_library NAMES ubox)
ENDIF(BUILD_STATIC)
IF(APPLE)
SET(UCODE_MODULE_LINK_OPTIONS "LINKER:-undefined,dynamic_lookup")
ENDIF()
SET(LIB_SOURCES uclient.c uclient-http.c uclient-utils.c)
ADD_LIBRARY(uclient SHARED ${LIB_SOURCES})
TARGET_LINK_LIBRARIES(uclient ${ubox_library} dl)
SET(CLI_SOURCES uclient-fetch.c progress.c)
ADD_EXECUTABLE(uclient-fetch ${CLI_SOURCES})
TARGET_LINK_LIBRARIES(uclient-fetch uclient)
IF(UNIT_TESTING)
ADD_DEFINITIONS(-DUNIT_TESTING)
ENABLE_TESTING()
ADD_SUBDIRECTORY(tests)
IF(CMAKE_C_COMPILER_ID STREQUAL "Clang")
ADD_LIBRARY(uclient-san SHARED ${LIB_SOURCES})
TARGET_COMPILE_OPTIONS(uclient-san PRIVATE -g -fno-omit-frame-pointer -fsanitize=undefined,address,leak -fno-sanitize-recover=all)
TARGET_LINK_OPTIONS(uclient-san PRIVATE -fsanitize=undefined,address,leak)
TARGET_LINK_LIBRARIES(uclient-san ${ubox_library} dl)
ADD_EXECUTABLE(uclient-fetch-san ${CLI_SOURCES})
TARGET_COMPILE_OPTIONS(uclient-fetch-san PRIVATE -g -fno-omit-frame-pointer -fsanitize=undefined,address,leak -fno-sanitize-recover=all)
TARGET_LINK_OPTIONS(uclient-fetch-san PRIVATE -fsanitize=undefined,address,leak)
TARGET_LINK_LIBRARIES(uclient-fetch-san uclient-san ${ubox_library} dl)
ENDIF()
ENDIF()
IF(BUILD_UCODE)
ADD_LIBRARY(uclient_lib MODULE ucode.c)
SET_TARGET_PROPERTIES(uclient_lib PROPERTIES OUTPUT_NAME uclient PREFIX "")
TARGET_LINK_OPTIONS(uclient_lib PRIVATE ${UCODE_MODULE_LINK_OPTIONS})
TARGET_LINK_LIBRARIES(uclient_lib uclient)
INSTALL(TARGETS uclient_lib
LIBRARY DESTINATION lib/ucode
)
ENDIF()
INSTALL(FILES uclient.h uclient-utils.h
DESTINATION include/libubox
)
INSTALL(TARGETS uclient uclient-fetch
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)