[CMake] Re: FIND_LIBRARY force?

Miguel A. Figueroa-Villanueva miguelf at ieee.org
Tue Jun 6 19:35:52 EDT 2006


On 6/5/06, Miguel A. Figueroa-Villanueva <miguelf at ieee.org> wrote:
> Hello,
>
> If I have a FIND_LIBRARY entry that depends on a variable, such as LIB_DIR here:
>
> FIND_LIBRARY(XXX_LIB lib_name ${LIB_DIR}/lib)
>
> How can I force the FIND_LIBRARY to run again upon changing the
> LIB_DIR value. Regularly it won't do it because there is a XXX_LIB
> entry for it already in the cache, right?

Well, It seems I found a solution to this... I post here for whoever
is interested, but I also would welcome feedback about it, specially
from the cmake gurus on whether or not I'm doing things right.

I set an INTERNAL CACHE entry OLD_LIB_DIR to store the LIB_DIR value.
Then if LIB_DIR changes I set the XXX library that had a
LIB_DIR-dependent path to "XXX-NOTFOUND". The assumption (which
obviously is working for me here) is that if the value of the library
variable is its variable name plus a "-NOTFOUND" tag appended to it
then FIND_LIBRARY tries to find it again when cmake is rerun. Is this
right?

Below the code that I'm using.

Thanks, Miguel
--
FIND_PATH(LIB_DIR ...)

IF( NOT OLD_LIB_DIR STREQUAL LIB_DIR )
  SET(OLD_LIB_DIR ${LIB_DIR} CACHE INTERNAL "Previous value for LIB_DIR")
  SET(XXX_LIB "XXX_LIB-NOTFOUND" CACHE FILEPATH "Cleared." FORCE)
ENDIF( NOT OLD_LIB_DIR STREQUAL LIB_DIR )

FIND_LIBRARY(XXX_LIB lib_name ${LIB_DIR})


More information about the CMake mailing list