Skip to content

Commit

Permalink
works with qt6
Browse files Browse the repository at this point in the history
  • Loading branch information
pbustos committed Apr 30, 2023
1 parent 0476e6b commit 912b0cf
Showing 1 changed file with 44 additions and 2 deletions.
46 changes: 44 additions & 2 deletions cmake/modules/qt.cmake
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
IF (NOT QT.CMAKE)
set (QT.CMAKE TRUE)
# QT
option (USE_QT5 "Build with QT5" ON)
option (USE_QT6 "Build with QT6" ON)
option (USE_QT5 "Build with QT5" OFF)
option (USE_QT4 "Build with QT4" OFF)

# Default => Qt5 if not found tries with Qt4
# Default => Qt6 if not found tries with Qt5
IF (USE_QT6)
find_package(Qt6 COMPONENTS Core REQUIRED)
IF(Qt6_FOUND)
set (USE_QT6 ON)
set (USE_QT5 OFF)
set (USE_QT4 OFF)
ELSEIF (Qt5_FOUND)
set (USE_QT4 OFF)
set (USE_QT5 ON)
set (USE_QT6 OFF)
ELSEIF (Qt4_FOUND)
set (USE_QT4 ON)
set (USE_QT5 OFF)
set (USE_QT6 OFF)
ENDIF(Qt6_FOUND)
ENDIF (USE_QT6)

IF (USE_QT5)
find_package(Qt5 COMPONENTS Core)
IF(Qt5_FOUND)
set (USE_QT5 ON)
set (USE_QT4 OFF)
set (USE_QT6 OFF)
ELSE (Qt5_FOUND)
set (USE_QT4 ON)
set (USE_QT5 OFF)
set (USE_QT6 OFF)
ENDIF(Qt5_FOUND)
ENDIF (USE_QT5)

Expand Down Expand Up @@ -67,6 +87,28 @@ IF (NOT QT.CMAKE)
ENDMACRO(QT_WRAP_UI)
ENDIF (USE_QT5)

IF (USE_QT6)
MESSAGE( STATUS "COMPILING WITH QT6" )
find_package(Qt6 REQUIRED COMPONENTS Gui Widgets Core OpenGL Xml )
set(QT_LIBRARIES Qt6::Gui Qt6::Core Qt6::Widgets Qt6::OpenGL Qt6::Xml)

MACRO(QT_WRAP_CPP output )
FOREACH( input_file ${ARGN} )
QT6_WRAP_CPP( ${output} ${input_file} )
ENDFOREACH( input_file)
SET_PROPERTY(SOURCE ${${output}} PROPERTY SKIP_AUTOGEN ON)
ENDMACRO(QT_WRAP_CPP)

MACRO (QT_WRAP_UI output )
FOREACH( input_file ${ARGN} )
MESSAGE( STATUS "Generating header file from ${input_file}")
QT6_WRAP_UI( ${output} ${input_file} )
ENDFOREACH( input_file)
SET_PROPERTY(SOURCE ${${output}} PROPERTY SKIP_AUTOGEN ON)
ENDMACRO(QT_WRAP_UI)
ENDIF (USE_QT6)


# Common
SET( CMAKE_AUTOMOC ON )
SET( CMAKE_AUTOUIC ON )
Expand Down

0 comments on commit 912b0cf

Please sign in to comment.