Skip to content

Exported target is missing the export() command #53

@cschreib

Description

@cschreib

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions