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