Skip to content
Latchkey

CMake "imported target ... INTERFACE_INCLUDE_DIRECTORIES ... does not exist" in CI

An imported target records its include path in INTERFACE_INCLUDE_DIRECTORIES. CMake checks that the path exists during generation and errors if it does not, which means the dependency was installed elsewhere or partially.

What this error means

Generation fails after find_package succeeds, complaining that an imported target references a non-existent include directory, often a path baked into a package config from a different machine.

CMake
CMake Error in CMakeLists.txt:
  Imported target "Foo::foo" includes non-existent path

    "/home/builder/foo/include"

  in its INTERFACE_INCLUDE_DIRECTORIES.

Common causes

How to fix it

Install the dependency so its include path exists

  1. Install the development package that provides the headers at the path the config expects.
  2. Or point CMAKE_PREFIX_PATH at a correct install tree and reconfigure.
Terminal
apt-get install -y libfoo-dev
cmake -S . -B build -DCMAKE_PREFIX_PATH=/usr

Rebuild relocatable package configs in the same prefix

If you build the dependency in CI, install it into a prefix you then point CMake at, so the recorded include path matches where the headers actually live.

Terminal
cmake --install dep-build --prefix "$PWD/stage"
cmake -S . -B build -DCMAKE_PREFIX_PATH="$PWD/stage"

How to prevent it

  • Install dependency headers alongside their config files and avoid copying package configs that bake in absolute paths from another machine.

Frequently asked questions

What causes ""INTERFACE_INCLUDE_DIRECTORIES does not exist""?
Generation fails after find_package succeeds, complaining that an imported target references a non-existent include directory, often a path baked into a package config from a different machine.
How do I fix "INTERFACE_INCLUDE_DIRECTORIES does not exist"?
Install the dependency so its include path exists

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card