Skip to content

Commit

Permalink
improve Qt5/Qt6 package searching
Browse files Browse the repository at this point in the history
  • Loading branch information
bhaller committed Aug 22, 2024
1 parent 813de4e commit 178e595
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
26 changes: 22 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,31 @@ if(BUILD_SLIMGUI)
# Default to Qt6 if available, fall back to Qt5; this defines QT_VERSION_MAJOR to be either 5 or 6
# This is complicated slightly by the modules needed differing between Qt5 and Qt6
# see https://doc.qt.io/qt-6/cmake-qt5-and-qt6-compatibility.html
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Gui Widgets)
if(${QT_VERSION_MAJOR} EQUAL 5)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets)
# I found that find_package(QT NAMES Qt6 Qt5 ...) was behaving oddly, so I shifted to the below
find_package(Qt6 COMPONENTS Core Gui Widgets OpenGLWidgets)
if(Qt6_FOUND)
set(QT_VERSION_MAJOR 6)
message(STATUS "Found Qt6 (${Qt6_VERSION}) at ${QT6_INSTALL_PREFIX}")
else()
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets OpenGLWidgets)
find_package(Qt5 COMPONENTS Core Gui Widgets)
if(Qt5_FOUND)
set(QT_VERSION_MAJOR 5)
message(STATUS "Could not find Qt6; if this is unexpected, you may wish to set Qt6_DIR and/or CMAKE_PREFIX_PATH")
message(STATUS "Found Qt5 (${Qt5_VERSION}) at ${Qt5_DIR}")
# note that on macOS, Qt5 has only the x86_64 architecture, so if you are on macOS-arm64 your build will fail
# you can supply -D CMAKE_OSX_ARCHITECTURES="x86_64" at the command line and it should build for x86_64
else()
message(FATAL_ERROR "Could not find Qt5 or Qt6; you may wish to set Qt6_DIR, Qt5_DIR, and/or CMAKE_PREFIX_PATH")
endif()
endif()

# a useful bit of debugging code that prints all defined variables
#get_cmake_property(_variableNames VARIABLES)
#list (SORT _variableNames)
#foreach (_variableName ${_variableNames})
# message(STATUS "${_variableName}=${${_variableName}}")
#endforeach()

if(WIN32)
set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME_SLIMGUI}_autogen/mocs_compilation.cpp" PROPERTIES COMPILE_FLAGS "-include config.h -DGNULIB_NAMESPACE=gnulib")
endif()
Expand Down
2 changes: 1 addition & 1 deletion VERSIONS
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ development head (in the master branch):
extend deviatePositions(), pointDeviated(), sampleNearbyPoint(), and sampleImprovedNearbyPoint() to allow vectorization with a different spatial kernel for each iteration
fix a line-ending bug in readFile(); a CRLF file from Windows, read on macOS/Linux, would not strip the CR off the ends of the lines
shift to supporting Qt6 and C++17 to build SLiMgui; Qt5 with C++11 is still supported
for macOS, Qt6 is now the supported plaform for macOS 11/12/13/14; Qt5 should only be used on macOS 10.15
for macOS, Qt6 is now the supported platform for macOS 11/12/13/14; Qt5 should only be used on macOS 10.15
for Windows, Qt6 is now the supported platform for Windows 10 (1809 or later) and Windows 11
for Linux, Qt6 is now the supported platform for Red Hat 8.6/8.8/9.2, openSUSE 15.5, and Ubuntu 22.04 among others
these recommendations are based on Qt6's recommended platforms; earlier platforms should use Qt5
Expand Down

0 comments on commit 178e595

Please sign in to comment.