Bug 929227 - CMake Config files assume wrong directory layout
Summary: CMake Config files assume wrong directory layout
Alias: None
Product: Fedora
Classification: Fedora
Component: qt5-qtbase
Version: rawhide
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Ngo Than
QA Contact: Fedora Extras Quality Assurance
: 950213 (view as bug list)
Depends On:
TreeView+ depends on / blocked
Reported: 2013-03-29 15:00 UTC by Kevin Kofler
Modified: 2013-04-20 20:01 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2013-04-10 13:13:56 UTC

Attachments (Terms of Use)

Description Kevin Kofler 2013-03-29 15:00:36 UTC
Description of problem:
In qt5-qtbase, at least %{_libdir}/cmake/Qt5Core/Qt5CoreConfigExtras.cmake definitely doesn't work.
get_filename_component(_qt5_corelib_install_prefix "${CMAKE_CURRENT_LIST_DIR}/" ABSOLUTE)
That makes no sense. It sets the Qt 5 prefix to %{_libdir}/cmake/Qt5Core. Then it looks for e.g. %{_libdir}/cmake/Qt5Core/bin/qmake.

I'd just patch this to set(_qt5_corelib_install_prefix "%{_libdir}/qt5") with %{_libdir} expanded at RPM build time (the file lives in %{_libdir}, so it doesn't have to be the same per arch).

And I see the same kind of brokenness in many other of the .cmake files Qt is shipping. You probably want to use a for loop with sed in the specfile to fix them all.

The module dependencies system also assumes that all the CMake config files are installed in the 
same directory:
            PATHS "${_qt5Core_install_prefix}" NO_DEFAULT_PATH
where _qt5Core_install_prefix is defined with that same get_filename_component command (only the variable name is different because this is Qt5CoreConfig.cmake, not Qt5CoreConfigExtras.cmake).

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

Comment 1 Kevin Kofler 2013-03-29 15:10:30 UTC
The way these files were written, they assume that 1. the *Config*.cmake files are all directly in the root of the prefix and 2. the other directories are all relative to that in the default way, e.g. bindir is prefix + "/bin" etc. 1. is definitely wrong, 2. may also be wrong.

Comment 2 Rex Dieter 2013-03-29 15:12:21 UTC
right, in particular, everything that matches:
contains similar code to set erroneous _qt5*_install_prefix variables

Comment 3 Rex Dieter 2013-03-29 15:34:26 UTC
Sent query to upstream ml for starters,

Comment 4 Kevin Kofler 2013-03-29 15:51:56 UTC
The *.cmake.in templates look like this:
mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in:get_filename_component(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
src/widgets/Qt5WidgetsConfigExtras.cmake.in:get_filename_component(_qt5_widgets_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
src/corelib/Qt5CoreConfigExtras.cmake.in:get_filename_component(_qt5_corelib_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
src/dbus/Qt5DBusConfigExtras.cmake.in:get_filename_component(_qt5_dbus_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
so the problem is that $${CMAKE_RELATIVE_INSTALL_DIR} vanishes in the installed files. It should probably be "../../qt5", but it's completely replaced away by the .cmake.in → .cmake generation.

Comment 5 Rex Dieter 2013-03-29 15:59:13 UTC

    CMAKE_RELATIVE_INSTALL_DIR = $$replace(CMAKE_LIB_DIR, "[^/]+", ..)
    # We need to go up another two levels because the CMake files are
    # installed in $${CMAKE_LIB_DIR}/cmake/Qt5$${CMAKE_MODULE_NAME}
} else {

is this part not used or failing somehow?

Comment 6 Kevin Kofler 2013-03-29 16:44:20 UTC
is false because CMAKE_LIB_DIR is not a subdirectory of $${CMAKE_QT_INSTALL_PREFIX_ESCAPED} (but the other way round).

So we enter the CMAKE_LIB_DIR_IS_ABSOLUTE case and the *Config*.cmake files are not written to handle that at all.

There's no code to handle a prefix within the libdir.

Comment 7 Rex Dieter 2013-03-29 17:24:04 UTC
Ah, so maybe one of my earlier naive suggestions to set
_qt5_prefix to be /usr (instead of %{_libdir}/qt5) may help here, but that may also have other side-effects as well.

Comment 8 Kevin Kofler 2013-03-29 18:23:04 UTC
Yeah, if you do that, it'll probably expect the unsuffixed binaries to be under /usr/bin. I guess we could patch in the suffixes (or patch the path) though. But it might also affect the placement of other files.

I'll have a look at create_cmake.prf to see whether I can make it do something sensible, I know both QMake and CMake to some extent.

Comment 9 Rex Dieter 2013-03-30 15:50:17 UTC
Tried qtbase-5.0.2-rc1, and problem appears to be fixed.  I'll do a little more testing to confirm, and import into rawhide.

Comment 10 Rex Dieter 2013-04-10 12:30:18 UTC
Hrm, still not quite right, per bug #950213 , trying to build Sigil , I get odd output like:

CMake Warning at /usr/lib64/cmake/Qt5Widgets/Qt5WidgetsConfig.cmake:49 (find_package):
  Could not find a package configuration file provided by "Qt5Gui" with any
  of the following names:


Except here they are:

Comment 11 Rex Dieter 2013-04-10 12:33:13 UTC
Ah, upstream pointed me to this:

Comment 12 Rex Dieter 2013-04-10 12:57:19 UTC
building... let's see if this one helps

* Wed Apr 10 2013 Rex Dieter <rdieter@fedoraproject.org> - 5.0.2-1
- 5.0.2
- fix cmake config (#929227)

Comment 13 Rex Dieter 2013-04-10 13:13:56 UTC
confirmed, mmm-mmm good this time. yay.

Comment 14 Rex Dieter 2013-04-10 13:14:47 UTC
*** Bug 950213 has been marked as a duplicate of this bug. ***

Comment 15 Rex Dieter 2013-04-10 14:36:11 UTC
Not quite 100% there ...

after installing, do in source tree:

$ cd /tests/auto/cmake; mkdir build; cd build; cmake ..;
$ ctest --output-on-failure

Test project /home/rdieter1/pkgs.fedoraproject.org/qt5-qtbase/qtbase-opensource-src-5.0.2/tests/auto/cmake/build
      Start  1: test_use_modules_function
 1/18 Test  #1: test_use_modules_function .........***Failed    0.03 sec
Internal cmake changing into directory: /home/rdieter1/pkgs.fedoraproject.org/qt5-qtbase/qtbase-opensource-src-5.0.2/tests/auto/cmake/build/test_use_modules_function
Error: cmake execution failed
CMake Warning at /usr/lib64/cmake/Qt5Core/Qt5CoreMacros.cmake:237 (find_package):
  Could not find a package configuration file provided by "Qt5Test" with any
  of the following names:


  Add the installation prefix of "Qt5Test" to CMAKE_PREFIX_PATH or set
  "Qt5Test_DIR" to a directory containing one of the above files.  If
  "Qt5Test" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  CMakeLists.txt:15 (qt5_use_modules)

CMake Error at /usr/lib64/cmake/Qt5Core/Qt5CoreMacros.cmake:240 (message):
  Can not use "Test" module which has not yet been found.
Call Stack (most recent call first):
  CMakeLists.txt:15 (qt5_use_modules)

Configuring incomplete, errors occurred!

      Start  2: test_wrap_cpp_and_resources
 2/18 Test  #2: test_wrap_cpp_and_resources .......   Passed    0.49 sec
      Start  3: test_dependent_modules
 3/18 Test  #3: test_dependent_modules ............   Passed    1.49 sec
      Start  4: test_add_resource_options
 4/18 Test  #4: test_add_resource_options .........   Passed    0.92 sec
      Start  5: test_wrap_cpp_options
 5/18 Test  #5: test_wrap_cpp_options .............   Passed    1.11 sec
      Start  6: test_needsquoting_dirname
 6/18 Test  #6: test_needsquoting_dirname .........   Passed    1.47 sec
      Start  7: test_platform_defs_include
 7/18 Test  #7: test_platform_defs_include ........   Passed    0.90 sec
      Start  8: test_qtmainwin_library
 8/18 Test  #8: test_qtmainwin_library ............   Passed    1.06 sec
      Start  9: test_dbus_module
 9/18 Test  #9: test_dbus_module ..................   Passed    1.72 sec
      Start 10: test_multiple_find_package
10/18 Test #10: test_multiple_find_package ........   Passed    1.03 sec
      Start 11: test_add_resources_delayed_file
11/18 Test #11: test_add_resources_delayed_file ...   Passed    1.02 sec
      Start 12: test_private_includes
12/18 Test #12: test_private_includes .............   Passed    1.05 sec
      Start 13: test_testlib_definitions
13/18 Test #13: test_testlib_definitions ..........   Passed    3.07 sec
      Start 14: test_json_plugin_includes
14/18 Test #14: test_json_plugin_includes .........   Passed    1.05 sec
      Start 15: test_testlib_no_link_gui
15/18 Test #15: test_testlib_no_link_gui ..........   Passed    1.20 sec
      Start 16: test_testlib_no_link_widgets
16/18 Test #16: test_testlib_no_link_widgets ......   Passed    1.43 sec
      Start 17: module_includes
17/18 Test #17: module_includes ...................   Passed    1.38 sec
      Start 18: test_concurrent_module
18/18 Test #18: test_concurrent_module ............   Passed    1.03 sec

94% tests passed, 1 tests failed out of 18

Total Test time (real) =  21.46 sec

The following tests FAILED:
          1 - test_use_modules_function (Failed)
Errors while running CTest

Comment 16 Fedora Update System 2013-04-10 22:17:21 UTC
qt5-qtbase-5.0.2-1.fc18 has been submitted as an update for Fedora 18.

Comment 17 Fedora Update System 2013-04-10 22:17:39 UTC
qt5-qtbase-5.0.2-1.fc17 has been submitted as an update for Fedora 17.

Comment 18 Fedora Update System 2013-04-10 22:18:10 UTC
qt5-qtbase-5.0.2-1.fc19 has been submitted as an update for Fedora 19.

Comment 19 Fedora Update System 2013-04-13 09:32:06 UTC
qt5-qtbase-5.0.2-3.fc19 has been submitted as an update for Fedora 19.

Comment 20 Fedora Update System 2013-04-15 23:55:06 UTC
qt5-qtbase-5.0.2-2.fc18 has been pushed to the Fedora 18 stable repository.

Comment 21 Fedora Update System 2013-04-20 20:01:34 UTC
qt5-qtbase-5.0.2-3.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.

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