cmake and Qt private headers



  • Hi

    I need to subclass QQuickFlickable which is placed in private headers,
    so I'm trying to add proper statements to CMakeLists.txt
    I found that qgammaray does it:
    https://github.com/KDAB/GammaRay/blob/master/CMakeLists.txt

    QQuickFlickable class is placed in:

    /usr/include/qt/QtQuick/5.7.1/QtQuick/private/qquickflickable_p.h
    

    So I'm adding:

    if(NOT "${Qt5Qml_PRIVATE_INCLUDE_DIRS}" MATCHES "/QtQml/")
        string(REPLACE "/QtCore" "/QtQml" replaceme "${Qt5Core_PRIVATE_INCLUDE_DIRS}")
        list(APPEND Qt5Qml_PRIVATE_INCLUDE_DIRS ${replaceme})
        list(REMOVE_DUPLICATES Qt5Qml_PRIVATE_INCLUDE_DIRS)
    endif()
    if(NOT "${Qt5Quick_PRIVATE_INCLUDE_DIRS}" MATCHES "/QtQuick/")
        string(REPLACE "/QtCore" "/QtQuick" replaceme "${Qt5Core_PRIVATE_INCLUDE_DIRS}")
        list(APPEND Qt5Quick_PRIVATE_INCLUDE_DIRS ${Qt5Qml_PRIVATE_INCLUDE_DIRS})
        list(APPEND Qt5Quick_PRIVATE_INCLUDE_DIRS ${replaceme})
        list(REMOVE_DUPLICATES Qt5Quick_PRIVATE_INCLUDE_DIRS)
    endif()
    
    include_directories( ${Qt5Quick_INCLUDE_DIRS} )
    include_directories( ${Qt5Quick_PRIVATE_INCLUDE_DIRS} )
    

    and list of include directories of my CMakeLists.txt looks like:

    get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
    foreach(dir ${dirs})
      message(STATUS "dir='${dir}'")
    endforeach()
    
    -- dir='/usr/include/qt'
    -- dir='/usr/include/qt/QtQuick'
    -- dir='/usr/include/qt/QtQml'
    -- dir='/usr/include/qt/QtNetwork'
    -- dir='/usr/include/qt/QtCore'
    -- dir='/usr/lib/qt/mkspecs/linux-g++'
    -- dir='/usr/include/qt/QtGui'
    -- dir='/usr/include'
    -- dir='/usr/include/qt/QtNetwork/5.7.1'
    -- dir='/usr/include/qt/QtNetwork/5.7.1/QtNetwork'
    -- dir='/usr/include/qt/QtCore/5.7.1'
    -- dir='/usr/include/qt/QtCore/5.7.1/QtCore'
    -- dir='/usr/include/qt/QtGui/5.7.1'
    -- dir='/usr/include/qt/QtGui/5.7.1/QtGui'
    -- dir='/usr/include/qt/QtQml/5.7.1'
    -- dir='/usr/include/qt/QtQml/5.7.1/QtQml'
    -- dir='/usr/include/qt/QtQuick/5.7.1'
    -- dir='/usr/include/qt/QtQuick/5.7.1/QtQuick'
    

    But if I include:

    #include <private/qquickflickable_p.h>
    

    It can not find private/qquickflickable_p.h
    but when I include this way:

    #define P_QQUICKFLICKABLE(major,minor,patch)  <QtQuick/major.minor.patch/QtQuick/private/qquickflickable_p.h>
    #include P_QQUICKFLICKABLE(QT_VERSION_MAJOR, QT_VERSION_MINOR, QT_VERSION_PATCH)
    

    It complains about missing private/qtquickglobal_p.h from qquickflickable_p.h
    which is also in the same directory.

    Please help how to manage it.



  • I give up... with using private headers.
    I did above by wrapping my component with Flickable on QML side.

    Anyway, it would find many practical purposes if QtQuick c++ classes will be not private.


  • Qt Champions 2016

    @SeeLook said in cmake and Qt private headers:

    Anyway, it would find many practical purposes if QtQuick c++ classes will be not private.

    Indeed but there is a good reason for it.
    binary compatible.
    https://community.kde.org/Policies/Binary_Compatibility_Examples

    :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.