[CMake] Question about find_library()

Robert Dailey rcdailey at gmail.com
Fri Mar 27 13:26:43 EDT 2009


On Thu, Mar 26, 2009 at 9:55 PM, Philip Lowman <philip at yhbt.com> wrote:

> On Thu, Mar 26, 2009 at 10:23 PM, Robert Dailey <rcdailey at gmail.com>wrote:
>
>> I'm assuming that the macro in question will automatically mark all cache
>> variables as advanced. Is this the case?
>>
>> @Mike Jackson
>> Thank you for this info. I forgot about that function.
>>
>> There seems to be an inconsistency in naming convention. For example, the
>> set() function uses the term INTERNAL to represent a "hidden" cache
>> variable. However, the function mark_as_advanced() is using the term
>> "advanced". What I would like to see is one of the following pairs:
>>
>> set( CACHE ADVANCED )
>> mark_as_advanced()
>>
>>  - OR -
>>
>> set( CACHE INTERNAL )
>> mark_as_internal()
>>
>> Does this make sense, or am I misunderstanding the difference between the
>> two?
>>
>
> You can consider INTERNAL "super advanced".  It won't get shown in the
> cache editor at all.  I think if you want an internal cache variable it
> probably should be created as an INTERNAL.  In general you probably want to
> avoid using INTERNAL unless you really need it.  Think of INTERNAL as a
> friendlier way to use set(...FORCE CACHE).  Basically you're setting a cache
> variable you want to be persistent, but you don't want to confuse the user
> into thinking they have a choice in changing it.
>
> Marking a variable as advanced is more of a discretionary thing.  Generally
> when writing a find module a good rule of thumb is do not mark_as_advanced()
> by default.  Generally, leave the user calling find_package() to do this and
> assume they care about the location of the library.
>

So I've revised my find module a bit to use the recommended function. Let me
know if it looks okay. You may disagree with my mark_as_advanced() calls in
there, however I do not wish to remove them. Thank you for taking the time
to help me out!

include( FindPackageHandleStandardArgs )

find_path( glFont2_INCLUDE_DIR glfont2.h )
find_library( glFont2_LIBRARY NAMES glfont2 )

mark_as_advanced( glFont2_INCLUDE_DIR )
mark_as_advanced( glFont2_LIBRARY )

find_package_handle_standard_args( glFont2 DEFAULT_MSG glFont2_INCLUDE_DIR
glFont2_LIBRARY )

set( glFont2_INCLUDE_DIRS ${glFont2_INCLUDE_DIR} )
set( glFont2_LIBRARY ${glFont2_LIBRARIES} )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090327/1d08986d/attachment.htm>


More information about the CMake mailing list