forked from keengo99/kangle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
205 lines (182 loc) · 7.32 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
cmake_minimum_required(VERSION 2.8.12)
project(kangle)
set(KANGLE_VERSION "3.6.0")
set(CPACK_PACKAGE_VERSION ${KANGLE_VERSION})
set(KANGLE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_CXX_STANDARD 17)
file(GLOB KANGLE_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/include/*.h
${CMAKE_CURRENT_SOURCE_DIR}/module/access/*.h
${CMAKE_CURRENT_SOURCE_DIR}/module/whm/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/module/whm/whmdso/core/*.cpp
)
list(APPEND KANGLE_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/khttpd/davlib/KXml.cpp
${CMAKE_CURRENT_SOURCE_DIR}/khttpd/davlib/KXmlDocument.cpp
${CMAKE_CURRENT_SOURCE_DIR}/khttpd/davlib/KXmlContext.cpp
${CMAKE_CURRENT_SOURCE_DIR}/khttpd/davlib/KXmlException.cpp
)
file(GLOB EXTWORKER_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/extworker/*.cpp
)
file(GLOB VHS_SQLITE_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/module/vhs_sqlite/*.cpp
)
file(GLOB TESTDSO_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/module/testdso/*.cpp)
file(GLOB FILTER_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/module/filter/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/module/filter/*.h)
list(APPEND EXTWORKER_SOURCE_FILES
src/EdcodeUtils.cpp
src/KHttpExt.cpp
src/KApiDso.cpp
src/KApiEnv.cpp
src/KEnvInterface.cpp
src/KFastcgiUtils.cpp
src/KPipeStream.cpp
src/KProcess.cpp
khttpd/src/KStream.cpp
khttpd/src/KStringBuf.cpp
src/KCgiEnv.cpp
src/process.cpp
src/KDynamicString.cpp
khttpd/src/KAutoBuffer.cpp
src/win_iconv.cpp
)
list(APPEND KANGLE_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
list(APPEND KANGLE_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/module/whm)
list(APPEND KANGLE_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/module/access)
list(APPEND KANGLE_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/khttpd/davlib)
include(CheckSymbolExists)
include(CheckIncludeFile)
include(./cmake/FindPCRE.cmake)
list(APPEND KANGLE_INCLUDE_DIR ${PCRE_INCLUDE_DIRS})
check_symbol_exists(timegm time.h HAVE_TIMEGM)
if (HAVE_TIMEGM)
add_definitions(-DHAVE_TIMEGM)
endif()
#message(STATUS ${PCRE_INCLUDE_DIRS})
check_symbol_exists(KSOCKET_SSL ${KASYNC_INCLUDE_DIR}/kasync_config.h HAVE_KSOCKET_SSL)
set(KANGLE_LIBS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/kasync/build")
option(ENABLE_BROTLI "enable brotli compress support" OFF)
option(HTTP_PROXY "build kangle as proxy server" OFF)
option(ENABLE_DISK_CACHE "enable disk cache" ON)
if (ENABLE_BROTLI)
check_include_file("brotli/encode.h" ENABLE_BROTLI)
if (NOT ENABLE_BROTLI)
message(FATAL_ERROR "cann't found brotli libary")
else()
list(APPEND KANGLE_LIBS "brotlienc-static" "brotlicommon-static")
# list(APPEND KANGLE_LIBS "brotlicommon" "brotlienc")
endif()
endif()
if (NOT (CMAKE_SYSTEM_NAME MATCHES "Windows"))
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g2")
endif()
set(KASYNC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/kasync)
#windows
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/build)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/build)
list(APPEND KANGLE_LIBS ws2_32)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/thirdinclude)
LINK_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/win32lib/${CMAKE_VS_PLATFORM_NAME}")
list(APPEND KANGLE_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/thirdinclude")
list(APPEND KANGLE_LIBS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/win32lib/${CMAKE_VS_PLATFORM_NAME}")
list(APPEND KANGLE_LIBS zdll pcre)
list(APPEND EXTWORKER_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/KWinCgiEnv.cpp")
list(APPEND VHS_SQLITE_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/module/vhs_sqlite/vhs_sqlite.def")
set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/thirdinclude")
else()
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/build)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/build)
include(FindZLIB)
if (NOT ZLIB_FOUND)
message(FATAL_ERROR "cann't found zlib")
endif()
list(APPEND KANGLE_LIBS ZLIB::ZLIB)
list(APPEND KANGLE_LIBS ${PCRE_LIBRARIES})
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
list(APPEND KANGLE_LIBS dl)
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
list(APPEND KANGLE_LIBS iconv)
endif()
endif()
add_subdirectory(khttpd)
#list(APPEND KANGLE_SOURCE_FILES ${KHTTPD_SOURCE_FILES})
list(APPEND KANGLE_INCLUDE_DIR ${KHTTPD_INCLUDE_DIR})
list(APPEND KANGLE_LIBS ${KHTTPD_LIBS})
include(FindSQLite3)
if (SQLite3_FOUND)
list(APPEND KANGLE_LIBS SQLite::SQLite3)
set(SQLITE3_LIB SQLite::SQLite3)
else()
add_library(sqlite3 ${CMAKE_CURRENT_SOURCE_DIR}/third_party/sqlite/sqlite3.c)
if (NOT(CMAKE_SYSTEM_NAME MATCHES "Windows"))
target_compile_options(sqlite3 PUBLIC -fPIC)
endif()
target_include_directories(sqlite3 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/third_party/sqlite)
list(APPEND KANGLE_LIBS sqlite3)
set(SQLITE3_LIB sqlite3)
endif()
if (ENABLE_JEMALLOC)
list(APPEND KANGLE_LIBS jemalloc)
endif()
message(STATUS "kangle version ${KANGLE_VERSION}")
configure_file(${KANGLE_DIR}/include/global.h.in ${KANGLE_DIR}/include/global.h @ONLY)
add_executable(kangle ${KANGLE_SOURCE_FILES} ${KHTTPD_INCLUDE_FILES})
list(APPEND KANGLE_LIBS khttpd)
target_include_directories(kangle PUBLIC ${KANGLE_INCLUDE_DIR})
target_link_directories(kangle PUBLIC ${KANGLE_LIBS_DIR})
if (NOT (CMAKE_SYSTEM_NAME MATCHES "Windows"))
target_compile_options(kangle PUBLIC -Wno-invalid-offsetof)
endif()
#message(STATUS "kangle link libs ${KANGLE_LIBS} http_libs ${KHTTPD_LIBS} ${KASYNC_LIBS}")
target_link_libraries(kangle ${KANGLE_LIBS})
if (NOT HTTP_PROXY)
add_executable(extworker ${EXTWORKER_SOURCE_FILES})
add_library(vhs_sqlite MODULE ${VHS_SQLITE_SOURCE_FILES})
add_library(testdso MODULE ${TESTDSO_SOURCE_FILES})
add_library(filter MODULE ${FILTER_SOURCE_FILES})
target_include_directories(extworker PUBLIC ${KANGLE_INCLUDE_DIR})
target_link_directories(extworker PUBLIC ${KANGLE_LIBS_DIR})
target_link_libraries(extworker ${KANGLE_LIBS})
set_property(TARGET vhs_sqlite PROPERTY PREFIX "")
target_include_directories(vhs_sqlite PUBLIC ${KANGLE_INCLUDE_DIR})
target_link_directories(vhs_sqlite PUBLIC ${KANGLE_LIBS_DIR})
target_link_libraries(vhs_sqlite ${SQLITE3_LIB})
set_property(TARGET testdso PROPERTY PREFIX "")
target_include_directories(testdso PUBLIC ${KANGLE_INCLUDE_DIR})
target_link_directories(testdso PUBLIC ${KANGLE_LIBS_DIR})
set_property(TARGET filter PROPERTY PREFIX "")
target_include_directories(filter PUBLIC ${KANGLE_INCLUDE_DIR})
target_link_directories(filter PUBLIC ${KANGLE_LIBS_DIR})
install(TARGETS extworker vhs_sqlite
RUNTIME DESTINATION bin
LIBRARY DESTINATION bin
)
endif()
add_subdirectory(module/webdav)
add_subdirectory(test/test_child)
add_dependencies(kangle khttpd)
install(TARGETS kangle
RUNTIME DESTINATION bin
LIBRARY DESTINATION bin
)
install(FILES
${KANGLE_DIR}/include/ksapi.h
${KANGLE_DIR}/kasync/include/kfeature.h
${KANGLE_DIR}/kasync/include/kforwin32.h
${KANGLE_DIR}/kasync/include/kasync_config.h
${KANGLE_DIR}/khttpd/include/khttp.h
TYPE INCLUDE)
install(DIRECTORY
${KANGLE_DIR}/webadmin/
DESTINATION "webadmin"
)
install(FILES
${KANGLE_DIR}/etc/config-default.xml
DESTINATION etc)
include(CPack)
set(CPACK_PACKAGE_NAME "kangle")