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 )
4 find_library ( YAJL_LIB NAMES yajl DOC "Location of YAJL library." )
5 mark_as_advanced ( YAJL_LIB )
7 if ( YAJL_INCLUDE_DIR )
8 file ( READ "${YAJL_INCLUDE_DIR}/yajl/yajl_version.h" ver )
10 string ( REGEX MATCH "YAJL_MAJOR ([0-9]*)" _ ${ver} )
11 set ( ver_major ${CMAKE_MATCH_1} )
13 string ( REGEX MATCH "YAJL_MINOR ([0-9]*)" _ ${ver} )
14 set ( ver_minor ${CMAKE_MATCH_1} )
16 string ( REGEX MATCH "YAJL_MICRO ([0-9]*)" _ ${ver} )
17 set ( ver_micro ${CMAKE_MATCH_1} )
19 set ( YAJL_VERSION "${ver_major}.${ver_minor}.${ver_micro}" )
25 endif ( YAJL_INCLUDE_DIR )
27 include ( FindPackageHandleStandardArgs )
28 find_package_handle_standard_args ( YAJL
29 REQUIRED_VARS YAJL_LIB YAJL_INCLUDE_DIR
30 VERSION_VAR YAJL_VERSION )
32 # Create the imported target
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 )