[CMake] Build flags when using Qt plugins (was: Where is QT_USE_IMPORTED_TARGETS not safe to use?)

Clinton Stimpson clinton at elemtech.com
Thu Jun 23 12:13:45 EDT 2011


On Wednesday, June 22, 2011 02:20:08 pm Clinton Stimpson wrote:
> On Wednesday, June 22, 2011 01:47:33 pm Stephen Kelly wrote:
> > Clinton Stimpson wrote:
> > >> The output is attached, but I'm not certain it's very helpful. Let me
> > >> know if anything else would be useful. I can maybe try to create a
> > >> smaller plugin using qt example for easy reproduction of the issue.
> > > 
> > > Also the files in templates/lib are not compiled with flags from
> > > QT_USE_FILE. You can tell that by whether files are compiled with
> > > -DQT_CORE_LIB.
> > 
> > Good catch. I'll remedy that and re-try.
> > 
> > In the mean-time I have created a CMake build system for the Qt
> > echoplugin example. On my setup it fails to load the plugin at runtime
> > unless I comment out the add_definition(-DQT_NO_DEBUG).
> > 
> > Could you try the same? That would at least show that it's a problem on
> > my end.
> 
> I tried the example, and if I use mingw, I have to set CMAKE_BUILD_TYPE to
> something for the example to work.
> 
> If I use nmake or visual studio, CMAKE_BUILD_TYPE is defaulted to Debug, so
> it just works.
> 
> So it seems one should fix the Platform/Windows-GNU.cmake or something to
> have something like a
> SET(CMAKE_BUILD_TYPE_INIT Release)
> or
> SET(CMAKE_BUILD_TYPE_INIT Debug)
> Would you like to submit a bug for this?
> 
> As a workaround, you can enforce a value for CMAKE_BUILD_TYPE if on Windows
> and CMAKE_CONFIGURATION_TYPES is empty.  If you enforce that, then you
> don't need to have the add_definition(-DQT_NO_DEBUG).

I just realized a perhaps better fix can be done in UseQt4.cmake.  And it'll 
still work if one clears the CMAKE_BUILD_TYPE after a default was set.

See the fix here:
<http://cmake.org/gitweb?p=cmake.git;a=commit;h=5a2b208617d13808287b3c785183fed9c99576f1>

-- 
Clinton Stimpson
Elemental Technologies, Inc
Computational Simulation Software, LLC
www.csimsoft.com


More information about the CMake mailing list