Thursday 18 June 2015

New learnings of CMake (>= 2.8.11) and Qt5

For quite a while now, I've been using commands like:

find_package(Qt5Core)
// ... define my_target
qt5_use_modules(my_target Core)
target_link_libraries(my_target nonQtDep)

But recently came across a post on StackOverflow that lead me to the following docs:

http://doc.qt.io/qt-5/cmake-manual.html

which says that since CMake 2.8.11 (old hat now) we should be doing the following:

find_package(Qt5Core)
// ... define my_target
target_link_libraries(my_target
  Qt5::Core
  nonQtDep
)

I, for one, think this will make mixed deps between Qt and non-Qt components much more readable in our CMake code.

Cheers,
    Pete