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
2012-05-15 13:12:21 +08:00
set ( GTSAM_VERSION_MAJOR 2 )
set ( GTSAM_VERSION_MINOR 0 )
2012-03-02 00:07:54 +08:00
set ( GTSAM_VERSION_PATCH 0 )
2011-12-14 10:24:18 +08:00
2012-02-01 03:59:16 +08:00
# Set the default install path to home
2012-04-11 00:47:02 +08:00
#set (CMAKE_INSTALL_PREFIX ${HOME} CACHE PATH "Install prefix for library")
2012-02-01 03:59:16 +08:00
2012-02-29 12:11:48 +08:00
# Use macros for creating tests/timing scripts
2012-04-24 22:01:40 +08:00
set ( CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${PROJECT_SOURCE_DIR}/cmake" )
2012-02-29 12:11:48 +08:00
include ( GtsamTesting )
include ( GtsamPrinting )
2011-12-14 10:24:18 +08:00
# guard against in-source builds
2012-05-25 04:11:38 +08:00
if ( ${ CMAKE_SOURCE_DIR } STREQUAL ${ CMAKE_BINARY_DIR } )
2011-12-14 10:24:18 +08:00
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 ( )
2012-05-15 13:12:13 +08:00
# See whether gtsam_unstable is available (it will be present only if we're using an SVN checkout)
if ( EXISTS "${PROJECT_SOURCE_DIR}/gtsam_unstable" AND IS_DIRECTORY "${PROJECT_SOURCE_DIR}/gtsam_unstable" )
set ( GTSAM_UNSTABLE_AVAILABLE 1 )
else ( )
set ( GTSAM_UNSTABLE_AVAILABLE 0 )
endif ( )
2012-04-21 09:45:05 +08:00
# Load build type flags and default to Debug mode
include ( GtsamBuildTypes )
2011-12-14 10:24:25 +08:00
2012-03-08 04:14:15 +08:00
# Check build types
if ( ${ CMAKE_MAJOR_VERSION } . ${ CMAKE_MINOR_VERSION } VERSION_GREATER 2.8 OR ${ CMAKE_MAJOR_VERSION } . ${ CMAKE_MINOR_VERSION } VERSION_EQUAL 2.8 )
2012-03-31 08:59:49 +08:00
set_property ( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS None Debug Release Timing Profiling RelWithDebInfo MinSizeRel )
2012-03-08 04:14:15 +08:00
endif ( )
2011-12-14 10:24:25 +08:00
string ( TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_tolower )
2012-03-31 08:59:49 +08:00
if ( NOT cmake_build_type_tolower STREQUAL ""
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 " n o n 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 " d e b u g "
2011-12-14 10:24:25 +08:00
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 "
2012-03-08 04:14:15 +08:00
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 " t i m i n g "
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 " p r o f i l i n g "
2011-12-14 10:24:25 +08:00
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 " )
2012-03-31 08:59:49 +08:00
message ( FATAL_ERROR "Unknown build type \" ${ CMAKE_BUILD_TYPE } \". Allowed values are None, Debug, Release, Timing, Profiling, RelWithDebInfo ( case-insensitive ) . " )
2011-12-14 10:24:25 +08:00
endif ( )
2011-12-14 10:24:18 +08:00
# Configurable Options
2012-04-02 06:21:07 +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 )
2012-05-15 13:12:13 +08:00
if ( GTSAM_UNSTABLE_AVAILABLE )
option ( GTSAM_BUILD_UNSTABLE "Enable/Disable libgtsam_unstable" OFF )
endif ( )
2012-04-02 06:21:07 +08:00
option ( GTSAM_BUILD_WRAP "Enable/Disable building of matlab wrap utility (necessary for matlab interface)" ON )
2012-05-24 02:51:42 +08:00
if ( MSVC )
option ( GTSAM_BUILD_SHARED_LIBRARY "Enable/Disable building of a shared version of gtsam" OFF )
else ( )
option ( GTSAM_BUILD_SHARED_LIBRARY "Enable/Disable building of a shared version of gtsam" ON )
endif ( )
2012-04-11 00:47:02 +08:00
option ( GTSAM_BUILD_STATIC_LIBRARY "Enable/Disable building of a static version of gtsam" ON )
2012-04-02 06:21:07 +08:00
option ( GTSAM_USE_QUATERNIONS "Enable/Disable using an internal Quaternion representation for rotations instead of rotation matrices" OFF )
2012-05-24 02:51:42 +08:00
if ( MSVC )
option ( GTSAM_BUILD_CONVENIENCE_LIBRARIES "Enable/Disable use of convenience libraries for faster development rebuilds, but slower install" OFF )
else ( )
option ( GTSAM_BUILD_CONVENIENCE_LIBRARIES "Enable/Disable use of convenience libraries for faster development rebuilds, but slower install" ON )
endif ( )
2012-04-02 06:21:07 +08:00
option ( GTSAM_INSTALL_MATLAB_TOOLBOX "Enable/Disable installation of matlab toolbox" ON )
option ( GTSAM_INSTALL_MATLAB_EXAMPLES "Enable/Disable installation of matlab examples" ON )
option ( GTSAM_INSTALL_MATLAB_TESTS "Enable/Disable installation of matlab tests" ON )
option ( GTSAM_INSTALL_WRAP "Enable/Disable installation of wrap utility" ON )
2012-02-24 23:03:01 +08:00
2012-04-11 00:47:02 +08:00
# Flags for choosing default packaging tools
set ( CPACK_SOURCE_GENERATOR "TGZ" CACHE STRING "CPack Default Source Generator" )
set ( CPACK_GENERATOR "TGZ" CACHE STRING "CPack Default Binary Generator" )
# Sanity check building of libraries
if ( NOT GTSAM_BUILD_SHARED_LIBRARY AND NOT GTSAM_BUILD_STATIC_LIBRARY )
message ( FATAL_ERROR "Both shared and static version of GTSAM library disabled - need to choose at least one!" )
endif ( )
2012-02-24 23:03:01 +08:00
# Add the Quaternion Build Flag if requested
if ( GTSAM_USE_QUATERNIONS )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGTSAM_DEFAULT_QUATERNIONS" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGTSAM_DEFAULT_QUATERNIONS" )
endif ( GTSAM_USE_QUATERNIONS )
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
2012-03-30 04:32:05 +08:00
# FIXME: can't add install dependencies, so libraries never get built
2012-02-01 03:59:16 +08:00
#set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE)
2011-12-14 10:24:19 +08:00
2012-05-02 00:24:45 +08:00
# Alternative version to keep tests from building during make install
# Use the EXCLUDE_FROM_ALL property on test executables
2012-05-04 01:03:28 +08:00
option ( GTSAM_ENABLE_INSTALL_TEST_FIX "Enable/Disable fix to remove dependency of tests on 'all' target" ON )
2012-05-19 10:21:21 +08:00
option ( GTSAM_ENABLE_INSTALL_EXAMPLE_FIX "Enable/Disable fix to remove dependency of examples on 'all' target" OFF )
2012-05-02 00:24:45 +08:00
2012-02-24 23:53:50 +08:00
# Pull in infrastructure
if ( GTSAM_BUILD_TESTS )
enable_testing ( )
include ( Dart )
include ( CTest )
endif ( )
2011-12-14 10:24:21 +08:00
# Find boost
2012-05-22 07:38:25 +08:00
if ( CYGWIN OR MSVC OR WIN32 )
2012-05-23 04:37:13 +08:00
set ( Boost_USE_STATIC_LIBS 1 )
endif ( )
2012-05-24 05:23:32 +08:00
find_package ( Boost 1.40 COMPONENTS serialization system chrono filesystem 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
2012-02-24 23:53:50 +08:00
$ { B o o s t _ I N C L U D E _ D I R } )
2011-12-14 10:24:21 +08:00
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 )
2012-02-29 06:43:45 +08:00
2012-05-04 01:03:25 +08:00
# Build gtsam_unstable
if ( GTSAM_BUILD_UNSTABLE )
add_subdirectory ( gtsam_unstable )
endif ( GTSAM_BUILD_UNSTABLE )
2012-05-22 07:38:25 +08:00
# Make config file
include ( GtsamMakeConfigFile )
GtsamMakeConfigFile ( gtsam )
2012-04-11 00:47:02 +08:00
# Set up CPack
set ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "GTSAM" )
set ( CPACK_PACKAGE_VENDOR "Frank Dellaert, Georgia Institute of Technology" )
set ( CPACK_PACKAGE_CONTACT "Frank Dellaert, dellaert@cc.gatech.edu" )
set ( CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README" )
set ( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE" )
set ( CPACK_PACKAGE_VERSION_MAJOR ${ GTSAM_VERSION_MAJOR } )
set ( CPACK_PACKAGE_VERSION_MINOR ${ GTSAM_VERSION_MINOR } )
set ( CPACK_PACKAGE_VERSION_PATCH ${ GTSAM_VERSION_PATCH } )
set ( CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}" )
2012-04-11 01:13:59 +08:00
set ( CPACK_INSTALLED_DIRECTORIES "doc;." ) # Include doc directory
2012-05-15 13:12:13 +08:00
set ( CPACK_SOURCE_IGNORE_FILES "/build;/\\\\.;/makedoc.sh$;/gtsam_unstable/" )
2012-04-11 00:47:02 +08:00
set ( CPACK_SOURCE_PACKAGE_FILE_NAME "gtsam-${GTSAM_VERSION_MAJOR}.${GTSAM_VERSION_MINOR}.${GTSAM_VERSION_PATCH}" )
#set(CPACK_SOURCE_PACKAGE_FILE_NAME "gtsam-aspn${GTSAM_VERSION_PATCH}") # Used for creating ASPN tarballs
2012-04-02 06:21:07 +08:00
# Record the root dir for gtsam - needed during external builds, e.g., ROS
set ( GTSAM_SOURCE_ROOT_DIR ${ CMAKE_CURRENT_SOURCE_DIR } )
message ( STATUS "GTSAM_SOURCE_ROOT_DIR: [${GTSAM_SOURCE_ROOT_DIR}]" )
2012-02-29 12:11:48 +08:00
# print configuration variables
message ( STATUS "===============================================================" )
message ( STATUS "================ Configuration Options ======================" )
message ( STATUS "Build flags " )
2012-05-02 00:24:45 +08:00
print_config_flag ( ${ GTSAM_BUILD_TIMING } "Build Timing scripts " )
print_config_flag ( ${ GTSAM_BUILD_EXAMPLES } "Build Examples " )
print_config_flag ( ${ GTSAM_BUILD_TESTS } "Build Tests " )
print_config_flag ( ${ GTSAM_BUILD_WRAP } "Build Wrap " )
print_config_flag ( ${ GTSAM_BUILD_SHARED_LIBRARY } "Build shared GTSAM Library " )
print_config_flag ( ${ GTSAM_BUILD_STATIC_LIBRARY } "Build static GTSAM Library " )
print_config_flag ( ${ GTSAM_BUILD_CONVENIENCE_LIBRARIES } "Build Convenience Libraries " )
2012-05-15 13:12:13 +08:00
if ( GTSAM_UNSTABLE_AVAILABLE )
print_config_flag ( ${ GTSAM_BUILD_UNSTABLE } "Build libgtsam_unstable " )
endif ( )
2012-05-02 00:24:45 +08:00
print_config_flag ( ${ GTSAM_ENABLE_INSTALL_TEST_FIX } "Tests excluded from all target " )
2012-05-19 10:21:21 +08:00
print_config_flag ( ${ GTSAM_ENABLE_INSTALL_EXAMPLE_FIX } "Examples excluded from all target " )
2012-03-08 04:14:15 +08:00
string ( TOUPPER "${CMAKE_BUILD_TYPE}" cmake_build_type_toupper )
message ( STATUS " Build type : ${CMAKE_BUILD_TYPE}" )
message ( STATUS " C compilation flags : ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${cmake_build_type_toupper}}" )
message ( STATUS " C++ compilation flags : ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${cmake_build_type_toupper}}" )
2012-02-29 12:11:48 +08:00
2012-04-11 00:47:02 +08:00
message ( STATUS "Packaging flags " )
message ( STATUS " CPack Source Generator : ${CPACK_SOURCE_GENERATOR}" )
message ( STATUS " CPack Generator : ${CPACK_GENERATOR}" )
2012-02-29 12:11:48 +08:00
message ( STATUS "GTSAM flags " )
print_config_flag ( ${ GTSAM_USE_QUATERNIONS } "Quaternions as default Rot3" )
message ( STATUS "MATLAB toolbox flags " )
print_config_flag ( ${ GTSAM_INSTALL_MATLAB_TOOLBOX } "Install matlab toolbox " )
print_config_flag ( ${ GTSAM_INSTALL_MATLAB_EXAMPLES } "Install matlab examples " )
print_config_flag ( ${ GTSAM_INSTALL_MATLAB_TESTS } "Install matlab tests " )
print_config_flag ( ${ GTSAM_INSTALL_WRAP } "Install wrap utility " )
message ( STATUS "===============================================================" )
2012-04-11 00:47:02 +08:00
# Include CPack *after* all flags
2012-02-29 06:43:45 +08:00
include ( CPack )