Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

simplified CMake files, using cmake's find for png, jpeg and fltk

  • Loading branch information...
commit 270d5cfc5f782f5b0999452643287ec1ef1d6c8d 1 parent 7dd4454
@rtv authored
View
114 CMakeLists.txt
@@ -42,9 +42,16 @@ ENDIF (NOT PROJECT_OS_WIN AND NOT PROJECT_OS_SOLARIS)
#####################################
# Build type cflags
SET (OPTIMIZE "-O2")
-SET (CMAKE_CXX_FLAGS_RELEASE " ${OPTIMIZE} -DNDEBUG ${WALL} " CACHE INTERNAL "C Flags for release" FORCE)
-SET (CMAKE_CXX_FLAGS_DEBUG "-ggdb ${WALL} " CACHE INTERNAL "C Flags for debug" FORCE)
-SET (CMAKE_CXX_FLAGS_PROFILE " -ggdb -pg ${WALL} " CACHE INTERNAL "C Flags for profile" FORCE)
+
+# uncomment this to force 32bit on OS X, for example if you can't build FLTK 64bit
+# e.g. using MacPorts on 10.6 Snow Leopard
+#if( PROJECT_OS_OSX )
+# SET( FORCE_ARCH "-arch i386" )
+#endif( PROJECT_OS_OSX)
+
+SET (CMAKE_CXX_FLAGS_RELEASE " ${FORCE_ARCH} ${OPTIMIZE} -DNDEBUG ${WALL} " CACHE INTERNAL "C Flags for release" FORCE)
+SET (CMAKE_CXX_FLAGS_DEBUG " -ggdb ${FORCE_ARCH} ${WALL} " CACHE INTERNAL "C Flags for debug" FORCE)
+SET (CMAKE_CXX_FLAGS_PROFILE " -ggdb -pg ${FORCE_ARCH} ${WALL} " CACHE INTERNAL "C Flags for profile" FORCE)
#####################################
# Set the default build type
@@ -74,79 +81,35 @@ include_directories(
${LTDL_INCLUDE_DIR}
)
-# find the easy modules
-include(FindPkgConfig)
MESSAGE( STATUS "Checking for required libraries..." )
SET( INDENT " * " )
-pkg_search_module( LIBPNG REQUIRED libpng )
-IF( LIBPNG_FOUND )
-# MESSAGE( STATUS ${INDENT} "Libpng version ${LIBPNG_VERSION} detected at ${LIBPNG_PREFIX}" )
-# MESSAGE( STATUS " LIBPNG_CFLAGS = ${LIBPNG_CFLAGS}" )
-# MESSAGE( STATUS " LIBPNG_LDFLAGS = ${LIBPNG_LDFLAGS}" )
-ELSE( LIBPNG_FOUND )
- MESSAGE( ${INDENT} "Libpng not detected" )
-ENDIF( LIBPNG_FOUND )
-
-#MESSAGE( STATUS "BUILD_GUI is ${BUILD_GUI}" )
-#IF( BUILD_GUI )
-
-## the FLTK package script is not useful - it finds an X11-based FLTK on OSX.
-## so we can't do this stuff
-#find_package( FLTK REQUIRED )
-#IF( FLTK_FOUND )
+find_package( JPEG REQUIRED )
+IF( JPEG_FOUND )
+ #MESSAGE( STATUS ${INDENT} "JPEG_INCLUDE_DIR = ${JPEG_INCLUDE_DIR}" )
+ #MESSAGE( STATUS ${INDENT} "JPEG_LIBRARIES = ${JPEG_LIBRARIES}" )
+ELSE( JPEG_FOUND )
+ MESSAGE( ${INDENT} "JPEG library not detected" )
+ENDIF( JPEG_FOUND )
+
+find_package( PNG REQUIRED )
+IF( PNG_FOUND )
+# MESSAGE( STATUS ${INDENT} "PNG_INCLUDE_DIR = ${PNG_INCLUDE_DIR}" )
+# MESSAGE( STATUS ${INDENT} "PNG_LIBRARIES = ${PNG_LIBRARIES}" )
+ELSE( PNG_FOUND )
+ MESSAGE( ${INDENT} "PNG library not detected" )
+ENDIF( PNG_FOUND )
+
+find_package( FLTK REQUIRED )
+IF( FLTK_FOUND )
# MESSAGE( STATUS ${INDENT} "FLTK_LIBRARIES=${FLTK_LIBRARIES}" )
# MESSAGE( STATUS ${INDENT} "FLTK_INCLUDE_DIR=${FLTK_INCLUDE_DIR}" )
-#ELSE( FLTK_FOUND )
-# MESSAGE( FATAL_ERROR "FLTK not found, aborting" )
-#ENDIF( FLTK_FOUND )
-
-## and we have to do all this instead
-IF ( NOT FLTK_CONFIG )
- FIND_PROGRAM ( FLTK_CONFIG NAMES fltk-config PATHS ${FLTK_CONFIG_PATH} )
-ENDIF ( NOT FLTK_CONFIG )
-IF ( NOT FLTK_CONFIG )
- MESSAGE( FATAL_ERROR "Cannot find fltk-config, aborting" )
-ENDIF( NOT FLTK_CONFIG)
-
-
-OPTION (LINK_FLTK_STATICALLY "Link to the FLTK libraries statically" OFF)
-IF (LINK_FLTK_STATICALLY)
- SET (FLTK_CONFIG_CMD "--ldstaticflags")
- MESSAGE (STATUS "Linking to FLTK statically.")
-ELSE (LINK_FLTK_STATICALLY)
- SET (FLTK_CONFIG_CMD "--ldflags")
- #MESSAGE (STATUS "Linking to FLTK dynamically.")
-ENDIF (LINK_FLTK_STATICALLY)
-
-EXECUTE_PROCESS ( COMMAND ${FLTK_CONFIG} --version
- OUTPUT_VARIABLE FLTK_VERSION
- OUTPUT_STRIP_TRAILING_WHITESPACE )
-MESSAGE( STATUS ${INDENT} "FLTK version ${FLTK_VERSION} detected via ${FLTK_CONFIG}")
-EXECUTE_PROCESS ( COMMAND ${FLTK_CONFIG} --use-gl --use-images --cxxflags
- OUTPUT_VARIABLE FLTK_CFLAGS
- OUTPUT_STRIP_TRAILING_WHITESPACE )
-EXECUTE_PROCESS ( COMMAND ${FLTK_CONFIG} --use-gl --use-images ${FLTK_CONFIG_CMD}
- OUTPUT_VARIABLE FLTK_LDFLAGS
- OUTPUT_STRIP_TRAILING_WHITESPACE )
-EXECUTE_PROCESS ( COMMAND ${FLTK_CONFIG} --use-gl --use-images --libs
- OUTPUT_VARIABLE FLTK_LIBS_NEWLINES
- OUTPUT_STRIP_TRAILING_WHITESPACE )
-# replace the newlines with semicolons
-STRING(REGEX REPLACE "\n" ";" FLTK_LIBS "${FLTK_LIBS_NEWLINES}")
-
-MESSAGE( STATUS " FLTK_CFLAGS = ${FLTK_CFLAGS}")
-MESSAGE( STATUS " FLTK_LDFLAGS = ${FLTK_LDFLAGS}")
-MESSAGE( STATUS " FLTK_LIBS = ${FLTK_LIBS}")
-
-
-SET (FLTK_FOUND TRUE)
-
-# ENDIF( BUILD_GUI )
-
-#MESSAGE( ${INDENT} "Checking for OpenGL" )
+ELSE( FLTK_FOUND )
+ MESSAGE( FATAL_ERROR "FLTK not found, aborting" )
+ENDIF( FLTK_FOUND )
+
find_package( OpenGL REQUIRED )
IF( NOT OPENGL_GLU_FOUND )
MESSAGE( FATAL_ERROR "OpenGL GLU not found, aborting" )
@@ -158,6 +121,10 @@ ENDIF( NOT OPENGL_GLU_FOUND )
MESSAGE( STATUS "Checking for optional libraries..." )
+# Player does not have a CMake package, but does provide pkgconfig info
+
+include(FindPkgConfig)
+
pkg_search_module( PLAYER playercore>=2.1.0 )
IF( PLAYER_FOUND )
MESSAGE( STATUS ${INDENT} "Player version ${PLAYER_VERSION} detected at ${PLAYER_PREFIX}" )
@@ -177,16 +144,13 @@ MESSAGE( STATUS "Installation path CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}"
include_directories( .
libstage
replace
- ${LIBPNG_INCLUDE_DIRS}
+ ${FLTK_INCLUDE_DIR}
+ ${PNG_INCLUDE_DIR}
+ ${JPEG_INCLUDE_DIR}
${CMAKE_INCLUDE_PATH}
)
-# all targets need these library directories
-link_directories(
- ${LIBPNG_LIBRARY_DIRS}
-)
-
# work through these subdirs
ADD_SUBDIRECTORY(libstage)
ADD_SUBDIRECTORY(examples)
View
12 libstage/CMakeLists.txt
@@ -43,7 +43,7 @@ set( stageSrcs
ancestor.cc
)
-set_source_files_properties( ${stageSrcs} PROPERTIES COMPILE_FLAGS "${FLTK_CFLAGS}" )
+#set_source_files_properties( ${stageSrcs} PROPERTIES COMPILE_FLAGS" )
add_library(stage SHARED ${stageSrcs})
@@ -57,10 +57,15 @@ 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}"
+# LINK_FLAGS "${FLTK_LDFLAGS}"
)
-target_link_libraries( stage ${LTDL_LIB} )
+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}" )
@@ -85,7 +90,6 @@ set_target_properties( stagebinary PROPERTIES OUTPUT_NAME stage )
# to explicitly link on Linux
target_link_libraries( stagebinary stage )
-#set_target_properties( stagebinary PROPERTIES LINK_FLAGS "${FLTK_LDFLAGS}" )
IF(PROJECT_OS_LINUX)
target_link_libraries( stagebinary stage pthread )
View
3  libstage/world.cc
@@ -672,6 +672,9 @@ bool World::Update()
unsigned int World::GetEventQueue( Model* mod ) const
{
+ // todo: there should be a policy that works faster than random, but
+ // random should do a good core load balancing.
+
if( worker_threads < 1 )
return 0;
return( (random() % worker_threads) + 1);
View
2  worlds/pioneer_flocking.world
@@ -13,7 +13,7 @@ paused 1
resolution 0.1
# this is very helpful if you have multiple CPUs - a good value is $(number of CPU cores) -
-threads 4
+threads 0
# configure the GUI window
window
Please sign in to comment.
Something went wrong with that request. Please try again.