I've added the yaml-cpp
git repository as a submodule and add it to my CMake project using add_subdirectory
.
Everything's fine but I have to set YAML_CPP_INCLUDE_DIR
and YAML_CPP_LIBRARIES
manually to use them for my own targets.
Because there is a file yaml-cpp-config.cmake
(generated in the build folder) setting these variables I tried to just include it:
include("${CMAKE_BINARY_DIR}/yaml-cpp/yaml-cpp-config.cmake")
but then I get:
CMake Error at /bla/bla/build/yaml-cpp/yaml-cpp-config.cmake:11 (include):
The file
/bla/bla/aml-cpp/yaml-cpp-targets.cmake
was generated by the export() command. It may not be used as the argument
to the include() command. Use ALIAS targets instead to refer to targets by
alternative names.
I really don't understand this message. How would I provide my targets with the yaml-cpp
include directories and libraries without having to set a hard coded variable?
I'm not searching for a way to correctly include()
the file in case it doesn't have to be done. I'm just interested in how I should provide the desired information to my targets.
Unfortunately yaml-cpp
seems to not make use of target_include_directories()
which would set the include directories automatically where needed.