Skip to content

Commit

Permalink
small cleanup of CMakeLists into submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
Armin Hornung committed Jul 22, 2011
1 parent de37357 commit 8e6781a
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 53 deletions.
54 changes: 9 additions & 45 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT( octomap )
PROJECT( OctoMap )

# version (e.g. for packaging)
set(V_MAJOR 1)
set(V_MINOR 0)
set(V_PATCH 0)
set(OCTOMAP_MAJOR_VERSION 1)
set(OCTOMAP_MINOR_VERSION 1)
set(OCTOMAP_PATCH_VERSION 0)

# get rid of a useless warning:
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)


# COMPILER SETTINGS (default: Release)
# use "-DCMAKE_BUILD_TYPE=Debug" in cmake for a Debug-build
IF(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release)
ENDIF(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)

# COMPILER FLAGS
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-error ")
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-error ")
SET (CMAKE_CXX_FLAGS_RELEASE "-O3 -funroll-loops -DNDEBUG -O3 -msse3 -mssse3")
SET (CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
# COMPILER SETTINGS (default: Release) and flags
INCLUDE(CMakeModules/CompilerSettings.cmake)

# Set output directories for libraries and executables
SET( BASE_DIR ${CMAKE_SOURCE_DIR} )
Expand All @@ -32,22 +22,13 @@ SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BASE_DIR}/bin )

SET (CMAKE_MODULE_PATH ${CMAKE_MODULES_PATH} ${BASE_DIR}/CMakeModules)

MESSAGE ("\n")
MESSAGE (STATUS "Building as ${CMAKE_BUILD_TYPE}")
MESSAGE ("\n")

INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/include
)


# Installation

# test dir for install
# IF(NOT CMAKE_INSTALL_PREFIX)
# set(CMAKE_INSTALL_PREFIX ${BASE_DIR}/install/)
# ENDIF(NOT CMAKE_INSTALL_PREFIX)

set(INSTALL_TARGETS_DEFAULT_ARGS
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
Expand Down Expand Up @@ -112,27 +93,10 @@ ELSE()
MESSAGE ( "See README.txt or http://octomap.sf.net for further information.\n")
ENDIF()

# Package building stuff - Experimental!
SET(CPACK_PACKAGE_VERSION_MAJOR "${V_MAJOR}")
SET(CPACK_PACKAGE_VERSION_MINOR "${V_MINOR}")
SET(CPACK_PACKAGE_VERSION_PATCH "${V_PATCH}")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${V_MAJOR}.${V_MINOR}")
SET(CPACK_PACKAGE_CONTACT "K.M. Wurm and A. Hornung")
SET(CPACK_PACKAGE_VENDOR "University of Freiburg")
SET(CPACK_GENERATOR "DEB")
SET(CPACK_SOURCE_GENERATOR "TGZ")


include(CMakeModules/InstallPkgConfigFile.cmake)
install_pkg_config_file(octomap
CFLAGS
LIBS -loctomap -loctomath
REQUIRES
VERSION ${V_MAJOR}.${V_MINOR}.${V_PATCH})


INCLUDE(CPack)
# Needs to be last statement:
INCLUDE(CMakeModules/CPackSettings.cmake)

# Finished:

MESSAGE (STATUS "\n")
MESSAGE (STATUS "Compile octomap using: make")
Expand Down
22 changes: 22 additions & 0 deletions CMakeModules/CPackSettings.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Package building stuff - Experimental!
SET(CPACK_PACKAGE_VERSION "${OCTOMAP_MAJOR_VERSION}.${OCTOMAP_MINOR_VERSION}.${OCTOMAP_PATCH_VERSION}")
SET(CPACK_PACKAGE_VERSION_MAJOR "${OCTOMAP_MAJOR_VERSION}")
SET(CPACK_PACKAGE_VERSION_MINOR "${OCTOMAP_MINOR_VERSION}")
SET(CPACK_PACKAGE_VERSION_PATCH "${OCTOMAP_PATCH_VERSION}")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${V_MAJOR}.${V_MINOR}")
SET(CPACK_PACKAGE_CONTACT "K.M. Wurm and A. Hornung")
SET(CPACK_PACKAGE_VENDOR "University of Freiburg")
SET(CPACK_GENERATOR "DEB")
SET(CPACK_SOURCE_GENERATOR "TGZ")


include(CMakeModules/InstallPkgConfigFile.cmake)
install_pkg_config_file(octomap
CFLAGS
LIBS -loctomap -loctomath
REQUIRES
VERSION ${OCTOMAP_MAJOR_VERSION}.${OCTOMAP_MINOR_VERSION}.${OCTOMAP_PATCH_VERSION})

# This must always be last statement!
INCLUDE(CPack)

28 changes: 28 additions & 0 deletions CMakeModules/CompilerSettings.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# COMPILER SETTINGS (default: Release)
# use "-DCMAKE_BUILD_TYPE=Debug" in cmake for a Debug-build
IF(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release)
ENDIF(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)

# COMPILER FLAGS
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-error ")
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-error ")
SET (CMAKE_CXX_FLAGS_RELEASE "-O3 -funroll-loops -DNDEBUG -O3 -msse3 -mssse3")
SET (CMAKE_CXX_FLAGS_DEBUG "-O0 -g")

MESSAGE ("\n")
MESSAGE (STATUS "Building as ${CMAKE_BUILD_TYPE}")
MESSAGE ("\n")

# Shared object compilation under 64bit (vtable)
ADD_DEFINITIONS(-fPIC)

# Set full rpath http://www.paraview.org/Wiki/CMake_RPATH_handling
# (good to have and required with ROS)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

# no prefix needed for python modules
set(CMAKE_SHARED_MODULE_PREFIX "")
1 change: 0 additions & 1 deletion src/octomap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ SET (octomap_SRCS
)

ADD_LIBRARY( octomap ${octomap_SRCS})
set_target_properties(octomap PROPERTIES COMPILE_FLAGS "-fPIC")

TARGET_LINK_LIBRARIES(
octomap octomath
Expand Down
6 changes: 0 additions & 6 deletions src/octomap/math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ SET (octomath_SRCS


ADD_LIBRARY( octomath ${octomath_SRCS})
set_target_properties(octomath PROPERTIES COMPILE_FLAGS "-fPIC")

# no more libs to link from here:
#TARGET_LINK_LIBRARIES(
# octomath
#)

# store all header files to install:
file(GLOB octomath_HDRS *.h *.hxx *.hpp)
Expand Down
1 change: 0 additions & 1 deletion src/octovis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ INCLUDE_DIRECTORIES(
# Library target
add_library(octovis_library ${viewerlib_SRCS})
target_link_libraries(octovis_library)
set_target_properties(octovis_library PROPERTIES COMPILE_FLAGS "-fPIC")
set_target_properties(octovis_library PROPERTIES OUTPUT_NAME octovis)

# Now add these generated files to the ADD_EXECUTABLE step
Expand Down

0 comments on commit 8e6781a

Please sign in to comment.