Bug 1846613 - Qt5 private header packaging breaks Qt5 Cmake files
Summary: Qt5 private header packaging breaks Qt5 Cmake files
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: qt5-qtbase
Version: 32
Hardware: All
OS: All
unspecified
medium
Target Milestone: ---
Assignee: Rex Dieter
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-06-12 09:27 UTC by James Turner
Modified: 2020-09-17 14:14 UTC (History)
5 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2020-09-17 14:14:45 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Cmake file showing the problem (303 bytes, text/plain)
2020-06-12 09:27 UTC, James Turner
no flags Details

Description James Turner 2020-06-12 09:27:32 UTC
Created attachment 1696964 [details]
Cmake file showing the problem

Packaging split of Qt5 devel / private-devel breaks Qt's Cmake scripts.

The Qt5 QtFooConfig.cmake modules define additional targets (qt, Qt5::GuiPrivate, Qt5::CorePrivate) conditionally if the private header files for each module are installed. Unfortunately, the do this by checking for particular subdirectories within the module's include prefix.

Unfortunately, Fedora is packaging these directories in the *non private* RPM, but of course the actual header files are in the private-devel RPM, and hence the targets defined by Qt5's CMake are useless: they report the private headers as being available, when they are not.

Eg, qt5-qtbase-devel contains:

  /usr/include/qt5/QtCore/5.13.2/QtCore

(an empty directory!)

As a result, Qt5::CorePrivate will be defined by:

  /usr/lib64/cmake/Qt5Core/Qt5CoreConfig.cmake

Since it uses the existence of this directory, to decide that the private headers are available.

Version-Release number of selected component (if applicable):

  applies to all versions of the qt5 packages on Fedora, it seems

How reproducible:
Consistently

Steps to Reproduce:
1. create a new directory
2. copy the attached CMake file to that directory, renaming to 'CMakeLists.txt'
3. run 'cmake .' in that directory

Actual results:
- GuiPrivate and CorePrivate targets are reported as available, regardless of whether the private headers are installed or not

Expected results:
- GuiPrivate and CorePrivate should not be available, unless qt5-qtbase-private-devel RPM is installed

Comment 1 James Turner 2020-06-12 10:41:47 UTC
Here's a link to the task which introduced the split: 
   https://bugzilla.redhat.com/show_bug.cgi?id=1233829

Note that on Debian, the -private-dev packages do not have this issue (CMake detection of Qt5::GuiPrivate etc works correctly)

Comment 2 Rex Dieter 2020-06-12 12:16:37 UTC
So, fix is to for the -private pkg to own not only the private/ dir but the parent as well?

E.g. not only
/usr/include/qt5/QtCore/5.13.2/QtCore/private/
but 
/usr/include/qt5/QtCore/5.13.2/QtCore/
too?

Comment 3 James Turner 2020-06-12 12:26:29 UTC
I would recommend that the 'versioned' dir is included as well, i.e:

qtbase-devel:
  /usr/include/qt5/QtCore

qtbase-private-devel:
  /usr/include/qt5/QtCore/5.13.2

This would be most consistent with what the CMake QtFooConfig.cmake files check for. 

Note this should also mean that for QtGui, the 'qpa' header files, which are currently included in qtbase-devel, should move to qtbase-private-devel. In my opinion this is correct, since QPAs are tied to their specific Qt version : that's why those files reside in the versioned subdir.

Here's an excerpt from /usr/lib64/cmake/Qt5Gui/Qt5GuiConfig.cmake

====================================================
    set(_Qt5Gui_OWN_INCLUDE_DIRS "${_qt5Gui_install_prefix}/include/qt5/" "${_qt5Gui_install_prefix}/include/qt5/QtGui")
    set(Qt5Gui_PRIVATE_INCLUDE_DIRS
        "${_qt5Gui_install_prefix}/include/qt5/QtGui/5.13.2"
        "${_qt5Gui_install_prefix}/include/qt5/QtGui/5.13.2/QtGui"
    )

   ...

   set(_Qt5Gui_PRIVATE_DIRS_EXIST TRUE)
    foreach (_Qt5Gui_PRIVATE_DIR ${Qt5Gui_OWN_PRIVATE_INCLUDE_DIRS})
        if (NOT EXISTS ${_Qt5Gui_PRIVATE_DIR})
            set(_Qt5Gui_PRIVATE_DIRS_EXIST FALSE)
        endif()
    endforeach()

    if (_Qt5Gui_PRIVATE_DIRS_EXIST)
        add_library(Qt5::GuiPrivate INTERFACE IMPORTED)
        set_property(TARGET Qt5::GuiPrivate PROPERTY
        ...
    endif()

====================================================


Note You need to log in before you can comment on or make changes to this bug.