CMake: Add compatibility for yaml-cpp 0.8.0. (#1115)

- Upstream uses YAML_CPP_INCLUDE_DIR
- yaml-cpp 0.8.0 does not set YAML_CPP_LIBRARIES to the new target name.
- Debug builds of yaml-cpp suffix the library with `d`.
This commit is contained in:
Pierre Wendling
2023-08-18 18:06:45 -07:00
committed by GitHub
parent cdd8cd9e34
commit f2687ed1ff
+9 -5
View File
@@ -1,27 +1,31 @@
FIND_PACKAGE(yaml-cpp QUIET)
IF(NOT yaml-cpp_FOUND)
IF(yaml-cpp_FOUND)
# yaml-cpp 0.8.0 uses the wrong target in YAML_CPP_LIBRARIES.
IF(yaml-cpp_VERSION VERSION_EQUAL "0.8.0")
SET(YAML_CPP_LIBRARIES yaml-cpp::yaml-cpp)
ENDIF()
ELSE()
find_package(PkgConfig QUIET)
IF(PKG_CONFIG_FOUND)
pkg_check_modules(yaml_cpp QUIET yaml-cpp)
IF(yaml_cpp_FOUND)
SET(YAML_CPP_LIBRARIES ${yaml_cpp_LIBRARIES})
SET(YAML_CPP_INCLUDE_DIRS ${yaml_cpp_INCLUDEDIR})
SET(YAML_CPP_INCLUDE_DIR ${yaml_cpp_INCLUDEDIR})
SET(yaml-cpp_FOUND ${yaml_cpp_FOUND})
ENDIF(yaml_cpp_FOUND)
ENDIF(PKG_CONFIG_FOUND)
ENDIF(NOT yaml-cpp_FOUND)
ENDIF(yaml-cpp_FOUND)
IF(yaml-cpp_FOUND)
SET(INCLUDE_DIRS
${YAML_CPP_INCLUDE_DIRS}
${YAML_CPP_INCLUDE_DIR}
)
SET(LIBRARIES
${YAML_CPP_LIBRARIES}
yaml-cpp
)
INCLUDE_DIRECTORIES(${INCLUDE_DIRS} yaml-cpp)