From aebadb101726c9f5bbbc5fcce675969540c2af6e Mon Sep 17 00:00:00 2001 From: Jeongseok Lee Date: Mon, 11 Nov 2024 15:16:56 -0800 Subject: [PATCH] Clean up CMakeLists.txt for gui-osg --- cmake/DARTFindOpenSceneGraph.cmake | 13 +++++++- dart/gui/CMakeLists.txt | 3 +- dart/gui/osg/CMakeLists.txt | 53 +++++++++++------------------- 3 files changed, 32 insertions(+), 37 deletions(-) diff --git a/cmake/DARTFindOpenSceneGraph.cmake b/cmake/DARTFindOpenSceneGraph.cmake index be084ceb37406..9f2e2a6e69ee8 100644 --- a/cmake/DARTFindOpenSceneGraph.cmake +++ b/cmake/DARTFindOpenSceneGraph.cmake @@ -6,7 +6,18 @@ # # This file is provided under the "BSD-style" License -find_package(OpenSceneGraph 3.6.5 QUIET +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() + +find_package(OpenSceneGraph ${min_osg_version} QUIET COMPONENTS osg osgViewer osgManipulator osgGA osgDB osgShadow osgUtil ) 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 83d2508c4239d..2bc19a81253a6 100644 --- a/dart/gui/osg/CMakeLists.txt +++ b/dart/gui/osg/CMakeLists.txt @@ -1,39 +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() - -set(component_dependency_packages ) - # OpenSceneGraph -if(DART_BUILD_GUI_OSG) - dart_find_package(OpenSceneGraph) - dart_check_required_package(OpenSceneGraph "dart-gui-osg" "OpenSceneGraph" "3.0") - list(APPEND component_dependency_packages OpenSceneGraph) +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") - list(APPEND component_dependency_packages imgui) - 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 @@ -48,18 +41,10 @@ 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})