Skip to content

CMake Unix Makefile: response file variables are not propagated to an app

I've got a toolchain file containing:

# Use response files always
set(CMAKE_ASM_USE_RESPONSE_FILE_FOR_INCLUDES 1)
set(CMAKE_C_USE_RESPONSE_FILE_FOR_INCLUDES 1)
set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES 1)

set(CMAKE_ASM_USE_RESPONSE_FILE_FOR_OBJECTS 1)
set(CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 1)
set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS 1)

set(CMAKE_ASM_USE_RESPONSE_FILE_FOR_LIBRARIES 1)
set(CMAKE_C_USE_RESPONSE_FILE_FOR_LIBRARIES 1)
set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_LIBRARIES 1)

# Ninja requires to be forced for response files
#if ("${CMAKE_GENERATOR}" MATCHES "Ninja")
    set(CMAKE_NINJA_FORCE_RESPONSE_FILE 1 CACHE INTERNAL "") 
#endif()

This is part of the bigger project (application uses add_subdirectory(library), where in library we got toolchain file setting these flags). This above code snippet works nicely with Ninja but it does not with Unix Makefile.

Make reports:

main.cpp.obj
/bin/sh: gcc-arm92020-q2-update/bin/arm-none-eabi-g++.exe: Argument list too long

Generated Makefiles containing Main.cpp.obj rules do not have .rsp (it uses the full commands so they are too long for windows). If I move the above _USE_RESPONSE_FILE to an application as well (keeping it in our toolchain file, and app CMake also sets them, it works.

I can't find much documentation to help me understand what is going on here neither why ninja works (Ninja uses .rsp for main.cpp) and Unix Makefiles do not.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information