[cmake-developers] qt4_use_modules

Stephen Kelly steveire at gmail.com
Thu Aug 16 05:51:34 EDT 2012


Clinton Stimpson wrote:

> On Wednesday, August 15, 2012 11:53:28 AM Brad King wrote:
>> On 08/15/2012 11:41 AM, Stephen Kelly wrote:
>> > Brad King wrote:
>> >> Please rebase the topic on master so you can drop the middle commit
>> >> that removes trailing whitespace.
>> > 
>> > I did this and squashed it into one commit.
>> 
>> Thanks.  The change looks good to me, though I'll still be more
>> comfortable if a Qt expert reviews it.
>> 
> 
> Stephen,
> 
> I've been playing with for a bit and was wondering how to handle the
> qtmain library with it?
> Do I actually have to put a if(WIN32) around that, like this?
> if(WIN32)
>   qt4_use_modules(myapp main)
> endif()
> 
> Previously, I could do
> target_link_libraries(cmake-gui CMakeLib ${QT_QTMAIN_LIBRARY}
> ${QT_LIBRARIES}) and on those platforms without qtmain, the variable is
> simply empty.

Short term, you should keep using 

target_link_libraries(cmake-gui CMakeLib ${QT_QTMAIN_LIBRARY})

medium term (hopefully by 2.8.10), we can make QT_QTMAIN_LIBRARY obsolete by 
adding something like this to qt{4,5}_use_modules (not tested):

set(NOT_WIN32 "$<NOT:$<TARGET_PROPERTY:WIN32_EXECUTABLE>>")
target_link_libraries(${_target} "$<${NOT_WIN32}:${QT_QTMAIN_LIBRARY}>")

TARGET_PROPERTY is a generator expression condition which does not exist 
yet, and which evaluates to the same result as:

get_target_property(RESULT_VAR ${this_target} THE_TARGET_PROPERTY_ARG).

See also:

http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/3615/focus=4480

and:

https://projects.kde.org/projects/kde/kdelibs/repository/revisions/f23293492c42bd1d03bfc58b6479386a6d23aac1

which can be reverted when this is done.

Of course, there will need to be some variable to disable the automatic 
linking to qtmain.a too. Any problems you see in the details and in what I 
have left out for the sake of clarity on this topic are solvable I'm sure.

Thanks,

Steve.





More information about the cmake-developers mailing list