[CMake] Location of library to be linked changing over time

Philip Lowman philip at yhbt.com
Thu Apr 30 22:21:16 EDT 2009


On Thu, Apr 30, 2009 at 8:41 PM, Bill O'Hara <billtohara at gmail.com> wrote:

> Thanks for the suggestion - a useful trick to have. I'd love an automatic
> way to trigger it though rather than having to run make rebuild_cache or
> thiis unset of the variable.


You could simply do this...

unset(FOO_LIBRARY CACHE)
find_library(FOO ...)

In addition to slowing you down on every configure, this has the unfortunate
side effect, however, of making it impossible for the user to edit the cache
entry from within the CMake cache editor since it will be immediately unset
on the next configure.  This may not be a big issue for you though.

If you needed the ability for users to change cache entries, I suppose you
could use a couple of variables....

find_library(FOO_LIBRARY_OVERRIDE ...)
unset(FOO_LIBRARY_NO_EDIT)
find_library(FOO_LIBRARY_NO_EDIT ...)
mark_as_advanced(FOO_LIBRARY_NO_EDIT)
if(FOO_LIBRARY_OVERRIDE)
   set(FOO_LIBRARY ${FOO_LIBRARY_OVERRIDE})
else()
   set(FOO_LIBRARY ${FOO_LIBRARY_NO_EDIT})
endif()
# link against ${FOO_LIBRARY})


-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090430/01a0f64b/attachment.htm>


More information about the CMake mailing list