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

Fix imgui is not properly set when DART_USE_SYSTEM_IMGUI=ON #1877

Merged
merged 3 commits into from
Nov 12, 2024
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
12 changes: 11 additions & 1 deletion cmake/DARTFindOpenSceneGraph.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,20 @@
#
# This file is provided under the "BSD-style" License

find_package(OpenSceneGraph 3.6.5 QUIET
find_package(OpenSceneGraph 3.0.0 QUIET
COMPONENTS osg osgViewer osgManipulator osgGA osgDB osgShadow osgUtil
)

# OpenSceneGraph 3.6.5 or less are not compatible with macOS 10.15 (Catalina) or greater
# See:
# - https://github.com/openscenegraph/OpenSceneGraph/issues/926
# - https://github.com/dartsim/dart/issues/1439
if(APPLE)
if(OPENSCENEGRAPH_VERSION VERSION_LESS 3.7.0)
message(WARNING "OSG (${OPENSCENEGRAPH_VERSION} < 3.7.0) doesn't work on macOS 10.15 or greater. See: https://github.com/openscenegraph/OpenSceneGraph/issues/926")
endif()
endif()

# It seems that OPENSCENEGRAPH_FOUND will inadvertently get set to true when
# OpenThreads is found, even if OpenSceneGraph is not installed. This is quite
# possibly a bug in OSG's cmake configuration file. For now, it seems that
Expand Down
3 changes: 1 addition & 2 deletions dart/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ add_component_dependencies(
utils
external-lodepng
)
add_component_dependency_packages(${PROJECT_NAME} ${component_name} OpenGL)
add_component_dependency_packages(${PROJECT_NAME} ${component_name} GLUT)
add_component_dependency_packages(${PROJECT_NAME} ${component_name} OpenGL GLUT)

# Add subdirectories
add_subdirectory(osg)
Expand Down
53 changes: 20 additions & 33 deletions dart/gui/osg/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,37 +1,32 @@
if(NOT DART_BUILD_GUI_OSG)
message(STATUS "Skipping OpenSceneGraph (DART_BUILD_GUI_OSG == ${DART_BUILD_GUI_OSG})")
return()
endif()

# Set local target name
set(target_name ${PROJECT_NAME}-gui-osg)
set(component_name gui-osg)
set(component_dependencies )
set(component_dependency_packages )
set(link_libraries )

# Dependency checks
dart_check_dependent_target(${target_name} dart-gui)

# Minimum required OSG version
set(min_osg_version 3.0.0)
# OpenSceneGraph 3.6.5 or less are not compatible with macOS 10.15 (Catalina) or greater
# See:
# - https://github.com/openscenegraph/OpenSceneGraph/issues/926
# - https://github.com/dartsim/dart/issues/1439
if(APPLE)
if(NOT ${CMAKE_SYSTEM_VERSION} VERSION_LESS 19)
set(min_osg_version 3.7.0)
endif()
endif()

# OpenSceneGraph
if(DART_BUILD_GUI_OSG)
dart_find_package(OpenSceneGraph)
dart_check_required_package(OpenSceneGraph "dart-gui-osg" "OpenSceneGraph" "3.0")
dart_find_package(OpenSceneGraph)
dart_check_required_package(OpenSceneGraph "dart-gui-osg" "OpenSceneGraph")
list(APPEND component_dependency_packages OpenSceneGraph)

# ImGui
if(DART_USE_SYSTEM_IMGUI)
dart_find_package(imgui)
dart_check_required_package(imgui "imgui")
else()
#
endif()
# ImGui
if(DART_USE_SYSTEM_IMGUI)
dart_find_package(imgui)
dart_check_required_package(imgui "imgui")
list(APPEND component_dependency_packages imgui)
list(APPEND link_libraries imgui::imgui)
else()
message(STATUS "Skipping OpenSceneGraph (DART_BUILD_GUI_OSG == ${DART_BUILD_GUI_OSG})")
return()
list(APPEND component_dependencies external-imgui)
list(APPEND link_libraries ${PROJECT_NAME}-external-imgui)
endif()

# Search all header and source files
Expand All @@ -46,22 +41,14 @@ set(dart_gui_osg_srcs ${srcs} ${detail_srcs})
add_subdirectory(render)

# Add target
if(DART_USE_SYSTEM_IMGUI)
set(link_libraries imgui::imgui)
else()
set(link_libraries ${PROJECT_NAME}-external-imgui)
endif()
dart_add_library(${target_name} ${hdrs} ${srcs} ${dart_gui_osg_hdrs} ${dart_gui_osg_srcs})
target_link_libraries(${target_name} dart-gui osg::osg ${link_libraries})

# Component
if(NOT DART_USE_SYSTEM_IMGUI)
set(component_dependencies external-imgui)
endif()
add_component(${PROJECT_NAME} ${component_name})
add_component_targets(${PROJECT_NAME} ${component_name} ${target_name})
add_component_dependencies(${PROJECT_NAME} ${component_name} gui ${component_dependencies})
add_component_dependency_packages(${PROJECT_NAME} ${component_name} OpenSceneGraph)
add_component_dependency_packages(${PROJECT_NAME} ${component_name} ${component_dependency_packages})

# Generate header for this namespace
dart_get_filename_components(header_names "gui osg headers" ${hdrs})
Expand Down
Loading