Skip to content

Commit

Permalink
Clean up CMakeLists.txt for gui-osg
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 committed Nov 11, 2024
1 parent e18ea4b commit aebadb1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 37 deletions.
13 changes: 12 additions & 1 deletion cmake/DARTFindOpenSceneGraph.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

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: 19 additions & 34 deletions dart/gui/osg/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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})
Expand Down

0 comments on commit aebadb1

Please sign in to comment.