cxx-qt icon indicating copy to clipboard operation
cxx-qt copied to clipboard

Add private include paths

Open akiselev opened this issue 1 year ago • 2 comments

I'm trying to bind QT Advanced Docking System but i'm getting the following error:

Qt-Advanced-Docking-System/src/ads_globals.cpp:45:10: fatal error: qpa/qplatformnativeinterface.h: No such file or directory
    45 | #include <qpa/qplatformnativeinterface.h>
       |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

That header is in QtGui/6.7.0/QtGui/qpa/qplatformnativeinterface.h so I have a very hacky solution below that builds, but it'd be nice to have official support.

let version: qt_build_utils::SemVer = qtbuild.version().clone();
for path in qtbuild.include_paths() {
    let path = path.to_str().unwrap();
    if path.contains("QtGui") {
        cc.include(format!("{}/{}/QtGui", path, version));
    }
}

akiselev avatar May 19 '24 02:05 akiselev

Thanks for taking the time to report this issue.

So this is a private header, but I believe under CMake this would be part of the QtGui Private target? Eg Qt::GuiPrivate in CMake ?

If so then yes I think we should try to add support for this somewhere, like by having a special case for "Private" in .qt_module so that .qt_module("GuiPrivate") does the right thing.

We'd have to investigate what the Qt CMake code is doing and then match that in qt-build-utils, an initial look appears to suggest this is a folder within the module itself eg /var/home/andrew/.var/Qt/6.5.2/gcc_64/include/QtGui/6.5.2/QtGui/private but i also note that the file you want is not under this private folder and instead under the version /var/home/andrew/.var/Qt/6.5.2/gcc_64/include/QtGui/6.5.2/QtGui/qpa/qplatformnativeinterface.h. So we should see what Qt CMake is doing.

ahayzen-kdab avatar May 21 '24 08:05 ahayzen-kdab

So we should see what Qt CMake is doing.

So I took a peek in the QtGui CMake, and it looks like their snippet:

set_target_properties(Qt6::GuiPrivate PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "\$<\$<BOOL:\$<TARGET_PROPERTY:Qt6::Gui,_qt_module_has_private_headers>>:>;\$<\$<BOOL:\$<TARGET_PROPERTY:Qt6::Gui,_qt_module_has_private_headers>>:>;\$<\$<BOOL:\$<TARGET_PROPERTY:Qt6::Gui,_qt_module_has_private_headers>>:${_IMPORT_PREFIX}/include/qt6/QtGui/6.8.1>;\$<\$<BOOL:\$<TARGET_PROPERTY:Qt6::Gui,_qt_module_has_private_headers>>:${_IMPORT_PREFIX}/include/qt6/QtGui/6.8.1/QtGui>"

(The most important bit is at the end, the rest is just generator expressions)

Except that the path is hardcoded, of course. It appears to be the same path in CorePrivate as well, and probably others.

redstrate avatar Jan 16 '25 17:01 redstrate