Cross-compilation - sysroot - pkg_check_modules

I am cross compiling for the Analogue devices ADSP-SC589 Datasheet and Product Info | Analog Devices which ADI provide an SDK for, including a cmake toolchain.

I am cross-compiling a library using autotools and the SDK provided by ADI and installing it in a local directory somewhere. This provides some pkg-config files (.pc) in the local directory. So far so good.

Now, I am trying to cross-compile my own software, which uses the library i mentioned above and a cmake script which uses pkg_check_modules() to import the dependency above.

Now, the cmake toolchain file provided by ADI specifies a SYSROOT. Fair enough. However, when running pkg_check_modules(), cmake adds the sysroot to the include directories and library directories even though the .pc files installed by the third-party library do not.

Then i get an error like “imported target PkgConfig::XXX includes non-existent path <SYSROOT>/<PKCONFIG INCLUDE PATH> in its INTERFACE_INCLUDE_DIRECTORIES …”

How do I tell Cmake not to add SYSROOT paths to pkg-config imported targets ?

I’ve tried

  • set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
  • unset(CMAKE_SYSROOT)

nothing worked