Skip to content

Expose clang resource/include directory through CMake variable #58918

Open
@tristan957

Description

@tristan957

I am using libclang to parse C source files. Given a small program like:

#include <stddef.h>

int main(void)
{
  size_t hello = 5;
  return hello;
}

libclang should report fatal error: 'stddef.h' file not found.

On my system (Fedora 36), the resource directory is located:

$ clang -print-resource-dir
/usr/lib64/clang/14.0.5

Which means the include directory is located at $(clang -print-resource-dir)/include). The clang cmake modules already expose a variable called CLANG_INCLUDE_DIRS, but the only directory exposed in this variable is $CMAKE_INSTALL_PREFIX/include, which isn't helpful for what I need.

Ideally these constants would be exposed in a cross buildsystem way like #9777, but I am willing to settle for just appending to the CLANG_INCLUDE_DIRS array since that should be as little effort as possible to solve what I need.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions