• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1file(GLOB c_sources *.c)
2set_source_files_properties(${c_sources} PROPERTIES
3  COMPILE_FLAGS "${WARNCFLAGS}")
4file(GLOB cxx_sources *.cc)
5set_source_files_properties(${cxx_sources} PROPERTIES
6  COMPILE_FLAGS "${WARNCXXFLAGS} ${CXX1XCXXFLAGS}")
7
8include_directories(
9  "${CMAKE_CURRENT_SOURCE_DIR}/includes"
10  "${CMAKE_CURRENT_SOURCE_DIR}/../third-party"
11  "${CMAKE_CURRENT_SOURCE_DIR}/../third-party/llhttp/include"
12
13  ${JEMALLOC_INCLUDE_DIRS}
14  ${LIBXML2_INCLUDE_DIRS}
15  ${LIBEV_INCLUDE_DIRS}
16  ${LIBNGHTTP3_INCLUDE_DIRS}
17  ${LIBNGTCP2_INCLUDE_DIRS}
18  ${LIBNGTCP2_CRYPTO_QUICTLS_INCLUDE_DIRS}
19  ${OPENSSL_INCLUDE_DIRS}
20  ${LIBCARES_INCLUDE_DIRS}
21  ${JANSSON_INCLUDE_DIRS}
22  ${ZLIB_INCLUDE_DIRS}
23  ${LIBBPF_INCLUDE_DIRS}
24  ${LIBBROTLIENC_INCLUDE_DIRS}
25  ${LIBBROTLIDEC_INCLUDE_DIRS}
26)
27
28# XXX per-target?
29link_libraries(
30  nghttp2
31  ${JEMALLOC_LIBRARIES}
32  ${LIBXML2_LIBRARIES}
33  ${LIBEV_LIBRARIES}
34  ${LIBNGHTTP3_LIBRARIES}
35  ${LIBNGTCP2_LIBRARIES}
36  ${LIBNGTCP2_CRYPTO_QUICTLS_LIBRARIES}
37  ${OPENSSL_LIBRARIES}
38  ${LIBCARES_LIBRARIES}
39  ${JANSSON_LIBRARIES}
40  ${ZLIB_LIBRARIES}
41  ${APP_LIBRARIES}
42  ${LIBBPF_LIBRARIES}
43  ${LIBBROTLIENC_LIBRARIES}
44  ${LIBBROTLIDEC_LIBRARIES}
45)
46
47if(ENABLE_APP)
48  set(HELPER_OBJECTS
49    util.cc
50    http2.cc timegm.c app_helper.cc nghttp2_gzip.c
51  )
52
53  # nghttp client
54  set(NGHTTP_SOURCES
55    ${HELPER_OBJECTS}
56    nghttp.cc
57    tls.cc
58  )
59  if(HAVE_LIBXML2)
60    list(APPEND NGHTTP_SOURCES HtmlParser.cc)
61  endif()
62
63  # nghttpd
64  set(NGHTTPD_SOURCES
65    ${HELPER_OBJECTS}
66    nghttpd.cc
67    tls.cc
68    HttpServer.cc
69  )
70
71  # h2load
72  set(H2LOAD_SOURCES
73    util.cc
74    http2.cc h2load.cc
75    timegm.c
76    tls.cc
77    h2load_http2_session.cc
78    h2load_http1_session.cc
79  )
80  if(ENABLE_HTTP3)
81    list(APPEND H2LOAD_SOURCES
82      h2load_http3_session.cc
83      h2load_quic.cc
84      quic.cc
85    )
86  endif()
87
88  # Common libnhttpx sources (used for nghttpx and unit tests)
89  set(NGHTTPX_SRCS
90    util.cc http2.cc timegm.c
91    app_helper.cc
92    tls.cc
93    shrpx_config.cc
94    shrpx_accept_handler.cc
95    shrpx_connection_handler.cc
96    shrpx_client_handler.cc
97    shrpx_http2_upstream.cc
98    shrpx_https_upstream.cc
99    shrpx_downstream.cc
100    shrpx_downstream_connection.cc
101    shrpx_http_downstream_connection.cc
102    shrpx_http2_downstream_connection.cc
103    shrpx_http2_session.cc
104    shrpx_downstream_queue.cc
105    shrpx_log.cc
106    shrpx_http.cc
107    shrpx_io_control.cc
108    shrpx_tls.cc
109    shrpx_worker.cc
110    shrpx_log_config.cc
111    shrpx_connect_blocker.cc
112    shrpx_live_check.cc
113    shrpx_downstream_connection_pool.cc
114    shrpx_rate_limit.cc
115    shrpx_connection.cc
116    shrpx_memcached_dispatcher.cc
117    shrpx_memcached_connection.cc
118    shrpx_worker_process.cc
119    shrpx_signal.cc
120    shrpx_router.cc
121    shrpx_api_downstream_connection.cc
122    shrpx_health_monitor_downstream_connection.cc
123    shrpx_null_downstream_connection.cc
124    shrpx_exec.cc
125    shrpx_dns_resolver.cc
126    shrpx_dual_dns_resolver.cc
127    shrpx_dns_tracker.cc
128    xsi_strerror.c
129  )
130  if(HAVE_MRUBY)
131    list(APPEND NGHTTPX_SRCS
132      shrpx_mruby.cc
133      shrpx_mruby_module.cc
134      shrpx_mruby_module_env.cc
135      shrpx_mruby_module_request.cc
136      shrpx_mruby_module_response.cc
137    )
138  endif()
139  if(ENABLE_HTTP3)
140    list(APPEND NGHTTPX_SRCS
141     shrpx_quic.cc
142     shrpx_quic_listener.cc
143     shrpx_quic_connection_handler.cc
144     shrpx_http3_upstream.cc
145     http3.cc
146     quic.cc
147    )
148  endif()
149  add_library(nghttpx_static STATIC ${NGHTTPX_SRCS})
150  set_target_properties(nghttpx_static PROPERTIES ARCHIVE_OUTPUT_NAME nghttpx)
151
152  set(NGHTTPX-bin_SOURCES
153    shrpx.cc
154  )
155
156  if(HAVE_SYSTEMD)
157    target_link_libraries(nghttpx_static ${SYSTEMD_LIBRARIES})
158    target_compile_definitions(nghttpx_static PUBLIC HAVE_LIBSYSTEMD)
159    target_include_directories(nghttpx_static PUBLIC ${SYSTEMD_INCLUDE_DIRS})
160  endif()
161
162  if(HAVE_MRUBY)
163    target_link_libraries(nghttpx_static mruby-lib)
164  endif()
165
166  if(HAVE_NEVERBLEED)
167    target_link_libraries(nghttpx_static neverbleed)
168  endif()
169
170  set(NGHTTPX_UNITTEST_SOURCES
171    shrpx-unittest.cc
172    shrpx_tls_test.cc
173    shrpx_downstream_test.cc
174    shrpx_config_test.cc
175    shrpx_worker_test.cc
176    shrpx_http_test.cc
177    shrpx_router_test.cc
178    http2_test.cc
179    util_test.cc
180    nghttp2_gzip_test.c
181    nghttp2_gzip.c
182    buffer_test.cc
183    memchunk_test.cc
184    template_test.cc
185    base64_test.cc
186    ${CMAKE_SOURCE_DIR}/tests/munit/munit.c
187  )
188  add_executable(nghttpx-unittest EXCLUDE_FROM_ALL
189    ${NGHTTPX_UNITTEST_SOURCES}
190    $<TARGET_OBJECTS:llhttp>
191    $<TARGET_OBJECTS:url-parser>
192    )
193  target_include_directories(nghttpx-unittest PRIVATE
194    ${CMAKE_SOURCE_DIR}/tests/munit
195  )
196  target_compile_definitions(nghttpx-unittest
197    PRIVATE "-DNGHTTP2_SRC_DIR=\"${CMAKE_SOURCE_DIR}/src\""
198  )
199  target_link_libraries(nghttpx-unittest nghttpx_static)
200  if(HAVE_MRUBY)
201    target_link_libraries(nghttpx-unittest mruby-lib)
202  endif()
203  if(HAVE_NEVERBLEED)
204    target_link_libraries(nghttpx-unittest neverbleed)
205  endif()
206
207  add_test(nghttpx-unittest nghttpx-unittest)
208  add_dependencies(check nghttpx-unittest)
209
210  add_executable(nghttp   ${NGHTTP_SOURCES}   $<TARGET_OBJECTS:llhttp>
211    $<TARGET_OBJECTS:url-parser>
212  )
213  add_executable(nghttpd  ${NGHTTPD_SOURCES}  $<TARGET_OBJECTS:llhttp>
214    $<TARGET_OBJECTS:url-parser>
215  )
216  add_executable(nghttpx  ${NGHTTPX-bin_SOURCES} $<TARGET_OBJECTS:llhttp>
217    $<TARGET_OBJECTS:url-parser>
218  )
219  target_compile_definitions(nghttpx PRIVATE
220    "-DPKGDATADIR=\"${PKGDATADIR}\""
221    "-DPKGLIBDIR=\"${PKGLIBDIR}\""
222  )
223  target_link_libraries(nghttpx nghttpx_static)
224  add_executable(h2load   ${H2LOAD_SOURCES}   $<TARGET_OBJECTS:llhttp>
225    $<TARGET_OBJECTS:url-parser>
226  )
227
228  install(TARGETS nghttp nghttpd nghttpx h2load)
229endif()
230
231if(ENABLE_HPACK_TOOLS)
232  set(inflatehd_SOURCES
233    inflatehd.cc
234    comp_helper.c
235  )
236  set(deflatehd_SOURCES
237    deflatehd.cc
238    comp_helper.c
239    util.cc
240    timegm.c
241  )
242  add_executable(inflatehd ${inflatehd_SOURCES})
243  add_executable(deflatehd ${deflatehd_SOURCES})
244  install(TARGETS inflatehd deflatehd)
245endif()
246