ninja command line too long

I am getting a The command line is too long. error when building on Windows using CMake 3.20.0 and Ninja 1.10.2.
I have tried the answer for cmake-command-line-too-long-windows, but it did not work.
The actual command that is failing is the archiver:

cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E rm -f path\to\mylib.a && C:\ti\ccs1010\ccs\tools\compiler\ti-cgt-arm_20.2.1.LTS\bin\armar.exe qr path\to\mylib.a <a-bunch-of-obj-files> && cd ."

I’m wondering if this is a bug (or lacking feature) of CMake where it needs to support using response files for archiving?
Is there a workaround or solution for this?

It looks like you’re might be using a custom toolchain. There are some variables you can use to indicate that your compiler does support them. From a grep:


If you’re not using a custom toolchain, CMake’s TI support might need updated if the compiler/linker does support response files now in different configurations. Please file an issue if that is the case.

Ahh, ok, so this is really an issue with the TI compiler? I did notice that the TI.cmake mentioned # After the --run_linker flag a response file is not possible. I guess I didn’t realize that response files were a compiler-specific feature; I thought it was a Ninja-specific feature.

I guess for the time being, the workaround I’ve found is to just split my target into multiple targets to reduce the command line length.

Ninja has support for making them, but the tool itself needs to provide the core logic for them. Splitting your libraries up can be suitable (though not always possible depending on the API you plan on providing).

I am having a similar issue, so using Ninja, TI C2000 compiler. Everything is fine on Darwin, Linux, and indeed on Windows when the path is short enough, but when the path increases the number of include-path directives creates a too long command line for Windows. I then tried forcing response files CMAKE_NINJA_FORCE_RESPONSE_FILE and CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS and CMAKE_C_USE_RESPONSE_FILE_FOR_INCLUDES all TRUE, and various combinations of this, and get to the situation where most files build, but when the response file line length exceeds roughly 7054 characters, the compiler command fails.
I wonder if there is some need to recognise the compiler response file length limitation in the toolchain on windows and either split the command into multiple response files?

Response files are to get around length limits…

IIRC, we are using Ninja’s built-in rspfile feature and teaching it about limits would be an interesting exercise.