forked from Gregwar/mongoose-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
144 lines (113 loc) · 3.38 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
cmake_minimum_required (VERSION 2.6)
project (mongoose)
find_package (Threads)
option (MAIN
"Compile the main" OFF)
option (EXAMPLES
"Compile examples" OFF)
option (WEBSOCKET
"Enables websocket" OFF)
option (CPP_BINDING
"Enables C++ binding" ON)
option (HAS_JSONCPP
"Enables JsonCpp" OFF)
option (ENABLE_STATS
"Enable server statistics" ON)
option (ENABLE_REGEX_URL
"Enable url regex matching dispatcher" OFF)
set (JSONCPP_DIR "${PROJECT_SOURCE_DIR}/../jsoncpp"
CACHE STRING "Json C++ directory")
set (SOURCES
mongoose.c
)
set (MONGOOSE_CPP "${PROJECT_SOURCE_DIR}/mongoose")
include_directories ("${PROJECT_SOURCE_DIR}")
if (ENABLE_STATS)
add_definitions("-DENABLE_STATS")
endif (ENABLE_STATS)
if (ENABLE_REGEX_URL)
add_definitions("-DENABLE_REGEX_URL")
SET (CMAKE_CXX_FLAGS "-std=c++11")
endif (ENABLE_REGEX_URL)
if (CPP_BINDING)
set (SOURCES
${SOURCES}
${MONGOOSE_CPP}/Utils.cpp
${MONGOOSE_CPP}/Controller.cpp
${MONGOOSE_CPP}/Mutex.cpp
${MONGOOSE_CPP}/Request.cpp
${MONGOOSE_CPP}/Response.cpp
${MONGOOSE_CPP}/Server.cpp
${MONGOOSE_CPP}/Session.cpp
${MONGOOSE_CPP}/Sessions.cpp
${MONGOOSE_CPP}/StreamResponse.cpp
${MONGOOSE_CPP}/UploadFile.cpp
${MONGOOSE_CPP}/WebController.cpp
)
if (HAS_JSONCPP)
set (SOURCES
${SOURCES}
${MONGOOSE_CPP}/JsonResponse.cpp
${MONGOOSE_CPP}/JsonController.cpp
)
include_directories ("${JSONCPP_DIR}/include/")
endif (HAS_JSONCPP)
if (WEBSOCKET)
set (SOURCES
${SOURCES}
${MONGOOSE_CPP}/WebSocket.cpp
${MONGOOSE_CPP}/WebSockets.cpp
)
endif (WEBSOCKET)
include_directories ("${MONGOOSE_CPP}")
endif (CPP_BINDING)
if (NOT WEBSOCKET)
add_definitions("-DNO_WEBSOCKET")
endif (NOT WEBSOCKET)
# Adding dl
if (NOT WIN32)
set (EXTRA_LIBS ${EXTRA_LIBS} dl)
endif (NOT WIN32)
# Adding sockets for Win32
if (WIN32)
set (EXTRA_LIBS ${EXTRA_LIBS} ws2_32)
endif (WIN32)
# Compiling library
add_library (_mongoose ${SOURCES})
target_link_libraries (_mongoose ${EXTRA_LIBS} ${CMAKE_THREAD_LIBS_INIT})
if (HAS_JSONCPP)
target_link_libraries (_mongoose json)
endif (HAS_JSONCPP)
if (EXAMPLES OR MAIN)
if (HAS_JSONCPP)
add_subdirectory("${JSONCPP_DIR}" jsoncpp)
endif (HAS_JSONCPP)
endif ()
# Compiling executable
if (MAIN)
add_executable (main main.c)
target_link_libraries (main _mongoose)
endif (MAIN)
# Compiling tests
if (EXAMPLES)
add_executable (post examples/post.c)
target_link_libraries (post _mongoose)
if (NOT WIN32)
add_executable (hello examples/hello.c)
target_link_libraries (hello _mongoose)
endif (NOT WIN32)
if (CPP_BINDING)
add_executable (helloworld examples/helloworld.cpp)
target_link_libraries (helloworld _mongoose)
add_executable (cpp examples/main.cpp)
target_link_libraries (cpp _mongoose)
if (HAS_JSONCPP)
add_executable (json_api examples/json.cpp)
target_link_libraries (json_api _mongoose)
endif (HAS_JSONCPP)
if (WEBSOCKET)
add_executable (cpp_websocket examples/websocket.cpp)
target_link_libraries (cpp_websocket _mongoose)
endif (WEBSOCKET)
endif (CPP_BINDING)
endif (EXAMPLES)