Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add private include paths #955

Open
akiselev opened this issue May 19, 2024 · 2 comments · May be fixed by #1160
Open

Add private include paths #955

akiselev opened this issue May 19, 2024 · 2 comments · May be fixed by #1160
Labels
🔨 build system Issues related to integrating CXX-Qt into CMake/Cargo ⬆️ feature New feature or request 🙋 good first issue Good for newcomers

Comments

@akiselev
Copy link
Contributor

akiselev commented May 19, 2024

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));
    }
}
@ahayzen-kdab
Copy link
Collaborator

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 ahayzen-kdab added ⬆️ feature New feature or request 🙋 good first issue Good for newcomers 🔨 build system Issues related to integrating CXX-Qt into CMake/Cargo labels May 21, 2024
@redstrate
Copy link
Contributor

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 added a commit to redstrate/cxx-qt that referenced this issue Jan 16, 2025
This allows you to include headers from private modules, e.g.
"qpa/qplatformnativeinterface.h" from GuiPrivate. It does this by adding
a special case for these modules, and appends the correct path.

Fixes KDAB#955
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 build system Issues related to integrating CXX-Qt into CMake/Cargo ⬆️ feature New feature or request 🙋 good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants