yaml-cpp: Cannot find headers (and libraries) as CMake variables are unset

Hello,

as per issue title, I’m having a problem when I try to use yaml-cpp in a project I’m working on. Namely, the compiler can’t find header files (but I suppose the same will go for libraries) when I try to compile.

This is due to the fact that the file used by CMake to set the paths of include and link directories does not set the proper values for the variables. The content of share/cmake/yaml-cpp/yaml-cpp-config.cmake after installation is;:

# - Config file for the yaml-cpp package
# It defines the following variables
#  YAML_CPP_INCLUDE_DIR - include directory
#  YAML_CPP_LIBRARIES    - libraries to link against

# Compute paths
get_filename_component(YAML_CPP_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(YAML_CPP_INCLUDE_DIR "")

# Our library dependencies (contains definitions for IMPORTED targets)
include("${YAML_CPP_CMAKE_DIR}/yaml-cpp-targets.cmake")

# These are IMPORTED targets created by yaml-cpp-targets.cmake
set(YAML_CPP_LIBRARIES "")

As you can see, the variables YAML_INCLUDE_DIR and YAML_CPP_LIBRARIES are empty. I believe the problem may lie in the input file yaml-cpp-config.cmake.in:

# - Config file for the yaml-cpp package
# It defines the following variables
#  YAML_CPP_INCLUDE_DIR - include directory
#  YAML_CPP_LIBRARIES    - libraries to link against

# Compute paths
get_filename_component(YAML_CPP_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(YAML_CPP_INCLUDE_DIR "@CONFIG_INCLUDE_DIRS@")

# Our library dependencies (contains definitions for IMPORTED targets)
include("${YAML_CPP_CMAKE_DIR}/yaml-cpp-targets.cmake")

# These are IMPORTED targets created by yaml-cpp-targets.cmake
set(YAML_CPP_LIBRARIES "@EXPORT_TARGETS@")

Indeed, grep-ing for CONFIG_INCLUDE_DIRS or EXPORT_TARGETS yields no results in the whole repository, so substitution should give an empty string.

Am I missing something?

Thanks!

mattia

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 9
  • Comments: 21 (3 by maintainers)

Commits related to this issue

Most upvoted comments

My approach is to fix the issue by setting the environtment value and manually changing the cmake file

export YAML_CPP_INCLUDE_DIR=/usr/include/yaml-cpp

CMakeLists.txt

# Add YAML CPP
include_directories ($ENV{YAML_CPP_INCLUDE_DIR})

Same problem on debian bullseye with 0.7.0. In the meantime, I stick to using version 0.6.x from a debian package.

Also came across the smae issue, after running make install, I found the yaml-cpp-config.cmake like this"

# - Config file for the yaml-cpp package
# It defines the following variables
#  YAML_CPP_INCLUDE_DIR - include directory
#  YAML_CPP_LIBRARIES    - libraries to link against

# Compute paths
get_filename_component(YAML_CPP_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(YAML_CPP_INCLUDE_DIR "")

# Our library dependencies (contains definitions for IMPORTED targets)
include("${YAML_CPP_CMAKE_DIR}/yaml-cpp-targets.cmake")

# These are IMPORTED targets created by yaml-cpp-targets.cmake
set(YAML_CPP_LIBRARIES "")

I don’t know why the YAML_CPP_INCLUDE_DIR and YAML_CPP_LIBRARIES are empty.