[CMake] Add external static libraries / ar-archives to a build.

Martin Köhler martin.pleissa at web.de
Tue Oct 21 04:54:29 EDT 2008


The libary could be the "wrong" because there are better ones on the system or in order to evalute so performece details I ( and other members of the project ) want to switch the version easily. So its the best way, I think , to do this by changing the command line options and not to search in the cmake cache and change the values there.  An other problem is that the FindBlas tooks an implementation that cause segfaults with my lib ( for example if the matlab blas is chosen) 

regards,
martin

-----Ursprüngliche Nachricht-----
Von: "Mathieu Malaterre" <mathieu.malaterre at gmail.com>
Gesendet: 21.10.08 10:34:16
An: "Martin Köhler" <martin.pleissa at web.de>
CC: CMake <cmake at cmake.org>
Betreff: Re: [CMake] Add external static libraries / ar-archives to a build.

[keep the mail on cmake ml, pls]

On Tue, Oct 21, 2008 at 10:26 AM, Martin Köhler <martin.pleissa at web.de> wrote:
>>Von: "Mathieu Malaterre" <mathieu.malaterre at gmail.com>
>>Gesendet: 21.10.08 10:10:44
>>An: "Martin Köhler" <martin.pleissa at web.de>
>>CC: cmake at cmake.org
>>Betreff: Re: [CMake] Add external static libraries / ar-archives to a build.
>>
>>On Tue, Oct 21, 2008 at 10:06 AM, Martin Köhler <martin.pleissa at web.de> wrote:
>>> Hi,
>>> I'm working on a library to solve sparse linear systems. All basic vector operations are realized by using the BLAS. The FindBLAS works fine but most of the blas implementations are provided as an ar-archive somewhere in the filesystem ( we use a standard blas, ATLAS, GotoBlas or malefactor specific variants). Is it possible to pass the wanted libblas.a as a parameter to cmake and add it to a target?
>>> For example when I want to use  the GotoBLAS  I want to call cmake this way:
>>>  cmake -DBLAS=/path/to/lib/libgoto.a PATH_TO_SOURCE
>>>
>>> If I link the lib manually I enter
>>> gcc -o output myfile.c /path/to/lib/libgoto.a
>>
>>FIND_PACKAGE(BLAS REQUIRED)
>>
>>ADD_EXECUTABLE(output myfile.c)
>>TARGET_LINK_LIBRARIES(output ${BLAS_LIBRARIES})
>>
>
> This way already works fine(I already noticed) but it is not that flexible I need for the project. I need to specify the ar-archive that contain the blas routines myself. The Find_package macro mostly finds the wrong blas that I don't want to use.

I do not understand what you mean. there is no 'wrong' library, cmake
just pick the first one based on your environment. If you have
multiple installation of blas, I do not see how cmake could guess
which one you want.

> In my opinion the best way is to pass the right file as parameter. The cause is that the choose of the blas implementation is very important to solve the problems as fast as possible and so I want an easy way to switch which blas is used.

Either run it via ccmake and changed whatever option is "wrong".
reading the code of FindBLAS.cmake there is apparently a subtle
mechanism which rely on the setting of "BLA_VENDOR", change this value
until you are happy with cmake system inspection (neither did I wrote
this module, nor did I ever used it...)

2cts
-- 
Mathieu



________________________________________________________________________
Schon gehört? Bei WEB.DE gibt' s viele kostenlose Spiele:
http://games.entertainment.web.de/de/entertainment/games/free/index.html



More information about the CMake mailing list