]>
Commit | Line | Data |
---|---|---|
7a6e0281 VP |
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() |