2013-04-30 164 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)