CMakeLists.txt 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # Doxygen documentation configuration
  2. option(GTSAM_BUILD_DOCS "Enable/Disable building of doxygen docs" ON)
  3. # configure doxygen
  4. option(GTSAM_BUILD_DOC_HTML "Enable/Disable doxygen HTML output" ON)
  5. option(GTSAM_BUILD_DOC_LATEX "Enable/Disable doxygen LaTeX output" OFF)
  6. # add a target to generate API documentation with Doxygen
  7. if (GTSAM_BUILD_DOCS)
  8. # Convert configuration to YES/NO variables
  9. if (GTSAM_BUILD_DOC_HTML)
  10. set(GTSAM_BUILD_DOC_HTML_YN "YES")
  11. else()
  12. set(GTSAM_BUILD_DOC_HTML_YN "NO")
  13. endif()
  14. if (GTSAM_BUILD_DOC_LATEX)
  15. set(GTSAM_BUILD_DOC_LATEX_YN "YES")
  16. else()
  17. set(GTSAM_BUILD_DOC_LATEX_YN "NO")
  18. endif()
  19. # GTSAM core subfolders
  20. set(gtsam_doc_subdirs
  21. gtsam/base
  22. gtsam/basis
  23. gtsam/discrete
  24. gtsam/geometry
  25. gtsam/inference
  26. gtsam/linear
  27. gtsam/navigation
  28. gtsam/nonlinear
  29. gtsam/sam
  30. gtsam/sfm
  31. gtsam/slam
  32. gtsam/smart
  33. gtsam/symbolic
  34. gtsam
  35. )
  36. # Optional GTSAM_UNSTABLE subfolders
  37. set(gtsam_unstable_doc_subdirs
  38. gtsam_unstable/base
  39. gtsam_unstable/discrete
  40. gtsam_unstable/linear
  41. gtsam_unstable/nonlinear
  42. gtsam_unstable/slam
  43. gtsam_unstable/dynamics
  44. gtsam_unstable
  45. )
  46. # Build a list of folders to include depending on build options
  47. set(doc_subdirs ${gtsam_doc_subdirs})
  48. if (GTSAM_BUILD_UNSTABLE)
  49. list(APPEND doc_subdirs ${gtsam_unstable_doc_subdirs})
  50. endif()
  51. if (GTSAM_BUILD_EXAMPLES)
  52. list(APPEND doc_subdirs examples)
  53. endif()
  54. # From subfolders, build a list with whitespace separation of paths
  55. set(GTSAM_DOXYGEN_INPUT_PATHS "")
  56. foreach(dir ${doc_subdirs})
  57. set(GTSAM_DOXYGEN_INPUT_PATHS "${GTSAM_DOXYGEN_INPUT_PATHS} ${PROJECT_SOURCE_DIR}/${dir}")
  58. endforeach()
  59. # Generate Doxyfile
  60. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
  61. # Add target to actually build documentation as configured
  62. add_custom_target(doc
  63. ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
  64. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  65. COMMENT "Generating API documentation with Doxygen" VERBATIM
  66. )
  67. # Clean target
  68. add_custom_target(doc_clean
  69. COMMAND
  70. cmake -E remove_directory ${CMAKE_CURRENT_SOURCE_DIR}/latex
  71. COMMAND
  72. cmake -E remove_directory ${CMAKE_CURRENT_SOURCE_DIR}/html
  73. COMMENT "Removing Doxygen documentation"
  74. )
  75. endif()