Search code examples
qtcmake

Add Qt private headers to CMake project


How should I add Qt private headers to my CMakeLists.txt ?

find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Quick QuickPrivate REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Quick QuickPrivate REQUIRED)

Solution

  • If you want to use the private API of the "QTMOD" submodule then you must include only the headers using the variable:

    Qt${QT_VERSION_MAJOR}QTMOD_INCLUDE_DIRS
    

    In your case:

    include_directories(${Qt${QT_VERSION_MAJOR}Quick_PRIVATE_INCLUDE_DIRS})
    

    Note: Not exist QuickPrivate