2012-01-31 13:27:54 +08:00
project ( GTSAM CXX C )
2011-12-14 10:24:23 +08:00
cmake_minimum_required ( VERSION 2.6 )
2012-02-01 03:59:15 +08:00
# Set the version number for the library
2011-12-14 10:24:18 +08:00
set ( GTSAM_VERSION_MAJOR 0 )
set ( GTSAM_VERSION_MINOR 9 )
set ( GTSAM_VERSION_PATCH 3 )
2012-02-01 03:59:16 +08:00
# Set the default install path to home
set ( CMAKE_INSTALL_PREFIX ${ HOME } CACHE DOCSTRING "Install prefix for library" )
2011-12-14 10:24:18 +08:00
# guard against in-source builds
if ( ${ CMAKE_SOURCE_DIR } STREQUAL ${ CMAKE_BINARY_DIR } )
message ( FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there. You may need to remove CMakeCache.txt. " )
endif ( )
2011-12-14 10:24:25 +08:00
# guard against bad build-type strings
if ( NOT CMAKE_BUILD_TYPE )
set ( CMAKE_BUILD_TYPE "Debug" )
endif ( )
string ( TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_tolower )
if ( NOT cmake_build_type_tolower STREQUAL "debug"
A N D N O T c m a k e _ b u i l d _ t y p e _ t o l o w e r S T R E Q U A L " r e l e a s e "
A N D N O T c m a k e _ b u i l d _ t y p e _ t o l o w e r S T R E Q U A L " r e l w i t h d e b i n f o " )
message ( FATAL_ERROR "Unknown build type \" ${ CMAKE_BUILD_TYPE } \". Allowed values are Debug, Release, RelWithDebInfo ( case-insensitive ) . " )
endif ( )
2012-01-31 13:28:03 +08:00
# Add debugging flags
2012-02-01 03:59:15 +08:00
set ( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fno-inline -Wall" )
2012-01-31 13:28:03 +08:00
set ( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-inline -Wall" )
2012-02-01 03:59:15 +08:00
set ( CMAKE_C_FLAGS_RELWITHDEBINFO "-g -fno-inline -Wall -DNDEBUG -DEIGEN_NO_DEBUG" )
2012-02-01 03:59:12 +08:00
set ( CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -fno-inline -Wall -DNDEBUG -DEIGEN_NO_DEBUG" )
2012-02-01 03:59:15 +08:00
set ( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG -Wall -DEIGEN_NO_DEBUG" )
2012-02-01 03:59:12 +08:00
set ( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -Wall -DEIGEN_NO_DEBUG" )
2011-12-14 10:24:18 +08:00
# Configurable Options
2012-02-01 03:59:15 +08:00
option ( GTSAM_BUILD_TESTS "Enable/Disable building of tests" ON )
option ( GTSAM_BUILD_TIMING "Enable/Disable building of timing scripts" ON )
option ( GTSAM_BUILD_EXAMPLES "Enable/Disable building of examples" ON )
option ( GTSAM_BUILD_WRAP "Enable/Disable building of matlab wrap utility (necessary for matlab interface)" ON )
2012-02-15 02:03:29 +08:00
option ( GTSAM_BUILD_CONVENIENCE_LIBRARIES "Enable/Disable using convenience librares for tests" ON )
2012-02-01 03:59:19 +08:00
option ( GTSAM_LINK_BINARIES_AGAINST_CONVENIENCE_LIBS
" E n a b l e / D i s a b l e l i n k i n g t e s t s a g a i n s t t h e c o n v e n i n c e l i b r a r i e s f o r f a s t e r d e b u g g i n g " O N )
2012-02-01 03:59:15 +08:00
# Avoid building non-installed exes and unit tests when installing
2012-02-01 03:59:16 +08:00
# FIXME: breaks generation and install of matlab toolbox
#set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE)
2011-12-14 10:24:19 +08:00
2012-02-15 02:03:29 +08:00
# Pull in infrastructure
if ( GTSAM_BUILD_TESTS )
enable_testing ( )
include ( Dart )
include ( CTest )
endif ( )
2011-12-14 10:24:23 +08:00
# Enable make check (http://www.cmake.org/Wiki/CMakeEmulateMakeCheck)
add_custom_target ( check COMMAND ${ CMAKE_CTEST_COMMAND } )
2011-12-16 00:17:58 +08:00
add_custom_target ( timing )
2011-12-14 10:24:19 +08:00
2011-12-14 10:24:21 +08:00
# Find boost
2012-01-31 13:28:00 +08:00
find_package ( Boost 1.40 COMPONENTS serialization REQUIRED )
2011-12-14 10:24:21 +08:00
2011-12-14 10:24:18 +08:00
# General build settings
2011-12-14 10:24:21 +08:00
include_directories (
g t s a m / 3 r d p a r t y / U F c o n f i g
g t s a m / 3 r d p a r t y / C C O L A M D / I n c l u d e
$ { C M A K E _ S O U R C E _ D I R }
C p p U n i t L i t e
$ { B O O S T _ I N C L U D E _ D I R } )
link_directories ( ${ Boost_LIBRARY_DIRS } )
2011-12-14 10:24:18 +08:00
# Build CppUnitLite
add_subdirectory ( CppUnitLite )
2012-01-31 13:28:03 +08:00
# Build GTSAM library
add_subdirectory ( gtsam )
2011-12-14 10:24:18 +08:00
# Build Tests
2012-01-31 13:28:00 +08:00
add_subdirectory ( tests )
2011-12-14 10:24:18 +08:00
# Build wrap
2012-02-01 03:59:15 +08:00
if ( GTSAM_BUILD_WRAP )
add_subdirectory ( wrap )
endif ( GTSAM_BUILD_WRAP )
2011-12-14 10:24:18 +08:00
# Build examples
2012-02-01 03:59:15 +08:00
if ( GTSAM_BUILD_EXAMPLES )
add_subdirectory ( examples )
endif ( GTSAM_BUILD_EXAMPLES )