17

Trying to get find_path to do what I want.

find_path(temmp include/help.h)
message("temmp= ${temmp}")

help.h is found. The output is temmp= /usr/local/toolA

find_path(temmp include/foo.shoe)
message("temmp= ${temmp}")

foo.shoe does not exist (not found). The output is temmp= /usr/local/toolA The cache variable exists, so the variable (temmp) is untouched.

I try and clear the cache var with this:

set (temmp "" CACHE INTERNAL "")
find_path(temmp include/help.h)
message("temmp= ${temmp}")

No change. The variable is cleared, but still exists. The output is temmp= (find_path does not run.)

How can I delete the temmp variable from the cache? (I want to force the find_path to run again.)

Doug
  • 2,783
  • 6
  • 33
  • 37

1 Answers1

22

You can use unset:

unset(temmp CACHE)

As an aside, the find_path calls should be more like:

find_path(temmp help.h include)
flederwiesel
  • 447
  • 1
  • 9
  • 17
Fraser
  • 74,704
  • 20
  • 238
  • 215
  • Unfortunately this **does NOT work if you have both a *normal-variable* and a *cached-variable* using the same name** (you would be forced to call `unset` yet another time, but without `CACHE` parameter). – Top-Master Jun 17 '21 at 10:21