# Problem with find\_program, HINTS and ENV

**URL:** https://discourse.cmake.org/t/problem-with-find-program-hints-and-env/4794
**Category:** Usage
**Created:** [January 7, 2022, 12:06pm UTC](https://discourse.cmake.org/t/problem-with-find-program-hints-and-env/4794 "2022-01-07T12:06:48Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![DavidA](https://discourse.cmake.org/user_avatar/discourse.cmake.org/davida/32/128_2.png) [@DavidA](https://discourse.cmake.org/u/DavidA)
#### Post date: [January 7, 2022, 12:06pm UTC](https://discourse.cmake.org/t/problem-with-find-program-hints-and-env/4794/1 "2022-01-07T12:06:49Z")

</div>

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

```auto
# 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:

```auto
>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:

```auto
  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:

```auto
# 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:

```auto
  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?

---

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [January 7, 2022, 12:59pm UTC](https://discourse.cmake.org/t/problem-with-find-program-hints-and-env/4794/2 "2022-01-07T12:59:29Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [January 7, 2022, 1:19pm UTC](https://discourse.cmake.org/t/problem-with-find-program-hints-and-env/4794/3 "2022-01-07T13:19:53Z")

</div>

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

---

<div class="post-metadata">

### Author: ![DavidA](https://discourse.cmake.org/user_avatar/discourse.cmake.org/davida/32/128_2.png) [@DavidA](https://discourse.cmake.org/u/DavidA)
#### Post date: [January 7, 2022, 2:28pm UTC](https://discourse.cmake.org/t/problem-with-find-program-hints-and-env/4794/4 "2022-01-07T14:28:44Z")

</div>

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.
