Skip to content

Commit

Permalink
Fix GLUT dependency check for Windows (#1405)
Browse files Browse the repository at this point in the history
* Test if find_package(GLUT) works on Windows

* Set DART_VERBOSE=On on Appveyor

* Print warning for disabled component due to missing dependent target

* Install tinyxml2 on Appveyor

* Install opengl and freeglut to see if dart-gui is built

* Update glut package name
  • Loading branch information
jslee02 authored Aug 17, 2019
1 parent 7b8cb9e commit 245aafb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 24 deletions.
3 changes: 2 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ install:
- cmd: vcpkg install --recurse --triplet %VCPKG_ARCH% assimp boost-system boost-filesystem ccd eigen3 fcl

# install optional dependencies
#- vcpkg install --recurse --triplet %VCPKG_ARCH% bullet3 flann freeglut nlopt ode opengl osg tinyxml2 urdfdom
- cmd: vcpkg install --recurse --triplet %VCPKG_ARCH% freeglut opengl tinyxml2
#- vcpkg install --recurse --triplet %VCPKG_ARCH% bullet3 flann nlopt ode osg urdfdom
#- vcpkg install ipopt:%VCPKG_ARCH%

- cmd: vcpkg integrate install
Expand Down
10 changes: 10 additions & 0 deletions cmake/DARTMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ macro(dart_check_optional_package variable component dependency)
endif()
endmacro()

#===============================================================================
macro(dart_check_dependent_target target)
foreach(dependent_target ${ARGN})
if (NOT TARGET ${dependent_target})
message(WARNING "${target} is disabled because dependent target ${dependent_target} is not being built.")
return()
endif()
endforeach()
endmacro()

#===============================================================================
function(dart_add_custom_target rel_dir property_name)
set(abs_dir "${CMAKE_CURRENT_LIST_DIR}/${rel_dir}")
Expand Down
28 changes: 12 additions & 16 deletions dart/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# Set local target name
set(target_name ${PROJECT_NAME}-gui)
set(component_name gui)

# Dependency checks
if (NOT TARGET dart-utils)
return()
endif()
dart_check_dependent_target(${target_name} dart-utils)

dart_find_package(OpenGL)
dart_check_optional_package(OPENGL "dart-gui" "OpenGL")

dart_find_package(GLUT)
if(WIN32 AND NOT CYGWIN)
set(GLUT_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include")
set(GLUT_LIBRARIES glut32)
set(HAVE_GLUT TRUE)
dart_check_optional_package(GLUT "dart-gui" "freeglut")
else()
dart_find_package(GLUT)
dart_check_optional_package(GLUT "dart-gui" "freeglut3")
if(GLUT_FOUND)
set(HAVE_GLUT TRUE)
else()
set(HAVE_GLUT FALSE)
endif()
endif()
if(GLUT_FOUND)
set(HAVE_GLUT TRUE)
else()
set(HAVE_GLUT FALSE)
endif()

# Search all header and source files
Expand All @@ -38,10 +38,6 @@ add_subdirectory(glut)
get_property(dart_gui_headers GLOBAL PROPERTY DART_GUI_HEADERS)
get_property(dart_gui_sources GLOBAL PROPERTY DART_GUI_SOURCES)

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

# Add target
dart_add_library(${target_name}
${hdrs} ${srcs} ${dart_gui_headers} ${dart_gui_sources}
Expand Down
12 changes: 5 additions & 7 deletions dart/gui/osg/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Set local target name
set(target_name ${PROJECT_NAME}-gui-osg)
set(component_name gui-osg)

# Dependency checks
if (NOT TARGET dart-gui)
return()
endif()
dart_check_dependent_target(${target_name} dart-gui)

# OpenSceneGraph
if(DART_BUILD_GUI_OSG)
Expand Down Expand Up @@ -62,10 +64,6 @@ set(dart_gui_osg_srcs ${srcs})

add_subdirectory(render)

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

# Add target
dart_add_library(${target_name} ${hdrs} ${srcs} ${dart_gui_osg_hdrs} ${dart_gui_osg_srcs})
target_include_directories(
Expand Down

0 comments on commit 245aafb

Please sign in to comment.