[CMake] 'uncaching' a path found by the find_XXX functions

Michael Wild themiwi at gmail.com
Thu Apr 14 06:52:02 EDT 2011


On 04/14/2011 12:46 PM, J.S. van Bethlehem wrote:
> Dear users,
> 
> As a new user CMake I've come across some things I don't fully
> understand yet. Here is such a thing:
> When a library consists of multiple separate lib-files, from the
> archives it seems that the way to go when writing a 'Find'-module for
> such a library, say library LIB, is first find each lib-file separately:
> find_library(${LIB1_PATH} ${LIB1} ${SEARCH_PATH})
> find_library(${LIB2_PATH} ${LIB2} ${SEARCH_PATH})
> etc.
> Then, when each of these were successfully found, do:
> set(LIB_LIBRARIES ${LIB1_PATH} ${LIB2_PATH} [other library files] )
> 
> But now I want LIB_LIBRARIES do become cached - that can be done with
> the CACHE option. But I also want the ${LIBX_PATH} variables NOT to be
> cached. How do I accomplish that? And is this indeed the right way to go
> with CMake?
> 
> Yours sincerely,
> Jakob van Bethlehem

Wrong, you never cache the XXX_LIBRARIES and XXX_INCLUDE_DIRS variables
and leave the XXX_LIBRARY and XXX_INCLUDE_DIR variables cached. The
former is for the use in the calling CMakeLists.txt file, while the
latter are to be modified by your user in the CMakeCache.txt file. If
you "uncached" them (why, by the way?), they wouldn't survive a
re-configure and your user wouldn't have a chance to specify a different
location.

For more information, read the Modules/readme.txt file in your CMake
installation.

Michael


More information about the CMake mailing list