• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1if(ENABLE_THIRD_PARTY)
2  set(LIBLLHTTP_SOURCES
3    llhttp/src/api.c
4    llhttp/src/http.c
5    llhttp/src/llhttp.c
6  )
7  add_library(llhttp OBJECT ${LIBLLHTTP_SOURCES})
8  target_include_directories(llhttp PRIVATE
9    "${CMAKE_CURRENT_SOURCE_DIR}/llhttp/include"
10  )
11  set_target_properties(llhttp PROPERTIES
12    POSITION_INDEPENDENT_CODE ON
13  )
14
15  set(LIBURL_PARSER_SOURCES
16    url-parser/url_parser.c
17  )
18  add_library(url-parser OBJECT ${LIBURL_PARSER_SOURCES})
19  set_target_properties(url-parser PROPERTIES
20    POSITION_INDEPENDENT_CODE ON)
21
22  if(HAVE_NEVERBLEED)
23    set(NEVERBLEED_SOURCES
24      neverbleed/neverbleed.c
25    )
26    add_library(neverbleed ${NEVERBLEED_SOURCES})
27    target_include_directories(neverbleed PRIVATE ${OPENSSL_INCLUDE_DIRS})
28    target_include_directories(neverbleed INTERFACE
29      "${CMAKE_SOURCE_DIR}/third-party/neverbleed"
30    )
31    target_link_libraries(neverbleed ${OPENSSL_LIBRARIES})
32  endif()
33
34  if(HAVE_MRUBY)
35    # EXTRA_DIST = build_config.rb mruby/*
36
37    set(MRUBY_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/mruby/build")
38    set(MRUBY_LIBRARY
39      "${CMAKE_STATIC_LIBRARY_PREFIX}mruby${CMAKE_STATIC_LIBRARY_SUFFIX}"
40    )
41
42    # The mruby build needs some env vars. Alternatively, look at cmake -P
43    if(CMAKE_VERSION VERSION_LESS "3.1")
44      # XXX works only for Unixes?
45      set(ENV_COMMAND env)
46    else()
47      set(ENV_COMMAND ${CMAKE_COMMAND} -E env)
48    endif()
49    # Required for the Ninja generator. For older CMake, you first have to
50    # invoke 'ninja mruby' before building dependents.
51    if(CMAKE_VERSION VERSION_LESS "3.2")
52      set(_byproducts)
53    else()
54      set(_byproducts BYPRODUCTS "mruby/build/lib/${MRUBY_LIBRARY}")
55    endif()
56    add_custom_target(mruby
57      COMMAND ${ENV_COMMAND}
58        "MRUBY_CONFIG=${CMAKE_CURRENT_SOURCE_DIR}/build_config.rb"
59        "BUILD_DIR=${MRUBY_BUILD_DIR}"
60        "INSTALL_DIR=${MRUBY_BUILD_DIR}/install/bin"
61        "MRUBY_CC=${CMAKE_C_COMPILER}" "MRUBY_CXX=${CMAKE_CXX_COMPILER}"
62        "${CMAKE_CURRENT_SOURCE_DIR}/mruby/minirake"
63        -f "${CMAKE_CURRENT_SOURCE_DIR}/mruby/Rakefile"
64      ${_byproducts}
65      VERBATIM
66    )
67
68    # Make the mruby library available to others in this project without them
69    # having to worry about include dirs and the mruby location.
70    add_library(mruby-lib STATIC IMPORTED GLOBAL)
71    set_target_properties(mruby-lib PROPERTIES
72      IMPORTED_LOCATION "${MRUBY_BUILD_DIR}/lib/${MRUBY_LIBRARY}"
73      INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/mruby/include"
74    )
75    add_dependencies(mruby-lib mruby)
76
77    set_directory_properties(PROPERTIES
78      ADDITIONAL_MAKE_CLEAN_FILES mruby/build
79    )
80  endif()
81endif()
82