[Development] How to build unit tests & examples on demand with Qt6/CMake?

Thiago Macieira thiago.macieira at intel.com
Mon Nov 16 20:08:57 CET 2020


With Qt5, I just did:
./configure -nomake tests -nomake examples [...]

And for each one I needed, I just ran qmake directly. For example:

 mkdir -p tests/auto/corelib
 cd tests/auto/corelib
 qmake $srcdir
 make qmake_all
 cd serialization/qcborvalue
 make check

 mkdir -p examples/corelib/serialization/cbordump
 cd examples/corelib/serialization/cbordump
 qmake $srcdir
 make

How do I do that with CMake? Configure line:

cmake -G Ninja $srcdir '-DBUILD_WITH_PCH=OFF' \
'-DCMAKE_INSTALL_PREFIX=/home/tjmaciei/obj/qt/qt6/qtbase' \
'-DQT_QMAKE_TARGET_MKSPEC=linux-g++-optimised' \
'-DFEATURE_optimize_debug=OFF' '-DFEATURE_developer_build=ON' \
'-DFEATURE_reduce_relocations=ON' '-DFEATURE_journald=ON' \
'-DFEATURE_sctp=ON' -DINPUT_qt_libinfix=.t -DFEATURE_openssl_linked=ON \
'-DBUILD_TESTING=ON' '-DBUILD_EXAMPLES=OFF'

The last line is likely significant. I want to be able to build only the tests 
and examples I specify. Never all.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel DPG Cloud Engineering





More information about the Development mailing list