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

Removed FLTK dependencies from headless stage #86

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
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
57 changes: 38 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ SET( MIN_PLAYER 2.1.0 )
OPTION (BUILD_PLAYER_PLUGIN "Build Player plugin" ON)
OPTION (BUILD_LSPTEST "Build Player plugin tests" OFF)
OPTION (CPACK_CFG "[release building] generate CPack configuration files" ON)

# todo - this doesn't work yet. Run Stage headless with -g.
# OPTION (BUILD_GUI "Build FLTK-based GUI. If OFF, build a gui-less Stage useful e.g. for headless compute clusters." ON )
OPTION (BUILD_GUI "Build FLTK-based GUI. If OFF, build a gui-less Stage useful e.g. for headless compute clusters." ON )

IF (CMAKE_MAJOR_VERSION EQUAL 2 AND NOT CMAKE_MINOR_VERSION LESS 6)
cmake_policy( SET CMP0003 NEW )
Expand Down Expand Up @@ -52,8 +50,8 @@ endif( PROJECT_OS_OSX)
# Build type cflags
SET (OPTIMIZE "-O2")

SET (CMAKE_CXX_FLAGS_RELEASE "${FORCE_ARCH} ${OPTIMIZE} -DNDEBUG ${WALL}" CACHE INTERNAL "CXX Flags for release" FORCE)
SET (CMAKE_CXX_FLAGS_DEBUG "-ggdb ${FORCE_ARCH} ${WALL} -DDEBUG" CACHE INTERNAL "CXX Flags for debug" FORCE)
SET (CMAKE_CXX_FLAGS_RELEASE "${FORCE_ARCH} ${OPTIMIZE} -DNDEBUG ${WALL} -std=c++11" CACHE INTERNAL "CXX Flags for release" FORCE)
SET (CMAKE_CXX_FLAGS_DEBUG "-ggdb ${FORCE_ARCH} ${WALL} -DDEBUG -std=c++11" CACHE INTERNAL "CXX Flags for debug" FORCE)
SET (CMAKE_CXX_FLAGS_PROFILE "-ggdb -pg ${FORCE_ARCH} ${WALL}" CACHE INTERNAL "CXX Flags for profile" FORCE)

#####################################
Expand All @@ -62,6 +60,7 @@ IF (NOT CMAKE_BUILD_TYPE)
SET (CMAKE_BUILD_TYPE "release" CACHE STRING
"Choose the type of build, options are: release (default) debug profile" FORCE)
ENDIF (NOT CMAKE_BUILD_TYPE)

STRING(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)

MESSAGE( STATUS "Build type ${CMAKE_BUILD_TYPE}" )
Expand All @@ -73,13 +72,13 @@ SET(RGBFILE ${CMAKE_INSTALL_PREFIX}/share/stage/rgb.txt )
# Create the config.h file
# config.h belongs with the source (and not in CMAKE_CURRENT_BINARY_DIR as in Brian's original version)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
${CMAKE_CURRENT_SOURCE_DIR}/config.h @ONLY)
${CMAKE_CURRENT_SOURCE_DIR}/config.h @ONLY)

message( STATUS "Checking for libtool" )
find_path( LTDL_INCLUDE_DIR ltdl.h DOC "Libtool include dir" )
find_library( LTDL_LIB ltdl DOC "Libtool lib" )

include_directories(
include_directories(
${OPENGL_INCLUDE_DIR}
${LTDL_INCLUDE_DIR}
)
Expand All @@ -88,7 +87,6 @@ include_directories(
MESSAGE( STATUS "Checking for required libraries..." )

find_package( JPEG REQUIRED )

find_package( PNG REQUIRED )

# deal with new missing X11 on OS X 10.8 Mountain Lion
Expand All @@ -97,7 +95,7 @@ find_package( PNG REQUIRED )
# SET( PNG_INCLUDE_DIR /opt/X11/include )

set (FLTK_SKIP_FLUID TRUE)
find_package( FLTK REQUIRED )
find_package( FLTK )
find_package( OpenGL REQUIRED )

IF( NOT OPENGL_GLU_FOUND )
Expand All @@ -121,12 +119,22 @@ MESSAGE( STATUS "Checking for optional libraries..." )
SET(PC_LIBRARIES ${FLTK_LIBRARIES} ${OPENGL_LIBRARIES})
SET(PC_INCLUDE_DIRS ${FLTK_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR})

if(FLTK_FOUND)
LIST(APPEND PC_LIBRARIES ${FLTK_LIBRARIES})
LIST(APPEND PC_INCLUDE_DIRS ${FLTK_INCLUDE_DIR})
else(FLTK_FOUND)
if(BUILD_GUI)
message(STATUS "Could not find FLTK. Turning off BUILD_GUI")
set(BUILD_GUI OFF)
endif(BUILD_GUI)
endif(FLTK_FOUND)

SET(PC_LINK_FLAGS "")
FOREACH(LIB ${PC_LIBRARIES})
GET_FILENAME_COMPONENT(LIBNAME ${LIB} NAME_WE)
STRING(REGEX REPLACE "^lib" "" LINKLIB ${LIBNAME})
SET(PC_LINK_FLAGS "${PC_LINK_FLAGS} -l${LINKLIB}")
ENDFOREACH(LIB ${FLTK_LIBRARIES})
ENDFOREACH(LIB ${PC_LIBRARIES})

SET(PC_INCLUDE_FLAGS "")
FOREACH(INC ${PC_INCLUDE_DIRS})
Expand All @@ -141,14 +149,16 @@ MESSAGE( STATUS "Installation path CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}"

# all targets need these include directories
include_directories( .
libstage
replace
${FLTK_INCLUDE_DIR}
${PNG_INCLUDE_DIR}
${JPEG_INCLUDE_DIR}
${CMAKE_INCLUDE_PATH}
libstage
replace
${PNG_INCLUDE_DIR}
${JPEG_INCLUDE_DIR}
${CMAKE_INCLUDE_PATH}
)

if(FLTK_FOUND)
include_directories(${FLTK_INCLUDE_DIR})
endif(FLTK_FOUND)

# work through these subdirs
ADD_SUBDIRECTORY(libstage)
Expand Down Expand Up @@ -177,13 +187,21 @@ ENDIF ( BUILD_PLAYER_PLUGIN )
# Create the CMake module files (needs to be run after the stage target was created)
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} GREATER 2.8.11)
# Use a generator expression if the version of cmake allows it.
set(STAGE_TARGET_NAME "$<TARGET_FILE_NAME:stage>")
set(STAGE_CORE_TARGET_NAME "$<TARGET_FILE_NAME:stage_core>")
if(BUILD_GUI)
set(STAGE_TARGET_NAME "$<TARGET_FILE_NAME:stage>")
endif(BUILD_GUI)
else()
# Otherwise use the LOCATION property of the target (this will produce a warning on newer versions of cmake)
get_property(location_ TARGET stage PROPERTY LOCATION)
get_filename_component(STAGE_TARGET_NAME "${location_}" NAME)
get_property(location_ TARGET stage_core PROPERTY LOCATION)
get_filename_component(STAGE_CORE_TARGET_NAME "${location_}" NAME)
if(BUILD_GUI)
get_property(location_ TARGET stage PROPERTY LOCATION)
get_filename_component(STAGE_TARGET_NAME "${location_}" NAME)
endif(BUILD_GUI)
unset(location_)
endif()

CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/stage-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/stage-config.cmake @ONLY)
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} GREATER 2.8.11)
# Also run it through file(GENERATE ...) to expand generator expressions (if the version of cmake supports it).
Expand All @@ -192,6 +210,7 @@ if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} GREATER
INPUT ${CMAKE_CURRENT_BINARY_DIR}/stage-config.cmake)
endif()
CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/stage-config-version.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/stage-config-version.cmake @ONLY)

INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/stage-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/stage-config-version.cmake DESTINATION ${PROJECT_LIB_DIR}/cmake/${PROJECT_NAME})

# generate a cpack config file used to create packaged tarballs
Expand Down
6 changes: 3 additions & 3 deletions avonstage/avonstage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -445,20 +445,20 @@ int main(int argc, char *argv[])
// help options
case '?':
puts(USAGE);
exit(0);
return -1;
break;
default:
printf("unhandled option %c\n", ch);
puts(USAGE);
// exit(0);
return -1;
}
}

const char *worldfilename = argv[optind];

if (worldfilename == NULL) {
puts("[AvonStage] no worldfile specified on command line. Quit.\n");
exit(-1);
return -1;
}

puts(""); // end the first start-up line
Expand Down
2 changes: 1 addition & 1 deletion examples/ctrl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ set_source_files_properties( ${PLUGINS} PROPERTIES
)

foreach( PLUGIN ${PLUGINS} )
TARGET_LINK_LIBRARIES( ${PLUGIN} stage ${OPENGL_LIBRARIES} )
TARGET_LINK_LIBRARIES( ${PLUGIN} stage_core ${OPENGL_LIBRARIES} )
endforeach( PLUGIN )

# delete the "lib" prefix from the plugin libraries
Expand Down
7 changes: 4 additions & 3 deletions examples/ctrl/fasr2.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <pthread.h>

#include "stage.hh"
#include "canvas.hh"
using namespace Stg;

// generic planner implementation
Expand Down Expand Up @@ -152,7 +153,7 @@ class Robot {

explicit GraphVis(Graph **graphpp) : Visualizer("graph", "vis_graph"), graphpp(graphpp) {}
virtual ~GraphVis() {}
virtual void Visualize(Model *mod, Camera *)
virtual void Visualize(Model *mod, Camera *, Canvas * canvas)
{
if (*graphpp == NULL)
return;
Expand All @@ -166,9 +167,9 @@ class Robot {
Color c = mod->GetColor();
c.a = 0.4;

mod->PushColor(c);
canvas->PushColor(c);
(*graphpp)->Draw();
mod->PopColor();
canvas->PopColor();

glPopMatrix();
}
Expand Down
2 changes: 1 addition & 1 deletion examples/libstage/stest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ int main(int argc, char *argv[])
// check and handle the argumets
if (argc < 3) {
puts("Usage: stest <worldfile> <number of robots>");
exit(0);
return -1;
}

const int popsize = atoi(argv[2]);
Expand Down
131 changes: 67 additions & 64 deletions libstage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ MESSAGE( STATUS "Configuring libstage" )
# for config.h
include_directories(${PROJECT_BINARY_DIR})

set( stageSrcs
set(stageSrcs
block.cc
blockgroup.cc
camera.cc
Expand Down Expand Up @@ -31,77 +31,80 @@ set( stageSrcs
stage.cc
stage.hh
texture_manager.cc
typetable.cc
world.cc
worldfile.cc
canvas.cc
options_dlg.cc
options_dlg.hh
vis_strip.cc
worldgui.cc
typetable.cc
world.cc
worldfile.cc
canvas.cc
vis_strip.cc
ancestor.cc
image.cc
)

# model_getset.cc
# model_load.cc

#set_source_files_properties( ${stageSrcs} PROPERTIES COMPILE_FLAGS" )

add_library(stage SHARED ${stageSrcs})

# if fltk-config didn't bring along the OpenGL dependencies (eg. on
# Debian/Ubuntu), add them explicity
IF (NOT(${FLTK_LDFLAGS} MATCHES "-lGL"))
target_link_libraries( stage ${OPENGL_LIBRARIES})
ENDIF (NOT(${FLTK_LDFLAGS} MATCHES "-lGL"))


# causes the shared library to have a version number
set_target_properties( stage PROPERTIES
# Core library. Contains simulation code and most part of platform-independent rendering code
add_library(stage_core SHARED ${stageSrcs})
set_target_properties( stage_core PROPERTIES
VERSION ${VERSION}
# LINK_FLAGS "${FLTK_LDFLAGS}"
)
target_link_libraries( stage_core ${OPENGL_LIBRARIES} ${LTDL_LIB} ${JPEG_LIBRARIES} ${PNG_LIBRARIES})

target_link_libraries( stage
${LTDL_LIB}
${JPEG_LIBRARIES}
${PNG_LIBRARIES}
${FLTK_LIBRARIES}
)

set( stagebinarySrcs main.cc )
set_source_files_properties( ${stagebinarySrcs} PROPERTIES COMPILE_FLAGS "${FLTK_CFLAGS}" )

# TODO: build an app bundle on OS X
#set(MACOSX_BUNDLE_INFO_STRING "${PROJECT_NAME}")
#set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.playerstage.stage")
#set(MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_NAME} Version ${VERSION}")
#set(MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME})
#set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${VERSION})
#set(MACOSX_BUNDLE_BUNDLE_VERSION ${VERSION})
#set(MACOSX_BUNDLE_COPYRIGHT "Copyright 2010. All Rights Reserved.")
# add_executable( stagebinary MACOSX_BUNDLE ${stagebinarySrcs} )

add_executable( stagebinary ${stagebinarySrcs} )


set_target_properties( stagebinary PROPERTIES OUTPUT_NAME stage )

# Apple seems to have trouble when libstage and stagebinary are linked against FLTK
# Newer Linux distributions won't allow stagebinary to inherit libstage's links to fltk, so we need
# to explicitly link on Linux

target_link_libraries( stagebinary stage )

IF(PROJECT_OS_LINUX)
target_link_libraries( stagebinary stage pthread )
ENDIF(PROJECT_OS_LINUX)
# Headless binary version. Does not need FLTK, but stil references a lot of OpenGL
add_executable( stagebinary_headless main_headless.cc )
set_target_properties( stagebinary_headless PROPERTIES OUTPUT_NAME stage_headless )
target_link_libraries( stagebinary_headless stage_core )

INSTALL(TARGETS stagebinary stage
RUNTIME DESTINATION bin
LIBRARY DESTINATION ${PROJECT_LIB_DIR}
install(TARGETS stagebinary_headless stage_core
RUNTIME DESTINATION bin LIBRARY DESTINATION ${PROJECT_LIB_DIR}
)

INSTALL(FILES stage.hh
DESTINATION include/${PROJECT_NAME}-${APIVERSION})
install(FILES stage.hh DESTINATION include/${PROJECT_NAME}-${APIVERSION})

# GUI part of the stage
if(FLTK_FOUND AND BUILD_GUI)
add_library(stage SHARED canvas_fltk.cc options_dlg.cc menu_manager_fltk.cc worldgui.cc)

# if fltk-config didn't bring along the OpenGL dependencies (eg. on
# Debian/Ubuntu), add them explicity
IF (NOT(${FLTK_LDFLAGS} MATCHES "-lGL"))
target_link_libraries( stage ${OPENGL_LIBRARIES})
ENDIF (NOT(${FLTK_LDFLAGS} MATCHES "-lGL"))

# causes the shared library to have a version number
set_target_properties( stage PROPERTIES
VERSION ${VERSION}
# LINK_FLAGS "${FLTK_LDFLAGS}"
)

target_link_libraries( stage stage_core ${FLTK_LIBRARIES})

set( stagebinarySrcs main.cc )
set_source_files_properties( ${stagebinarySrcs} PROPERTIES COMPILE_FLAGS "${FLTK_CFLAGS}" )

# TODO: build an app bundle on OS X
#set(MACOSX_BUNDLE_INFO_STRING "${PROJECT_NAME}")
#set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.playerstage.stage")
#set(MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_NAME} Version ${VERSION}")
#set(MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME})
#set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${VERSION})
#set(MACOSX_BUNDLE_BUNDLE_VERSION ${VERSION})
#set(MACOSX_BUNDLE_COPYRIGHT "Copyright 2010. All Rights Reserved.")
# add_executable( stagebinary MACOSX_BUNDLE ${stagebinarySrcs} )

add_executable( stagebinary ${stagebinarySrcs} )
set_target_properties( stagebinary PROPERTIES OUTPUT_NAME stage )

# Apple seems to have trouble when libstage and stagebinary are linked against FLTK
# Newer Linux distributions won't allow stagebinary to inherit libstage's links to fltk, so we need
# to explicitly link on Linux
target_link_libraries( stagebinary stage_core stage )

if(PROJECT_OS_LINUX)
target_link_libraries( stagebinary stage pthread )
endif(PROJECT_OS_LINUX)
install(TARGETS stagebinary stage RUNTIME DESTINATION bin LIBRARY DESTINATION ${PROJECT_LIB_DIR})

# All GUI-specific code was stripped from stage.hh
# GUI-supported world now is located at world_gui.hh, so it should be installed
install(FILES world_gui.hh DESTINATION include/${PROJECT_NAME}-${APIVERSION})
endif(FLTK_FOUND AND BUILD_GUI)

7 changes: 2 additions & 5 deletions libstage/block.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "region.hh"
#include "worldfile.hh"



using namespace Stg;
using std::vector;

Expand Down Expand Up @@ -39,8 +41,6 @@ void Block::Translate(double x, double y)
it->x += x;
it->y += y;
}

group->BuildDisplayList();
}

/** Return the value half way between the min and max Y position of
Expand Down Expand Up @@ -108,9 +108,6 @@ void Block::SetZ(double min, double max)
{
local_z.min = min;
local_z.max = max;

// force redraw
group->BuildDisplayList();
}

void Block::AppendTouchingModels(std::set<Model *> &touchers)
Expand Down
Loading