Permalink
Browse files

Added build system patches for the following:

- Install libraries to lib/ or lib64/, depending on detected
  architecture (Linux only)
  -- Recognized 64 bit archs: ppc64, x86_64, s390x
- Install Stage plugins to lib/stage or lib64/stage
- Add lib/stage or lib64/stage to hard-coded plugin search paths
  -- model_load.cc, added with lt_dladdsearchpath
- Add make uninstall target, borrowed from Player
- Fix double-installation of "fasr2" library
  • Loading branch information...
1 parent 6da3a7b commit a91f2b538f0577b6c9fffdc76f76f66841d85e28 Rich Mattes committed Jun 20, 2010
View
18 CMakeLists.txt
@@ -30,7 +30,7 @@ MESSAGE (STATUS "${PROJECT_NAME} version ${VERSION}")
SET (PROJECT_CMAKE_DIR ${PROJECT_SOURCE_DIR}/cmake CACHE PATH "Location of CMake scripts")
# Determine the operating system in detail
INCLUDE (${PROJECT_CMAKE_DIR}/internal/FindOS.cmake)
-
+INCLUDE (${PROJECT_CMAKE_DIR}/internal/UninstallTarget.cmake)
# Enable -Wall by default unless on Win or Solaris
IF (NOT PROJECT_OS_WIN AND NOT PROJECT_OS_SOLARIS)
# Using -Wall on Windows causes MSVC to produce thousands of warnings in its
@@ -40,9 +40,9 @@ ENDIF (NOT PROJECT_OS_WIN AND NOT PROJECT_OS_SOLARIS)
#####################################
# Build type cflags
-SET (CMAKE_CXX_FLAGS_RELEASE " -O3 -DNDEBUG ${WALL} " CACHE INTERNAL "C Flags for release" FORCE)
+SET (CMAKE_CXX_FLAGS_RELEASE " -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 " -O3 -ggdb -pg ${WALL} " CACHE INTERNAL "C Flags for profile" FORCE)
+SET (CMAKE_CXX_FLAGS_PROFILE " -ggdb -pg ${WALL} " CACHE INTERNAL "C Flags for profile" FORCE)
#####################################
# Set the default build type
@@ -140,6 +140,16 @@ STRING(REGEX REPLACE "\n" ";" FLTK_LIBS "${FLTK_LIBS_NEWLINES}")
#MESSAGE( STATUS " FLTK_LDFLAGS = ${FLTK_LDFLAGS}")
#MESSAGE( STATUS " FLTK_LIBS = ${FLTK_LIBS}")
+STRING(REGEX REPLACE " -lGLU" "" TMP "${FLTK_LDFLAGS}")
+STRING(REGEX REPLACE " -lGL" "" TMP2 "${TMP}")
+STRING(REGEX REPLACE " -lpng" "" FLTK_LDFLAGS_PKGCONFIG "${TMP2}")
+
+
+STRING(REGEX REPLACE " -lgl" "" FLTK_LIBS_PKGCONFIG "${FLTK_LIBS}")
+STRING(REGEX REPLACE " -lglu" "" FLTK_LIBS_PKGCONFIG" "${FLTK_LIBS_PKGCONFIG}")
+STRING(REGEX REPLACE " -lpng" "" FLTK_LIBS_PKGCONFIG" "${FLTK_LIBS_PKGCONFIG}")
+
+
SET (FLTK_FOUND TRUE)
# ENDIF( BUILD_GUI )
@@ -178,7 +188,7 @@ ENDIF( PLAYER_FOUND )
# Create the pkgconfig file
CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/stage.pc.in ${CMAKE_CURRENT_BINARY_DIR}/stage.pc @ONLY)
-INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/stage.pc DESTINATION lib/pkgconfig/)
+INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/stage.pc DESTINATION ${PROJECT_LIB_DIR}/pkgconfig/)
MESSAGE( STATUS "Installation path CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}" )
View
26 cmake/internal/FindOS.cmake
@@ -43,3 +43,29 @@ ELSEIF (PROJECT_OS_SOLARIS)
ELSE (PROJECT_OS_LINUX)
MESSAGE (STATUS "Operating system is generic Unix")
ENDIF (PROJECT_OS_LINUX)
+
+# 32 or 64 bit Linux
+IF (PROJECT_OS_LINUX)
+ # Set the library directory suffix accordingly
+ IF (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
+ SET (PROJECT_PROC_64BIT TRUE BOOL INTERNAL)
+ MESSAGE (STATUS "Linux x86_64 Detected")
+ ELSEIF (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "ppc64")
+ MESSAGE (STATUS "Linux ppc64 Detected")
+ SET (PROJECT_PROC_64BIT TRUE BOOL INTERNAL)
+ ELSEIF ($CMAKE_SYSTEM_PROCESSOR} STREQUAL "s390x")
+ MESSAGE (STATEUS "Linux s390x Detected")
+ SET (PROJECT_PROC_64BIT TRUE BOOL INTERNAL)
+ ENDIF (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
+ENDIF (PROJECT_OS_LINUX)
+
+IF(PROJECT_PROC_64BIT)
+ # Set the install path to lib64
+ SET(PROJECT_LIB_DIR "lib64")
+ SET(PROJECT_PLUGIN_DIR "lib64/stage/")
+ELSE (PROJECT_PROC_64BIT)
+ SET(PROJECT_LIB_DIR "lib")
+ SET(PROJECT_PLUGIN_DIR "lib/stage")
+ENDIF (PROJECT_PROC_64BIT)
+
+MESSAGE(STATUS "Installing Libraries to ${PROJECT_LIB_DIR}")
View
5 cmake/internal/UninstallTarget.cmake
@@ -0,0 +1,5 @@
+# Add an "uninstall" target
+
+CONFIGURE_FILE ("${PROJECT_CMAKE_DIR}/internal/cmake_uninstall.cmake.in" "${PROJECT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
+
+ADD_CUSTOM_TARGET (uninstall "${CMAKE_COMMAND}" -P "${PROJECT_BINARY_DIR}/cmake_uninstall.cmake")
View
21 cmake/internal/cmake_uninstall.cmake.in
@@ -0,0 +1,21 @@
+IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+ MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
+ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+
+FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
+STRING(REGEX REPLACE "\n" ";" files "${files}")
+FOREACH(file ${files})
+ MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
+ IF(EXISTS "$ENV{DESTDIR}${file}")
+ EXEC_PROGRAM(
+ "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
+ OUTPUT_VARIABLE rm_out
+ RETURN_VALUE rm_retval
+ )
+ IF(NOT "${rm_retval}" STREQUAL 0)
+ MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
+ ENDIF(NOT "${rm_retval}" STREQUAL 0)
+ ELSE(EXISTS "$ENV{DESTDIR}${file}")
+ MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
+ ENDIF(EXISTS "$ENV{DESTDIR}${file}")
+ENDFOREACH(file)
View
1 config.h.in
@@ -5,6 +5,7 @@
#define VERSION "@VERSION@"
#define APIVERSION "@APIVERSION@"
#define INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@"
+#define PLUGIN_PATH "@CMAKE_INSTALL_PREFIX@/@PROJECT_PLUGIN_DIR@"
#cmakedefine BUILD_GUI
View
2 examples/ctrl/CMakeLists.txt
@@ -38,5 +38,5 @@ endforeach( PLUGIN )
SET_TARGET_PROPERTIES( ${PLUGINS} PROPERTIES PREFIX "" )
# install in <prefix>/lib
-install( TARGETS ${PLUGINS} fasr2 DESTINATION lib)
+install( TARGETS ${PLUGINS} DESTINATION ${PROJECT_PLUGIN_DIR})
View
2 libstage/CMakeLists.txt
@@ -77,7 +77,7 @@ ENDIF(NOT PROJECT_OS_LINUX)
INSTALL(TARGETS stagebinary stage
RUNTIME DESTINATION bin
- LIBRARY DESTINATION lib
+ LIBRARY DESTINATION ${PROJECT_LIB_DIR}
)
INSTALL(FILES stage.hh
View
6 libstage/model_load.cc
@@ -10,6 +10,7 @@
#include "stage.hh"
#include "worldfile.hh"
#include "file_manager.hh"
+#include "config.h"
using namespace Stg;
//#define DEBUG
@@ -229,7 +230,7 @@ void Model::Load()
}
- interval = 1000 * wf->Readint( wf_entity, "update_interval", interval/1000 );
+ interval = 1000 * wf->ReadInt( wf_entity, "update_interval", interval/1000 );
Say( wf->ReadString(wf_entity, "say", "" ));
@@ -326,6 +327,9 @@ void Model::LoadControllerModule( const char* lib )
lt_dlsetsearchpath( FileManager::stagePath().c_str() );
+ // PLUGIN_PATH now defined in config.h
+ lt_dladdsearchdir( PLUGIN_PATH );
+
lt_dlhandle handle = NULL;
// the library name is the first word in the string
View
4 stage.pc.in
@@ -3,6 +3,6 @@ prefix=@CMAKE_INSTALL_PREFIX@
Name: stage
Description: Stage robot simulation program, C++ library and Player plugin - part of the Player/Stage Project
Version: @VERSION@
-Requires:
-Libs: -L${prefix}/lib -lstage @FLTK_LDFLAGS@
+Requires: glu libpng
+Libs: -L${prefix}/@PROJECT_LIB_DIR@ -lstage @FLTK_LDFLAGS_PKGCONFIG@
Cflags: -I${prefix}/include/Stage-@APIVERSION@ @FLTK_CFLAGS@
View
22 worlds/CMakeLists.txt
@@ -1,9 +1,21 @@
ADD_SUBDIRECTORY(benchmark)
+
+FILE( GLOB cfgs "*.cfg" )
+FILE( GLOB worlds "*.world" )
+FILE( GLOB incs "*.inc" )
+FILE( GLOB scripts "*.sh" )
+
+INSTALL(FILES ${cfgs} ${worlds} ${incs} ${scripts}
+DESTINATION share/stage/worlds)
+
+#INSTALL (DIRECTORY bitmaps wifi DESTINATION share/stage/worlds)
+
ADD_SUBDIRECTORY(bitmaps)
+ADD_SUBDIRECTORY(wifi)
-FILE(GLOB worlds "*.world")
-FILE(GLOB incs "*.inc")
-INSTALL(FILES ${worlds} ${incs}
- DESTINATION share/stage/worlds
-)
+#FILE(GLOB worlds "*.world")
+#FILE(GLOB incs "*.inc")
+#INSTALL(FILES ${worlds} ${incs}
+# DESTINATION share/stage/worlds
+#)
View
2 worlds/benchmark/CMakeLists.txt
@@ -10,4 +10,4 @@ TARGET_LINK_LIBRARIES( expand_pioneer stage )
set_source_files_properties( ${expand_pioneerSrcs} PROPERTIES COMPILE_FLAGS "${FLTK_CFLAGS}" )
SET_TARGET_PROPERTIES( expand_pioneer PROPERTIES PREFIX "" )
-INSTALL( TARGETS expand_swarm expand_pioneer DESTINATION lib)
+INSTALL( TARGETS expand_swarm expand_pioneer DESTINATION ${PROJECT_LIB_DIR}/stage)

4 comments on commit a91f2b5

@rtv
Owner

Rich, I'm new to git and want to be sure I''m doing it right. Does my pull'n'merge post this nice commit look good as far as you can tell? - rtv

@jpgr87

I haven't used git before now either, but I'm really starting to like it. There are a few changes that didn't make it in. I made four commits last night (I thought I was done four times, whoops). It looks like you got the first one got in and the last three didn't. The last three are small, but they are kind of important.

@jpgr87

never mind, the extra changes aren't in this particular diff, but are in the master branch. everything is fine

@gbiggs

I like the switch from -O3 to -O2. O3 is known to randomly result in incorrect machine code.

Please sign in to comment.