Provide options to build utilities with Qt6

This commit is contained in:
Vadim Kuznetsov 2023-01-26 11:15:02 +03:00
parent caf1aa85d3
commit 764bf9ff85
7 changed files with 104 additions and 37 deletions

View File

@ -20,7 +20,11 @@ set(PROJECT_DOMAIN_SECOND "org")
ADD_DEFINITIONS( -DHAVE_CONFIG_H )
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall ")
IF(WITH_QT6)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 ")
ELSE(WITH_QT6)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x ")
ENDIF(WITH_QT6)
#configure the header config.h
@ -31,8 +35,19 @@ CONFIGURE_FILE (
INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
IF(WITH_QT6)
FIND_PACKAGE( Qt6 COMPONENTS Core Gui Widgets Svg REQUIRED)
INCLUDE_DIRECTORIES(
${Qt6Core_INCLUDE_DIRS}
${Qt6Widgets_INCLUDE_DIRS}
${Qt6Svg_INCLUDE_DIRS}
)
# bug, the find package does not seem to set the QT_LIBRARIES, do it manually
SET(QT_LIBRARIES ${Qt6Core_LIBRARIES} ${Qt6Widgets_LIBRARIES} ${Qt6Svg_LIBRARIES} )
ELSE(WITH_QT6)
FIND_PACKAGE( Qt5 COMPONENTS Core Gui Widgets Svg REQUIRED)
#INCLUDE( ${QT_USE_FILE} )
INCLUDE_DIRECTORIES(
${Qt5Core_INCLUDE_DIRS}
@ -42,7 +57,7 @@ INCLUDE_DIRECTORIES(
# bug, the find package does not seem to set the QT_LIBRARIES, do it manually
SET(QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Svg_LIBRARIES} )
ENDIF(WITH_QT6)
ADD_DEFINITIONS(${QT_DEFINITIONS})
@ -64,10 +79,15 @@ qucsactivefilter.h
helpdialog.h
)
QT5_WRAP_CPP(QUCS-ACTIVE-FILTER_MOC_SRCS ${QUCS-ACTIVE-FILTER_MOC_HDRS})
SET(RESOURCES qucsactivefilter.qrc)
IF(WITH_QT6)
QT6_WRAP_CPP(QUCS-ACTIVE-FILTER_MOC_SRCS ${QUCS-ACTIVE-FILTER_MOC_HDRS})
QT6_ADD_RESOURCES(RESOURCES_SRCS ${RESOURCES})
ELSE(WITH_QT6)
QT5_WRAP_CPP(QUCS-ACTIVE-FILTER_MOC_SRCS ${QUCS-ACTIVE-FILTER_MOC_HDRS})
QT5_ADD_RESOURCES(RESOURCES_SRCS ${RESOURCES})
ENDIF(WITH_QT6)
IF(APPLE)

View File

@ -28,19 +28,25 @@ CONFIGURE_FILE (
INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall ") # enable warning level
IF(WITH_QT6)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 ") # enable C++11
FIND_PACKAGE( Qt6 COMPONENTS Core Gui Widgets REQUIRED )
INCLUDE_DIRECTORIES(
${Qt6Core_INCLUDE_DIRS}
${Qt6Widgets_INCLUDE_DIRS}
)
# bug, the find package does not seem to set the QT_LIBRARIES, do it manually
SET(QT_LIBRARIES ${Qt6Core_LIBRARIES} ${Qt6Widgets_LIBRARIES} )
ELSE(WITH_QT6)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x ") # enable C++11
FIND_PACKAGE( Qt5 COMPONENTS Core Gui Widgets REQUIRED )
#SET( QT_USE_QTGUI TRUE )
INCLUDE_DIRECTORIES(
${Qt5Core_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
)
# bug, the find package does not seem to set the QT_LIBRARIES, do it manually
SET(QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Widgets_LIBRARIES} )
ENDIF(WITH_QT6)
ADD_DEFINITIONS(${QT_DEFINITIONS})
@ -50,11 +56,15 @@ SET( attenuator_sources attenuatorfunc.cpp main.cpp qucsattenuator.cpp )
SET( attenuator_moc_headers qucsattenuator.h )
QT5_WRAP_CPP( attenuator_moc_sources ${attenuator_moc_headers} )
SET(RESOURCES qucsattenuator.qrc)
IF(WITH_QT6)
QT6_WRAP_CPP( attenuator_moc_sources ${attenuator_moc_headers} )
QT6_ADD_RESOURCES(RESOURCES_SRCS ${RESOURCES})
ELSE(WITH_QT6)
QT5_WRAP_CPP( attenuator_moc_sources ${attenuator_moc_headers} )
QT5_ADD_RESOURCES(RESOURCES_SRCS ${RESOURCES})
ENDIF(WITH_QT6)
IF(APPLE)
# set information on Info.plist file

View File

@ -29,20 +29,26 @@ CONFIGURE_FILE (
INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall ") # enable warning level
IF(WITH_QT6)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 ") # enable C++17
FIND_PACKAGE( Qt6 COMPONENTS Core Gui Widgets REQUIRED)
INCLUDE_DIRECTORIES(
${Qt6Core_INCLUDE_DIRS}
${Qt6Widgets_INCLUDE_DIRS}
)
# bug, the find package does not seem to set the QT_LIBRARIES, do it manually
SET(QT_LIBRARIES ${Qt6Core_LIBRARIES} ${Qt6Widgets_LIBRARIES} )
ELSE(WITH_QT6)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x ") # enable C++11
FIND_PACKAGE( Qt5 COMPONENTS Core Gui Widgets REQUIRED)
INCLUDE_DIRECTORIES(
${Qt5Core_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
)
# bug, the find package does not seem to set the QT_LIBRARIES, do it manually
SET(QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Widgets_LIBRARIES} )
ENDIF(WITH_QT6)
ADD_DEFINITIONS(${QT_DEFINITIONS})
@ -84,11 +90,15 @@ SET(QUCS-FILTER_MOC_HDRS
qucsfilter.h
)
QT5_WRAP_CPP(QUCS-FILTER_MOC_SRCS ${QUCS-FILTER_MOC_HDRS})
SET(RESOURCES qucsfilter.qrc)
QT5_ADD_RESOURCES(RESOURCES_SRCS ${RESOURCES})
IF(WITH_QT6)
QT6_WRAP_CPP(QUCS-FILTER_MOC_SRCS ${QUCS-FILTER_MOC_HDRS})
QT6_ADD_RESOURCES(RESOURCES_SRCS ${RESOURCES})
ELSE(WITH_QT6)
QT5_WRAP_CPP(QUCS-FILTER_MOC_SRCS ${QUCS-FILTER_MOC_HDRS})
QT5_ADD_RESOURCES(RESOURCES_SRCS ${RESOURCES})
ENDIF(WITH_QT6)
IF(APPLE)
# set information on Info.plist file

View File

@ -28,19 +28,29 @@ CONFIGURE_FILE (
INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall ") # enable warning level
IF(WITH_QT6)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 ") # enable C++17
FIND_PACKAGE( Qt6 COMPONENTS Core Gui Widgets Svg REQUIRED)
INCLUDE_DIRECTORIES(
${Qt6Core_INCLUDE_DIRS}
${Qt6Widgets_INCLUDE_DIRS}
${Qt6Svg_INCLUDE_DIRS}
)
# bug, the find package does not seem to set the QT_LIBRARIES, do it manually
SET(QT_LIBRARIES ${Qt6Core_LIBRARIES} ${Qt6Widgets_LIBRARIES} ${Qt6Svg_LIBRARIES} )
ELSE(WITH_QT6)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x ") # enable C++11
# flag not available in mingw 4.8.2, MSVC10
FIND_PACKAGE( Qt5 COMPONENTS Core Gui Widgets Svg REQUIRED)
INCLUDE_DIRECTORIES(
${Qt5Core_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
${Qt5Svg_INCLUDE_DIRS}
)
# bug, the find package does not seem to set the QT_LIBRARIES, do it manually
SET(QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Svg_LIBRARIES} )
ENDIF(WITH_QT6)
ADD_DEFINITIONS(${QT_DEFINITIONS})
@ -57,11 +67,14 @@ SET(QUCS-POWCOMB_MOC_HDRS
qucspowercombiningtool.h
)
QT5_WRAP_CPP(QUCS-POWCOMB_MOC_SRCS ${QUCS-POWCOMB_MOC_HDRS})
SET(RESOURCES qucspowercombining.qrc)
IF(WITH_QT6)
QT6_WRAP_CPP(QUCS-POWCOMB_MOC_SRCS ${QUCS-POWCOMB_MOC_HDRS})
QT6_ADD_RESOURCES(RESOURCES_SRCS ${RESOURCES})
ELSE(WITH_QT6)
QT5_WRAP_CPP(QUCS-POWCOMB_MOC_SRCS ${QUCS-POWCOMB_MOC_HDRS})
QT5_ADD_RESOURCES(RESOURCES_SRCS ${RESOURCES})
ENDIF(WITH_QT6)
IF(APPLE)
# set information on Info.plist file

View File

@ -29,23 +29,27 @@ INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall ") # enable warning level
IF(WITH_QT6)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 ") # enable C++11
FIND_PACKAGE( Qt6 COMPONENTS Core Gui Widgets REQUIRED)
INCLUDE_DIRECTORIES(
${Qt6Core_INCLUDE_DIRS}
${Qt6Widgets_INCLUDE_DIRS}
)
# bug, the find package does not seem to set the QT_LIBRARIES, do it manually
SET(QT_LIBRARIES ${Qt6Core_LIBRARIES} ${Qt6Widgets_LIBRARIES} )
ELSE(WITH_QT6)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x ") # enable C++11
# flag not available in mingw 4.8.2, MSVC10
IF(NOT WIN32)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-register ")
ENDIF()
FIND_PACKAGE( Qt5 COMPONENTS Core Gui Widgets REQUIRED)
INCLUDE_DIRECTORIES(
${Qt5Core_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
)
# bug, the find package does not seem to set the QT_LIBRARIES, do it manually
SET(QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Widgets_LIBRARIES} )
ENDIF(WITH_QT6)
ADD_DEFINITIONS(${QT_DEFINITIONS})
@ -73,7 +77,6 @@ SET(QUCSTRANS_MOC_HDRS
qucstrans.h
)
QT5_WRAP_CPP( QUCSTRANS_MOC_SRCS ${QUCSTRANS_MOC_HDRS} )
SET( LIB_SRC
c_microstrip.cpp
@ -87,7 +90,13 @@ SET( LIB_SRC
SET(RESOURCES qucstrans_.qrc)
IF(WITH_QT6)
QT6_WRAP_CPP( QUCSTRANS_MOC_SRCS ${QUCSTRANS_MOC_HDRS} )
QT6_ADD_RESOURCES(RESOURCES_SRCS ${RESOURCES})
ELSE(WITH_QT6)
QT5_WRAP_CPP( QUCSTRANS_MOC_SRCS ${QUCSTRANS_MOC_HDRS} )
QT5_ADD_RESOURCES(RESOURCES_SRCS ${RESOURCES})
ENDIF(WITH_QT6)
ADD_LIBRARY(transcalc STATIC ${LIB_SRC} )

View File

@ -96,7 +96,11 @@ INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR} )
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra ") # enable warning level
IF(WITH_QT6)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 ") # enable C++11 c++0x
ELSE()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x ") # enable C++11 c++0x
ENDIF()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC ") # enable C++11

View File

@ -25,6 +25,7 @@ IF (UPDATE_TRANSLATIONS)
QT5_CREATE_TRANSLATION ( QM_FILES ${FILES_TO_TRANSLATE} ${TRANSLATIONS_FILES})
ELSE (UPDATE_TRANSLATIONS)
QT5_ADD_TRANSLATION ( QM_FILES ${TRANSLATIONS_FILES})
ENDIF (UPDATE_TRANSLATIONS)
ENDIF(WITH_QT6)
ADD_CUSTOM_TARGET (translations ALL DEPENDS ${QM_FILES})