I’m testing my CMake project (v3.16 to support at least Ubuntu 20.04 LTS and later). With QNX8, there are new warnings saying that “cc: warning - lang-c++ is deprecated”.
This is documented by QNX at QNX Momentics IDE, which says:
“In addition, projects that use -lang-c++ should use -x c++ instead.”
I don’t seem to be able to modify the behaviour of the variable CMAKE_CXX_COMPILE_OBJECT
or CMAKE_CXX_LINK_EXECUTABLE
in a toolchain file (it appears to be ignored).
string(REPLACE "<CMAKE_CXX_COMPILER> -lang-c++" "<CMAKE_CXX_COMPILER> -xc++" CMAKE_CXX_COMPILE_OBJECT ${CMAKE_CXX_COMPILE_OBJECT})
string(REPLACE "<CMAKE_CXX_COMPILER> -lang-c++" "<CMAKE_CXX_COMPILER>" CMAKE_CXX_LINK_EXECUTABLE ${CMAKE_CXX_LINK_EXECUTABLE})
Seeing the file Modules/Compiler/QCC-CXX.cmake
and modifying it there does fix the warning.
I could do a string replace, but my concern here is that if it is deprecated in QNX 8.0, what if a newer version of QNX makes this an error?
Is there a best practice, or a recommended way to write a toolchain file to properly handle this, that would be considered portable from CMake 3.16 and later?
My toolchain file for now contains (works with QNX 7.1 and QNX 8)
set(CMAKE_SYSTEM_NAME QNX)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(arch gcc_ntoaarch64le)
set(CMAKE_C_COMPILER qcc)
set(CMAKE_C_COMPILER_TARGET ${arch})
set(CMAKE_CXX_COMPILER q++)
set(CMAKE_CXX_COMPILER_TARGET ${arch})
The docs to use QCC
is not correct, as the qnxsdp-env.sh
doesn’t expose that on the path. But it does qcc
and q++
.