[CMake] how to get the version of a library
brice rebsamen
brice.rebsamen at gmail.com
Mon Apr 27 22:12:17 EDT 2009
brice rebsamen wrote:
> Ralf Habacker wrote:
>> brice rebsamen schrieb:
>>> How to know the version of an installed library? My code has #if
>>> macros to handle different APIs. So I would need to get the version
>>> and set 2 variables (MAJOR and MINOR) and pass them to the compiler
>>> (-D).
>>>
>>> To be more precise, I am interested in Player/Stage. One way to get
>>> the version is to run the player executable. Under linux:
>>>
>>> VERSION=`player 2>&1 | grep "Player v" | cut -d' ' -f2`
>>> this gives "v2.2.0". Then
>>> MAJOR=`echo $VERSION | cut -d'.' -f2`
>>> MINOR=`echo $VERSION | cut -d'.' -f3`
>>>
>>> I do not particularly need a solution that would work under windows
>>> at the moment, but that would be a bonus of course.
>> There is a win32 api function for this, see
>> http://msdn.microsoft.com/en-us/library/ms647003.aspx for more
>> informations.
>>
>> Regards
>> Ralf
>>
>
> I am looking for a way to do it with CMake: the information is required
> at compile time because different versions have a different API. How can
> I write a script in CMake that would check the library version at
> configuration time, then either set Makefile variables to be passed to
> the compiler or write some header file to be included in the source?
Anybody? Even if you cannot think of a OS-independent way its fine. I
immediately interested in how to do it under Linux, i.e. how to tell
CMake to run the small script above to retrieve the minor and major of
the player library.
More information about the CMake
mailing list