Skip to main content

FindQtDocs CMake module

· 2 min read
CMake mark

I'm currently shitfing some common CMake code from various disparate projects to common shared CMake modules. The first of these is some code for locating Qt's documentation tag files for linking Doxygen-based documentation to Qt's documentation. The resutling FindQtDocs module is now availble on GitHub here.

The module works by using either Qt's qtpaths (from Qt 6.2.0 onwards) or qmake (before Qt 6.2.0) to fetch Qt's QT_INSTALL_DOCS property1. Once the QT_INSTALL_DOCS path is known, the module simply looks for the requires Qt modules' *.tags files, setting the relevant CMake variables following the usual find_package conventions, such as:

find_package(QtDocs COMPONENTS Core Bluetooth)
if (QtDocs_FOUND)
message(DEBUG "Do things with ${QtDocs_Core_TAGS} and ${QtDocs_Bluetooth_TAGS}")
endif()

Further Reading

Footnotes

  1. Support for the -query option was added to qtpaths in Qt 6.2.0. It works the same as qmake's -query, but presumably was added to assist the gradual removal of qmake, since CMake is now Qt's preferred build system.