[CMake] deleting a cache variable from within CMake script

Philip Lowman philip at yhbt.com
Wed Aug 13 07:55:32 EDT 2008


On Wed, Aug 13, 2008 at 3:50 AM, Yuri V. Timenkov
<ytimenkov at parallels.com>wrote:

> Why not find two libraries always and and then use
> set(${module_uc}_LIBRARY debug ${module_uc}_LIBRARY_DEBUG optimized
> ${module_uc}_LIBRARY_RELEASE)
> This way CMake will use proper libraries for debug and release modes in
> studio.


Finding two libraries would certainly be the simplest approach.  The short
answer to why I would prefer not to do this

1. It's safe to search for "osgd" and then fallback on "osg" for the
_LIBRARY_DEBUG find_library() call on most platforms, but not on MSVC.  On
MSVC if the user links against "osg.lib" with a debug build the only
indication they'll get that things aren't working is when they go to run
their debug executable and it instantly crashes.  This is exactly what will
happen if they don't have the debug libraries installed.

2. I see no reason to clutter the cache with additional _LIBRARY_DEBUG
variables if the user doesn't desire them.

The compromise of setting *_LIBRARY_DEBUG to *_LIBRARY unless the user needs
to selectively link against debug libraries seems to be a reasonable one to
me (otherwise it greatly complicates TARGET_LINK_LIBRARIES())

I can have a control variable that determines whether or not these DEBUG
variables are created in the cache, I just can't find an easy way to delete
them if the user changes their mind after initial configure.


-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20080813/0e97e58a/attachment.htm>


More information about the CMake mailing list