Problem with too long dependency file path (.d)

I’m running in a problem with dependency file path which seem to be too long for CMAKE:

example: [4/1995] Building CXX object x_service_server_ServiceRplOnline…neChangeReq_eGetActivePouTypeChangeListReq_SkelDesFac_.cpp.obj

FAILED: x_service_server_ServiceRplOnlineChange.pro/CMakeFiles/x_service_server_ServiceRplOnlineChange.pro.dir/aa5c030395ffb07dc8b198181308a9b1/SvcRplOnlineChangeReq_eGetActivePouTypeChangeListReq_SkelDesFac_.cpp.obj

C:\PROGRA~2\GNU_TO~1\8_2019~1\bin\AR10B2~1.EXE -DARM_CYCLONVSOC -DHW_CHANNEL_ID_A -DOS_CFG_ICC_ENABLE=1 -DOS_CFG_MICROC -DRUN_FROM_RAM -DSSP_RUNTIME_FS -DTARGET_DEVICE_G1 -DTARGET_DEVICE_G1_CPU2 -D_DEBUG -Dsoc_cv_av -IL:/platform/system_framework/X_SFW_DeviceManager/build/target/Batch -IL:/platform/pilz_os/build/target/libraries/armv7a/gcc_header/armv7a-none-eabi/include/c++/8.3.1/backward -IL:/platform/pilz_os/build/target/libraries/armv7a/gcc_header/armv7a-none-eabi/include/c++/8.3.1/arm-none-eabi -IL:/platform/pilz_os/build/target/libraries/armv7a/gcc_header/armv7a-none-eabi/include/c++/8.3.1 -IL:/platform/pilz_os/build/target/libraries/armv7a/gcc_header/lib/gcc/armv7a-none-eabi/8.3.1/include -IL:/platform/pilz_os/build/target/libraries/armv7a/gcc_header/lib/gcc/armv7a-none-eabi/8.3.1/include-fixed -IL:/platform/pilz_os/build/target/libraries/armv7a/gcc_header/armv7a-none-eabi/inconfig -IL:/platform/safetynet/build/default_config -IL:/platform/safetynet/src/snet -march=armv7-a -mtune=cortex-a9 -mfloat-abi=hard -mfpu=neon -ffreestanding -fno-short-enums -nostdinc -g -O2 -fno-strict-aliasing -std=gnu++11 --specs=nosys.specs -MD -MT x_service_server_ServiceRplOnlineChange.pro/CMakeFiles/x_service_server_ServiceRplOnlineChange.pro.dir/aa5c030395ffb07dc8b198181308a9b1/SvcRplOnlineChangeReq_eGetActivePouTypeChangeListReq_SkelDesFac_.cpp.obj -MF x_service_server_ServiceRplOnlineChange.pro\CMakeFiles\x_service_server_ServiceRplOnlineChange.pro.dir\aa5c030395ffb07dc8b198181308a9b1\SvcRplOnlineChangeReq_eGetActivePouTypeChangeListReq_SkelDesFac_.cpp.obj.d -o x_service_server_ServiceRplOnlineChange.pro/CMakeFiles/x_service_server_ServiceRplOnlineChange.pro.dir/aa5c030395ffb07dc8b198181308a9b1/SvcRplOnlineChangeReq_eGetActivePouTypeChangeListReq_SkelDesFac_.cpp.obj -c L:/platform/services/rplonlinechange/ServiceRplOnlineChange/src/SvcRplOnlineChangeReq_eGetActivePouTypeChangeListReq_SkelDesFac_.cpp

L:/platform/services/rplonlinechange/ServiceRplOnlineChange/src/SvcRplOnlineChangeReq_eGetActivePouTypeChangeListReq_SkelDesFac_.cpp:16:1: fatal error: opening dependency file x_service_server_ServiceRplOnlineChange.pro\CMakeFiles\x_service_server_ServiceRplOnlineChange.pro.dir\aa5c030395ffb07dc8b198181308a9b1\SvcRplOnlineChangeReq_eGetActivePouTypeChangeListReq_SkelDesFac_.cpp.obj.d: No such file or directory

Increasing the value of variable “CMAKE_OBJECT_PATH_MAX” and enabling Windows long paths does not solve the problem.

Unfortunately, I have no simple way to reduce the directory structure created by CMAKE.

Is there any way of solving that problem?

This is a known problem, and really annoying to deal with. If you know that the project supports Windows, then developers might have already tried to account for it; but most likely they are at their limit. So, what you wanna do is to start with the shortest path possible, ie. L:/b and hope that it works.

If I’m right Windows Terminal plays nicer with this, so, if you haven’t tried this, maybe try using Windows Terminal after enabling Windows Long Paths. It might help as well.

Whatever tool outputs this needs to learn about long path syntax (\\?\L:\…). Maybe there’s a way to tell CMake that the build directory starts with \\?\ (-B perhaps?) to cause it to generate such paths automatically?