]> git.stg.codes - stg.git/blob - cmake/modules/FindYAJL.cmake
Remove std::list from tariffs.
[stg.git] / cmake / modules / FindYAJL.cmake
1 find_path ( YAJL_INCLUDE_DIR NAMES yajl/yajl_parse.h yajl/yajl_version.h DOC "Path to YAJL header files." )
2 mark_as_advanced ( YAJL_INCLUDE_DIR )
3
4 find_library ( YAJL_LIB NAMES yajl DOC "Location of YAJL library." )
5 mark_as_advanced ( YAJL_LIB )
6
7 if ( YAJL_INCLUDE_DIR )
8     file ( READ "${YAJL_INCLUDE_DIR}/yajl/yajl_version.h" ver )
9
10     string ( REGEX MATCH "YAJL_MAJOR ([0-9]*)" _ ${ver} )
11     set ( ver_major ${CMAKE_MATCH_1} )
12
13     string ( REGEX MATCH "YAJL_MINOR ([0-9]*)" _ ${ver} )
14     set ( ver_minor ${CMAKE_MATCH_1} )
15
16     string ( REGEX MATCH "YAJL_MICRO ([0-9]*)" _ ${ver} )
17     set ( ver_micro ${CMAKE_MATCH_1} )
18
19     set ( YAJL_VERSION "${ver_major}.${ver_minor}.${ver_micro}" )
20
21     unset ( ver )
22     unset ( ver_major )
23     unset ( ver_minor )
24     unset ( ver_micro )
25 endif ( YAJL_INCLUDE_DIR )
26
27 include ( FindPackageHandleStandardArgs )
28 find_package_handle_standard_args ( YAJL
29                                     REQUIRED_VARS YAJL_LIB YAJL_INCLUDE_DIR
30                                     VERSION_VAR YAJL_VERSION )
31
32 # Create the imported target
33 if ( YAJL_FOUND )
34     set ( YAJL_INCLUDE_DIRS ${YAJL_INCLUDE_DIR} )
35     set ( YAJL_LIBRARIES ${YAJL_LIB} )
36     if ( NOT TARGET YAJL::YAJL )
37         add_library ( YAJL::YAJL UNKNOWN IMPORTED )
38         set_target_properties ( YAJL::YAJL PROPERTIES
39                                 IMPORTED_LOCATION "${YAJL_LIB}"
40                                 INTERFACE_INCLUDE_DIRECTORIES "${YAJL_INCLUDE_DIR}" )
41     endif ( NOT TARGET YAJL::YAJL )
42 endif ( YAJL_FOUND )