-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
73 lines (64 loc) · 2.1 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
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
CMAKE_POLICY(SET CMP0003 NEW)
PROJECT(h2o)
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
FIND_PACKAGE(OpenSSL REQUIRED)
FIND_PACKAGE(LibUV)
FIND_PACKAGE(LibYAML)
FIND_PACKAGE(Wslay)
SET(CMAKE_C_FLAGS "-O2 -g -Wall -Wno-unused-function ${CMAKE_C_FLAGS}")
INCLUDE_DIRECTORIES(
include
deps/klib
deps/picohttpparser
deps/yoml
${OPENSSL_INCLUDE_DIR})
IF (LIBUV_FOUND)
INCLUDE_DIRECTORIES(${LIBUV_INCLUDE_DIR})
ELSE (LIBUV_FOUND)
SET(LIBUV_LIBRARIES -luv)
ENDIF (LIBUV_FOUND)
IF (LIBYAML_FOUND)
INCLUDE_DIRECTORIES(${LIBYAML_INCLUDE_DIR})
ELSE (LIBYAML_FOUND)
SET(LIBYAML_LIBRARIES -lyaml)
ENDIF (LIBYAML_FOUND)
IF (WSLAY_FOUND)
INCLUDE_DIRECTORIES(${WSLAY_INCLUDE_DIR})
ELSE (WSLAY_FOUND)
SET(WSLAY_LIBRARIES -lwslay -lnettle)
ENDIF (WSLAY_FOUND)
SET(LIB_SOURCE_FILES
deps/picohttpparser/picohttpparser.c
lib/access_log.c
lib/chunked.c
lib/context.c
lib/global-configurators.c
lib/file.c
lib/headers.c
lib/http1.c
lib/http2/connection.c
lib/http2/frame.c
lib/http2/hpack.c
lib/http2/stream.c
lib/memory.c
lib/mimemap.c
lib/request.c
lib/rproxy.c
lib/socket.c
lib/timeout.c
lib/token.c
lib/util.c)
ADD_LIBRARY(libh2o STATIC ${LIB_SOURCE_FILES})
SET_TARGET_PROPERTIES(libh2o PROPERTIES OUTPUT_NAME h2o)
SET_TARGET_PROPERTIES(libh2o PROPERTIES EXCLUDE_FROM_ALL 1)
ADD_EXECUTABLE(examples-simple examples/simple.c)
SET_TARGET_PROPERTIES(examples-simple PROPERTIES EXCLUDE_FROM_ALL 1)
TARGET_LINK_LIBRARIES(examples-simple libh2o ${OPENSSL_LIBRARIES} ${LIBUV_LIBRARIES})
ADD_EXECUTABLE(examples-websocket lib/websocket.c examples/websocket.c)
SET_TARGET_PROPERTIES(examples-websocket PROPERTIES EXCLUDE_FROM_ALL 1)
TARGET_LINK_LIBRARIES(examples-websocket libh2o ${OPENSSL_LIBRARIES} ${LIBUV_LIBRARIES} ${WSLAY_LIBRARIES})
# directly links to libh2o using evloop
ADD_EXECUTABLE(h2o ${LIB_SOURCE_FILES} src/main.c)
SET_TARGET_PROPERTIES(h2o PROPERTIES COMPILE_FLAGS "-DH2O_USE_LIBUV=0")
TARGET_LINK_LIBRARIES(h2o ${OPENSSL_LIBRARIES} ${LIBYAML_LIBRARIES})