diff mbox series

[libubootenv] cmake: use pkg-config to locate libyaml

Message ID 20250116113400.112160-1-michael.adler@siemens.com
State New
Delegated to: Stefano Babic
Headers show
Series [libubootenv] cmake: use pkg-config to locate libyaml | expand

Commit Message

Michael Adler Jan. 16, 2025, 11:34 a.m. UTC
Fixes the build for systems like FreeBSD where libyaml is installed in
/usr/local.

Signed-off-by: Michael Adler <michael.adler@siemens.com>
---
 src/CMakeLists.txt | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c56d0c7..7c2ae4b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -18,6 +18,13 @@  SET(include_HEADERS
 )
 
 include(GNUInstallDirs) # for the CMAKE_INSTALL_LIBDIR variable
+include(FindPkgConfig)
+
+if (NOT NO_YML_SUPPORT)
+  pkg_check_modules(YAML REQUIRED yaml-0.1)
+  include_directories(${YAML_INCLUDE_DIRS})
+  link_directories(${YAML_LIBRARY_DIRS})
+endif(NOT NO_YML_SUPPORT)
 
 add_library(ubootenv SHARED ${libubootenv_SOURCES} ${include_HEADERS})
 SET_TARGET_PROPERTIES(ubootenv PROPERTIES VERSION ${VERSION} SOVERSION ${SOVERSION})
@@ -27,7 +34,7 @@  SET_TARGET_PROPERTIES(ubootenv_static PROPERTIES OUTPUT_NAME ubootenv)
 add_executable(fw_printenv fw_printenv.c)
 target_link_libraries(ubootenv z)
 if (NOT NO_YML_SUPPORT)
-target_link_libraries(ubootenv yaml)
+  target_link_libraries(ubootenv ${YAML_LIBRARIES})
 endif(NOT NO_YML_SUPPORT)
 
 target_link_libraries(fw_printenv ubootenv)