Skip to content

Commit c28295b

Browse files
Trompettesibjbeder
authored andcommitted
Add CMake integration example
1 parent 94710bb commit c28295b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,27 @@ cmake [-G generator] [-DYAML_BUILD_SHARED_LIBS=on|OFF] ..
4949

5050
**Note:** To clean up, just remove the `build` directory.
5151

52+
## How to Integrate it within your project using CMake
53+
54+
You can use for example FetchContent :
55+
56+
```cmake
57+
include(FetchContent)
58+
59+
FetchContent_Declare(yaml-cpp
60+
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
61+
GIT_TAG 1b50109f7bea60bd382d8ea7befce3d2bd67da5f) # The latest yaml-cpp commit at the time of writing.
62+
FetchContent_GetProperties(yaml-cpp)
63+
64+
if(NOT yaml-cpp_POPULATED)
65+
message(STATUS "Fetching yaml-cpp...")
66+
FetchContent_Populate(yaml-cpp)
67+
add_subdirectory(${yaml-cpp_SOURCE_DIR} ${yaml-cpp_BINARY_DIR})
68+
endif()
69+
70+
target_link_libraries(YOUR_LIBRARY PUBLIC yaml-cpp::yaml-cpp) # The library or executable that require yaml-cpp library
71+
```
72+
5273
## Recent Releases
5374

5475
[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.

0 commit comments

Comments
 (0)