You’re relying on the version of the compiler, which on QNX 7.1 reports (CMake 3.22.1, CMake 4.1.0-rc4-g6845fa6):
CMAKE_CXX_COMPILER_VERSION = 8.3.0
On QNX 8.0, reports:
CMAKE_CXX_COMPILER_VERSION = 12.2.0
Please don’t do this for detecting the version of QNX. QNX can allow other compilers, not just GCC (qcc is a front-end wrapper, that might call GCC backend, or LLVM, or ICC, etc.).
My scripts used the variable CMAKE_SYSTEM_VERSION
. This matches the description of the Operating system version we’re building for (e.g. 7.1.0 or 8.0.0).
Normally this variable isn’t set at all in my tests.
To get the CMAKE_SYSTEM_VERSION
is a little tricky, it’s found in my repo at code.research/cmake/modules/research/qnx.cmake at c3cdd2e59c3fadb53218eccbf5da1f00a67ee6b9 · jcurl/code.research · GitHub
i.e. on 7.1.0 and earlier, it’s defined in the headers as _NTO_VERSION
. On QNX 8.0 and later, it’s defined in the headers as __QNX__
.