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

Exported target is missing the export() command #53

Closed
cschreib opened this issue Dec 26, 2021 · 0 comments · Fixed by #55
Closed

Exported target is missing the export() command #53

cschreib opened this issue Dec 26, 2021 · 0 comments · Fixed by #55

Comments

@cschreib
Copy link
Contributor

The c4 CMake scripts automatically take care of creating the CMake config files. Based on my (ever incomplete) understanding of CMake, I think that somewhere in this process there is a missing export(). I have seen it done in other libraries (fmtlib, pugixml, etc.)

For example, in c4Project.cmake:

    #
    # cfg_dst is the path relative to install root where the export
    # should be installed; cfg_dst_rel is the path from there to
    # the install root
    macro(__c4_install_exports cfg_dst cfg_dst_rel)
        # make sure that different exports are staged in different directories
        set(case ${CMAKE_CURRENT_BINARY_DIR}/export_cases/${cfg_dst})
        file(MAKE_DIRECTORY ${case})
        #
        install(EXPORT "${_TARGET}"
            FILE "${targets_file}"
            NAMESPACE "${_NAMESPACE}"
            DESTINATION "${cfg_dst}")
        export(EXPORT "${_TARGET}")  # <---- this line is missing
        #...

Without it, if I use rapidyaml in a library of my own and want to create an install target for my library, with exports, CMake currently complains that

CMake Error in CMakeLists.txt:
  export called with target "mylib" which requires target "rapidyaml" that is not
  in any export set.

This error is fixed by adding the export() command as above. I'm happy to create a PR to suggest the modification, but I don't know if there's perhaps a better place to do this within the c4 scripts.

biojppm added a commit to biojppm/cmake that referenced this issue Dec 26, 2021
biojppm added a commit that referenced this issue Dec 26, 2021
biojppm added a commit that referenced this issue Dec 26, 2021
biojppm added a commit to biojppm/rapidyaml that referenced this issue Dec 26, 2021
biojppm added a commit to biojppm/rapidyaml that referenced this issue Dec 27, 2021
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.

1 participant