Skip to content

cmake: include path for ggml.h not exported if GGML_BACKEND_DL is set #1467

@SchaichAlonso

Description

@SchaichAlonso

Description

Projects consuming ggml use find_package(ggml) in order to import the ggml::ggml target, which results in the installed version of cmake/ggml-config.cmake.in being processed by cmake.

In order to be able to consume ggml, comsumer source files #include <ggml.h>, which requires the ggml.h to be within an include path passed to the compiler. ggml-config.cmake assures the corresponding path to be passed to the compiler by assigning this path to the INTERFACE_INCLUDE_DIRECTORY cmake property for each installed backend in line 141 of the v0.10.0 version of the file, and each backend is then assigned to the ggml::ggml target in lines 175, 179 and 180.

If, however, the GGML_BACKEND_DL option was enabled when building ggml, lines 143 and 175 will not be processed over the condition in line 128, resulting in ggml::ggml being only ggml::ggml-base, which does not have an INTERFACE_INCLUDE_DIRECTORY property assigned to it.

Expectation

A third party project that was able to import ggml::ggml via find_package(ggml) should be able to use the ggml.h header file without having to search for it explicitly, even if ggml was not installed into a system directory. cmake handles the details as long as it can discover ggml-config.cmake on the system.

Solution

Assign the INTERFACE_INCLUDE_DIRECTORY property to ggml::ggml-base within a context that is independend on GGML_BACKEND_DL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions