yaml-cpp icon indicating copy to clipboard operation
yaml-cpp copied to clipboard

CMake Export Error When Including yaml-cpp as a Subdirectory in a Project

Open lkersting opened this issue 6 years ago • 4 comments

I have a project that includes yaml-cpp as a subdirectory in my project and uses it as a public dependency to one of my libraries. After the new CMake changes I get the following error:

CMake Error: install(EXPORT "${PROJECT_NAME}Targets" ...) includes target "${TARGET}" which requires target "yaml-cpp" that is not in the export set.

It worked with the previous version before yaml-cpp-targets was exported by CMake. Now on line 129 of the top level CMakeLists.txt file you only export yaml-cpp-targets if YAML_CPP_INSTALL=ON. The problem is that YAML_CPP_INSTALL is turned off when yaml-cpp is built as a subdirectory.

I tried SET(YAML_CPP_INSTALL ON CACHE INTERNAL "") and it still did not turn YAML_CPP_INSTALL on.

There should be a way to enable generation of the yaml-cpp install targets when it is included as a subdirectory in another project.

lkersting avatar Dec 05 '19 19:12 lkersting

I have the same problem.

nicolamos avatar Feb 25 '20 22:02 nicolamos

I am currently having the same issue. YAML_CPP_INSTALL should not be defined with a cmake_dependent_option, because it does not allow for cached values to be used from parent projects, as far as I can tell.

nickelsey avatar Mar 03 '20 03:03 nickelsey

This is holding us back from using the master, we are adding yaml-cpp via external-project-add, what is the correct solution here ?

HarryDC avatar Jun 04 '20 13:06 HarryDC

I just hit this as well with the new version .0.7.0 due to making it a cmake_dependent_option

jasonbeach avatar Jul 15 '21 18:07 jasonbeach