Skip to content

export( should not be scoped by FMT_INSTALL #4806

Description

@Krzmbrzl

Currently the export(...) cmake directive is scoped inside if (FMT_INSTALL):

fmt/CMakeLists.txt

Lines 496 to 499 in 11ddbcb

export(
TARGETS ${INSTALL_TARGETS}
NAMESPACE fmt::
FILE ${PROJECT_BINARY_DIR}/${targets_export_name}.cmake)

However, there are cases in which downstream projects might not want to install fmt but might still want to provide a export(...) themselves. However, this is impossible to do when depending on another target that doesn't export itself. CMake will error with something like

CMake Error: export("MyLibTargets" ...) includes target "mylib" which requires target "fmt" that is not in any export set.

Since having the exported target files in the build tree don't harm anyone, I suggest just unconditionally exporting regardless of whether FMT_INSTALL is true or not.

See also e.g. Kistler-Group/sdbus-cpp#523

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions