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 target_compile_definitions(neverbleed PUBLIC _GNU_SOURCE) 33 endif() 34 35 if(HAVE_MRUBY) 36 # EXTRA_DIST = build_config.rb mruby/* 37 38 set(MRUBY_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/mruby/build") 39 set(MRUBY_LIBRARY 40 "${CMAKE_STATIC_LIBRARY_PREFIX}mruby${CMAKE_STATIC_LIBRARY_SUFFIX}" 41 ) 42 43 # The mruby build needs some env vars. Alternatively, look at cmake -P 44 if(CMAKE_VERSION VERSION_LESS "3.1") 45 # XXX works only for Unixes? 46 set(ENV_COMMAND env) 47 else() 48 set(ENV_COMMAND ${CMAKE_COMMAND} -E env) 49 endif() 50 # Required for the Ninja generator. For older CMake, you first have to 51 # invoke 'ninja mruby' before building dependents. 52 if(CMAKE_VERSION VERSION_LESS "3.2") 53 set(_byproducts) 54 else() 55 set(_byproducts BYPRODUCTS "mruby/build/lib/${MRUBY_LIBRARY}") 56 endif() 57 add_custom_target(mruby 58 COMMAND ${ENV_COMMAND} 59 "MRUBY_CONFIG=${CMAKE_CURRENT_SOURCE_DIR}/build_config.rb" 60 "BUILD_DIR=${MRUBY_BUILD_DIR}" 61 "INSTALL_DIR=${MRUBY_BUILD_DIR}/install/bin" 62 "MRUBY_CC=${CMAKE_C_COMPILER}" "MRUBY_CXX=${CMAKE_CXX_COMPILER}" 63 "${CMAKE_CURRENT_SOURCE_DIR}/mruby/minirake" 64 -f "${CMAKE_CURRENT_SOURCE_DIR}/mruby/Rakefile" 65 ${_byproducts} 66 VERBATIM 67 ) 68 69 # Make the mruby library available to others in this project without them 70 # having to worry about include dirs and the mruby location. 71 add_library(mruby-lib STATIC IMPORTED GLOBAL) 72 set_target_properties(mruby-lib PROPERTIES 73 IMPORTED_LOCATION "${MRUBY_BUILD_DIR}/lib/${MRUBY_LIBRARY}" 74 INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/mruby/include" 75 ) 76 add_dependencies(mruby-lib mruby) 77 78 set_directory_properties(PROPERTIES 79 ADDITIONAL_MAKE_CLEAN_FILES mruby/build 80 ) 81 endif() 82endif() 83