Blame CMakeLists.txt

Packit Bot 4c90e1
# nghttp2 - HTTP/2 C Library
Packit Bot 4c90e1
#
Packit Bot 4c90e1
# Copyright (c) 2012, 2013, 2014, 2015 Tatsuhiro Tsujikawa
Packit Bot 4c90e1
# Copyright (c) 2016 Peter Wu <peter@lekensteyn.nl>
Packit Bot 4c90e1
#
Packit Bot 4c90e1
# Permission is hereby granted, free of charge, to any person obtaining
Packit Bot 4c90e1
# a copy of this software and associated documentation files (the
Packit Bot 4c90e1
# "Software"), to deal in the Software without restriction, including
Packit Bot 4c90e1
# without limitation the rights to use, copy, modify, merge, publish,
Packit Bot 4c90e1
# distribute, sublicense, and/or sell copies of the Software, and to
Packit Bot 4c90e1
# permit persons to whom the Software is furnished to do so, subject to
Packit Bot 4c90e1
# the following conditions:
Packit Bot 4c90e1
#
Packit Bot 4c90e1
# The above copyright notice and this permission notice shall be
Packit Bot 4c90e1
# included in all copies or substantial portions of the Software.
Packit Bot 4c90e1
#
Packit Bot 4c90e1
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Packit Bot 4c90e1
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Packit Bot 4c90e1
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Packit Bot 4c90e1
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
Packit Bot 4c90e1
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
Packit Bot 4c90e1
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
Packit Bot 4c90e1
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Packit Bot 4c90e1
Packit Bot 4c90e1
cmake_minimum_required(VERSION 3.0)
Packit Bot 4c90e1
# XXX using 1.8.90 instead of 1.9.0-DEV
Packit Bot 4c90e1
project(nghttp2 VERSION 1.33.0)
Packit Bot 4c90e1
Packit Bot 4c90e1
# See versioning rule:
Packit Bot 4c90e1
#  http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
Packit Bot 4c90e1
set(LT_CURRENT  31)
Packit Bot 4c90e1
set(LT_REVISION 0)
Packit Bot 4c90e1
set(LT_AGE      17)
Packit Bot 4c90e1
Packit Bot 4c90e1
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
Packit Bot 4c90e1
include(Version)
Packit Bot 4c90e1
Packit Bot 4c90e1
math(EXPR LT_SOVERSION "${LT_CURRENT} - ${LT_AGE}")
Packit Bot 4c90e1
set(LT_VERSION "${LT_SOVERSION}.${LT_AGE}.${LT_REVISION}")
Packit Bot 4c90e1
set(PACKAGE_VERSION     "${PROJECT_VERSION}")
Packit Bot 4c90e1
HexVersion(PACKAGE_VERSION_NUM ${PROJECT_VERSION_MAJOR} ${PROJECT_VERSION_MINOR} ${PROJECT_VERSION_PATCH})
Packit Bot 4c90e1
Packit Bot 4c90e1
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
Packit Bot 4c90e1
  set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the build type" FORCE)
Packit Bot 4c90e1
Packit Bot 4c90e1
  # Include "None" as option to disable any additional (optimization) flags,
Packit Bot 4c90e1
  # relying on just CMAKE_C_FLAGS and CMAKE_CXX_FLAGS (which are empty by
Packit Bot 4c90e1
  # default). These strings are presented in cmake-gui.
Packit Bot 4c90e1
  set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
Packit Bot 4c90e1
    "None" "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
Packit Bot 4c90e1
endif()
Packit Bot 4c90e1
Packit Bot 4c90e1
include(GNUInstallDirs)
Packit Bot 4c90e1
Packit Bot 4c90e1
# For Python bindings and documentation
Packit Bot 4c90e1
# (Must be called before PythonLibs for matching versions.)
Packit Bot 4c90e1
find_package(PythonInterp)
Packit Bot 4c90e1
Packit Bot 4c90e1
# Auto-detection of features that can be toggled
Packit Bot 4c90e1
find_package(OpenSSL 1.0.1)
Packit Bot 4c90e1
find_package(Libev 4.11)
Packit Bot 4c90e1
find_package(Libcares 1.7.5)
Packit Bot 4c90e1
find_package(ZLIB 1.2.3)
Packit Bot 4c90e1
if(OPENSSL_FOUND AND LIBEV_FOUND AND ZLIB_FOUND)
Packit Bot 4c90e1
  set(ENABLE_APP_DEFAULT ON)
Packit Bot 4c90e1
else()
Packit Bot 4c90e1
  set(ENABLE_APP_DEFAULT OFF)
Packit Bot 4c90e1
endif()
Packit Bot 4c90e1
find_package(Jansson  2.5)
Packit Bot 4c90e1
set(ENABLE_HPACK_TOOLS_DEFAULT ${JANSSON_FOUND})
Packit Bot 4c90e1
# 2.0.8 is required because we use evconnlistener_set_error_cb()
Packit Bot 4c90e1
find_package(Libevent 2.0.8 COMPONENTS libevent openssl)
Packit Bot 4c90e1
set(ENABLE_EXAMPLES_DEFAULT ${LIBEVENT_OPENSSL_FOUND})
Packit Bot 4c90e1
find_package(Cython)
Packit Bot 4c90e1
find_package(PythonLibs)
Packit Bot 4c90e1
if(CYTHON_FOUND AND PYTHONLIBS_FOUND)
Packit Bot 4c90e1
  set(ENABLE_PYTHON_BINDINGS_DEFAULT ON)
Packit Bot 4c90e1
else()
Packit Bot 4c90e1
  set(ENABLE_PYTHON_BINDINGS_DEFAULT OFF)
Packit Bot 4c90e1
endif()
Packit Bot 4c90e1
Packit Bot 4c90e1
find_package(LibXml2 2.6.26)
Packit Bot 4c90e1
set(WITH_LIBXML2_DEFAULT    ${LIBXML2_FOUND})
Packit Bot 4c90e1
find_package(Jemalloc)
Packit Bot 4c90e1
set(WITH_JEMALLOC_DEFAULT   ${JEMALLOC_FOUND})
Packit Bot 4c90e1
find_package(Spdylay 1.3.2)
Packit Bot 4c90e1
set(WITH_SPDYLAY_DEFAULT    ${SPDYLAY_FOUND})
Packit Bot 4c90e1
Packit Bot 4c90e1
include(CMakeOptions.txt)
Packit Bot 4c90e1
Packit Bot 4c90e1
if(ENABLE_LIB_ONLY AND (ENABLE_APP OR ENABLE_HPACK_TOOLS OR ENABLE_EXAMPLES OR
Packit Bot 4c90e1
  ENABLE_PYTHON_BINDINGS))
Packit Bot 4c90e1
  # Remember when disabled options are disabled for later diagnostics.
Packit Bot 4c90e1
  set(ENABLE_LIB_ONLY_DISABLED_OTHERS 1)
Packit Bot 4c90e1
else()
Packit Bot 4c90e1
  set(ENABLE_LIB_ONLY_DISABLED_OTHERS 0)
Packit Bot 4c90e1
endif()
Packit Bot 4c90e1
if(ENABLE_LIB_ONLY)
Packit Bot 4c90e1
  set(ENABLE_APP            OFF)
Packit Bot 4c90e1
  set(ENABLE_HPACK_TOOLS    OFF)
Packit Bot 4c90e1
  set(ENABLE_EXAMPLES       OFF)
Packit Bot 4c90e1
  set(ENABLE_PYTHON_BINDINGS OFF)
Packit Bot 4c90e1
endif()
Packit Bot 4c90e1
Packit Bot 4c90e1
# Do not disable assertions based on CMAKE_BUILD_TYPE.
Packit Bot 4c90e1
foreach(_build_type "Release" "MinSizeRel" "RelWithDebInfo")
Packit Bot 4c90e1
  foreach(_lang C CXX)
Packit Bot 4c90e1
    string(TOUPPER "CMAKE_${_lang}_FLAGS_${_build_type}" _var)
Packit Bot 4c90e1
    string(REGEX REPLACE "(^| )[/-]D *NDEBUG($| )" " " ${_var} "${${_var}}")
Packit Bot 4c90e1
  endforeach()
Packit Bot 4c90e1
endforeach()
Packit Bot 4c90e1
Packit Bot 4c90e1
if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
Packit Bot 4c90e1
  set(HINT_NORETURN       "__attribute__((noreturn))")
Packit Bot 4c90e1
else()
Packit Bot 4c90e1
  set(HINT_NORETURN)
Packit Bot 4c90e1
endif()
Packit Bot 4c90e1
Packit Bot 4c90e1
include(ExtractValidFlags)
Packit Bot 4c90e1
foreach(_cxx1x_flag -std=c++11 -std=c++0x)
Packit Bot 4c90e1
  extract_valid_cxx_flags(_cxx1x_flag_supported ${_cxx1x_flag})
Packit Bot 4c90e1
  if(_cxx1x_flag_supported)
Packit Bot 4c90e1
    set(CXX1XCXXFLAGS ${_cxx1x_flag})
Packit Bot 4c90e1
    break()
Packit Bot 4c90e1
  endif()
Packit Bot 4c90e1
endforeach()
Packit Bot 4c90e1
Packit Bot 4c90e1
include(CMakePushCheckState)
Packit Bot 4c90e1
include(CheckCXXSourceCompiles)
Packit Bot 4c90e1
cmake_push_check_state()
Packit Bot 4c90e1
set(CMAKE_REQUIRED_DEFINITIONS "${CXX1XCXXFLAGS}")
Packit Bot 4c90e1
# Check that std::future is available.
Packit Bot 4c90e1
check_cxx_source_compiles("
Packit Bot 4c90e1
#include <vector>
Packit Bot 4c90e1
#include <future>
Packit Bot 4c90e1
int main() { std::vector<std::future<int>> v; }" HAVE_STD_FUTURE)
Packit Bot 4c90e1
# Check that std::map::emplace is available for g++-4.7.
Packit Bot 4c90e1
check_cxx_source_compiles("
Packit Bot 4c90e1
#include <map>
Packit Bot 4c90e1
int main() { std::map<int, int>().emplace(1, 2); }" HAVE_STD_MAP_EMPLACE)
Packit Bot 4c90e1
cmake_pop_check_state()
Packit Bot 4c90e1
Packit Bot 4c90e1
Packit Bot 4c90e1
# Checks for libraries.
Packit Bot 4c90e1
# Additional libraries required for programs under src directory.
Packit Bot 4c90e1
set(APP_LIBRARIES)
Packit Bot 4c90e1
Packit Bot 4c90e1
if(ENABLE_PYTHON_BINDINGS)
Packit Bot 4c90e1
  if(NOT (CYTHON_FOUND AND PYTHONLIBS_FOUND))
Packit Bot 4c90e1
    message(FATAL_ERROR "python bindings were requested "
Packit Bot 4c90e1
      "(ENABLE_PYTHON_BINDINGS=1) but dependencies are not met.")
Packit Bot 4c90e1
  endif()
Packit Bot 4c90e1
  if(NOT PYTHON_VERSION_STRING STREQUAL PYTHONLIBS_VERSION_STRING)
Packit Bot 4c90e1
    message(FATAL_ERROR
Packit Bot 4c90e1
      "Python executable and library must have the same version!"
Packit Bot 4c90e1
      " Found Python ${PYTHON_VERSION_STRING} and"
Packit Bot 4c90e1
      " PythonLibs ${PYTHONLIBS_VERSION_STRING}"
Packit Bot 4c90e1
    )
Packit Bot 4c90e1
  endif()
Packit Bot 4c90e1
endif()
Packit Bot 4c90e1
Packit Bot 4c90e1
set(CMAKE_THREAD_PREFER_PTHREAD 1)
Packit Bot 4c90e1
find_package(Threads)
Packit Bot 4c90e1
if(CMAKE_USE_PTHREADS_INIT)
Packit Bot 4c90e1
  list(APPEND APP_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
Packit Bot 4c90e1
endif()
Packit Bot 4c90e1
# XXX android and C++, is this still needed in cmake?
Packit Bot 4c90e1
# case "$host" in
Packit Bot 4c90e1
#   *android*)
Packit Bot 4c90e1
#     android_build=yes
Packit Bot 4c90e1
#     # android does not need -pthread, but needs followng 3 libs for C++
Packit Bot 4c90e1
#     APPLDFLAGS="$APPLDFLAGS -lstdc++ -latomic -lsupc++"
Packit Bot 4c90e1
Packit Bot 4c90e1
# dl: openssl requires libdl when it is statically linked.
Packit Bot 4c90e1
# XXX shouldn't ${CMAKE_DL_LIBS} be appended to OPENSSL_LIBRARIES instead of
Packit Bot 4c90e1
# APP_LIBRARIES if it is really specific to OpenSSL?
Packit Bot 4c90e1
Packit Bot 4c90e1
find_package(CUnit 2.1)
Packit Bot 4c90e1
enable_testing()
Packit Bot 4c90e1
set(HAVE_CUNIT      ${CUNIT_FOUND})
Packit Bot 4c90e1
if(HAVE_CUNIT)
Packit Bot 4c90e1
  add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
Packit Bot 4c90e1
endif()
Packit Bot 4c90e1
Packit Bot 4c90e1
# openssl (for src)
Packit Bot 4c90e1
set(HAVE_OPENSSL    ${OPENSSL_FOUND})
Packit Bot 4c90e1
if(OPENSSL_FOUND)
Packit Bot 4c90e1
  set(OPENSSL_INCLUDE_DIRS  ${OPENSSL_INCLUDE_DIR})
Packit Bot 4c90e1
else()
Packit Bot 4c90e1
  set(OPENSSL_INCLUDE_DIRS  "")
Packit Bot 4c90e1
  set(OPENSSL_LIBRARIES     "")
Packit Bot 4c90e1
endif()
Packit Bot 4c90e1
# libev (for src)
Packit Bot 4c90e1
set(HAVE_LIBEV      ${LIBEV_FOUND})
Packit Bot 4c90e1
set(HAVE_ZLIB       ${ZLIB_FOUND})
Packit Bot 4c90e1
set(HAVE_LIBEVENT_OPENSSL ${LIBEVENT_FOUND})
Packit Bot 4c90e1
if(LIBEVENT_FOUND)
Packit Bot 4c90e1
  # Must both link the core and openssl libraries.
Packit Bot 4c90e1
  set(LIBEVENT_OPENSSL_LIBRARIES ${LIBEVENT_LIBRARIES})
Packit Bot 4c90e1
endif()
Packit Bot 4c90e1
# libc-ares (for src)
Packit Bot 4c90e1
set(HAVE_LIBCARES   ${LIBCARES_FOUND})
Packit Bot 4c90e1
if(LIBCARES_FOUND)
Packit Bot 4c90e1
  set(LIBCARES_INCLUDE_DIRS ${LIBCARES_INCLUDE_DIR})
Packit Bot 4c90e1
else()
Packit Bot 4c90e1
  set(LIBCARES_INCLUDE_DIRS "")
Packit Bot 4c90e1
  set(LIBCARES_LIBRARIES    "")
Packit Bot 4c90e1
endif()
Packit Bot 4c90e1
# jansson (for src/nghttp, src/deflatehd and src/inflatehd)
Packit Bot 4c90e1
set(HAVE_JANSSON    ${JANSSON_FOUND})
Packit Bot 4c90e1
# libxml2 (for src/nghttp)
Packit Bot 4c90e1
set(HAVE_LIBXML2    ${LIBXML2_FOUND})
Packit Bot 4c90e1
if(LIBXML2_FOUND)
Packit Bot 4c90e1
  set(LIBXML2_INCLUDE_DIRS  ${LIBXML2_INCLUDE_DIR})
Packit Bot 4c90e1
else()
Packit Bot 4c90e1
  set(LIBXML2_INCLUDE_DIRS  "")
Packit Bot 4c90e1
  set(LIBXML2_LIBRARIES     "")
Packit Bot 4c90e1
endif()
Packit Bot 4c90e1
# jemalloc
Packit Bot 4c90e1
set(HAVE_JEMALLOC   ${JEMALLOC_FOUND})
Packit Bot 4c90e1
# spdylay (for src/nghttpx and src/h2load)
Packit Bot 4c90e1
set(HAVE_SPDYLAY    ${SPDYLAY_FOUND})
Packit Bot 4c90e1
Packit Bot 4c90e1
if(ENABLE_ASIO_LIB)
Packit Bot 4c90e1
  find_package(Boost 1.54.0 REQUIRED system thread)
Packit Bot 4c90e1
endif()
Packit Bot 4c90e1
Packit Bot 4c90e1
# The nghttp, nghttpd and nghttpx under src depend on zlib, OpenSSL and libev
Packit Bot 4c90e1
if(ENABLE_APP AND NOT (ZLIB_FOUND AND OPENSSL_FOUND AND LIBEV_FOUND))
Packit Bot 4c90e1
  message(FATAL_ERROR "Applications were requested (ENABLE_APP=1) but dependencies are not met.")
Packit Bot 4c90e1
endif()
Packit Bot 4c90e1
Packit Bot 4c90e1
# HPACK tools requires jansson
Packit Bot 4c90e1
if(ENABLE_HPACK_TOOLS AND NOT HAVE_JANSSON)
Packit Bot 4c90e1
  message(FATAL_ERROR "HPACK tools were requested (ENABLE_HPACK_TOOLS=1) but dependencies are not met.")
Packit Bot 4c90e1
endif()
Packit Bot 4c90e1
Packit Bot 4c90e1
# C++ library libnghttp2_asio
Packit Bot 4c90e1
if(ENABLE_EXAMPLES AND NOT (OPENSSL_FOUND AND LIBEVENT_OPENSSL_FOUND))
Packit Bot 4c90e1
  message(FATAL_ERROR "examples were requested (ENABLE_EXAMPLES=1) but dependencies are not met.")
Packit Bot 4c90e1
endif()
Packit Bot 4c90e1
Packit Bot 4c90e1
# third-party http-parser only be built when needed
Packit Bot 4c90e1
if(ENABLE_EXAMPLES OR ENABLE_APP OR ENABLE_HPACK_TOOLS OR ENABLE_ASIO_LIB)
Packit Bot 4c90e1
  set(ENABLE_THIRD_PARTY 1)
Packit Bot 4c90e1
  # mruby (for src/nghttpx)
Packit Bot 4c90e1
  set(HAVE_MRUBY      ${WITH_MRUBY})
Packit Bot 4c90e1
  set(HAVE_NEVERBLEED ${WITH_NEVERBLEED})
Packit Bot 4c90e1
else()
Packit Bot 4c90e1
  set(HAVE_MRUBY 0)
Packit Bot 4c90e1
  set(HAVE_NEVERBLEED 0)
Packit Bot 4c90e1
endif()
Packit Bot 4c90e1
Packit Bot 4c90e1
# Checks for header files.
Packit Bot 4c90e1
include(CheckIncludeFile)
Packit Bot 4c90e1
check_include_file("arpa/inet.h"    HAVE_ARPA_INET_H)
Packit Bot 4c90e1
check_include_file("fcntl.h"        HAVE_FCNTL_H)
Packit Bot 4c90e1
check_include_file("inttypes.h"     HAVE_INTTYPES_H)
Packit Bot 4c90e1
check_include_file("limits.h"       HAVE_LIMITS_H)
Packit Bot 4c90e1
check_include_file("netdb.h"        HAVE_NETDB_H)
Packit Bot 4c90e1
check_include_file("netinet/in.h"   HAVE_NETINET_IN_H)
Packit Bot 4c90e1
check_include_file("pwd.h"          HAVE_PWD_H)
Packit Bot 4c90e1
check_include_file("sys/socket.h"   HAVE_SYS_SOCKET_H)
Packit Bot 4c90e1
check_include_file("sys/time.h"     HAVE_SYS_TIME_H)
Packit Bot 4c90e1
check_include_file("syslog.h"       HAVE_SYSLOG_H)
Packit Bot 4c90e1
check_include_file("time.h"         HAVE_TIME_H)
Packit Bot 4c90e1
check_include_file("unistd.h"       HAVE_UNISTD_H)
Packit Bot 4c90e1
Packit Bot 4c90e1
include(CheckTypeSize)
Packit Bot 4c90e1
# Checks for typedefs, structures, and compiler characteristics.
Packit Bot 4c90e1
# AC_TYPE_SIZE_T
Packit Bot 4c90e1
check_type_size("ssize_t" SIZEOF_SSIZE_T)
Packit Bot 4c90e1
if(SIZEOF_SSIZE_T STREQUAL "")
Packit Bot 4c90e1
  # ssize_t is a signed type in POSIX storing at least -1.
Packit Bot 4c90e1
  # Set it to "int" to match the behavior of AC_TYPE_SSIZE_T (autotools).
Packit Bot 4c90e1
  set(ssize_t int)
Packit Bot 4c90e1
endif()
Packit Bot 4c90e1
# AC_TYPE_UINT8_T
Packit Bot 4c90e1
# AC_TYPE_UINT16_T
Packit Bot 4c90e1
# AC_TYPE_UINT32_T
Packit Bot 4c90e1
# AC_TYPE_UINT64_T
Packit Bot 4c90e1
# AC_TYPE_INT8_T
Packit Bot 4c90e1
# AC_TYPE_INT16_T
Packit Bot 4c90e1
# AC_TYPE_INT32_T
Packit Bot 4c90e1
# AC_TYPE_INT64_T
Packit Bot 4c90e1
# AC_TYPE_OFF_T
Packit Bot 4c90e1
# AC_TYPE_PID_T
Packit Bot 4c90e1
# AC_TYPE_UID_T
Packit Bot 4c90e1
# XXX To support inline for crappy compilers, see https://cmake.org/Wiki/CMakeTestInline
Packit Bot 4c90e1
# AC_C_INLINE
Packit Bot 4c90e1
# XXX is AC_SYS_LARGEFILE still needed for modern systems?
Packit Bot 4c90e1
# add_definitions(-D_FILE_OFFSET_BITS=64)
Packit Bot 4c90e1
Packit Bot 4c90e1
include(CheckStructHasMember)
Packit Bot 4c90e1
check_struct_has_member("struct tm" tm_gmtoff time.h HAVE_STRUCT_TM_TM_GMTOFF)
Packit Bot 4c90e1
Packit Bot 4c90e1
# Check size of pointer to decide we need 8 bytes alignment adjustment.
Packit Bot 4c90e1
check_type_size("int *"   SIZEOF_INT_P)
Packit Bot 4c90e1
check_type_size("time_t"  SIZEOF_TIME_T)
Packit Bot 4c90e1
Packit Bot 4c90e1
# Checks for library functions.
Packit Bot 4c90e1
include(CheckFunctionExists)
Packit Bot 4c90e1
check_function_exists(_Exit     HAVE__EXIT)
Packit Bot 4c90e1
check_function_exists(accept4   HAVE_ACCEPT4)
Packit Bot 4c90e1
check_function_exists(mkostemp  HAVE_MKOSTEMP)
Packit Bot 4c90e1
Packit Bot 4c90e1
include(CheckSymbolExists)
Packit Bot 4c90e1
# XXX does this correctly detect initgroups (un)availability on cygwin?
Packit Bot 4c90e1
check_symbol_exists(initgroups grp.h HAVE_DECL_INITGROUPS)
Packit Bot 4c90e1
if(NOT HAVE_DECL_INITGROUPS AND HAVE_UNISTD_H)
Packit Bot 4c90e1
  # FreeBSD declares initgroups() in unistd.h
Packit Bot 4c90e1
  check_symbol_exists(initgroups unistd.h HAVE_DECL_INITGROUPS2)
Packit Bot 4c90e1
  if(HAVE_DECL_INITGROUPS2)
Packit Bot 4c90e1
    set(HAVE_DECL_INITGROUPS 1)
Packit Bot 4c90e1
  endif()
Packit Bot 4c90e1
endif()
Packit Bot 4c90e1
Packit Bot 4c90e1
set(WARNCFLAGS)
Packit Bot 4c90e1
set(WARNCXXFLAGS)
Packit Bot 4c90e1
if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
Packit Bot 4c90e1
  if(ENABLE_WERROR)
Packit Bot 4c90e1
    set(WARNCFLAGS    /WX)
Packit Bot 4c90e1
    set(WARNCXXFLAGS  /WX)
Packit Bot 4c90e1
  endif()
Packit Bot 4c90e1
else()
Packit Bot 4c90e1
  if(ENABLE_WERROR)
Packit Bot 4c90e1
    extract_valid_c_flags(WARNCFLAGS    -Werror)
Packit Bot 4c90e1
    extract_valid_c_flags(WARNCXXFLAGS  -Werror)
Packit Bot 4c90e1
  endif()
Packit Bot 4c90e1
Packit Bot 4c90e1
  # For C compiler
Packit Bot 4c90e1
  extract_valid_c_flags(WARNCFLAGS
Packit Bot 4c90e1
    -Wall
Packit Bot 4c90e1
    -Wextra
Packit Bot 4c90e1
    -Wmissing-prototypes
Packit Bot 4c90e1
    -Wstrict-prototypes
Packit Bot 4c90e1
    -Wmissing-declarations
Packit Bot 4c90e1
    -Wpointer-arith
Packit Bot 4c90e1
    -Wdeclaration-after-statement
Packit Bot 4c90e1
    -Wformat-security
Packit Bot 4c90e1
    -Wwrite-strings
Packit Bot 4c90e1
    -Wshadow
Packit Bot 4c90e1
    -Winline
Packit Bot 4c90e1
    -Wnested-externs
Packit Bot 4c90e1
    -Wfloat-equal
Packit Bot 4c90e1
    -Wundef
Packit Bot 4c90e1
    -Wendif-labels
Packit Bot 4c90e1
    -Wempty-body
Packit Bot 4c90e1
    -Wcast-align
Packit Bot 4c90e1
    -Wclobbered
Packit Bot 4c90e1
    -Wvla
Packit Bot 4c90e1
    -Wpragmas
Packit Bot 4c90e1
    -Wunreachable-code
Packit Bot 4c90e1
    -Waddress
Packit Bot 4c90e1
    -Wattributes
Packit Bot 4c90e1
    -Wdiv-by-zero
Packit Bot 4c90e1
    -Wshorten-64-to-32
Packit Bot 4c90e1
Packit Bot 4c90e1
    -Wconversion
Packit Bot 4c90e1
    -Wextended-offsetof
Packit Bot 4c90e1
    -Wformat-nonliteral
Packit Bot 4c90e1
    -Wlanguage-extension-token
Packit Bot 4c90e1
    -Wmissing-field-initializers
Packit Bot 4c90e1
    -Wmissing-noreturn
Packit Bot 4c90e1
    -Wmissing-variable-declarations
Packit Bot 4c90e1
    # Not used because we cannot change public structs
Packit Bot 4c90e1
    # -Wpadded
Packit Bot 4c90e1
    -Wsign-conversion
Packit Bot 4c90e1
    # Not used because this basically disallows default case
Packit Bot 4c90e1
    # -Wswitch-enum
Packit Bot 4c90e1
    -Wunreachable-code-break
Packit Bot 4c90e1
    -Wunused-macros
Packit Bot 4c90e1
    -Wunused-parameter
Packit Bot 4c90e1
    -Wredundant-decls
Packit Bot 4c90e1
    # Only work with Clang for the moment
Packit Bot 4c90e1
    -Wheader-guard
Packit Bot 4c90e1
    # This is required because we pass format string as "const char*.
Packit Bot 4c90e1
    -Wno-format-nonliteral
Packit Bot 4c90e1
  )
Packit Bot 4c90e1
Packit Bot 4c90e1
  extract_valid_cxx_flags(WARNCXXFLAGS
Packit Bot 4c90e1
    # For C++ compiler
Packit Bot 4c90e1
    -Wall
Packit Bot 4c90e1
    -Wformat-security
Packit Bot 4c90e1
  )
Packit Bot 4c90e1
endif()
Packit Bot 4c90e1
Packit Bot 4c90e1
if(ENABLE_DEBUG)
Packit Bot 4c90e1
  set(DEBUGBUILD 1)
Packit Bot 4c90e1
endif()
Packit Bot 4c90e1
Packit Bot 4c90e1
# Some platform does not have working std::future.  We disable
Packit Bot 4c90e1
# threading for those platforms.
Packit Bot 4c90e1
if(NOT ENABLE_THREADS OR NOT HAVE_STD_FUTURE)
Packit Bot 4c90e1
  set(NOTHREADS 1)
Packit Bot 4c90e1
endif()
Packit Bot 4c90e1
Packit Bot 4c90e1
add_definitions(-DHAVE_CONFIG_H)
Packit Bot 4c90e1
configure_file(cmakeconfig.h.in config.h)
Packit Bot 4c90e1
# autotools-compatible names
Packit Bot 4c90e1
# Sphinx expects relative paths in the .rst files. Use the fact that the files
Packit Bot 4c90e1
# below are all one directory level deep.
Packit Bot 4c90e1
file(RELATIVE_PATH top_srcdir   "${CMAKE_CURRENT_BINARY_DIR}/dir" "${CMAKE_CURRENT_SOURCE_DIR}")
Packit Bot 4c90e1
file(RELATIVE_PATH top_builddir "${CMAKE_CURRENT_BINARY_DIR}/dir" "${CMAKE_CURRENT_BINARY_DIR}")
Packit Bot 4c90e1
set(abs_top_srcdir  "${CMAKE_CURRENT_SOURCE_DIR}")
Packit Bot 4c90e1
set(abs_top_builddir "${CMAKE_CURRENT_BINARY_DIR}")
Packit Bot 4c90e1
# libnghttp2.pc (pkg-config file)
Packit Bot 4c90e1
set(prefix          "${CMAKE_INSTALL_PREFIX}")
Packit Bot 4c90e1
set(exec_prefix     "${CMAKE_INSTALL_PREFIX}")
Packit Bot 4c90e1
set(libdir          "${CMAKE_INSTALL_FULL_LIBDIR}")
Packit Bot 4c90e1
set(includedir      "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
Packit Bot 4c90e1
set(VERSION         "${PACKAGE_VERSION}")
Packit Bot 4c90e1
# For init scripts and systemd service file (in contrib/)
Packit Bot 4c90e1
set(bindir          "${CMAKE_INSTALL_FULL_BINDIR}")
Packit Bot 4c90e1
set(sbindir         "${CMAKE_INSTALL_FULL_SBINDIR}")
Packit Bot 4c90e1
foreach(name
Packit Bot 4c90e1
   lib/libnghttp2.pc
Packit Bot 4c90e1
   lib/includes/nghttp2/nghttp2ver.h
Packit Bot 4c90e1
   src/libnghttp2_asio.pc
Packit Bot 4c90e1
   python/setup.py
Packit Bot 4c90e1
   integration-tests/config.go
Packit Bot 4c90e1
   integration-tests/setenv
Packit Bot 4c90e1
   doc/conf.py
Packit Bot 4c90e1
   doc/index.rst
Packit Bot 4c90e1
   doc/package_README.rst
Packit Bot 4c90e1
   doc/tutorial-client.rst
Packit Bot 4c90e1
   doc/tutorial-server.rst
Packit Bot 4c90e1
   doc/tutorial-hpack.rst
Packit Bot 4c90e1
   doc/nghttpx-howto.rst
Packit Bot 4c90e1
   doc/h2load-howto.rst
Packit Bot 4c90e1
   doc/libnghttp2_asio.rst
Packit Bot 4c90e1
   doc/python-apiref.rst
Packit Bot 4c90e1
   doc/building-android-binary.rst
Packit Bot 4c90e1
   doc/nghttp2.h.rst
Packit Bot 4c90e1
   doc/nghttp2ver.h.rst
Packit Bot 4c90e1
   doc/asio_http2.h.rst
Packit Bot 4c90e1
   doc/asio_http2_server.h.rst
Packit Bot 4c90e1
   doc/asio_http2_client.h.rst
Packit Bot 4c90e1
   doc/contribute.rst
Packit Bot 4c90e1
)
Packit Bot 4c90e1
  configure_file("${name}.in" "${name}" @ONLY)
Packit Bot 4c90e1
endforeach()
Packit Bot 4c90e1
Packit Bot 4c90e1
include_directories(
Packit Bot 4c90e1
  "${CMAKE_CURRENT_BINARY_DIR}" # for config.h
Packit Bot 4c90e1
)
Packit Bot 4c90e1
# For use in src/CMakeLists.txt
Packit Bot 4c90e1
set(PKGDATADIR "${CMAKE_INSTALL_FULL_DATADIR}/${CMAKE_PROJECT_NAME}")
Packit Bot 4c90e1
Packit Bot 4c90e1
install(FILES README.rst DESTINATION "${CMAKE_INSTALL_DOCDIR}")
Packit Bot 4c90e1
Packit Bot 4c90e1
add_subdirectory(lib)
Packit Bot 4c90e1
#add_subdirectory(lib/includes)
Packit Bot 4c90e1
add_subdirectory(third-party)
Packit Bot 4c90e1
add_subdirectory(src)
Packit Bot 4c90e1
#add_subdirectory(src/includes)
Packit Bot 4c90e1
add_subdirectory(examples)
Packit Bot 4c90e1
add_subdirectory(python)
Packit Bot 4c90e1
add_subdirectory(tests)
Packit Bot 4c90e1
#add_subdirectory(tests/testdata)
Packit Bot 4c90e1
add_subdirectory(integration-tests)
Packit Bot 4c90e1
add_subdirectory(doc)
Packit Bot 4c90e1
add_subdirectory(contrib)
Packit Bot 4c90e1
add_subdirectory(script)
Packit Bot 4c90e1
Packit Bot 4c90e1
Packit Bot 4c90e1
string(TOUPPER "${CMAKE_BUILD_TYPE}" _build_type)
Packit Bot 4c90e1
message(STATUS "summary of build options:
Packit Bot 4c90e1
Packit Bot 4c90e1
    Package version: ${VERSION}
Packit Bot 4c90e1
    Library version: ${LT_CURRENT}:${LT_REVISION}:${LT_AGE}
Packit Bot 4c90e1
    Install prefix:  ${CMAKE_INSTALL_PREFIX}
Packit Bot 4c90e1
    Target system:   ${CMAKE_SYSTEM_NAME}
Packit Bot 4c90e1
    Compiler:
Packit Bot 4c90e1
      Build type:     ${CMAKE_BUILD_TYPE}
Packit Bot 4c90e1
      C compiler:     ${CMAKE_C_COMPILER}
Packit Bot 4c90e1
      CFLAGS:         ${CMAKE_C_FLAGS_${_build_type}} ${CMAKE_C_FLAGS}
Packit Bot 4c90e1
      C++ compiler:   ${CMAKE_CXX_COMPILER}
Packit Bot 4c90e1
      CXXFLAGS:       ${CMAKE_CXX_FLAGS_${_build_type}} ${CMAKE_CXX_FLAGS}
Packit Bot 4c90e1
      WARNCFLAGS:     ${WARNCFLAGS}
Packit Bot 4c90e1
      CXX1XCXXFLAGS:  ${CXX1XCXXFLAGS}
Packit Bot 4c90e1
    Python:
Packit Bot 4c90e1
      Python:         ${PYTHON_EXECUTABLE}
Packit Bot 4c90e1
      PYTHON_VERSION: ${PYTHON_VERSION_STRING}
Packit Bot 4c90e1
      Library version:${PYTHONLIBS_VERSION_STRING}
Packit Bot 4c90e1
      Cython:         ${CYTHON_EXECUTABLE}
Packit Bot 4c90e1
    Test:
Packit Bot 4c90e1
      CUnit:          ${HAVE_CUNIT} (LIBS='${CUNIT_LIBRARIES}')
Packit Bot 4c90e1
      Failmalloc:     ${ENABLE_FAILMALLOC}
Packit Bot 4c90e1
    Libs:
Packit Bot 4c90e1
      OpenSSL:        ${HAVE_OPENSSL} (LIBS='${OPENSSL_LIBRARIES}')
Packit Bot 4c90e1
      Libxml2:        ${HAVE_LIBXML2} (LIBS='${LIBXML2_LIBRARIES}')
Packit Bot 4c90e1
      Libev:          ${HAVE_LIBEV} (LIBS='${LIBEV_LIBRARIES}')
Packit Bot 4c90e1
      Libc-ares:      ${HAVE_LIBCARES} (LIBS='${LIBCARES_LIBRARIES}')
Packit Bot 4c90e1
      Libevent(SSL):  ${HAVE_LIBEVENT_OPENSSL} (LIBS='${LIBEVENT_OPENSSL_LIBRARIES}')
Packit Bot 4c90e1
      Spdylay:        ${HAVE_SPDYLAY} (LIBS='${SPDYLAY_LIBRARIES}')
Packit Bot 4c90e1
      Jansson:        ${HAVE_JANSSON} (LIBS='${JANSSON_LIBRARIES}')
Packit Bot 4c90e1
      Jemalloc:       ${HAVE_JEMALLOC} (LIBS='${JEMALLOC_LIBRARIES}')
Packit Bot 4c90e1
      Zlib:           ${HAVE_ZLIB} (LIBS='${ZLIB_LIBRARIES}')
Packit Bot 4c90e1
      Boost::System:  ${Boost_SYSTEM_LIBRARY}
Packit Bot 4c90e1
      Boost::Thread:  ${Boost_THREAD_LIBRARY}
Packit Bot 4c90e1
    Third-party:
Packit Bot 4c90e1
      http-parser:    ${ENABLE_THIRD_PARTY}
Packit Bot 4c90e1
      MRuby:          ${HAVE_MRUBY}
Packit Bot 4c90e1
      Neverbleed:     ${HAVE_NEVERBLEED}
Packit Bot 4c90e1
    Features:
Packit Bot 4c90e1
      Applications:   ${ENABLE_APP}
Packit Bot 4c90e1
      HPACK tools:    ${ENABLE_HPACK_TOOLS}
Packit Bot 4c90e1
      Libnghttp2_asio:${ENABLE_ASIO_LIB}
Packit Bot 4c90e1
      Examples:       ${ENABLE_EXAMPLES}
Packit Bot 4c90e1
      Python bindings:${ENABLE_PYTHON_BINDINGS}
Packit Bot 4c90e1
      Threading:      ${ENABLE_THREADS}
Packit Bot 4c90e1
")
Packit Bot 4c90e1
if(ENABLE_LIB_ONLY_DISABLED_OTHERS)
Packit Bot 4c90e1
  message("Only the library will be built. To build other components "
Packit Bot 4c90e1
    "(such as applications and examples), set ENABLE_LIB_ONLY=OFF.")
Packit Bot 4c90e1
endif()