On Wednesday, 2 de November de 2011 11:26:10 Stephen Kelly wrote:
> The use file is a convenience that is relatively common in cmake modules
> that  adds includes and definitions etc, but the more direct way is also
> possible.

So we go back to what I said: the names of the individual variables are part
of the public API of FindQt5.cmake.

However, let me make a suggestion: use macros, not variables. We've run into
this problem before in Qt 4 where CMake did not add the -D macros that qmake
did and then some results were different (unit tests, for example).

So the example I had should be instead rewritten to:

project(MyLib)
find_target(Qt5)

add_library(mylib SHARED ${mylib_SRCS})
qt5_add_module(mylib PUBLIC Core Gui Declarative PRIVATE Xml)

add_executable(tst_mylib NOGUI ${tst_mylib_SRC})
target_link_libraries(tst_mylib mylib)
qt5_add_module(tst_mylib Test Xml)


Much simpler and more future-proof. What's more, since QtCore, QtGui and
QtDeclarative are part of MyLib's public interface, anything linking to it
automatically inherits them (e.g., qmake's QT += or LIBS += line). The private
dependencies are an implementation detail, which may need to be exposed if
static linking is being attempted (qmake's QT_PRIVATE += or LIBS_PRIVATE +line).

Another benefit is that I don't have to remember to list which modules I want
in find_target. They should be automatically gathered from the qt5_add_module
commands -- like qmake. Unlike qmake, if I want to decide whether to add some
code based on the presence or absence a dependency, then I'd verify some
variables set by FindQt5.cmake.

The above is only missing a listing of headers so that qt5_add_module knows
what to moc. I don't know how that is implemented these days (qmake's
HEADERS += line).

--
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
     Intel Sweden AB - Registration Number: 556189-6027
     Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to