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