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