2016-02-11 12:46:59 +00:00
|
|
|
# nghttp2 - HTTP/2 C Library
|
|
|
|
#
|
|
|
|
# Copyright (c) 2012, 2013, 2014, 2015 Tatsuhiro Tsujikawa
|
|
|
|
# Copyright (c) 2016 Peter Wu <peter@lekensteyn.nl>
|
|
|
|
#
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
# a copy of this software and associated documentation files (the
|
|
|
|
# "Software"), to deal in the Software without restriction, including
|
|
|
|
# without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
# permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
# the following conditions:
|
|
|
|
#
|
|
|
|
# The above copyright notice and this permission notice shall be
|
|
|
|
# included in all copies or substantial portions of the Software.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
|
|
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
|
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
|
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
cmake_minimum_required(VERSION 3.0)
|
2016-03-13 15:19:23 +00:00
|
|
|
# XXX using 1.8.90 instead of 1.9.0-DEV
|
2023-10-27 10:48:48 +00:00
|
|
|
project(nghttp2 VERSION 1.58.0)
|
2016-02-11 12:46:59 +00:00
|
|
|
|
2016-02-11 21:11:14 +00:00
|
|
|
# See versioning rule:
|
2021-09-21 11:40:57 +00:00
|
|
|
# https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
|
2023-10-10 13:48:46 +00:00
|
|
|
set(LT_CURRENT 39)
|
2023-10-27 10:48:48 +00:00
|
|
|
set(LT_REVISION 1)
|
2023-10-10 13:48:46 +00:00
|
|
|
set(LT_AGE 25)
|
2016-02-11 21:11:14 +00:00
|
|
|
|
2017-12-06 17:48:52 +00:00
|
|
|
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
|
2016-02-11 12:46:59 +00:00
|
|
|
include(Version)
|
|
|
|
|
2016-02-11 22:06:35 +00:00
|
|
|
math(EXPR LT_SOVERSION "${LT_CURRENT} - ${LT_AGE}")
|
|
|
|
set(LT_VERSION "${LT_SOVERSION}.${LT_AGE}.${LT_REVISION}")
|
2016-02-11 12:46:59 +00:00
|
|
|
set(PACKAGE_VERSION "${PROJECT_VERSION}")
|
|
|
|
HexVersion(PACKAGE_VERSION_NUM ${PROJECT_VERSION_MAJOR} ${PROJECT_VERSION_MINOR} ${PROJECT_VERSION_PATCH})
|
|
|
|
|
2016-03-15 12:37:51 +00:00
|
|
|
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
|
|
|
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the build type" FORCE)
|
|
|
|
|
|
|
|
# Include "None" as option to disable any additional (optimization) flags,
|
|
|
|
# relying on just CMAKE_C_FLAGS and CMAKE_CXX_FLAGS (which are empty by
|
|
|
|
# default). These strings are presented in cmake-gui.
|
|
|
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
|
|
|
|
"None" "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
|
|
|
endif()
|
|
|
|
|
2016-02-11 21:11:14 +00:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2022-12-24 09:23:18 +00:00
|
|
|
# For documentation
|
|
|
|
find_package(Python3 COMPONENTS Interpreter)
|
2016-02-16 11:17:49 +00:00
|
|
|
|
2016-02-15 00:12:07 +00:00
|
|
|
# Auto-detection of features that can be toggled
|
2016-02-16 15:29:39 +00:00
|
|
|
find_package(OpenSSL 1.0.1)
|
2016-03-13 11:50:33 +00:00
|
|
|
find_package(Libev 4.11)
|
2016-12-10 13:16:35 +00:00
|
|
|
find_package(Libcares 1.7.5)
|
2016-02-16 15:29:39 +00:00
|
|
|
find_package(ZLIB 1.2.3)
|
2021-08-22 14:10:36 +00:00
|
|
|
find_package(Libngtcp2 0.0.0)
|
2023-07-09 12:09:43 +00:00
|
|
|
find_package(Libngtcp2_crypto_quictls 0.0.0)
|
|
|
|
if(LIBNGTCP2_CRYPTO_QUICTLS_FOUND)
|
|
|
|
set(HAVE_LIBNGTCP2_CRYPTO_QUICTLS 1)
|
2021-10-15 14:39:44 +00:00
|
|
|
endif()
|
2021-08-22 14:10:36 +00:00
|
|
|
find_package(Libnghttp3 0.0.0)
|
2021-11-16 13:03:30 +00:00
|
|
|
if(WITH_LIBBPF)
|
|
|
|
find_package(Libbpf 0.4.0)
|
|
|
|
if(NOT LIBBPF_FOUND)
|
|
|
|
message(FATAL_ERROR "libbpf was requested (WITH_LIBBPF=1) but not found.")
|
|
|
|
endif()
|
|
|
|
endif()
|
2016-02-15 00:12:07 +00:00
|
|
|
if(OPENSSL_FOUND AND LIBEV_FOUND AND ZLIB_FOUND)
|
|
|
|
set(ENABLE_APP_DEFAULT ON)
|
|
|
|
else()
|
|
|
|
set(ENABLE_APP_DEFAULT OFF)
|
|
|
|
endif()
|
2019-07-29 10:19:43 +00:00
|
|
|
find_package(Systemd 209)
|
2016-02-16 15:29:39 +00:00
|
|
|
find_package(Jansson 2.5)
|
2016-02-15 00:12:07 +00:00
|
|
|
set(ENABLE_HPACK_TOOLS_DEFAULT ${JANSSON_FOUND})
|
2016-02-16 13:01:44 +00:00
|
|
|
# 2.0.8 is required because we use evconnlistener_set_error_cb()
|
2022-12-07 14:33:10 +00:00
|
|
|
find_package(Libevent 2.0.8 COMPONENTS core extra openssl)
|
2016-02-15 00:12:07 +00:00
|
|
|
set(ENABLE_EXAMPLES_DEFAULT ${LIBEVENT_OPENSSL_FOUND})
|
|
|
|
|
2017-10-04 13:19:25 +00:00
|
|
|
find_package(LibXml2 2.6.26)
|
2016-02-15 00:12:07 +00:00
|
|
|
set(WITH_LIBXML2_DEFAULT ${LIBXML2_FOUND})
|
2016-02-16 15:29:39 +00:00
|
|
|
find_package(Jemalloc)
|
2016-02-15 00:12:07 +00:00
|
|
|
set(WITH_JEMALLOC_DEFAULT ${JEMALLOC_FOUND})
|
|
|
|
|
|
|
|
include(CMakeOptions.txt)
|
2016-02-11 12:46:59 +00:00
|
|
|
|
2022-12-24 09:23:18 +00:00
|
|
|
if(ENABLE_LIB_ONLY AND (ENABLE_APP OR ENABLE_HPACK_TOOLS OR ENABLE_EXAMPLES))
|
2016-02-16 13:01:44 +00:00
|
|
|
# Remember when disabled options are disabled for later diagnostics.
|
|
|
|
set(ENABLE_LIB_ONLY_DISABLED_OTHERS 1)
|
|
|
|
else()
|
|
|
|
set(ENABLE_LIB_ONLY_DISABLED_OTHERS 0)
|
|
|
|
endif()
|
2016-02-11 12:46:59 +00:00
|
|
|
if(ENABLE_LIB_ONLY)
|
|
|
|
set(ENABLE_APP OFF)
|
|
|
|
set(ENABLE_HPACK_TOOLS OFF)
|
|
|
|
set(ENABLE_EXAMPLES OFF)
|
|
|
|
endif()
|
|
|
|
|
2016-03-16 13:10:42 +00:00
|
|
|
# Do not disable assertions based on CMAKE_BUILD_TYPE.
|
|
|
|
foreach(_build_type "Release" "MinSizeRel" "RelWithDebInfo")
|
|
|
|
foreach(_lang C CXX)
|
|
|
|
string(TOUPPER "CMAKE_${_lang}_FLAGS_${_build_type}" _var)
|
2017-10-18 12:25:17 +00:00
|
|
|
string(REGEX REPLACE "(^| )[/-]D *NDEBUG($| )" " " ${_var} "${${_var}}")
|
2016-03-16 13:10:42 +00:00
|
|
|
endforeach()
|
|
|
|
endforeach()
|
|
|
|
|
2016-02-11 12:46:59 +00:00
|
|
|
if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
2016-03-16 13:25:58 +00:00
|
|
|
set(HINT_NORETURN "__attribute__((noreturn))")
|
2016-02-11 12:46:59 +00:00
|
|
|
else()
|
2016-03-16 13:25:58 +00:00
|
|
|
set(HINT_NORETURN)
|
2016-02-11 12:46:59 +00:00
|
|
|
endif()
|
|
|
|
|
2016-02-11 21:15:46 +00:00
|
|
|
include(ExtractValidFlags)
|
2018-11-02 08:45:03 +00:00
|
|
|
foreach(_cxx1x_flag -std=c++14)
|
2016-02-11 21:15:46 +00:00
|
|
|
extract_valid_cxx_flags(_cxx1x_flag_supported ${_cxx1x_flag})
|
|
|
|
if(_cxx1x_flag_supported)
|
2016-02-11 12:46:59 +00:00
|
|
|
set(CXX1XCXXFLAGS ${_cxx1x_flag})
|
|
|
|
break()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
include(CMakePushCheckState)
|
|
|
|
include(CheckCXXSourceCompiles)
|
|
|
|
cmake_push_check_state()
|
2016-03-13 15:41:21 +00:00
|
|
|
set(CMAKE_REQUIRED_DEFINITIONS "${CXX1XCXXFLAGS}")
|
2016-02-11 12:46:59 +00:00
|
|
|
# Check that std::future is available.
|
2016-02-11 16:54:30 +00:00
|
|
|
check_cxx_source_compiles("
|
2016-02-11 12:46:59 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <future>
|
|
|
|
int main() { std::vector<std::future<int>> v; }" HAVE_STD_FUTURE)
|
|
|
|
# Check that std::map::emplace is available for g++-4.7.
|
2016-02-11 16:54:30 +00:00
|
|
|
check_cxx_source_compiles("
|
2016-02-11 12:46:59 +00:00
|
|
|
#include <map>
|
|
|
|
int main() { std::map<int, int>().emplace(1, 2); }" HAVE_STD_MAP_EMPLACE)
|
|
|
|
cmake_pop_check_state()
|
|
|
|
|
|
|
|
|
|
|
|
# Checks for libraries.
|
2016-02-12 12:12:33 +00:00
|
|
|
# Additional libraries required for programs under src directory.
|
|
|
|
set(APP_LIBRARIES)
|
|
|
|
|
|
|
|
set(CMAKE_THREAD_PREFER_PTHREAD 1)
|
|
|
|
find_package(Threads)
|
|
|
|
if(CMAKE_USE_PTHREADS_INIT)
|
|
|
|
list(APPEND APP_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
endif()
|
|
|
|
# XXX android and C++, is this still needed in cmake?
|
2016-02-11 12:46:59 +00:00
|
|
|
# case "$host" in
|
|
|
|
# *android*)
|
|
|
|
# android_build=yes
|
2022-01-13 20:21:56 +00:00
|
|
|
# # android does not need -pthread, but needs following 3 libs for C++
|
2016-02-11 12:46:59 +00:00
|
|
|
# APPLDFLAGS="$APPLDFLAGS -lstdc++ -latomic -lsupc++"
|
|
|
|
|
2016-02-12 12:12:33 +00:00
|
|
|
# dl: openssl requires libdl when it is statically linked.
|
|
|
|
# XXX shouldn't ${CMAKE_DL_LIBS} be appended to OPENSSL_LIBRARIES instead of
|
|
|
|
# APP_LIBRARIES if it is really specific to OpenSSL?
|
2016-02-11 12:46:59 +00:00
|
|
|
|
2016-02-15 00:12:07 +00:00
|
|
|
find_package(CUnit 2.1)
|
2016-02-16 13:01:44 +00:00
|
|
|
enable_testing()
|
|
|
|
set(HAVE_CUNIT ${CUNIT_FOUND})
|
2016-03-11 23:57:30 +00:00
|
|
|
if(HAVE_CUNIT)
|
|
|
|
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
|
|
|
|
endif()
|
2016-02-11 12:46:59 +00:00
|
|
|
|
|
|
|
# openssl (for src)
|
2021-08-22 14:10:36 +00:00
|
|
|
include(CheckSymbolExists)
|
2016-02-16 13:01:44 +00:00
|
|
|
set(HAVE_OPENSSL ${OPENSSL_FOUND})
|
2016-02-11 17:19:45 +00:00
|
|
|
if(OPENSSL_FOUND)
|
2016-03-16 16:31:54 +00:00
|
|
|
set(OPENSSL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})
|
2021-08-22 14:10:36 +00:00
|
|
|
cmake_push_check_state()
|
|
|
|
set(CMAKE_REQUIRED_INCLUDES "${OPENSSL_INCLUDE_DIR}")
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES "${OPENSSL_LIBRARIES}")
|
2022-07-14 05:33:24 +00:00
|
|
|
if(WIN32)
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}" "ws2_32" "bcrypt")
|
|
|
|
endif()
|
2021-08-22 14:10:36 +00:00
|
|
|
check_symbol_exists(SSL_is_quic "openssl/ssl.h" HAVE_SSL_IS_QUIC)
|
|
|
|
if(NOT HAVE_SSL_IS_QUIC)
|
2022-08-29 12:05:58 +00:00
|
|
|
message(WARNING "OpenSSL in ${OPENSSL_LIBRARIES} does not have SSL_is_quic. HTTP/3 support cannot be enabled")
|
2021-08-22 14:10:36 +00:00
|
|
|
endif()
|
|
|
|
cmake_pop_check_state()
|
2016-03-16 16:31:54 +00:00
|
|
|
else()
|
|
|
|
set(OPENSSL_INCLUDE_DIRS "")
|
|
|
|
set(OPENSSL_LIBRARIES "")
|
2016-02-11 17:19:45 +00:00
|
|
|
endif()
|
2016-02-15 00:12:07 +00:00
|
|
|
# libev (for src)
|
2016-02-16 13:01:44 +00:00
|
|
|
set(HAVE_LIBEV ${LIBEV_FOUND})
|
|
|
|
set(HAVE_ZLIB ${ZLIB_FOUND})
|
2019-07-29 10:19:43 +00:00
|
|
|
set(HAVE_SYSTEMD ${SYSTEMD_FOUND})
|
2016-02-16 13:01:44 +00:00
|
|
|
set(HAVE_LIBEVENT_OPENSSL ${LIBEVENT_FOUND})
|
|
|
|
if(LIBEVENT_FOUND)
|
|
|
|
# Must both link the core and openssl libraries.
|
2016-02-15 00:12:07 +00:00
|
|
|
set(LIBEVENT_OPENSSL_LIBRARIES ${LIBEVENT_LIBRARIES})
|
2016-02-11 17:19:45 +00:00
|
|
|
endif()
|
2016-12-10 13:16:35 +00:00
|
|
|
# libc-ares (for src)
|
|
|
|
set(HAVE_LIBCARES ${LIBCARES_FOUND})
|
|
|
|
if(LIBCARES_FOUND)
|
|
|
|
set(LIBCARES_INCLUDE_DIRS ${LIBCARES_INCLUDE_DIR})
|
|
|
|
else()
|
|
|
|
set(LIBCARES_INCLUDE_DIRS "")
|
|
|
|
set(LIBCARES_LIBRARIES "")
|
|
|
|
endif()
|
2016-02-16 13:01:44 +00:00
|
|
|
# jansson (for src/nghttp, src/deflatehd and src/inflatehd)
|
|
|
|
set(HAVE_JANSSON ${JANSSON_FOUND})
|
2016-02-11 12:46:59 +00:00
|
|
|
# libxml2 (for src/nghttp)
|
2016-02-16 13:01:44 +00:00
|
|
|
set(HAVE_LIBXML2 ${LIBXML2_FOUND})
|
2016-03-16 16:31:54 +00:00
|
|
|
if(LIBXML2_FOUND)
|
|
|
|
set(LIBXML2_INCLUDE_DIRS ${LIBXML2_INCLUDE_DIR})
|
|
|
|
else()
|
|
|
|
set(LIBXML2_INCLUDE_DIRS "")
|
|
|
|
set(LIBXML2_LIBRARIES "")
|
|
|
|
endif()
|
2016-02-11 12:46:59 +00:00
|
|
|
# jemalloc
|
2016-02-16 13:01:44 +00:00
|
|
|
set(HAVE_JEMALLOC ${JEMALLOC_FOUND})
|
2016-02-11 12:46:59 +00:00
|
|
|
|
2021-08-31 06:26:39 +00:00
|
|
|
# libbpf (for bpf)
|
|
|
|
set(HAVE_LIBBPF ${LIBBPF_FOUND})
|
|
|
|
if(LIBBPF_FOUND)
|
|
|
|
set(BPFCFLAGS -Wall -O2 -g)
|
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
|
|
# For Debian/Ubuntu
|
|
|
|
set(EXTRABPFCFLAGS -I/usr/include/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
check_c_source_compiles("
|
|
|
|
#include <linux/bpf.h>
|
|
|
|
int main() { enum bpf_stats_type foo; (void)foo; }" HAVE_BPF_STATS_TYPE)
|
|
|
|
endif()
|
|
|
|
|
2016-02-11 14:49:39 +00:00
|
|
|
# The nghttp, nghttpd and nghttpx under src depend on zlib, OpenSSL and libev
|
|
|
|
if(ENABLE_APP AND NOT (ZLIB_FOUND AND OPENSSL_FOUND AND LIBEV_FOUND))
|
|
|
|
message(FATAL_ERROR "Applications were requested (ENABLE_APP=1) but dependencies are not met.")
|
|
|
|
endif()
|
|
|
|
|
2023-07-09 12:09:43 +00:00
|
|
|
# HTTP/3 requires quictls/openssl, libngtcp2, libngtcp2_crypto_quictls
|
2021-08-22 14:10:36 +00:00
|
|
|
# and libnghttp3.
|
2023-07-09 12:09:43 +00:00
|
|
|
if(ENABLE_HTTP3 AND NOT (HAVE_SSL_IS_QUIC AND LIBNGTCP2_FOUND AND LIBNGTCP2_CRYPTO_QUICTLS_FOUND AND LIBNGHTTP3_FOUND))
|
2021-08-22 14:10:36 +00:00
|
|
|
message(FATAL_ERROR "HTTP/3 was requested (ENABLE_HTTP3=1) but dependencies are not met.")
|
|
|
|
endif()
|
|
|
|
|
2016-02-11 14:49:39 +00:00
|
|
|
# HPACK tools requires jansson
|
|
|
|
if(ENABLE_HPACK_TOOLS AND NOT HAVE_JANSSON)
|
|
|
|
message(FATAL_ERROR "HPACK tools were requested (ENABLE_HPACK_TOOLS=1) but dependencies are not met.")
|
|
|
|
endif()
|
|
|
|
|
2022-12-24 07:49:02 +00:00
|
|
|
# examples
|
2016-02-11 14:49:39 +00:00
|
|
|
if(ENABLE_EXAMPLES AND NOT (OPENSSL_FOUND AND LIBEVENT_OPENSSL_FOUND))
|
2016-02-15 00:12:07 +00:00
|
|
|
message(FATAL_ERROR "examples were requested (ENABLE_EXAMPLES=1) but dependencies are not met.")
|
2016-02-11 14:49:39 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# third-party http-parser only be built when needed
|
2022-12-24 07:49:02 +00:00
|
|
|
if(ENABLE_EXAMPLES OR ENABLE_APP OR ENABLE_HPACK_TOOLS)
|
2016-02-11 14:49:39 +00:00
|
|
|
set(ENABLE_THIRD_PARTY 1)
|
|
|
|
# mruby (for src/nghttpx)
|
2016-02-16 13:01:44 +00:00
|
|
|
set(HAVE_MRUBY ${WITH_MRUBY})
|
|
|
|
set(HAVE_NEVERBLEED ${WITH_NEVERBLEED})
|
2016-02-11 17:19:45 +00:00
|
|
|
else()
|
|
|
|
set(HAVE_MRUBY 0)
|
|
|
|
set(HAVE_NEVERBLEED 0)
|
2016-02-11 14:49:39 +00:00
|
|
|
endif()
|
|
|
|
|
2016-02-11 15:08:07 +00:00
|
|
|
# Checks for header files.
|
2016-02-11 16:12:10 +00:00
|
|
|
include(CheckIncludeFile)
|
2016-02-11 15:08:07 +00:00
|
|
|
check_include_file("arpa/inet.h" HAVE_ARPA_INET_H)
|
|
|
|
check_include_file("fcntl.h" HAVE_FCNTL_H)
|
|
|
|
check_include_file("inttypes.h" HAVE_INTTYPES_H)
|
|
|
|
check_include_file("limits.h" HAVE_LIMITS_H)
|
|
|
|
check_include_file("netdb.h" HAVE_NETDB_H)
|
|
|
|
check_include_file("netinet/in.h" HAVE_NETINET_IN_H)
|
2023-08-02 08:47:51 +00:00
|
|
|
check_include_file("netinet/ip.h" HAVE_NETINET_IP_H)
|
2016-02-11 15:08:07 +00:00
|
|
|
check_include_file("pwd.h" HAVE_PWD_H)
|
|
|
|
check_include_file("sys/socket.h" HAVE_SYS_SOCKET_H)
|
|
|
|
check_include_file("sys/time.h" HAVE_SYS_TIME_H)
|
2023-09-30 15:05:01 +00:00
|
|
|
check_include_file("sysinfoapi.h" HAVE_SYSINFOAPI_H)
|
2016-02-11 15:08:07 +00:00
|
|
|
check_include_file("syslog.h" HAVE_SYSLOG_H)
|
|
|
|
check_include_file("time.h" HAVE_TIME_H)
|
|
|
|
check_include_file("unistd.h" HAVE_UNISTD_H)
|
|
|
|
|
2016-03-16 16:33:20 +00:00
|
|
|
include(CheckTypeSize)
|
2016-02-11 15:08:07 +00:00
|
|
|
# Checks for typedefs, structures, and compiler characteristics.
|
2016-02-11 12:46:59 +00:00
|
|
|
# AC_TYPE_SIZE_T
|
2016-03-16 16:33:20 +00:00
|
|
|
check_type_size("ssize_t" SIZEOF_SSIZE_T)
|
|
|
|
if(SIZEOF_SSIZE_T STREQUAL "")
|
|
|
|
# ssize_t is a signed type in POSIX storing at least -1.
|
|
|
|
# Set it to "int" to match the behavior of AC_TYPE_SSIZE_T (autotools).
|
|
|
|
set(ssize_t int)
|
|
|
|
endif()
|
2016-02-11 12:46:59 +00:00
|
|
|
# AC_TYPE_UINT8_T
|
|
|
|
# AC_TYPE_UINT16_T
|
|
|
|
# AC_TYPE_UINT32_T
|
|
|
|
# AC_TYPE_UINT64_T
|
|
|
|
# AC_TYPE_INT8_T
|
|
|
|
# AC_TYPE_INT16_T
|
|
|
|
# AC_TYPE_INT32_T
|
|
|
|
# AC_TYPE_INT64_T
|
|
|
|
# AC_TYPE_OFF_T
|
|
|
|
# AC_TYPE_PID_T
|
|
|
|
# AC_TYPE_UID_T
|
2016-02-11 16:12:10 +00:00
|
|
|
# XXX To support inline for crappy compilers, see https://cmake.org/Wiki/CMakeTestInline
|
2016-02-11 12:46:59 +00:00
|
|
|
# AC_C_INLINE
|
2016-02-11 16:12:10 +00:00
|
|
|
# XXX is AC_SYS_LARGEFILE still needed for modern systems?
|
|
|
|
# add_definitions(-D_FILE_OFFSET_BITS=64)
|
2016-02-11 15:08:07 +00:00
|
|
|
|
|
|
|
include(CheckStructHasMember)
|
2016-02-11 16:54:30 +00:00
|
|
|
check_struct_has_member("struct tm" tm_gmtoff time.h HAVE_STRUCT_TM_TM_GMTOFF)
|
2016-02-11 15:08:07 +00:00
|
|
|
|
|
|
|
# Check size of pointer to decide we need 8 bytes alignment adjustment.
|
|
|
|
check_type_size("int *" SIZEOF_INT_P)
|
|
|
|
check_type_size("time_t" SIZEOF_TIME_T)
|
|
|
|
|
2016-02-11 16:12:10 +00:00
|
|
|
# Checks for library functions.
|
|
|
|
include(CheckFunctionExists)
|
2016-02-11 16:54:30 +00:00
|
|
|
check_function_exists(_Exit HAVE__EXIT)
|
|
|
|
check_function_exists(accept4 HAVE_ACCEPT4)
|
2023-09-30 15:05:01 +00:00
|
|
|
check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
|
2017-12-02 04:35:00 +00:00
|
|
|
check_function_exists(mkostemp HAVE_MKOSTEMP)
|
2016-02-11 16:12:10 +00:00
|
|
|
|
2023-09-30 15:05:01 +00:00
|
|
|
check_symbol_exists(GetTickCount64 sysinfoapi.h HAVE_GETTICKCOUNT64)
|
|
|
|
|
2016-02-11 16:12:10 +00:00
|
|
|
include(CheckSymbolExists)
|
|
|
|
# XXX does this correctly detect initgroups (un)availability on cygwin?
|
2016-02-11 16:54:30 +00:00
|
|
|
check_symbol_exists(initgroups grp.h HAVE_DECL_INITGROUPS)
|
2016-03-13 15:19:23 +00:00
|
|
|
if(NOT HAVE_DECL_INITGROUPS AND HAVE_UNISTD_H)
|
|
|
|
# FreeBSD declares initgroups() in unistd.h
|
|
|
|
check_symbol_exists(initgroups unistd.h HAVE_DECL_INITGROUPS2)
|
|
|
|
if(HAVE_DECL_INITGROUPS2)
|
|
|
|
set(HAVE_DECL_INITGROUPS 1)
|
|
|
|
endif()
|
|
|
|
endif()
|
2016-02-11 16:12:10 +00:00
|
|
|
|
2016-02-16 13:57:05 +00:00
|
|
|
set(WARNCFLAGS)
|
|
|
|
set(WARNCXXFLAGS)
|
2016-03-16 16:33:20 +00:00
|
|
|
if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
|
|
|
|
if(ENABLE_WERROR)
|
|
|
|
set(WARNCFLAGS /WX)
|
|
|
|
set(WARNCXXFLAGS /WX)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
if(ENABLE_WERROR)
|
2023-10-09 10:51:11 +00:00
|
|
|
set(WARNCFLAGS "-Werror")
|
|
|
|
set(WARNCXXFLAGS "-Werror")
|
2016-03-16 16:33:20 +00:00
|
|
|
endif()
|
|
|
|
|
2023-10-09 10:51:11 +00:00
|
|
|
include(PickyWarningsC)
|
|
|
|
include(PickyWarningsCXX)
|
2019-09-14 23:01:21 +00:00
|
|
|
endif()
|
|
|
|
|
2016-02-11 16:54:30 +00:00
|
|
|
if(ENABLE_DEBUG)
|
|
|
|
set(DEBUGBUILD 1)
|
|
|
|
endif()
|
|
|
|
|
2016-02-11 17:06:21 +00:00
|
|
|
# Some platform does not have working std::future. We disable
|
|
|
|
# threading for those platforms.
|
|
|
|
if(NOT ENABLE_THREADS OR NOT HAVE_STD_FUTURE)
|
|
|
|
set(NOTHREADS 1)
|
|
|
|
endif()
|
|
|
|
|
2016-02-11 21:11:14 +00:00
|
|
|
add_definitions(-DHAVE_CONFIG_H)
|
2016-02-11 17:06:21 +00:00
|
|
|
configure_file(cmakeconfig.h.in config.h)
|
|
|
|
# autotools-compatible names
|
2016-02-13 16:47:04 +00:00
|
|
|
# Sphinx expects relative paths in the .rst files. Use the fact that the files
|
|
|
|
# below are all one directory level deep.
|
2016-10-12 15:23:20 +00:00
|
|
|
file(RELATIVE_PATH top_srcdir "${CMAKE_CURRENT_BINARY_DIR}/dir" "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
|
|
file(RELATIVE_PATH top_builddir "${CMAKE_CURRENT_BINARY_DIR}/dir" "${CMAKE_CURRENT_BINARY_DIR}")
|
|
|
|
set(abs_top_srcdir "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
|
|
set(abs_top_builddir "${CMAKE_CURRENT_BINARY_DIR}")
|
2016-02-11 17:42:40 +00:00
|
|
|
# libnghttp2.pc (pkg-config file)
|
|
|
|
set(prefix "${CMAKE_INSTALL_PREFIX}")
|
2016-02-11 21:11:14 +00:00
|
|
|
set(exec_prefix "${CMAKE_INSTALL_PREFIX}")
|
2016-02-11 21:23:57 +00:00
|
|
|
set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}")
|
|
|
|
set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
|
2016-02-11 17:06:21 +00:00
|
|
|
set(VERSION "${PACKAGE_VERSION}")
|
2016-02-13 17:09:01 +00:00
|
|
|
# For init scripts and systemd service file (in contrib/)
|
2016-02-11 21:11:14 +00:00
|
|
|
set(bindir "${CMAKE_INSTALL_FULL_BINDIR}")
|
|
|
|
set(sbindir "${CMAKE_INSTALL_FULL_SBINDIR}")
|
2016-02-11 17:06:21 +00:00
|
|
|
foreach(name
|
|
|
|
lib/libnghttp2.pc
|
|
|
|
lib/includes/nghttp2/nghttp2ver.h
|
|
|
|
integration-tests/config.go
|
|
|
|
integration-tests/setenv
|
|
|
|
doc/conf.py
|
|
|
|
doc/index.rst
|
|
|
|
doc/package_README.rst
|
|
|
|
doc/tutorial-client.rst
|
|
|
|
doc/tutorial-server.rst
|
|
|
|
doc/tutorial-hpack.rst
|
|
|
|
doc/nghttpx-howto.rst
|
|
|
|
doc/h2load-howto.rst
|
|
|
|
doc/building-android-binary.rst
|
|
|
|
doc/nghttp2.h.rst
|
|
|
|
doc/nghttp2ver.h.rst
|
|
|
|
doc/contribute.rst
|
|
|
|
)
|
|
|
|
configure_file("${name}.in" "${name}" @ONLY)
|
|
|
|
endforeach()
|
|
|
|
|
2021-08-21 10:00:43 +00:00
|
|
|
if(APPLE)
|
|
|
|
add_definitions(-D__APPLE_USE_RFC_3542)
|
|
|
|
endif()
|
|
|
|
|
2016-02-11 22:27:31 +00:00
|
|
|
include_directories(
|
2016-10-12 15:23:20 +00:00
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}" # for config.h
|
2016-02-11 22:27:31 +00:00
|
|
|
)
|
2016-02-12 12:12:33 +00:00
|
|
|
# For use in src/CMakeLists.txt
|
|
|
|
set(PKGDATADIR "${CMAKE_INSTALL_FULL_DATADIR}/${CMAKE_PROJECT_NAME}")
|
2021-08-24 12:13:05 +00:00
|
|
|
set(PKGLIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}/${CMAKE_PROJECT_NAME}")
|
2016-02-11 21:11:14 +00:00
|
|
|
|
2016-02-16 15:19:28 +00:00
|
|
|
install(FILES README.rst DESTINATION "${CMAKE_INSTALL_DOCDIR}")
|
|
|
|
|
2016-02-11 21:11:14 +00:00
|
|
|
add_subdirectory(lib)
|
|
|
|
#add_subdirectory(lib/includes)
|
|
|
|
add_subdirectory(third-party)
|
|
|
|
add_subdirectory(src)
|
|
|
|
add_subdirectory(examples)
|
|
|
|
add_subdirectory(tests)
|
|
|
|
#add_subdirectory(tests/testdata)
|
2016-02-13 19:04:33 +00:00
|
|
|
add_subdirectory(integration-tests)
|
2021-07-06 20:06:03 +00:00
|
|
|
if(ENABLE_DOC)
|
|
|
|
add_subdirectory(doc)
|
|
|
|
endif()
|
2016-02-11 21:11:14 +00:00
|
|
|
add_subdirectory(contrib)
|
|
|
|
add_subdirectory(script)
|
2021-08-31 06:26:39 +00:00
|
|
|
add_subdirectory(bpf)
|
2016-02-11 21:11:14 +00:00
|
|
|
|
2016-02-11 17:19:45 +00:00
|
|
|
|
2016-02-14 12:22:32 +00:00
|
|
|
string(TOUPPER "${CMAKE_BUILD_TYPE}" _build_type)
|
2016-02-11 17:19:45 +00:00
|
|
|
message(STATUS "summary of build options:
|
|
|
|
|
|
|
|
Package version: ${VERSION}
|
2016-02-11 21:11:14 +00:00
|
|
|
Library version: ${LT_CURRENT}:${LT_REVISION}:${LT_AGE}
|
2016-02-14 12:22:32 +00:00
|
|
|
Install prefix: ${CMAKE_INSTALL_PREFIX}
|
|
|
|
Target system: ${CMAKE_SYSTEM_NAME}
|
2016-02-11 17:19:45 +00:00
|
|
|
Compiler:
|
2016-02-16 15:29:39 +00:00
|
|
|
Build type: ${CMAKE_BUILD_TYPE}
|
2016-02-14 12:22:32 +00:00
|
|
|
C compiler: ${CMAKE_C_COMPILER}
|
2016-03-15 12:58:53 +00:00
|
|
|
CFLAGS: ${CMAKE_C_FLAGS_${_build_type}} ${CMAKE_C_FLAGS}
|
2016-02-11 17:19:45 +00:00
|
|
|
C++ compiler: ${CMAKE_CXX_COMPILER}
|
2016-03-15 12:58:53 +00:00
|
|
|
CXXFLAGS: ${CMAKE_CXX_FLAGS_${_build_type}} ${CMAKE_CXX_FLAGS}
|
2016-02-11 17:19:45 +00:00
|
|
|
WARNCFLAGS: ${WARNCFLAGS}
|
|
|
|
CXX1XCXXFLAGS: ${CXX1XCXXFLAGS}
|
2023-10-09 10:57:01 +00:00
|
|
|
WARNCXXFLAGS: ${WARNCXXFLAGS}
|
2016-02-11 17:19:45 +00:00
|
|
|
Python:
|
2022-12-24 09:23:18 +00:00
|
|
|
Python: ${Python3_EXECUTABLE}
|
|
|
|
Python3_VERSION: ${Python3_VERSION}
|
2016-02-11 17:19:45 +00:00
|
|
|
Test:
|
2016-02-14 12:22:32 +00:00
|
|
|
CUnit: ${HAVE_CUNIT} (LIBS='${CUNIT_LIBRARIES}')
|
2016-02-11 17:19:45 +00:00
|
|
|
Failmalloc: ${ENABLE_FAILMALLOC}
|
|
|
|
Libs:
|
2016-02-14 12:22:32 +00:00
|
|
|
OpenSSL: ${HAVE_OPENSSL} (LIBS='${OPENSSL_LIBRARIES}')
|
|
|
|
Libxml2: ${HAVE_LIBXML2} (LIBS='${LIBXML2_LIBRARIES}')
|
|
|
|
Libev: ${HAVE_LIBEV} (LIBS='${LIBEV_LIBRARIES}')
|
2016-12-10 13:16:35 +00:00
|
|
|
Libc-ares: ${HAVE_LIBCARES} (LIBS='${LIBCARES_LIBRARIES}')
|
2021-08-22 14:10:36 +00:00
|
|
|
Libngtcp2: ${HAVE_LIBNGTCP2} (LIBS='${LIBNGTCP2_LIBRARIES}')
|
2023-07-09 12:09:43 +00:00
|
|
|
Libngtcp2_crypto_quictls: ${HAVE_LIBNGTCP2_CRYPTO_QUICTLS} (LIBS='${LIBNGTCP2_CRYPTO_QUICTLS_LIBRARIES}')
|
2021-08-22 14:10:36 +00:00
|
|
|
Libnghttp3: ${HAVE_LIBNGHTTP3} (LIBS='${LIBNGHTTP3_LIBRARIES}')
|
2021-08-31 06:26:39 +00:00
|
|
|
Libbpf: ${HAVE_LIBBPF} (LIBS='${LIBBPF_LIBRARIES}')
|
2016-02-14 12:22:32 +00:00
|
|
|
Libevent(SSL): ${HAVE_LIBEVENT_OPENSSL} (LIBS='${LIBEVENT_OPENSSL_LIBRARIES}')
|
|
|
|
Jansson: ${HAVE_JANSSON} (LIBS='${JANSSON_LIBRARIES}')
|
|
|
|
Jemalloc: ${HAVE_JEMALLOC} (LIBS='${JEMALLOC_LIBRARIES}')
|
|
|
|
Zlib: ${HAVE_ZLIB} (LIBS='${ZLIB_LIBRARIES}')
|
2019-07-29 10:19:43 +00:00
|
|
|
Systemd: ${HAVE_SYSTEMD} (LIBS='${SYSTEMD_LIBRARIES}')
|
2016-02-11 17:19:45 +00:00
|
|
|
Third-party:
|
|
|
|
http-parser: ${ENABLE_THIRD_PARTY}
|
2016-02-16 15:29:39 +00:00
|
|
|
MRuby: ${HAVE_MRUBY}
|
2016-02-11 17:19:45 +00:00
|
|
|
Neverbleed: ${HAVE_NEVERBLEED}
|
|
|
|
Features:
|
|
|
|
Applications: ${ENABLE_APP}
|
|
|
|
HPACK tools: ${ENABLE_HPACK_TOOLS}
|
|
|
|
Examples: ${ENABLE_EXAMPLES}
|
|
|
|
Threading: ${ENABLE_THREADS}
|
2021-08-22 14:10:36 +00:00
|
|
|
HTTP/3(EXPERIMENTAL): ${ENABLE_HTTP3}
|
2016-02-11 17:19:45 +00:00
|
|
|
")
|
2016-02-16 13:01:44 +00:00
|
|
|
if(ENABLE_LIB_ONLY_DISABLED_OTHERS)
|
|
|
|
message("Only the library will be built. To build other components "
|
|
|
|
"(such as applications and examples), set ENABLE_LIB_ONLY=OFF.")
|
|
|
|
endif()
|