Menu

#30 Qt 5 CMake patch

None
closed-accepted
None
5
2014-09-09
2014-09-03
No

I could not get CMake to properly detect Qt5 (using git commit 48a633e29592d74c4b0da789d7b70b537aafe6b0). This patch makes things work for me, using Qt 5.3.1.

diff --git a/cmake/modules/qt.cmake b/cmake/modules/qt.cmake
index f6f6e77..1ca609c 100644
--- a/cmake/modules/qt.cmake
+++ b/cmake/modules/qt.cmake
@@ -127,7 +127,7 @@ if(ENABLE_qt)
       string(TOUPPER ${Qt5_library_name} macro_core_name)
       # Set required macros so headers will be found.
       set(pc_qt_COMPILE_FLAGS "${pc_qt_COMPILE_FLAGS} -DQT_${macro_core_name}_LIB")
-      find_file(${Qt5_library_name}_header_directory Qt${Qt5_library_name})
+      find_file(${Qt5_library_name}_header_directory Qt${Qt5_library_name} HINTS ${Qt5${Qt5_library_name}_INCLUDE_DIRS})
       if(${Qt5_library_name}_header_directory)
    if(${Qt5_library_name} STREQUAL "Core")
      get_filename_component(parent_directory ${${Qt5_library_name}_header_directory} DIRECTORY)
@@ -136,19 +136,13 @@ if(ENABLE_qt)
    set(pc_qt_COMPILE_FLAGS "${pc_qt_COMPILE_FLAGS} -I${${Qt5_library_name}_header_directory}")
       else(${Qt5_library_name}_header_directory)
    message(STATUS "${Qt5_library_name}_header_directory = ${${Qt5_library_name}_header_directory}")
-   message(FATAL_ERROR "${Qt${Qt5_library_name}} header_directory not found.")
+   message(FATAL_ERROR "${Qt5_library_name} header_directory not found.")
       endif(${Qt5_library_name}_header_directory)
     endforeach(Qt5_library_name ${Qt5_library_name_list})

     set(Qt5_library_fullpath_list)
     foreach(Qt5_library_name ${Qt5_library_name_list})
-      find_library(Qt5${Qt5_library_name}_fullpath Qt5${Qt5_library_name})
-      if(Qt5${Qt5_library_name}_fullpath)
-   list(APPEND Qt5_library_fullpath_list ${Qt5${Qt5_library_name}_fullpath})
-      else(Qt5${Qt5_library_name}_fullpath)
-   message(STATUS "Qt5${Qt5_library_name}_fullpath = ${Qt5${Qt5_library_name}_fullpath}")
-   message(FATAL_ERROR "Qt5${Qt5_library_name} library not found.")
-      endif(Qt5${Qt5_library_name}_fullpath)
+      list(APPEND Qt5_library_fullpath_list ${Qt5${Qt5_library_name}_LIBRARIES})
     endforeach(Qt5_library_name ${Qt5_library_name_list})

     pkg_config_link_flags(Qt5_library_LINK_FLAGS "${Qt5_library_fullpath_list}")

Discussion

  • Alan W. Irwin

    Alan W. Irwin - 2014-09-05
    • status: open --> pending
    • assigned_to: Alan W. Irwin
    • Group: -->
     
  • Alan W. Irwin

    Alan W. Irwin - 2014-09-05

    I am having some problems cutting and pasting this patch because of html rendering issues so please attach it instead. Also please use git format-patch to generate the patch you are going to attach since that includes some additional useful information.

     
  • Torsten Martinsen

    Patch attached.

     
  • Alan W. Irwin

    Alan W. Irwin - 2014-09-08

    Thanks for that attachment. Note my response is going to be delayed (probably to early tomorrow) because I want to test your patch for 5.3.1 myself, and that means (since my system is Debian stable) that I have to build Qt5.3.1 myself. My last Qt5 build was for 5.2.1 and that proved to have severe character alignment issues which I hope have now been fixed for 5.3.1, but I will check that once the build is complete. But in any case its a good sign that you have found your build-system patch works with 5.3.1 since I am not going to be concerned about earlier versions of Qt5.x.y because of the known character alignment issues for those versions.

     
  • Alan W. Irwin

    Alan W. Irwin - 2014-09-09
    • status: pending --> closed-accepted
     
  • Alan W. Irwin

    Alan W. Irwin - 2014-09-09

    Applied, see
    https://sourceforge.net/p/plplot/plplot/ci/9bfe5acca361d30935aa3c888c97d59a0f0e6035/.

    Thanks very much for this help with configuring how Qt5 is found. With the previous version, it worked if I set all of PATH, CMAKE_LIBRARY_PATH, and CMAKE_INCLUDE_PATH appropriately, but now with your changes only PATH has to be set (and not even that, if Qt5 is installed in a system location).

    Here are two other Qt5-related topics that might interest you.

    With regard to the build I did for Qt5.3.1: I did that with the epa_build project you can find in cmake/epa_build. It's configured to build an extremely lite version of Qt5 which only has the modules/components that are needed for PLplot. The advantage of that approach is the build takes only ~20 minutes.

    With regard to the preferred version of Qt for PLplot it is still Qt4 which has no character alignment or any other issues from the PLplot perspective. Currently, the uniform empirical offset I apply to vertical positioning of characters to work around the Qt5 alignment bugs is pretty good both for Qt5.2.1 and 5.3.1, but someone else has reported bad character alignment issues (where the offsets vary strongly from character to character so one uniform offset does not compensate very well) for 5.3.0. Therefore, if you insist on using Qt5, I suggest you carefully pick the version (i.e., you should probably avoid 5.x.0 versions). At some point the more-or-less uniform vertical alignment issue for Qt5 will become fixed, and at that point I will need to remove my compensation for that Qt5 bug in the PLplot code. But that point has obviously not occurred yet for 5.3.1, and if you look on the Qt5 bug tracker there are still many open issues there concerning character alignment so we may have to wait until 5.4.x or even 5.5.x before this issue is completely resolved. (We had similar problems for the 4.x series until 4.5 or so.)

     

Log in to post a comment.