[Moved] Q_EXPORT_PLUGIN2 and variables in TARGET
-
The documentation states:
@
Q_EXPORT_PLUGIN2 ( PluginName, ClassName )
@bq. This macro exports the plugin class ClassName for the plugin specified by PluginName. The value of PluginName should correspond to the TARGET specified in the plugin's project file.
However my TARGET contains variables like the architecture or debug/release mode.
Is there anyway to handle this through $$qtLibraryTarget() or #ifdef ?[EDIT: fixed formatting, Volker]
-
qmake's variables are not available in the C++ preprocessor. You can define a macro in the qmake project file and export this to the precprocessor (just as -D on the command line would do). #ifdef is also an option.
EDIT: moved to the Tools forum, as it's more a qmake issue.
-
Thanks for the format fix, and sorry if I posted in the wrong section.
You say #ifdef is a solution, but is the Q_EXPORT_PLUGIN2 expanded when I run qmake on my pro file, or when moc'ing with visual studio? -
It's a regular preprocessor macro, so it's expanded at compile time. It's possible that moc also recognizes it and generates some code.
qmake does not expand the macros in the code; in fact you can create Qt projects without qmake (eg. with CMake or write the Makefiles manually).
-
It is strange that this macro looks like it's not using the PLUGIN var:
@# define Q_EXPORT_PLUGIN2(PLUGIN, PLUGINCLASS)
Q_PLUGIN_VERIFICATION_DATA
Q_EXTERN_C Q_DECL_EXPORT
const char * Q_STANDARD_CALL qt_plugin_query_verification_data()
{ return qt_plugin_verification_data; }
Q_EXTERN_C Q_DECL_EXPORT QT_PREPEND_NAMESPACE(QObject) * Q_STANDARD_CALL qt_plugin_instance()
Q_PLUGIN_INSTANCE(PLUGINCLASS)@