[CMake] find_library and caching

Lucas Soltic lucas.soltic at orange.fr
Sun Jun 15 13:33:33 EDT 2014


Hello,

I use a FindSomeLib.cmake script for my project, for which there is a variable (let's call it LINK_STATIC) to define if one wants to link 	against SomeLib statically. The default is to look for dynamic libraries.

The issue is that when first running CMake's configure, the user may have forgotten to set LINK_STATIC, so the script finds the dynamic version of SomeLib and set a cache entry for it. Then in CMake's GUI the user realizes he wants static linking so he sets the LINK_STATIC flag, but at this point find_library has already cached the result and won't look again for static version of SomeLib.

This ends up with the user thinking he's using static linking, which is not what's happening.
I saw in CMake's doc that in order to let find_library search again, I'd need to clear the library entry it has found. But if I do this at each CMake configure run, it removes the interest of the cache.

Would anyone know about the preferred way to fix this caching issue?
I would be really grateful :)

Thanks,
Lucas


More information about the CMake mailing list