CMakeLists.txt 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. project(GTSAM CXX C)
  2. cmake_minimum_required(VERSION 3.0)
  3. # new feature to Cmake Version > 2.8.12
  4. # Mac ONLY. Define Relative Path on Mac OS
  5. if(NOT DEFINED CMAKE_MACOSX_RPATH)
  6. set(CMAKE_MACOSX_RPATH 0)
  7. endif()
  8. # Set the version number for the library
  9. set (GTSAM_VERSION_MAJOR 4)
  10. set (GTSAM_VERSION_MINOR 1)
  11. set (GTSAM_VERSION_PATCH 1)
  12. math (EXPR GTSAM_VERSION_NUMERIC "10000 * ${GTSAM_VERSION_MAJOR} + 100 * ${GTSAM_VERSION_MINOR} + ${GTSAM_VERSION_PATCH}")
  13. set (GTSAM_VERSION_STRING "${GTSAM_VERSION_MAJOR}.${GTSAM_VERSION_MINOR}.${GTSAM_VERSION_PATCH}")
  14. set (CMAKE_PROJECT_VERSION ${GTSAM_VERSION_STRING})
  15. set (CMAKE_PROJECT_VERSION_MAJOR ${GTSAM_VERSION_MAJOR})
  16. set (CMAKE_PROJECT_VERSION_MINOR ${GTSAM_VERSION_MINOR})
  17. set (CMAKE_PROJECT_VERSION_PATCH ${GTSAM_VERSION_PATCH})
  18. ###############################################################################
  19. # Gather information, perform checks, set defaults
  20. set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
  21. include(GtsamMakeConfigFile)
  22. include(GNUInstallDirs)
  23. # Load build type flags and default to Debug mode
  24. include(GtsamBuildTypes)
  25. # Use macros for creating tests/timing scripts
  26. include(GtsamTesting)
  27. include(GtsamPrinting)
  28. # guard against in-source builds
  29. if(${GTSAM_SOURCE_DIR} STREQUAL ${GTSAM_BINARY_DIR})
  30. 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. ")
  31. endif()
  32. include(cmake/HandleGeneralOptions.cmake) # CMake build options
  33. # Libraries:
  34. include(cmake/HandleBoost.cmake) # Boost
  35. include(cmake/HandleCCache.cmake) # ccache
  36. include(cmake/HandleCPack.cmake) # CPack
  37. include(cmake/HandleEigen.cmake) # Eigen3
  38. include(cmake/HandleMetis.cmake) # metis
  39. include(cmake/HandleMKL.cmake) # MKL
  40. include(cmake/HandleOpenMP.cmake) # OpenMP
  41. include(cmake/HandlePerfTools.cmake) # Google perftools
  42. include(cmake/HandlePython.cmake) # Python options and commands
  43. include(cmake/HandleTBB.cmake) # TBB
  44. include(cmake/HandleUninstall.cmake) # for "make uninstall"
  45. include(cmake/HandleAllocators.cmake) # Must be after tbb, pertools
  46. include(cmake/HandleGlobalBuildFlags.cmake) # Build flags
  47. ###############################################################################
  48. # Add components
  49. # Build CppUnitLite
  50. add_subdirectory(CppUnitLite)
  51. # Build GTSAM library
  52. add_subdirectory(gtsam)
  53. # Build Tests
  54. add_subdirectory(tests)
  55. # Build examples
  56. add_subdirectory(examples)
  57. # Build timing
  58. add_subdirectory(timing)
  59. # Build gtsam_unstable
  60. if (GTSAM_BUILD_UNSTABLE)
  61. add_subdirectory(gtsam_unstable)
  62. endif()
  63. # This is the new wrapper
  64. if(GTSAM_BUILD_PYTHON OR GTSAM_INSTALL_MATLAB_TOOLBOX)
  65. # Need to set this for the wrap package so we don't use the default value.
  66. set(WRAP_PYTHON_VERSION ${GTSAM_PYTHON_VERSION}
  67. CACHE STRING "The Python version to use for wrapping")
  68. # Set the include directory for matlab.h
  69. set(GTWRAP_INCLUDE_NAME "wrap")
  70. add_subdirectory(wrap)
  71. list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/wrap/cmake")
  72. endif()
  73. # Python toolbox
  74. if(GTSAM_BUILD_PYTHON)
  75. add_subdirectory(python)
  76. endif()
  77. # Matlab toolbox
  78. if(GTSAM_INSTALL_MATLAB_TOOLBOX)
  79. add_subdirectory(matlab)
  80. endif()
  81. # Install config and export files
  82. GtsamMakeConfigFile(GTSAM "${CMAKE_CURRENT_SOURCE_DIR}/gtsam_extra.cmake.in")
  83. export(TARGETS ${GTSAM_EXPORTED_TARGETS} FILE GTSAM-exports.cmake)
  84. if (GTSAM_BUILD_UNSTABLE)
  85. GtsamMakeConfigFile(GTSAM_UNSTABLE "${CMAKE_CURRENT_SOURCE_DIR}/gtsam_extra.cmake.in")
  86. export(TARGETS ${GTSAM_UNSTABLE_EXPORTED_TARGETS} FILE GTSAM_UNSTABLE-exports.cmake)
  87. endif()
  88. # Check for doxygen availability - optional dependency
  89. find_package(Doxygen)
  90. # Doxygen documentation - enabling options in subfolder
  91. if (DOXYGEN_FOUND)
  92. add_subdirectory(doc)
  93. endif()
  94. # CMake Tools
  95. add_subdirectory(cmake)
  96. # Print configuration variables
  97. include(cmake/HandlePrintConfiguration.cmake)
  98. # Print warnings at the end
  99. include(cmake/HandleFinalChecks.cmake)
  100. # Include CPack *after* all flags
  101. include(CPack)