Hi!
I need to define different variables if the project is built with Qt.
How could i define for example:
#ifdef QtBuild
......
.....
#else
.........
#endif
Thanks for the help.
Hi!
I need to define different variables if the project is built with Qt.
How could i define for example:
#ifdef QtBuild
......
.....
#else
.........
#endif
Thanks for the help.
How about passing your own compiler define?
I'm not exactly sure if there's any common compiler preprocessor macro defined in each and every Qt project. Most of the useful defines are defined in <QtGlobal> which you presumably don't want to include to a non-Qt project.
J-P Nurmi
How about using "#ifdef QT_VERSION" ?
QT_VERSION is defined by QtGlobal, so I don't think you can do anything based on that. However, I believe you'll find that Qt defines preprocessor symbols for the various libraries you use, so for example you could use QT_CORE_LIB.
#ifdef QT_CORE_LIB
#include <QtGlobal>
#endif
// now QT_VERSION is defined
I don't really see a problem... If the macro is NOT defined, you know you're NOT using Qt files when compiling this module. Of course if you want to do somehing in a file which doesn't include anything "Qt-ish" but is consolidated with Qt code later on then relying on QtGlobal is not possible. But relying on other Qt-defined macros is possible only when qmake is informed it is to use Qt with the project. So you can't rely on it when compiling (for example) some libraries or modules which will then be used by a Qt-based project. The best choice really is to do what J-P suggested - use a custom macro of your own.
The question was "I need to define different variables if the project is built with Qt."
Part of the problem is defining what "built with Qt" means. I took it at face value, which is to say built with qmake. Do Makefiles generated with qmake define QT_CORE_LIB? If so, you can detect Qt's building system that way. If not, I agree it's useless.
Hi to all!
Yes I mean a project generated with qmake.
Thanks for the help.
Bookmarks