diff --git a/cmake/DARTFindOpenSceneGraph.cmake b/cmake/DARTFindOpenSceneGraph.cmake index be084ceb37406..4adb705020067 100644 --- a/cmake/DARTFindOpenSceneGraph.cmake +++ b/cmake/DARTFindOpenSceneGraph.cmake @@ -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 diff --git a/dart/gui/CMakeLists.txt b/dart/gui/CMakeLists.txt index ac5966a5b1192..e89d98ebcc912 100644 --- a/dart/gui/CMakeLists.txt +++ b/dart/gui/CMakeLists.txt @@ -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) diff --git a/dart/gui/osg/CMakeLists.txt b/dart/gui/osg/CMakeLists.txt index a6a58eae805df..2bc19a81253a6 100644 --- a/dart/gui/osg/CMakeLists.txt +++ b/dart/gui/osg/CMakeLists.txt @@ -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 @@ -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})