Problems with long path lengths (CMAKE_OBJECT_PATH_MAX errors)

Device: nRF5340

SDK: nRF Connect SDK v2.2.0

IDE: nRF Connect for VS Code v2023.6.345, Running on Windows 10

------------

We are working on a new project for the nRF5340, and I get a lot of errors such as the one below when I try to build:

The object file directory

C:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/build/hci_rpmsg/zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/./

has 245 characters. The maximum full path to an object file is 250
characters (see CMAKE_OBJECT_PATH_MAX). Object file

reset.S.obj

cannot be safely placed under this directory. The build may not work
correctly.

In the above you'll notice that the working directory has a very long path (I obfuscated some of the directory names). I have seen a few other posts in the forum with similar issues, and the main advice seems to be to "make the path shorter". Unfortunately this is not an option for us because of the current structure of our code base.

I did try the following:

1. I followed the link from this post and modified my Windows registry settings. I updated the setting using an admin account and rebooted after making the modification.

2. I added "set(CMAKE_OBJECT_PATH_MAX 512)" to my CMakeLists.txt.

Even after making the above changes, I still see this error.

I do notice that the error is referencing other CMakeLists.txt files from NCS and from Zephyr, and those may not increased max path length. Is there any way that I can make my "set(CMAKE_OBJECT_PATH_MAX 512)" apply globally to all the different CMakeLists.txt?

Is there anything else that I can do here?

Thanks!

Below is the entire build log output (with some directory and files names obfuscated for confidentiality):

 *  Executing task: nRF Connect: Generate config nrf5340dk_nrf5340_cpuapp for c:\git\embedded3\embedded\Nordic123nd45\app\bf755\ncs\extra01234567890\extra01234567890\extra01234567890\extra01234567890\di675_Xb001

Building di675_Xb001
C:\windows\system32\cmd.exe /d /s /c "west build --build-dir c:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/build c:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001 --pristine --board nrf5340dk_nrf5340_cpuapp -- -DNCS_TOOLCHAIN_VERSION:STRING="NONE" -DCONFIG_DEBUG_OPTIMIZATIONS=y -DCONFIG_DEBUG_THREAD_INFO=y -DCONF_FILE:STRING="c:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/prj.conf" -DBOARD_ROOT:STRING="c:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001""

-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: C:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001
-- Found Python3: C:/ncs/toolchains/v2.2.0/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter
-- Cache files will be written to: C:/ncs/v2.2.0/zephyr/.cache
-- Zephyr version: 3.2.99 (C:/ncs/v2.2.0/zephyr)
-- Found west (found suitable version "0.14.0", minimum required is "0.7.1")
-- Board: nrf5340dk_nrf5340_cpuapp
-- Found host-tools: zephyr 0.15.1 (C:/ncs/toolchains/v2.2.0/opt/zephyr-sdk)
-- Found toolchain: zephyr 0.15.1 (C:/ncs/toolchains/v2.2.0/opt/zephyr-sdk)
-- Found Dtc: C:/ncs/toolchains/v2.2.0/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
-- Found BOARD.dts: C:/ncs/v2.2.0/zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340dk_nrf5340_cpuapp.dts
-- Found devicetree overlay: C:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/boards/nrf5340dk_nrf5340_cpuapp.overlay
-- Generated zephyr.dts: C:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/build/zephyr/zephyr.dts
-- Generated devicetree_generated.h: C:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/build/zephyr/include/generated/devicetree_generated.h
-- Including generated dts.cmake file: C:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/build/zephyr/dts.cmake

warning: LOG_DEFAULT_LEVEL (defined at C:/ncs/v2.2.0/nrf\samples/Kconfig:98,
subsys/logging\Kconfig.filtering:13) was assigned the value '2' but got the value ''. Check these
unsatisfied dependencies: (LOG || LOG) (=n). See
LOG_DEFAULT_LEVEL in the menuconfig/guiconfig interface. The Application Development Primer, Setting
Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful
too.


warning: Experimental symbol SPI_SLAVE is enabled.

Parsing C:/ncs/v2.2.0/zephyr/Kconfig
Loaded configuration 'C:/ncs/v2.2.0/zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340dk_nrf5340_cpuapp_defconfig'
Merged configuration 'c:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/prj.conf'
Merged configuration 'C:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/build/zephyr/misc/generated/extra_kconfig_options.conf'
Configuration saved to 'C:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/build/zephyr/.config'
Kconfig header saved to 'C:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/build/zephyr/include/generated/autoconf.h'
-- The C compiler identification is GNU 12.1.0
-- The CXX compiler identification is GNU 12.1.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe

=== child image hci_rpmsg - CPUNET begin ===
loading initial cache file C:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/build/hci_rpmsg/child_image_preload.cmake
Loading Zephyr default modules (Zephyr base).
-- Application: C:/ncs/v2.2.0/zephyr/samples/bluetooth/hci_rpmsg
-- Found Python3: C:/ncs/toolchains/v2.2.0/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter
-- Cache files will be written to: C:/ncs/v2.2.0/zephyr/.cache
-- Zephyr version: 3.2.99 (C:/ncs/v2.2.0/zephyr)
-- Found west (found suitable version "0.14.0", minimum required is "0.7.1")
-- Board: nrf5340dk_nrf5340_cpunet
-- Found host-tools: zephyr 0.15.1 (C:/ncs/toolchains/v2.2.0/opt/zephyr-sdk)
-- Found toolchain: zephyr 0.15.1 (C:/ncs/toolchains/v2.2.0/opt/zephyr-sdk)
-- Found Dtc: C:/ncs/toolchains/v2.2.0/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
-- Found BOARD.dts: C:/ncs/v2.2.0/zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340dk_nrf5340_cpunet.dts
-- Generated zephyr.dts: C:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/build/hci_rpmsg/zephyr/zephyr.dts
-- Generated devicetree_generated.h: C:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/build/hci_rpmsg/zephyr/include/generated/devicetree_generated.h
-- Including generated dts.cmake file: C:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/build/hci_rpmsg/zephyr/dts.cmake
Parsing C:/ncs/v2.2.0/zephyr/Kconfig
Loaded configuration 'C:/ncs/v2.2.0/zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340dk_nrf5340_cpunet_defconfig'
Merged configuration 'C:/ncs/v2.2.0/zephyr/samples/bluetooth/hci_rpmsg/prj.conf'
Merged configuration 'C:/ncs/v2.2.0/nrf/subsys/partition_manager/partition_manager_enabled.conf'
Configuration saved to 'C:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/build/hci_rpmsg/zephyr/.config'
Kconfig header saved to 'C:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/build/hci_rpmsg/zephyr/include/generated/autoconf.h'
-- The C compiler identification is GNU 12.1.0
-- The CXX compiler identification is GNU 12.1.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
-- Build type:  
-- Host:    Windows/AMD64
-- Target:  Generic/arm
-- Machine: arm
-- libmetal version: 1.2.0 (C:/ncs/v2.2.0/zephyr/samples/bluetooth/hci_rpmsg)
-- Looking for include file stdatomic.h
-- Looking for include file stdatomic.h - found
-- open-amp version: 1.2.0 (C:/ncs/v2.2.0/modules/lib/open-amp/open-amp)
-- Host:    Windows/AMD64
-- Target:  Generic/arm
-- Machine: arm
-- C_FLAGS :  -Wall -Wextra
-- Looking for include file fcntl.h
-- Looking for include file fcntl.h - found
-- Configuring done
CMake Warning in ../../../arch/arm/core/aarch32/cortex_m/CMakeLists.txt:
  The object file directory

    C:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/build/hci_rpmsg/zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/./

  has 245 characters.  The maximum full path to an object file is 250
  characters (see CMAKE_OBJECT_PATH_MAX).  Object file

    reset.S.obj

  cannot be safely placed under this directory.  The build may not work
  correctly.


CMake Warning in ../../../arch/arm/core/aarch32/cortex_m/cmse/CMakeLists.txt:
  The object file directory

    C:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/build/hci_rpmsg/zephyr/arch/arch/arm/core/aarch32/cortex_m/cmse/CMakeFiles/arch__arm__core__aarch32__cortex_m__cmse.dir/./

  has 256 characters.  The maximum full path to an object file is 250
  characters (see CMAKE_OBJECT_PATH_MAX).  Object file

    arm_core_cmse.c.obj

  cannot be safely placed under this directory.  The build may not work
  correctly.


CMake Warning in ../../../arch/arm/core/aarch32/mpu/CMakeLists.txt:
  The object file directory

    C:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/build/hci_rpmsg/zephyr/arch/arch/arm/core/aarch32/mpu/CMakeFiles/arch__arm__core__aarch32__mpu.dir/./

  has 235 characters.  The maximum full path to an object file is 250
  characters (see CMAKE_OBJECT_PATH_MAX).  Object file

    arm_core_mpu.c.obj

  cannot be safely placed under this directory.  The build may not work
  correctly.


CMake Warning in ../../../drivers/interrupt_controller/CMakeLists.txt:
  The object file directory

    C:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/build/hci_rpmsg/zephyr/drivers/interrupt_controller/CMakeFiles/drivers__interrupt_controller.dir/./

  has 233 characters.  The maximum full path to an object file is 250
  characters (see CMAKE_OBJECT_PATH_MAX).  Object file

    __/__/misc/empty_file.c.obj

  cannot be safely placed under this directory.  The build may not work
  correctly.


CMake Warning in C:/ncs/v2.2.0/nrf/lib/multithreading_lock/CMakeLists.txt:
  The object file directory

    C:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/build/hci_rpmsg/modules/nrf/lib/multithreading_lock/CMakeFiles/..__nrf__lib__multithreading_lock.dir/./

  has 237 characters.  The maximum full path to an object file is 250
  characters (see CMAKE_OBJECT_PATH_MAX).  Object file

    multithreading_lock.c.obj

  cannot be safely placed under this directory.  The build may not work
  correctly.


CMake Warning in C:/ncs/v2.2.0/nrf/subsys/bluetooth/controller/CMakeLists.txt:
  The object file directory

    C:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/build/hci_rpmsg/modules/nrf/subsys/bluetooth/controller/CMakeFiles/..__nrf__subsys__bluetooth__controller.dir/./

  has 246 characters.  The maximum full path to an object file is 250
  characters (see CMAKE_OBJECT_PATH_MAX).  Object file

    hci_driver.c.obj

  cannot be safely placed under this directory.  The build may not work
  correctly.


CMake Warning in C:/ncs/v2.2.0/nrf/subsys/mpsl/fem/CMakeLists.txt:
  The object file directory

    C:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/build/hci_rpmsg/modules/nrf/subsys/mpsl/fem/CMakeFiles/..__nrf__subsys__mpsl__fem.dir/./

  has 222 characters.  The maximum full path to an object file is 250
  characters (see CMAKE_OBJECT_PATH_MAX).  Object file

    api_init/mpsl_fem_api_init.c.obj

  cannot be safely placed under this directory.  The build may not work
  correctly.


CMake Warning in C:/ncs/v2.2.0/nrf/drivers/mpsl/clock_control/CMakeLists.txt:
  The object file directory

    C:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/build/hci_rpmsg/modules/nrf/drivers/mpsl/clock_control/CMakeFiles/..__nrf__drivers__mpsl__clock_control.dir/./

  has 244 characters.  The maximum full path to an object file is 250
  characters (see CMAKE_OBJECT_PATH_MAX).  Object file

    nrfx_clock_mpsl.c.obj

  cannot be safely placed under this directory.  The build may not work
  correctly.


CMake Warning in ../../../modules/hal_nordic/nrfx/CMakeLists.txt:
  The object file directory

    C:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/build/hci_rpmsg/modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/./

  has 217 characters.  The maximum full path to an object file is 250
  characters (see CMAKE_OBJECT_PATH_MAX).  Object file

    C_/ncs/v2.2.0/modules/hal/nordic/nrfx/drivers/src/nrfx_ipc.c.obj

  cannot be safely placed under this directory.  The build may not work
  correctly.


-- Generating done
-- Build files have been written to: C:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/build/hci_rpmsg
=== child image hci_rpmsg - CPUNET end ===

-- libmetal version: 1.2.0 (C:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001)
-- Build type:  
-- Host:    Windows/AMD64
-- Target:  Generic/arm
-- Machine: arm
-- Looking for include file stdatomic.h
-- Looking for include file stdatomic.h - found
-- open-amp version: 1.2.0 (C:/ncs/v2.2.0/modules/lib/open-amp/open-amp)
-- Host:    Windows/AMD64
-- Target:  Generic/arm
-- Machine: arm
-- C_FLAGS :  -Wall -Wextra
-- Looking for include file fcntl.h
-- Looking for include file fcntl.h - found
-- Configuring done
CMake Error at C:/ncs/v2.2.0/zephyr/cmake/modules/extensions.cmake:418 (add_library):
  Cannot find source file:

    ../../../../...src/ble/zephyr_g12_interface.c
Call Stack (most recent call first):
  C:/ncs/v2.2.0/zephyr/cmake/modules/kernel.cmake:209 (zephyr_library_named)
  C:/ncs/v2.2.0/zephyr/cmake/modules/zephyr_default.cmake:117 (include)
  C:/ncs/v2.2.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
  C:/ncs/v2.2.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
  CMakeLists.txt:23 (find_package)


-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.
FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\v2.2.0\opt\bin\cmake.EXE' '-DWEST_PYTHON=C:\ncs\toolchains\v2.2.0\opt\bin\python.exe' '-Bc:\git\embedded3\embedded\Nordic123nd45\app\bf755\ncs\extra01234567890\extra01234567890\extra01234567890\extra01234567890\di675_Xb001\build' -GNinja -DBOARD=nrf5340dk_nrf5340_cpuapp -DNCS_TOOLCHAIN_VERSION:STRING=NONE -DCONFIG_DEBUG_OPTIMIZATIONS=y -DCONFIG_DEBUG_THREAD_INFO=y -DCONF_FILE:STRING=c:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001/prj.conf -DBOARD_ROOT:STRING=c:/git/embedded3/embedded/Nordic123nd45/app/bf755/ncs/extra01234567890/extra01234567890/extra01234567890/extra01234567890/di675_Xb001 '-Sc:\git\embedded3\embedded\Nordic123nd45\app\bf755\ncs\extra01234567890\extra01234567890\extra01234567890\extra01234567890\di675_Xb001'

 *  The terminal process terminated with exit code: 1.
 *  Terminal will be reused by tasks, press any key to close it.

Related