nghttp2/third-party/CMakeLists.txt

64 lines
2.1 KiB
CMake

if(ENABLE_THIRD_PARTY)
set(LIBHTTP_PARSER_SOURCES
http-parser/http_parser.c
)
add_library(http-parser OBJECT ${LIBHTTP_PARSER_SOURCES})
if(HAVE_NEVERBLEED)
set(NEVERBLEED_SOURCES
neverbleed/neverbleed.c
)
add_library(neverbleed ${NEVERBLEED_SOURCES})
target_include_directories(neverbleed PRIVATE ${OPENSSL_INCLUDE_DIRS})
target_include_directories(neverbleed INTERFACE
"${CMAKE_SOURCE_DIR}/third-party/neverbleed"
)
target_link_libraries(neverbleed ${OPENSSL_LIBRARIES})
endif()
if(HAVE_MRUBY)
# EXTRA_DIST = build_config.rb mruby/*
set(MRUBY_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/mruby/build")
set(MRUBY_LIBRARY
"${CMAKE_STATIC_LIBRARY_PREFIX}mruby${CMAKE_STATIC_LIBRARY_SUFFIX}"
)
# The mruby build needs some env vars. Alternatively, look at cmake -P
if(CMAKE_VERSION VERSION_LESS "3.1")
# XXX works only for Unixes?
set(ENV_COMMAND env)
else()
set(ENV_COMMAND ${CMAKE_COMMAND} -E env)
endif()
# Required for the Ninja generator. For older CMake, you first have to
# invoke 'ninja mruby' before building dependents.
if(CMAKE_VERSION VERSION_LESS "3.2")
set(_byproducts)
else()
set(_byproducts BYPRODUCTS "mruby/build/lib/${MRUBY_LIBRARY}")
endif()
add_custom_target(mruby
COMMAND ${ENV_COMMAND}
"MRUBY_CONFIG=${CMAKE_CURRENT_SOURCE_DIR}/build_config.rb"
"BUILD_DIR=${MRUBY_BUILD_DIR}"
"INSTALL_DIR=${MRUBY_BUILD_DIR}/install/bin"
"CC=${CMAKE_C_COMPILER}" "CXX=${CMAKE_CXX_COMPILER}"
"${CMAKE_CURRENT_SOURCE_DIR}/mruby/minirake"
-f "${CMAKE_CURRENT_SOURCE_DIR}/mruby/Rakefile"
${_byproducts}
VERBATIM
)
# Make the mruby library available to others in this project without them
# having to worry about include dirs and the mruby location.
add_library(mruby-lib STATIC IMPORTED GLOBAL)
set_target_properties(mruby-lib PROPERTIES
IMPORTED_LOCATION "${MRUBY_BUILD_DIR}/lib/${MRUBY_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/mruby/include"
)
# XXX clean ${CMAKE_CURRENT_BINARY_DIR}/mruby/build
endif()
endif()