From c28295bda489422e4b5928aa0b978eb51dbdcbb1 Mon Sep 17 00:00:00 2001 From: Alexandre TISSOT <60519602+Trompettesib@users.noreply.github.com> Date: Thu, 13 Oct 2022 22:12:19 +0200 Subject: [PATCH] Add CMake integration example --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index e8607062b..f2ec0613a 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,27 @@ cmake [-G generator] [-DYAML_BUILD_SHARED_LIBS=on|OFF] .. **Note:** To clean up, just remove the `build` directory. +## How to Integrate it within your project using CMake + +You can use for example FetchContent : + +```cmake +include(FetchContent) + +FetchContent_Declare(yaml-cpp + GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git + GIT_TAG 1b50109f7bea60bd382d8ea7befce3d2bd67da5f) # The latest yaml-cpp commit at the time of writing. +FetchContent_GetProperties(yaml-cpp) + +if(NOT yaml-cpp_POPULATED) + message(STATUS "Fetching yaml-cpp...") + FetchContent_Populate(yaml-cpp) + add_subdirectory(${yaml-cpp_SOURCE_DIR} ${yaml-cpp_BINARY_DIR}) +endif() + +target_link_libraries(YOUR_LIBRARY PUBLIC yaml-cpp::yaml-cpp) # The library or executable that require yaml-cpp library +``` + ## Recent Releases [yaml-cpp 0.6.0](https://github.com/jbeder/yaml-cpp/releases/tag/yaml-cpp-0.6.0) released! This release requires C++11, and no longer depends on Boost.