[CMake] find library for static libraries

Yuri Timenkov yuri at timenkov.ru
Thu Mar 31 23:44:31 EDT 2011


Hi David, Robert,

In my project I used the approach taken from FindBoost:

include(MacroPushRequiredVars)
macro_push_variables(CMAKE_FIND_LIBRARY_SUFFIXES)

if(UNIX AND WITH_MY_LIB_STATIC)
    # Find only static libraries
    set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
endif(UNIX AND WITH_MY_LIB_STATIC)

find_library(MY_LIB NAMES thelibrary ...)

macro_pop_variables(CMAKE_FIND_LIBRARY_SUFFIXES)

Actually this code was written for CMake 2.4 and now there may be more
convenient functions to push/pop vars. The MacroPushRequiredVars is written
by Alexander Neundorf, you can find it with your favorite search engine.

For windows things may be a bit trickier and heavily depend on particular
library architecture.

Regards,
Yuri

On Thu, Mar 31, 2011 at 7:51 PM, David Cole <david.cole at kitware.com> wrote:

> Does:
>
>   find_library(
>     MY_LIB
>     libthelibrary.a
>     PATHS
>   ...
>   )
>
> work?
>
>
> On Thu, Mar 31, 2011 at 11:38 AM, Robert Bielik <robert.bielik at xponaut.se>wrote:
>
>> I'm trying to use find_library to find static (.a) libraries on Mac OS X
>> (cmake 2.8.1). In a lib path I have f.i.:
>>
>> .../lib/libthelibrary.a
>> .../lib/libthelibrary.dylib
>>
>> and with:
>>
>> find_library(
>>   MY_LIB
>>   thelibrary
>>   PATHS
>> ...
>> )
>>
>> it consequently finds only the .dylib ones, whereas I'd like to get hold
>> of the .a ones...
>>
>> How to?
>>
>> TIA
>> /Rob
>>  _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.cmake.org/mailman/listinfo/cmake
>>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110401/764bab2b/attachment.htm>


More information about the CMake mailing list