build: libyaml: Search libyaml with pkg-config and handle homebrew-ed libyaml
* build: libyaml: Search libyaml with pkg-config and handle homebrew-ed
libyaml
* build: Fix a typo
@@ -666,7 +666,20 @@ endif()
# Configuration file YAML format support
if(FLB_CONFIG_YAML)
-# Requies libyaml support
+ find_package(PkgConfig)
+ # libyaml's corresponding pkg-config file is yaml-0.1.pc.
+ # We should search it first.
+ pkg_check_modules(LIBYAML QUIET yaml-0.1)
+
+ if (LIBYAML_FOUND)
+ # For if(FLB_HAVE_LIBYAML) clause on CMakeList.txt.
+ set(FLB_HAVE_LIBYAML 1)
+ FLB_DEFINITION(FLB_HAVE_LIBYAML)
+ # For non-standard libyaml installation paths such as homebrew bottled libyaml.
+ include_directories(${LIBYAML_INCLUDEDIR})
+ link_directories(${LIBYAML_LIBRARY_DIRS})
+ else()
+ # Requires libyaml support
check_c_source_compiles("
#include <yaml.h>
int main() {
@@ -685,6 +698,7 @@ check_c_source_compiles("
FLB_DEFINITION(FLB_HAVE_LIBYAML)
endif()
+endif()
# check attribute alloc_size
check_c_source_compiles("
