[CMake] Inconsistent dll linkage under Windows

Bill Hoffman bill.hoffman at kitware.com
Mon May 14 11:59:53 EDT 2007


Nic wrote:
> Hello,
>   I'm actually using Qt with CMake and becoming pretty mad with it :)
> I'm trying to compile a custom widget as a plugin for Designer, i.e as 
> dll
> for the designer.
> For all tries I made for my CMakeLists I get the same result:
> "warning C4273: 'staticMetaObject' : inconsistent dll linkage"
>
> Seems that there is a problem specific to windows, for which we have to
> define an export macro for dlls. I currently use QDESIGNER_WIDGET_EXPORT
> macro defined by Qt.
> Does anyone had similar problems ?
So, from here we can see what the macro is:

http://www.koders.com/c/fid1986F1BE870743CAF0EB82CDD3534640EE771CB3.aspx

When building your plugin you need to make sure this is defined:

QDESIGNER_EXPORT_WIDGETS <javascript:searchRef('QDESIGNER_EXPORT_WIDGETS')>

When using it you need to make sure it is not defined.
So, you need to see:
http://www.cmake.org/HTML/Documentation.html
SET_TARGET_PROPERTIES, and specifically this part:

"DEFINE_SYMBOL sets the name of the preprocessor symbol defined when
compiling sources in a shared library. If not set here then it is set
to target_EXPORTS by default (with some substitutions if the target is
not a valid C identifier). This is useful for headers to know whether
they are being included from inside their library our outside to
properly setup dllexport/dllimport decorations."

So, 
set_targer_properties(browserPileImagesPlugin PROPERTIES DEFINE_SYMBOL 
QDESIGNER_EXPORT_WIDGETS <javascript:searchRef('QDESIGNER_EXPORT_WIDGETS')> )

Should do the trick.

-Bill





More information about the CMake mailing list