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 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
- Install the development package that provides the headers at the path the config expects.
- Or point CMAKE_PREFIX_PATH at a correct install tree and reconfigure.
apt-get install -y libfoo-dev
cmake -S . -B build -DCMAKE_PREFIX_PATH=/usrRebuild 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.
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.