# Cross-compilation - sysroot - pkg\_check\_modules

**URL:** <https://discourse.cmake.org/t/cross-compilation-sysroot-pkg-check-modules/10610>\
**Category:** Code\
**Tags:** os:linux\
**Created:** [April 8, 2024, 2:53pm UTC](https://discourse.cmake.org/t/cross-compilation-sysroot-pkg-check-modules/10610 "2024-04-08T14:53:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter\_Featherstone](https://discourse.cmake.org/user_avatar/discourse.cmake.org/peter_featherstone/32/4279_2.png) [@Peter\_Featherstone](https://discourse.cmake.org/u/Peter_Featherstone)\
**Post date:** [April 8, 2024, 2:53pm UTC](https://discourse.cmake.org/t/cross-compilation-sysroot-pkg-check-modules/10610/1 "2024-04-08T14:53:56Z")

</div>

I am cross compiling for the Analogue devices [ADSP-SC589 Datasheet and Product Info | Analog Devices](https://www.analog.com/en/products/adsp-sc589.html) 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
