Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GUI] Fix compilation using QDocBrowser #4354

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions Sofa/GUI/Qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ cmake_minimum_required(VERSION 3.12)
project(Sofa.GUI.Qt LANGUAGES CXX)

# Qt dependencies
set(QT_TARGETS "")
set(SOFA_GUI_QT_TARGETS "")
set(QT_USE_IMPORTED_TARGETS 1)
set(QT5_NO_LINK_QTMAIN 1)




# Will only use Qt6 if Qt6 is found and Qt5 is not found
# if Qt5 and Qt6 are both found, Qt5 will take priority
# Qt6 needs cmake >= 3.16, https://doc.qt.io/qt-6/cmake-get-started.html
Expand All @@ -19,11 +22,11 @@ endif()
if (Qt5Core_FOUND)
message("${PROJECT_NAME}: will use Qt5")
sofa_find_package(Qt5 COMPONENTS Core Gui OpenGL REQUIRED)
set(QT_TARGETS ${QT_TARGETS} Qt5::Core Qt5::Gui Qt5::OpenGL)
set(SOFA_GUI_QT_TARGETS ${SOFA_GUI_QT_TARGETS} Qt5::Core Qt5::Gui Qt5::OpenGL)
elseif (Qt6Core_FOUND)
message("${PROJECT_NAME}: will use Qt6 (beta)")
sofa_find_package(Qt6 COMPONENTS Gui GuiTools Widgets WidgetsTools OpenGLWidgets REQUIRED)
set(QT_TARGETS ${QT_TARGETS} Qt::Core Qt::Gui Qt::Widgets Qt::OpenGLWidgets )
set(SOFA_GUI_QT_TARGETS ${SOFA_GUI_QT_TARGETS} Qt::Core Qt::Gui Qt::Widgets Qt::OpenGLWidgets )
else()
message(SEND_ERROR "${PROJECT_NAME}: Could not find either Qt5 or Qt6.")
endif()
Expand All @@ -32,24 +35,25 @@ if (Qt5Core_FOUND)
# Profiling
sofa_find_package(Qt5 COMPONENTS Charts QUIET BOTH_SCOPES)
if(Qt5Charts_FOUND)
set(QT_TARGETS ${QT_TARGETS} Qt5::Charts)
set(SOFA_GUI_QT_TARGETS ${SOFA_GUI_QT_TARGETS} Qt5::Charts)
else()
message(STATUS "${PROJECT_NAME}: Qt5Charts not found. No chart nor Profile will be compiled")
endif()

# QDocBrowser
find_package(Qt5 COMPONENTS WebEngine QUIET) # if found, then QDocBrowser will be ON by default
option(SOFA_GUI_QT_ENABLE_QDOCBROWSER "Build the QDocBrowser. QtWebEngine is needed." ${Qt5WebEngine_FOUND})

if(SOFA_GUI_QT_ENABLE_QDOCBROWSER)
sofa_find_package(Qt5 COMPONENTS WebEngine WebEngineWidgets REQUIRED BOTH_SCOPES)
set(QT_TARGETS ${QT_TARGETS} Qt5::WebEngine Qt5::WebEngineWidgets)
set(SOFA_GUI_QT_TARGETS ${SOFA_GUI_QT_TARGETS} Qt5::WebEngine Qt5::WebEngineWidgets)
endif()
elseif (Qt6Core_FOUND)

# Profiling
sofa_find_package(Qt6 COMPONENTS Charts QUIET BOTH_SCOPES)
if(Qt6Charts_FOUND)
set(QT_TARGETS ${QT_TARGETS} Qt::Charts)
set(SOFA_GUI_QT_TARGETS ${SOFA_GUI_QT_TARGETS} Qt::Charts)
else()
message(STATUS "${PROJECT_NAME}: Qt6 Charts not found. No chart nor Profile will be compiled")
endif()
Expand All @@ -60,11 +64,13 @@ elseif (Qt6Core_FOUND)
if(SOFA_GUI_QT_ENABLE_QDOCBROWSER)
# WebEngineCore needs Positioning WebChannel at cmake configure step (?)
sofa_find_package(Qt6 COMPONENTS Positioning WebChannel WebEngineCore WebEngineWidgets REQUIRED BOTH_SCOPES)
set(QT_TARGETS ${QT_TARGETS} Qt::WebEngineCore Qt::WebEngineWidgets)
set(SOFA_GUI_QT_TARGETS ${SOFA_GUI_QT_TARGETS} Qt::WebEngineCore Qt::WebEngineWidgets)
endif()
endif()


find_package(Sofa.GL QUIET)

# QtViewer and QGLViewer
if(Sofa.GL_FOUND)
# QtViewer
Expand Down Expand Up @@ -109,6 +115,8 @@ if(SOFA_DUMP_VISITOR_INFO)
sofa_find_package(TinyXML REQUIRED BOTH_SCOPES)
endif()



set(SRC_ROOT src/sofa/gui/qt)

set(MOC_HEADER_FILES
Expand Down Expand Up @@ -212,6 +220,7 @@ set(QRC_FILES
${SRC_ROOT}/resources/RealGUI.qrc
)


if(SOFA_DUMP_VISITOR_INFO)
list(APPEND MOC_HEADER_FILES
${SRC_ROOT}/WindowVisitor.h
Expand Down Expand Up @@ -286,6 +295,8 @@ else()
endif()




#NodeEditor
if (SOFA_GUI_QT_ENABLE_NODEGRAPH)
list(APPEND MOC_HEADER_FILES
Expand Down Expand Up @@ -315,13 +326,16 @@ sofa_find_package(Sofa.Component.SceneUtility REQUIRED)
set(CMAKE_AUTORCC ON)
add_library(${PROJECT_NAME} SHARED ${MOC_HEADER_FILES} ${HEADER_FILES} ${MOC_FILES} ${FORM_FILES} ${SOURCE_FILES} ${QRC_FILES})


# For files generated by the moc
target_include_directories(${PROJECT_NAME} PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>")

target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.GUI.Common)
target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Component.Visual)
target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Component.SceneUtility)
target_link_libraries(${PROJECT_NAME} PUBLIC ${QT_TARGETS})
target_link_libraries(${PROJECT_NAME} PUBLIC ${SOFA_GUI_QT_TARGETS})



if(SOFA_DUMP_VISITOR_INFO)
target_link_libraries(${PROJECT_NAME} PUBLIC tinyxml)
Expand Down Expand Up @@ -357,6 +371,9 @@ install(FILES "${CMAKE_BINARY_DIR}/etc/installed${PROJECT_NAME}.ini" DESTINATION

install(DIRECTORY "${SRC_ROOT}/resources/" DESTINATION "share/sofa/gui/qt" COMPONENT resources)




sofa_create_package_with_targets(
PACKAGE_NAME ${PROJECT_NAME}
PACKAGE_VERSION ${Sofa_VERSION}
Expand Down
6 changes: 3 additions & 3 deletions Sofa/GUI/Qt/libQGLViewer/QGLViewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ endif()

if (Qt5Core_FOUND)
sofa_find_package(Qt5 COMPONENTS Core Gui Xml OpenGL Widgets REQUIRED)
set(QT_TARGETS Qt5::Core Qt5::Gui Qt5::Xml Qt5::OpenGL Qt5::Widgets)
set(QGLViewer_QT_TARGETS Qt5::Core Qt5::Gui Qt5::Xml Qt5::OpenGL Qt5::Widgets)
elseif (Qt6Core_FOUND)
sofa_find_package(Qt6 COMPONENTS Gui GuiTools Widgets WidgetsTools OpenGLWidgets Xml REQUIRED)
set(QT_TARGETS ${QT_TARGETS} Qt::Core Qt::Gui Qt::Widgets Qt::OpenGLWidgets Qt::Xml)
set(QGLViewer_QT_TARGETS ${QGLViewer_QT_TARGETS} Qt::Core Qt::Gui Qt::Widgets Qt::OpenGLWidgets Qt::Xml)
endif()

set(MOC_HEADER_FILES
Expand Down Expand Up @@ -98,7 +98,7 @@ endif()
add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${MOC_FILES} ${FORM_FILES} ${SOURCE_FILES})

set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "SofaExtlibs")
target_link_libraries(${PROJECT_NAME} PUBLIC ${QT_TARGETS})
target_link_libraries(${PROJECT_NAME} PUBLIC ${QGLViewer_QT_TARGETS})
if(TARGET OpenGL::GL AND TARGET OpenGL::GLU) # Imported targets defined since CMake 3.8
target_link_libraries(${PROJECT_NAME} PUBLIC OpenGL::GL OpenGL::GLU)
else()
Expand Down
Loading