Le 15 juin 2014 à 20:19, Nils Gladitz <nilsglad...@gmail.com> a écrit :

> On 15.06.2014 19:33, Lucas Soltic wrote:
>> 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 :)
>> 
> 
> Perhaps you could use distinct cache variables for static and shared 
> libraries.
> 
> e.g.
> 
> find_library(FOO_STATIC_LIBRARY ...)
> find_library(FOO_SHARED_LIBRARY ...)
> 
> set(FOO_LIBRARIES "")
> 
> if(FOO_LINK_STATIC)
>    list(APPEND FOO_LIBRARIES ${FOO_STATIC_LIBRARY})
> else()
>    list(APPEND FOO_LIBRARIES ${FOO_SHARED_LIBRARY})
> endif()
> 
> Nils

Oh my… really interesting idea! Thanks!!

Lucas
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to