2013-10-04 03:51:56 +08:00
project ( GTSAM CXX C )
2019-01-15 07:38:14 +08:00
cmake_minimum_required ( VERSION 3.0 )
2013-10-04 03:51:56 +08:00
2014-10-23 11:27:01 +08:00
# new feature to Cmake Version > 2.8.12
2014-10-23 11:42:35 +08:00
# Mac ONLY. Define Relative Path on Mac OS
if ( NOT DEFINED CMAKE_MACOSX_RPATH )
set ( CMAKE_MACOSX_RPATH 0 )
endif ( )
2014-10-23 11:27:01 +08:00
2013-10-04 03:51:56 +08:00
# Set the version number for the library
2014-11-14 09:27:04 +08:00
set ( GTSAM_VERSION_MAJOR 4 )
2020-08-22 09:36:15 +08:00
set ( GTSAM_VERSION_MINOR 1 )
set ( GTSAM_VERSION_PATCH 0 )
2013-10-04 03:51:56 +08:00
math ( EXPR GTSAM_VERSION_NUMERIC "10000 * ${GTSAM_VERSION_MAJOR} + 100 * ${GTSAM_VERSION_MINOR} + ${GTSAM_VERSION_PATCH}" )
set ( GTSAM_VERSION_STRING "${GTSAM_VERSION_MAJOR}.${GTSAM_VERSION_MINOR}.${GTSAM_VERSION_PATCH}" )
2020-09-18 09:26:11 +08:00
set ( CMAKE_PROJECT_VERSION ${ GTSAM_VERSION_STRING } )
set ( CMAKE_PROJECT_VERSION_MAJOR ${ GTSAM_VERSION_MAJOR } )
set ( CMAKE_PROJECT_VERSION_MINOR ${ GTSAM_VERSION_MINOR } )
set ( CMAKE_PROJECT_VERSION_PATCH ${ GTSAM_VERSION_PATCH } )
2013-10-04 03:51:56 +08:00
###############################################################################
# Gather information, perform checks, set defaults
set ( CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake" )
include ( GtsamMakeConfigFile )
2020-05-29 06:09:31 +08:00
include ( GNUInstallDirs )
2013-10-04 03:51:56 +08:00
# Load build type flags and default to Debug mode
include ( GtsamBuildTypes )
# Use macros for creating tests/timing scripts
include ( GtsamTesting )
include ( GtsamPrinting )
# 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 ( )
2020-10-07 23:02:39 +08:00
include ( cmake/HandleBoost.cmake ) # Boost
include ( cmake/HandleCCache.cmake ) # ccache
include ( cmake/HandleCPack.cmake ) # CPack
include ( cmake/HandleEigen.cmake ) # Eigen3
include ( cmake/HandleGeneralOptions.cmake ) # CMake build options
include ( cmake/HandleMKL.cmake ) # MKL
include ( cmake/HandleOpenMP.cmake ) # OpenMP
include ( cmake/HandlePerfTools.cmake ) # Google perftools
include ( cmake/HandlePython.cmake ) # Python options and commands
include ( cmake/HandleTBB.cmake ) # TBB
include ( cmake/HandleUninstall.cmake ) # for "make uninstall"
include ( cmake/HandleAllocators.cmake ) # Must be after tbb, pertools
include ( cmake/HandleGlobalBuildFlags.cmake ) # Build flags
2013-10-04 03:51:56 +08:00
###############################################################################
# Add components
# Build CppUnitLite
add_subdirectory ( CppUnitLite )
2020-08-18 05:13:10 +08:00
# This is the new wrapper
if ( GTSAM_BUILD_PYTHON )
2020-08-18 23:47:38 +08:00
list ( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/wrap/cmake" )
add_subdirectory ( python )
2020-08-18 05:13:10 +08:00
endif ( )
2013-10-04 03:51:56 +08:00
# Build GTSAM library
add_subdirectory ( gtsam )
# Build Tests
add_subdirectory ( tests )
# Build examples
2014-02-23 06:13:13 +08:00
add_subdirectory ( examples )
2013-10-04 03:51:56 +08:00
2014-06-08 10:02:11 +08:00
# Build timing
add_subdirectory ( timing )
2017-07-24 02:55:23 +08:00
# Build gtsam_unstable
if ( GTSAM_BUILD_UNSTABLE )
add_subdirectory ( gtsam_unstable )
2019-12-11 23:31:43 +08:00
endif ( )
2017-07-24 02:55:23 +08:00
2013-10-04 03:51:56 +08:00
# Matlab toolbox
if ( GTSAM_INSTALL_MATLAB_TOOLBOX )
2020-08-18 23:47:38 +08:00
add_subdirectory ( matlab )
2013-10-04 03:51:56 +08:00
endif ( )
# Install config and export files
GtsamMakeConfigFile ( GTSAM "${CMAKE_CURRENT_SOURCE_DIR}/gtsam_extra.cmake.in" )
export ( TARGETS ${ GTSAM_EXPORTED_TARGETS } FILE GTSAM-exports.cmake )
# Check for doxygen availability - optional dependency
find_package ( Doxygen )
# Doxygen documentation - enabling options in subfolder
if ( DOXYGEN_FOUND )
add_subdirectory ( doc )
endif ( )
2014-02-20 02:10:37 +08:00
# CMake Tools
add_subdirectory ( cmake )
2013-10-04 03:51:56 +08:00
# Print configuration variables
2020-10-07 23:02:39 +08:00
include ( cmake/HandlePrintConfiguration.cmake )
2013-10-04 03:51:56 +08:00
2013-11-19 03:23:23 +08:00
# Print warnings at the end
2020-10-07 23:02:39 +08:00
include ( cmake/HandleFinalChecks.cmake )
2013-10-04 03:51:56 +08:00
# Include CPack *after* all flags
include ( CPack )