Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems integrating yaml-cpp into project. Not using find_package? #1330

Open
acampove opened this issue Dec 17, 2024 · 4 comments
Open

Problems integrating yaml-cpp into project. Not using find_package? #1330

acampove opened this issue Dec 17, 2024 · 4 comments

Comments

@acampove
Copy link

Hi,

I am reading this after an hour wasted trying to build my project against yours. I normally do:

find_package(YAML-CPP REQUIRED yaml-cpp)

if (NOT YAML-CPP_FOUND)
...

Which works with all the C++ projects I have ever used in the last 15 years. But you do not seem to do things this way. For some reason you seem to require the user to use FETCHCONTENT. It would be very beneficial for 99% of the people out there, who do not know what FETCHCONTENT is that you update the documentation.

Cheers.

@jbeder
Copy link
Owner

jbeder commented Dec 17, 2024

I'm not sure I understand. Is the documentation you linked to incorrect? If so, happy to update it. Also, happy to update the CMake file if you have a suggestion. I'm not a CMake expert at all, and basically just let people boss me around for whatever's in it.

@ahogen
Copy link

ahogen commented Dec 17, 2024

@acampove you did not indicate whether you are trying to integrate yaml-cpp as a system package dependency or a source/embedded (e.g. git submodule) dependency. You likely know that find_package() is looking for either a Find<package>.cmake or <package>-config.cmake file. This project creates the latter from a template at build time for use when the project is installed or packaged (reference). If you are trying to find a system package and that is failing, consider inspecting and possibly appending to CMAKE_MODULE_PATH.

@jbeder the pattern you have documented is perfectly fine when using the repo as a source dependency. This pattern is commonly documented by other large projects:

In short, imo, what you have now is fine. Maybe could be improved to show how to use find_package when installed from a DEB/RPM package, but I wouldn't remove the existing text.

@acampove
Copy link
Author

I'm not sure I understand. Is the documentation you linked to incorrect? If so, happy to update it. Also, happy to update the CMake file if you have a suggestion. I'm not a CMake expert at all, and basically just let people boss me around for whatever's in it.

Hi,

The documentation should contain:

In order to integrate this project with CMAKE, add the following lines to the CMakeLists.txt

    find_package(YAML-CPP REQUIRED yaml-cpp)
    if (NOT YAML-CPP_FOUND)
        message(FATAL_ERROR "YAML-CPP found ${YAML-CPP_FOUND}")
    endif()

additionally, your cmake needs to define YAML_CPP_VERSION. TLDR, you need a change in the cmake config and another in the documentation.

@jbeder
Copy link
Owner

jbeder commented Dec 18, 2024

@ahogen Does the above text look reasonable? Based on e.g. fmt's documentation you linked to, this would be the "Installed" path? Would it be reasonable to essentially duplicate their three choices?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants