Problem with find_program, HINTS and ENV

I’m running cmake 3.20.2 on Windows 10 and trying to use find_program to find arm-none-eabi-gcc.exe:

# Find the path of arm-none-eabi-gcc.exe
set (SUFFIX .exe)
set(CMAKE_FIND_DEBUG_MODE TRUE)
find_program(CROSS_GCC_PATH arm-none-eabi-gcc${SUFFIX}
      HINTS "/Program Files (x86)/GNU Arm Embedded Toolchain/10 2021.10/bin"
      #HINTS $ENV{GNU_ARM_TOOLCHAIN_PATH}
      REQUIRED)
set(CMAKE_FIND_DEBUG_MODE FALSE)

Env variable GNU_ARM_TOOLCHAIN_PATH is set as follows:

>set GNU_ARM_TOOLCHAIN_PATH
GNU_ARM_TOOLCHAIN_PATH="/Program Files (x86)/GNU Arm Embedded Toolchain/10 2021.10/bin"

With the code as shown, the compiler is found:

  find_program considered the following locations:

    /Program Files (x86)/GNU Arm Embedded Toolchain/10 2021.10/bin/arm-none-eabi-gcc.exe.com

  The item was found at

    /Program Files (x86)/GNU Arm Embedded Toolchain/10 2021.10/bin/arm-none-eabi-gcc.exe

But if I attempt to use the env variable:

# Find the path of arm-none-eabi-gcc.exe
set (SUFFIX .exe)
set(CMAKE_FIND_DEBUG_MODE TRUE)
find_program(CROSS_GCC_PATH arm-none-eabi-gcc${SUFFIX}
      #HINTS "/Program Files (x86)/GNU Arm Embedded Toolchain/10 2021.10/bin"
      HINTS $ENV{GNU_ARM_TOOLCHAIN_PATH}
      REQUIRED)
set(CMAKE_FIND_DEBUG_MODE FALSE)

Find fails:

  find_program considered the following locations:

    C:/SVNProj/Elysion/trunk/software/prototypes/wdt_interrupt_gnu/Program Files (x86)/GNU Arm Embedded Toolchain/10 2021.10/bin"/arm-none-eabi-gcc.exe.com
    C:/SVNProj/Elysion/trunk/software/prototypes/wdt_interrupt_gnu/Program Files (x86)/GNU Arm Embedded Toolchain/10 2021.10/bin"/arm-none-eabi-gcc.exe
<snip>

It seems that if I use ENV my hint is appended to the current working directory, instead of being used as a root path.

How can I fix this please?

Why didn’t you specify the drive part for the HINT? Without it, this is not an absolute path, so can explain your troubles…

There’s still the oddity of “variable” versus “raw value”. One difference is quoting. Does "$ENV{…}" work?

If I specify the root directory in the env variable, the hint appears not to be used at all.

Quoting didn’t help either, sorry.