QNX SDP 8 Compiler flag `-lang-c++` now marked as deprecated

The flag is added because of a CMake bug long ago where CXX=qcc would work even though it should have been rejected. See this commit message. It refers to this commit which introduced the bug.

The commit description refers to having -lang-c++ if qcc is used which is true. Why not have users provide the proper compiler name of q++ where the option is not needed? The option -lang-c was never provided for qcc where that is the default.

I think what also helps, is that today, since QNX 7.0 and later, the compiler only exists as a cross compiler. So a user must always provide a CMake toolchain file. I am suspecting the commit made 11 years ago was trying to cater compiling locally where qcc may have been seen as the default compiler when running on the host nto which is not possible anymore due to lack of support in the gnu toolchain.

Because of CMake’s backwards compatibility guarantees. We made a mistake in qcc support when adding C++ support that allowed qcc to work there…so in order to not break such usage, we continue to do so. We could make a policy to fix it once and for all, but the extra flag is probably less work…but such a patch would probably be welcome (though policies that live at the toolchain level are not “simple”).

Perhaps it was supporting running qcc on QNX itself?

Back in QNX 6.x, you could run self hosted. Then if CMake was also running self hosted I can imagine it finding the CXX as qcc. That was about 10 years ago.

QNX never runs self hosted anymore since 7.0, so whatever is done here will never run in QNX self hosted. So you must provide a toolchain file and there’s no guessing anymore. A toolchain file must do that in the docs so the user could be reasonably expected to already provide the correct compiler name and the correct options.

So like in a previous comment, I don’t think you have to worry about qcc being used for compiling C++.

I have just tried this on a QNX 8 machine with self-hosted tools. CMake first looks for c++, then g++. Since I have both (with c++ being a symlink to g++) this just works. If I want it to use q++ then passing CMAKE_CXX_COMPILER=q++ works.

elahav@meddle:~/src/cmake_example/build$ cmake -DCMAKE_CXX_COMPILER=q++ ..
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- The C compiler identification is QCC 12.2.0
-- The CXX compiler identification is QCC 12.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /system/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /system/bin/q++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (0.3s)
-- Generating done (0.0s)
-- Build files have been written to: /data/home/elahav/src/cmake_example/build
elahav@meddle:~/src/cmake_example/build$ cmake --build . --verbose
Change Dir: '/data/home/elahav/src/cmake_example/build'

Run Build Command(s): /system/local/bin/cmake -E env VERBOSE=1 /system/bin/make -f Makefile
/system/local/bin/cmake -S/data/home/elahav/src/cmake_example -B/data/home/elahav/src/cmake_example/build --check-build-system CMakeFiles/Makefile.cmake 0
/system/local/bin/cmake -E cmake_progress_start /data/home/elahav/src/cmake_example/build/CMakeFiles /data/home/elahav/src/cmake_example/build//CMakeFiles/progress.marks
/system/bin/make  -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/data/home/elahav/src/cmake_example/build'
/system/bin/make  -f CMakeFiles/app.dir/build.make CMakeFiles/app.dir/depend
make[2]: Entering directory '/data/home/elahav/src/cmake_example/build'
cd /data/home/elahav/src/cmake_example/build && /system/local/bin/cmake -E cmake_depends "Unix Makefiles" /data/home/elahav/src/cmake_example /data/home/elahav/src/cmake_example /data/home/elahav/src/cmake_example/build /data/home/elahav/src/cmake_example/build /data/home/elahav/src/cmake_example/build/CMakeFiles/app.dir/DependInfo.cmake "--color="
make[2]: Leaving directory '/data/home/elahav/src/cmake_example/build'
/system/bin/make  -f CMakeFiles/app.dir/build.make CMakeFiles/app.dir/build
make[2]: Entering directory '/data/home/elahav/src/cmake_example/build'
[-150%] Building CXX object CMakeFiles/app.dir/main.cc.o
/system/bin/q++    -Wp,-MD,CMakeFiles/app.dir/main.cc.o.d -Wp,-MT,CMakeFiles/app.dir/main.cc.o -Wp,-MF,CMakeFiles/app.dir/main.cc.o.d -o CMakeFiles/app.dir/main.cc.o -c /data/home/elahav/src/cmake_example/main.cc
[-150%] Linking CXX executable app
/system/local/bin/cmake -E cmake_link_script CMakeFiles/app.dir/link.txt --verbose=1
/system/bin/q++ CMakeFiles/app.dir/main.cc.o -o app 
make[2]: Leaving directory '/data/home/elahav/src/cmake_example/build'
[-150%] Built target app
make[1]: Leaving directory '/data/home/elahav/src/cmake_example/build'
/system/local/bin/cmake -E cmake_progress_start /data/home/elahav/src/cmake_example/build/CMakeFiles 0
elahav@meddle:~/src/cmake_example/build$ ./app 
Hello World!