2013-04-30 163 views
5

试图让find_path做我想做的事。如何清除/删除缓存变量

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

help.h is found。输出为temmp= /usr/local/toolA

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

foo.shoe不存在(未找到)。输出为temmp= /usr/local/toolA 缓存变量存在,所以变量(temmp)未被改动。

我试着和该清除缓存VAR:

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

没有变化。该变量被清除,但仍然存在。输出为temmp=find_path不运行。)

如何从缓存中删除temmp变量? (我想迫使find_path再次运行。)

回答

9

您可以使用unset

unset(temmp CACHE) 

顺便说一句,在find_path电话应该更像:

find_path(temmp help.h include)