This forum has been archived. All content is frozen. Please use KDE Discuss instead.

[SOLVED] Using CMake check result in C++ preprocessor possible?

Tags: None
(comma "," separated)
User avatar
urwald
Registered Member
Posts
30
Karma
0
OS
Hello.

Is it is possible to use the results of the system check made by CMake in the C++ preprocessor?

I want to build a class differently according if the KDE version for which the package is build is >=4.2 or not - writing than in the source code something like this:

#ifdef OLDKDE
[special code for libkde 4.0 and 4.1]
#else
[special code for libkde 4.2 or newer - making use of function not yet available in 4.0/4.1]
#endif

Is CMake able to make the results of it's system check available to the preprocessor in some way - or to do something similar?

Regards.

Tim

Last edited by urwald on Wed Nov 19, 2008 1:04 pm, edited 1 time in total.


urwald, proud to be a member of KDE forums since 2008-Oct.
User avatar
anda_skoa
KDE Developer
Posts
783
Karma
4
OS
You could include kdeversion.h and use KDE_IS_VERSION

for example

Code: Select all
#if KDE_IS_VERSION(4,1,0)
//code for 4.1.0 or later
#else
// code for earlier versions
#endif


Cheers,
_


anda_skoa, proud to be a member of KDE forums since 2008-Oct.
User avatar
urwald
Registered Member
Posts
30
Karma
0
OS
Thanks, that's working fine.

(By the way - for other users interested in this question: http://api.kde.org/4.x-api/kdelibs-apid ... 11efe3b015 has the documentation.)

Last edited by urwald on Wed Nov 26, 2008 11:58 am, edited 1 time in total.


urwald, proud to be a member of KDE forums since 2008-Oct.


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], markhm, rblackwell, sethaaaa, Sogou [Bot], Yahoo [Bot]