| 1 |
# - Try to find http-parser |
| 2 |
# |
| 3 |
# Defines the following variables: |
| 4 |
# |
| 5 |
# HTTP_PARSER_FOUND - system has http-parser |
| 6 |
# HTTP_PARSER_INCLUDE_DIR - the http-parser include directory |
| 7 |
# HTTP_PARSER_LIBRARIES - Link these to use http-parser |
| 8 |
# HTTP_PARSER_VERSION_MAJOR - major version |
| 9 |
# HTTP_PARSER_VERSION_MINOR - minor version |
| 10 |
# HTTP_PARSER_VERSION_STRING - the version of http-parser found |
| 11 |
|
| 12 |
# Find the header and library |
| 13 |
find_path(HTTP_PARSER_INCLUDE_DIR NAMES http_parser.h) |
| 14 |
find_library(HTTP_PARSER_LIBRARY NAMES http_parser libhttp_parser) |
| 15 |
|
| 16 |
# Found the header, read version |
| 17 |
if(HTTP_PARSER_INCLUDE_DIR AND EXISTS "${HTTP_PARSER_INCLUDE_DIR}/http_parser.h") |
| 18 |
file(READ "${HTTP_PARSER_INCLUDE_DIR}/http_parser.h" HTTP_PARSER_H) |
| 19 |
if(HTTP_PARSER_H) |
| 20 |
string(REGEX REPLACE ".*#define[\t ]+HTTP_PARSER_VERSION_MAJOR[\t ]+([0-9]+).*" "\\1" HTTP_PARSER_VERSION_MAJOR "${HTTP_PARSER_H}") |
| 21 |
string(REGEX REPLACE ".*#define[\t ]+HTTP_PARSER_VERSION_MINOR[\t ]+([0-9]+).*" "\\1" HTTP_PARSER_VERSION_MINOR "${HTTP_PARSER_H}") |
| 22 |
set(HTTP_PARSER_VERSION_STRING "${HTTP_PARSER_VERSION_MAJOR}.${HTTP_PARSER_VERSION_MINOR}") |
| 23 |
endif() |
| 24 |
unset(HTTP_PARSER_H) |
| 25 |
endif() |
| 26 |
|
| 27 |
# Handle the QUIETLY and REQUIRED arguments and set HTTP_PARSER_FOUND |
| 28 |
# to TRUE if all listed variables are TRUE |
| 29 |
include(FindPackageHandleStandardArgs) |
| 30 |
find_package_handle_standard_args(HTTP_Parser REQUIRED_VARS HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY) |
| 31 |
|
| 32 |
# Hide advanced variables |
| 33 |
mark_as_advanced(HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY) |
| 34 |
|
| 35 |
# Set standard variables |
| 36 |
if(HTTP_PARSER_FOUND) |
| 37 |
set(HTTP_PARSER_LIBRARIES ${HTTP_PARSER_LIBRARY}) |
| 38 |
set(HTTP_PARSER_INCLUDE_DIRS ${HTTP_PARSER_INCLUDE_DIR}) |
| 39 |
endif() |