thliebig / QCSXCAD

QCSXCAD - Qt-GUI for CSXCAD
http://openEMS.de
GNU Lesser General Public License v3.0
5 stars 13 forks source link

Building on Enterprise Linux 8 (RHEL/Alma/Oracle/Rocky) #15

Open KJ7LNW opened 10 months ago

KJ7LNW commented 10 months ago

There is a a problem in Enterprise Linux 8 where VTK-QT is available as version 9, but OS only has QT 5 installed.additionally, forsome reason it does not detect the QT version.

While this is not production ready, it does allow cmake to complete and build successfully. I set version 4.5 even though it is using VTK-QT version 9, which triggers a build against qt5. There must be a better way to do this but I do not know what it is:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 73329ec..05bae99 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -110,6 +110,8 @@ else()
 endif()

 message(STATUS "Found package VTK. Using version " ${VTK_VERSION})
+message(STATUS "Found package VTK QT. Using version " ${VTK_QT_VERSION})
+SET(VTK_QT_VERSION 4.5)
 INCLUDE_DIRECTORIES (${VTK_INCLUDE_DIRS})

 # Qt 
thliebig commented 9 months ago

Can you explain what this does? We cannot fix or set Qt to any Qt4 version as Qt5 or soon Qt6 should be default!?

KJ7LNW commented 9 months ago

Here is more context, more below:

message(STATUS "Found package VTK. Using version " ${VTK_VERSION})
+message(STATUS "Found package VTK QT. Using version " ${VTK_QT_VERSION})
+SET(VTK_QT_VERSION 4.5) # <<< to get QT5 with VTK v9
INCLUDE_DIRECTORIES (${VTK_INCLUDE_DIRS})

# Qt 
SET(RESOURCES resources.qrc)
set(CMAKE_AUTOMOC ON)
if(VTK_QT_VERSION VERSION_GREATER "5")
    FIND_PACKAGE(Qt6 COMPONENTS Core Core5Compat Widgets Xml REQUIRED)
    set(QT_LIBRARIES Qt6::Core5Compat Qt6::Widgets Qt6::Xml)
    QT6_ADD_RESOURCES(RESOURCES_SRCS ${RESOURCES})
elseif(${VTK_VERSION} VERSION_GREATER "6" AND VTK_QT_VERSION VERSION_GREATER "4")
    FIND_PACKAGE(Qt5 COMPONENTS Core Widgets Xml REQUIRED)
    set(QT_LIBRARIES Qt5::Widgets Qt5::Xml)
    QT5_ADD_RESOURCES(RESOURCES_SRCS ${RESOURCES})
else()
    # in Qt4, QT_LIBRARIES is set by CMake
    FIND_PACKAGE(Qt4 REQUIRED QtCore QtGui QtXml)
    INCLUDE( ${QT_USE_FILE} )
    QT4_ADD_RESOURCES(RESOURCES_SRCS ${RESOURCES})
endif()

Oracle Linux it has VTK_QT_VERSION as "", an empty string. Thus, I had to define it. Without defining it is defaulted to QT 4 (else()). However, Oracle Linux 8 only uses QT 5. The version of vtk-qt that I built on Oracle Linux 8 was 9.0.1 (because it does not come with for distribution); even if VTK_VERSION evaluated properly as 9.0.1 then it would not build on Oracle 8 because it would try to build on QT 6. Ultimately There are two issues:

  1. The QSXCAD CMakefile does not support the combination of vtk-qt version 9.0.1 with QT 5. (Perhaps this is an unusual combination but it works.)
  2. That problem is compounded by VTK_QT_VERSION being an empty string; perhaps the vtk-qt dev libraries on OL8 did not define it, defined it as a different name, or a CMake module is not available. I can only speculate as I am not that familiar with CMake. Because of the empty string issue, I hacked version 4.5 so that it would select QT 5. Because QT 6 is not available in Oracle Linux 8.

NB: Oracle Linux it is a clone of Red Hat enterprise Linux 8. It is basically the same as Rocky Linux or Alma Linux 8. The series of operating systems runs Python 3.6 and is supported as long term support release until to 2029.

KJ7LNW commented 9 months ago

To clarify, the SET(VTK_QT_VERSION 4.5) line that I added was not suggested as a fix. Just information about what worked for me. Of course it would need to be generalized.

thliebig commented 9 months ago

I still do not like this change? What happens on more modern system that have Qt6 (only)? I guess it should still work with this change? Forcing a Qt/vtk version like this seems just wrong??? But what can we do? I think we could drop Qt4 support at this point and use Qt5 as fallback? Any opinions?

KJ7LNW commented 9 months ago

The point is that QT and VTK versions need to be identified separately. The way it is written now, VTK and QT are detected simultaneously, and that doesn't work across distros.

I think this would be best:

What do you think?