Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cmake command line too long windows

Tags:

windows

cmake

From my understanding of cmake, the tool takes care of file path and command lines length to avoid reaching windows limitation of 8191 characters.

However I'm cross compiling with arm_none_eabi on windows and cmake doesn't generate a makefile using response files or any other workaround for the path length. Thus the link step fails.

Here is the generated makefile line that causes issue

XXXXX_EXTERNAL_OBJECTS =
XXXX_OBJECTS = \
"file1.c.obj" \
"file2.c.obj" \
"file3.c.obj" \
"fileXX.c.obj" \

C:/YYYY/GNU_Tools_ARM_Embedded/6-2016-q4-major/bin/arm-none-eabi-gcc.exe  -mcpu=cortex-m4  -mthumb -DSTM32L4__xx -mfloat-abi=softfp -DXXXX -O0 -g -Wfatal-errors -Wall -Wno-unused-function -std=c99 -fdata-sections -ffunction-sections  -mcpu=cortex-m4  -march=armv7e-m -O0 -g --specs=nano.specs -mthumb -Wl,--gc-sections -nostartfiles -Wl,[email protected] -TC:SSSSSSSSS/STM32L4__RGTx_FLASH.ld $(XXXX_OBJECTS) $(XXXXX_EXTERNAL_OBJECTS)  -o outHexFile_XXXX  -LC:/YYYYYYYYYYYYYYYY/arm-nano-eabi/lib

The final line length is about 23000 characters (far over 8191).

Why is Cmake not generating a makefile usable by windows ? Is this only because I am cross-compiling ? What can I do to avoid this issue ?

EDIT

Generator is GNU Makefiles

CMake Version 3.7.2

EDIT 2

this may be automatically handled in future versions

submited bug

like image 815
Julien Avatar asked Apr 03 '17 12:04

Julien


1 Answers

Turning my comment into an answer

I had the same problem with the command line length and could solve it with adding the following "use response file" settings to my toolchain file:

SET(CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 1)
SET(CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS 1)

SET(CMAKE_C_RESPONSE_FILE_LINK_FLAG "@")
SET(CMAKE_CXX_RESPONSE_FILE_LINK_FLAG "@")

And if you would have had used ninja you would need an additional:

SET(CMAKE_NINJA_FORCE_RESPONSE_FILE 1 CACHE INTERNAL "")
like image 128
Florian Avatar answered Sep 18 '22 21:09

Florian