Skip to content

QNX: Add support for CMAKE_SYSROOT

Stephen Kelly requested to merge steveire/cmake:QNX_CMAKE_SYSROOT into master

QCC is a wrapper around GCC, but it is not a fully transparent wrapper. Some compile options need to be passed to GCC using a -Wc option.

QCC does not support --sysroot, so setting CMAKE_SYSROOT in a toolchain file currently does not work. Override the GCC option for sysroot in the QCC.cmake file with -Wc,-isysroot.

This exposes a further issue in that the QNX SDK does not follow the same architectural folder structure as linux uses. That is, on linux systems, architecture-specific libraries might be in

<sysroot>/usr/lib/<arch>

such as

/usr/lib/x86_64-linux-gnu/libcurl.so

CMake models this by suffixing the onto lib directories when searching for libraries.

The QNX SDK is structured differently such that the should be used as a prefix:

<sysroot>/<arch>/usr/lib

such as

<sysroot>/x86_64/usr/lib/libcurl.so

Add a variable for platform configuration to set whether to prefix or suffix the and set that in the QCC.cmake.

Use the directory structure of the QNX SDK to compute the from the implicit library directories. The assumption is that the arch will be a single directory directly below the CMAKE_SYSROOT, below which the usr/ prefix occurs.

It would not be appropriate to instruct users to make the part of the sysroot when specified in the toolchain file because:

  1. That would be non-DRY - The QCC wrapper already determines the by the -V argument passed to the compiler, specified in the toolchain file as the CMAKE_C_COMPILER_TARGET variable.
  2. The includes in the QNX SDK are not below the directory.

So, the location of the in the full path is different on QNX compared to, say an embedded linux platform, but the intent is the same.

Add documentation to recommend the use of CMAKE_SYSROOT in a QNX toolchain file.

Edited by Brad King

Merge request reports