-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathCMakeLists.txt
115 lines (101 loc) · 2.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
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR)
project(libxutils LANGUAGES C)
IF (WIN32)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Od /W3")
ELSE()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O2 -Wall")
ENDIF()
set(XUTILS_INSTALL_PREFIX "/usr/local")
string(SUBSTRING "${XUTILS_INSTALL_PREFIX}" 0 2 PREFIX_START)
if("${PREFIX_START}" STREQUAL "./")
get_filename_component(CURRENT_WORKING_DIR "${CMAKE_SOURCE_DIR}" REALPATH)
string(SUBSTRING "${XUTILS_INSTALL_PREFIX}" 1 -1 RELATIVE_PATH)
set(CMAKE_INSTALL_PREFIX "${CURRENT_WORKING_DIR}${RELATIVE_PATH}")
endif()
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
find_package(OpenSSL)
if(OpenSSL_FOUND)
include_directories(${OPENSSL_INCLUDE_DIR})
link_directories(${OPENSSL_LIBRARIES})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XUTILS_USE_SSL")
endif()
SET(HEADER_DST "include/xutils")
SET(SOURCE_DIR "./src")
SET(CRYPT_DIR "./src/crypt")
SET(DATA_DIR "./src/data")
SET(NET_DIR "./src/net")
SET(SYS_DIR "./src/sys")
include_directories(
${SOURCE_DIR}
${CRYPT_DIR}
${DATA_DIR}
${NET_DIR}
${SYS_DIR}
)
add_library(xutils STATIC
./src/xver.c
./src/crypt/aes.c
./src/crypt/base64.c
./src/crypt/crc32.c
./src/crypt/crypt.c
./src/crypt/hmac.c
./src/crypt/md5.c
./src/crypt/rsa.c
./src/crypt/sha256.c
./src/crypt/sha1.c
./src/data/array.c
./src/data/hash.c
./src/data/jwt.c
./src/data/list.c
./src/data/map.c
./src/data/xbuf.c
./src/data/xjson.c
./src/data/xstr.c
./src/net/addr.c
./src/net/event.c
./src/net/http.c
./src/net/mdtp.c
./src/net/ntp.c
./src/net/rtp.c
./src/net/sock.c
./src/net/api.c
./src/net/ws.c
./src/sys/sync.c
./src/sys/pool.c
./src/sys/thread.c
./src/sys/xcli.c
./src/sys/xcpu.c
./src/sys/xfs.c
./src/sys/xlog.c
./src/sys/xsig.c
./src/sys/xtime.c
./src/sys/xtop.c
./src/sys/xtype.c
)
install(TARGETS xutils DESTINATION lib)
install(DIRECTORY "${SOURCE_DIR}/"
DESTINATION "${HEADER_DST}"
FILES_MATCHING
PATTERN "*.h"
)
install(DIRECTORY "${CRYPT_DIR}/"
DESTINATION "${HEADER_DST}"
FILES_MATCHING
PATTERN "*.h"
)
install(DIRECTORY "${DATA_DIR}/"
DESTINATION "${HEADER_DST}"
FILES_MATCHING
PATTERN "*.h"
)
install(DIRECTORY "${NET_DIR}/"
DESTINATION "${HEADER_DST}"
FILES_MATCHING
PATTERN "*.h"
)
install(DIRECTORY "${SYS_DIR}/"
DESTINATION "${HEADER_DST}"
FILES_MATCHING
PATTERN "*.h"
)