Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Fix compilation for Qt6#1023

Open
jporcher wants to merge2 commits intocommontk:master
base:master
Choose a base branch
Loading
fromjporcher:qt6_support

Conversation

jporcher
Copy link

Few changes to make code compile with Qt6. Did not test the changes as I'm not familiar with the classes modified. However, at least it compiles if one wants to play with it.

Copy link
Member

@lassoanlassoan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is awesome, thanks a lot for your contribution. I've added a couple of comments, it would be great if you could update your pull request based on them (but if you don't have time for it then we'll eventually get to it when CTK will have Qt6 support officially).

@jporcher
Copy link
Author

@lassoan Thank you for your comments, I updated the code and hopefully the pull request (I'm not a Git expert). Please let me know if it looks OK now!

@jporcher
Copy link
Author

@lassoan Let me know if there's any action expected from me to have this pull requested be merged to your master.

@lassoan
Copy link
Member

How did you build CTK with Qt6? I'm getting errors that Qt cannot be found when I'm trying to build with Qt6.

What did you set yourCTK_QT_VERSION CMake variableto: 5 or 6?
Did you specifyQt5_DIR orQt6_DIR variable?

There are lots of hardcoded references to Qt5 in the CMake files. They would need to be changed similarly to how it was done for VTK:Kitware/VTK@190059d

@jporcher
Copy link
Author

@lassoan Sorry, but I'm not using the original CMakeLists.txt, I've written my own.

In mine, I simply changed:
QT5_WRAP_CPP toQT_WRAP_CPP
QT5_WRAP_UI toQT_WRAP_UI
QT5_ADD_RESOURCES toQT_ADD_RESOURCES

Also had to setset(CMAKE_CXX_STANDARD 17)

And, as you mentioned, many variables had to be changed, if you setCTK_QT_VERSION to6 thenQt5_DIR must be set toQt${CTK_QT_VERSION}_DIR,find_package(Qt5Core) to find_package(Qt${CTK_QT_VERSION}Core)...etc

@lassoan
Copy link
Member

Please commit all your changes that were necessary to build with Qt6. We would then review those changes and either merge them or fix them up/generalize. Thank you very much!

@jporcher
Copy link
Author

As I mentioned, I did not use your CMakeLIsts.txt to build the library, so all the "changes" I did are commited. I have no more contribution available...

I gave a quick look at your code, there are many places where you do testCTK_QT_VERSION and thay all have to be reworked.

First main change is to lookup for Qt6 instead of Qt5, so in ctkMacroSetupQt.cmake:

if(CTK_QT_VERSION VERSION_GREATER "4")...else()...endif()

has to be changed to something like:

if(CTK_QT_VERSION VERSION_GREATER "5")    cmake_minimum_required(VERSION 3.16)    set(CMAKE_CXX_STANDARD 17)    set(CMAKE_CXX_STANDARD_REQUIRED ON)    find_package(Qt6)    set(CTK_QT6_COMPONENTS Core Xml Concurrent Sql Test Multimedia)    if(CTK_ENABLE_Widgets OR CTK_LIB_Widgets OR CTK_LIB_CommandLineModules/Frontend/QtGui OR CTK_BUILD_ALL OR CTK_BUILD_ALL_LIBRARIES)      list(APPEND CTK_QT6_COMPONENTS Widgets OpenGL UiTools)    endif()    if(CTK_LIB_CommandLineModules/Frontend/QtWebKit OR CTK_BUILD_ALL OR CTK_BUILD_ALL_LIBRARIES)      if(TARGET Qt6::WebKitWidgets)        list(APPEND CTK_QT6_COMPONENTS WebKitWidgets)      else()        list(APPEND CTK_QT6_COMPONENTS WebEngineWidgets)      endif()    endif()    if(CTK_LIB_XNAT/Core OR CTK_BUILD_ALL OR CTK_BUILD_ALL_LIBRARIES)      list(APPEND CTK_QT6_COMPONENTS Script)    endif()    find_package(Qt6 COMPONENTS ${CTK_QT6_COMPONENTS} REQUIRED)    mark_as_superbuild(Qt6_DIR) # Qt 6    # XXX Backward compatible way    if(DEFINED CMAKE_PREFIX_PATH)      mark_as_superbuild(CMAKE_PREFIX_PATH) # Qt 6    endif()elseif(CTK_QT_VERSION VERSION_GREATER "4")...else()...endif()

Then all other places has to be reworked as well, like, for instance, in Libs\Visualization\VTK\Core\Testing\Cpp\CMakeLists.txt:

if(CTK_QT_VERSION VERSION_GREATER "4")  QT5_WRAP_CPP(KIT_HELPER_SRCS ctkVTKObjectTestHelper.h)  include_directories(${Qt5Widgets_INCLUDE_DIRS})else()  QT4_WRAP_CPP(KIT_HELPER_SRCS ctkVTKObjectTestHelper.h)endif()

should be changed to:

if(CTK_QT_VERSION VERSION_GREATER "5")  QT6_WRAP_CPP(KIT_HELPER_SRCS ctkVTKObjectTestHelper.h)  include_directories(${Qt6Widgets_INCLUDE_DIRS})elseif(CTK_QT_VERSION VERSION_GREATER "4")  QT5_WRAP_CPP(KIT_HELPER_SRCS ctkVTKObjectTestHelper.h)  include_directories(${Qt5Widgets_INCLUDE_DIRS})else()  QT4_WRAP_CPP(KIT_HELPER_SRCS ctkVTKObjectTestHelper.h)endif()

etc....

You may also decide to use versionless commands, and then, you simply need to remove the Qt version suffix and use${CTK_QT_VERSION} when needed. This would be more elegant and easy to maintain:

if(CTK_QT_VERSION VERSION_GREATER "4")  QT_WRAP_CPP(KIT_HELPER_SRCS ctkVTKObjectTestHelper.h)  include_directories(${Qt${CTK_QT_VERSION}Widgets_INCLUDE_DIRS})else()  QT4_WRAP_CPP(KIT_HELPER_SRCS ctkVTKObjectTestHelper.h)endif()

@jamesobutler
Copy link
Contributor

@jporcher How did you build CTK without using the CMakeLists.txt provided athttps://github.com/jporcher/CTK/blob/qt6_support/CMakeLists.txt? Can you commit the CMakeLists.txt that you used for your own project?

@jporcher
Copy link
Author

@jamesobutler That would be difficult as this CMakeLists.txt has dependencies on other files of my project, but I can paste you some part of it:

set (LIBNAME qtcommontk)# This project compiles the external library qwtPROJECT(${LIBNAME})SET( CMAKE_DEBUG_POSTFIX ${SDE_DEBUG_FLAG} )file( GLOB C_filesLibs/Widgets/ctkBasePopupWidget.cppLibs/Widgets/ctkDoubleRangeSlider.cppLibs/Widgets/ctkDoubleRangeSliderEventPlayer.cppLibs/Widgets/ctkDoubleRangeSliderEventTranslator.cppLibs/Widgets/ctkDoubleSlider.cppLibs/Widgets/ctkDoubleSpinBox.cppLibs/Widgets/ctkPopupWidget.cppLibs/Widgets/ctkRangeSlider.cppLibs/Widgets/ctkRangeWidget.cppLibs/Widgets/ctkSliderWidget.cppLibs/Core/ctkUtils.cppLibs/Core/ctkValueProxy.cppLibs/Widgets/ctkWidgetsUtils.cpp../QtTesting-master/pqWidgetEventPlayer.cxx../QtTesting-master/pqWidgetEventTranslator.cxx )file( GLOB H_filesLibs/Widgets/ctkBasePopupWidget.hLibs/Widgets/ctkDoubleRangeSlider.hLibs/Widgets/ctkDoubleRangeSliderEventPlayer.hLibs/Widgets/ctkDoubleRangeSliderEventTranslator.hLibs/Widgets/ctkDoubleSlider.hLibs/Widgets/ctkDoubleSpinBox.hLibs/Widgets/ctkPopupWidget.hLibs/Widgets/ctkRangeSlider.hLibs/Widgets/ctkRangeWidget.hLibs/Widgets/ctkSliderWidget.hLibs/Core/ctkUtils.hLibs/Core/ctkValueProxy.hLibs/Widgets/ctkWidgetsUtils.hLibs/Widgets/ctkBasePopupWidget_p.hLibs/Widgets/ctkDoubleSpinBox_p.hLibs/Widgets/ctkPopupWidget_p.h../QtTesting-master/pqWidgetEventPlayer.h../QtTesting-master/pqWidgetEventTranslator.h )file( GLOB UI_files Libs/Widgets/Resources/UI/ctkRangeWidget.ui Libs/Widgets/Resources/UI/ctkSliderWidget.ui )file( GLOB QRC_files Libs/Widgets/Resources/ctkWidgets.qrc )# We need to include all directories where the headers areinclude_directories( Libs/Widgets )include_directories( Libs/Core )include_directories( ../QtTesting-master )include_directories( sde )SET(SDE3P_QTSDEVER 6)SET(SDE3P_QTDIR "${CMAKE_CURRENT_LIST_DIR}/../../qt/6.2.2")MESSAGE( "Set QTDIR=${SDE3P_QTDIR}" )find_package(Qt${SDE3P_QTSDEVER}Core)find_package(Qt${SDE3P_QTSDEVER}Gui)find_package(Qt${SDE3P_QTSDEVER}Widgets)set( pre_qt_wrap_sources ${C_files} )QT_WRAP_CPP( MOC_FILES ${H_files})list( APPEND C_files ${MOC_FILES} )QT_WRAP_UI( UIC_SRCS ${UI_files} )list( APPEND C_files ${UIC_SRCS} )QT_ADD_RESOURCES( QRC_SRCS ${QRC_files} )list( APPEND C_files ${QRC_SRCS} )# C++17 is required by Qt6add_definitions( "/Zc:__cplusplus" )set(CMAKE_CXX_STANDARD 17)# Library will depend on all source filesADD_LIBRARY( ${LIBNAME} SHARED ${C_files} ${H_files} ${SRCS_CXX})include_directories( ${QT_INCLUDE_DIR} )include_directories( ${QT_INCLUDE_DIR}/QtCore )include_directories( ${QT_INCLUDE_DIR}/QtGui )include_directories( ${QT_INCLUDE_DIR}/QtWidgets )

@EricAtORSEricAtORS mentioned this pull requestDec 7, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@lassoanlassoanlassoan left review comments

Assignees
No one assigned
Labels
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@jporcher@lassoan@jamesobutler

[8]ページ先頭

©2009-2025 Movatter.jp