# usage of CMAKE\_SYSROOT and CMAKE\_INSTALL\_PREFIX when cross-compiling

**URL:** https://discourse.cmake.org/t/usage-of-cmake-sysroot-and-cmake-install-prefix-when-cross-compiling/1460
**Category:** Usage
**Created:** [June 29, 2020, 9:33pm UTC](https://discourse.cmake.org/t/usage-of-cmake-sysroot-and-cmake-install-prefix-when-cross-compiling/1460 "2020-06-29T21:33:40Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Stefan\_Seefeld](https://discourse.cmake.org/user_avatar/discourse.cmake.org/stefan_seefeld/32/714_2.png) [@Stefan\_Seefeld](https://discourse.cmake.org/u/Stefan_Seefeld)
#### Post date: [June 29, 2020, 9:33pm UTC](https://discourse.cmake.org/t/usage-of-cmake-sysroot-and-cmake-install-prefix-when-cross-compiling/1460/1 "2020-06-29T21:33:40Z")

</div>

I’m trying to build packages for a cross-build environment (QNX), and I’m slightly confused by the use of the CMAKE\_SYSROOT and CMAKE\_INSTALL\_PREFIX variables.  
I would expect my generated (debian) package to contain installed files somewhere under  
`<sysroot>/<prefix>/`, but it doesn’t seem like the `CMAKE_SYSROOT` variable is being used during packaging. For simple files I can of course define the `CMAKE_INSTALL_PREFIX` variable to incorporate the sysroot, but I expect a number of cases where that would result in the wrong behaviour.  
Notably, the install prefix is often built into the generated executables to look up runtime resources. The sysroot should never be exposed to the runtime environment, as it only has meaning as part of the SDK. To take a specific example, the RPATH can conveniently be generated from the `CMAKE_INSTALL_PREFIX`, but that approach would obviously fail if the latter were to include the sysroot.

So, what is the right way to build SDK packages to be used in a cross-compilation environment with CMake ?

Thanks,
