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

[CMake] Including as add_subdirectory does not declare the alias target ryml::ryml #173

Closed
cschreib opened this issue Dec 22, 2021 · 1 comment · Fixed by #174
Closed

Comments

@cschreib
Copy link

In CMake, the find_package(ryml) command defines the target ryml::ryml, which is (afaik) the expected format for an imported target. It is good practice to make the library accessible with this name regardless of the method that was used to create the target, so that downstream CMake code does not need to worry about how the target was created/imported; the name should always be ryml::ryml.

Currently, this is not true if rapidyaml is included as a submodule and then add_subdirectory(). This only creates the target ryml. This causes issues:

if (BUILD_RYML)
    add_subdirectory(extern/ryml)
    # defines target 'ryml'
else()
    find_package(ryml)
    # defines target 'ryml::ryml`
endif()

To fix this, I have to add to my own CMake scripts:

add_subdirectory(extern/ryml)
add_library(ryml::ryml ALIAS ryml) # this line needs adding

I believe this should be done by rapidyaml's root CMake file.

@cschreib cschreib changed the title [CMake] Including as add_subdiretory does not declare the alias target ryml::ryml [CMake] Including as add_subdirectory does not declare the alias target ryml::ryml Dec 22, 2021
@biojppm
Copy link
Owner

biojppm commented Dec 22, 2021

Yes, that's a needed improvement.

biojppm added a commit to biojppm/cmake that referenced this issue Dec 22, 2021
biojppm added a commit to biojppm/c4core that referenced this issue Dec 22, 2021
biojppm added a commit that referenced this issue Dec 22, 2021
biojppm added a commit that referenced this issue Dec 23, 2021
[fix] re #173: add alias target ryml::ryml
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

Successfully merging a pull request may close this issue.

2 participants