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 )
2021-12-29 06:55:01 +08:00
set ( GTSAM_VERSION_MINOR 2 )
2020-08-22 09:36:15 +08:00
set ( GTSAM_VERSION_PATCH 0 )
2022-11-29 13:48:03 +08:00
set ( GTSAM_PRERELEASE_VERSION "a8" )
2013-10-04 03:51:56 +08:00
math ( EXPR GTSAM_VERSION_NUMERIC "10000 * ${GTSAM_VERSION_MAJOR} + 100 * ${GTSAM_VERSION_MINOR} + ${GTSAM_VERSION_PATCH}" )
2021-12-29 06:55:01 +08:00
if ( ${ GTSAM_VERSION_PATCH } EQUAL 0 )
set ( GTSAM_VERSION_STRING "${GTSAM_VERSION_MAJOR}.${GTSAM_VERSION_MINOR}${GTSAM_PRERELEASE_VERSION}" )
else ( )
set ( GTSAM_VERSION_STRING "${GTSAM_VERSION_MAJOR}.${GTSAM_VERSION_MINOR}.${GTSAM_VERSION_PATCH}${GTSAM_PRERELEASE_VERSION}" )
endif ( )
2022-02-21 21:00:27 +08:00
project ( GTSAM
L A N G U A G E S C X X C
V E R S I O N " $ { G T S A M _ V E R S I O N _ M A J O R } . $ { G T S A M _ V E R S I O N _ M I N O R } . $ { G T S A M _ V E R S I O N _ P A T C H } " )
2021-12-29 06:55:01 +08:00
message ( STATUS "GTSAM Version: ${GTSAM_VERSION_STRING}" )
2020-09-18 09:26:11 +08:00
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
2021-01-18 05:19:54 +08:00
if ( ${ GTSAM_SOURCE_DIR } STREQUAL ${ GTSAM_BINARY_DIR } )
2013-10-04 03:51:56 +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 ( )
2020-10-19 13:52:12 +08:00
include ( cmake/HandleGeneralOptions.cmake ) # CMake build options
# Libraries:
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
2020-10-19 13:52:12 +08:00
include ( cmake/HandleMetis.cmake ) # metis
2020-10-07 23:02:39 +08:00
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 )
# 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
2021-03-14 01:01:05 +08:00
# This is the new wrapper
if ( GTSAM_BUILD_PYTHON OR GTSAM_INSTALL_MATLAB_TOOLBOX )
# Need to set this for the wrap package so we don't use the default value.
set ( WRAP_PYTHON_VERSION ${ GTSAM_PYTHON_VERSION }
C A C H E S T R I N G " T h e P y t h o n v e r s i o n t o u s e f o r w r a p p i n g " )
2021-03-25 04:58:44 +08:00
# Set the include directory for matlab.h
set ( GTWRAP_INCLUDE_NAME "wrap" )
2021-12-07 00:05:01 +08:00
# Copy matlab.h to the correct folder.
configure_file ( ${ PROJECT_SOURCE_DIR } /wrap/matlab.h
$ { P R O J E C T _ B I N A R Y _ D I R } / w r a p / m a t l a b . h C O P Y O N L Y )
2021-03-14 01:01:05 +08:00
add_subdirectory ( wrap )
list ( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/wrap/cmake" )
endif ( )
# Python toolbox
if ( GTSAM_BUILD_PYTHON )
add_subdirectory ( python )
endif ( )
2013-10-04 03:51:56 +08:00
# Matlab toolbox
2021-03-14 01:01:05 +08:00
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 )
2021-10-24 00:45:21 +08:00
if ( GTSAM_BUILD_UNSTABLE )
GtsamMakeConfigFile ( GTSAM_UNSTABLE "${CMAKE_CURRENT_SOURCE_DIR}/gtsam_extra.cmake.in" )
export ( TARGETS ${ GTSAM_UNSTABLE_EXPORTED_TARGETS } FILE GTSAM_UNSTABLE-exports.cmake )
endif ( )
2013-10-04 03:51:56 +08:00
# 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 )