CMake ninja RSP generator for QNX
Hello! I'm using a recent CMake build from the master branch on a Windows host, targetting a QNX 6.6 / ARMv7 platform.
I've got a very large project. The linker command line is very long, which means I have to use a response file. I'm using the ninja generator (the Unix Makefiles generator has additional issues for me). Judging by tests, the QCC compiler requires that the response file contains spaces to separate each flag (this is configurable for Ninja, but not for the Unix Makefiles), and requires a space at the end of the file. If QCC gets a response file without a space at the end, it adds memory garbage to the end of the last linker dependency argument, and generates an error of not being able to find that library. Example error message for libsac: C:\qnx660\host\win32\x86\usr\bin\arm-unknown-nto-qnx6.6.0eabi-ld: cannot find -lsacMzČlć
The QCC compiler is closed source and I have to support its current version, so a fix for this issue is not feasible within QCC. The ninja configuration is flexible enough to support QCC, so there is no issue within ninja itself.
The current CMake ninja-generator code trims all spaces from the ends of lines at the time of writing the ninja script within the cmGlobalNinjaGenerator::WriteVariable function (called from cmGlobalNinjaGenerator::WriteBuild). I see that this is required when writing some ninja variables elsewhere. I would like a workaround be implemented for just the "LINK_LIBRARIES" variable to not be trimmed at this point. By default the link libraries go to the end of the response file as generated by ninja, and if a space is added to the end of this variable within build.ninja, the linking succeeds. Without writing that space to build.ninja, the linking fails as above.
I'm capable of creating a fix within the CMake executable, testing it and contributing it back if needed, but right now I cannot think of a solution that would be acceptable.