nvbio.cmake 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # this keeps track of the targets that are generated for doxygen,
  2. # used to set up the doc target later on
  3. # unfortunately, this has to be a property instead of a variable due to cmake's
  4. # weird scoping rules
  5. set_property(GLOBAL PROPERTY _nvbio_doxygen_target_list "")
  6. # set up doxygen for a given nvbio module
  7. # checks if there's a Doxyfile.in in the module directory
  8. # and sets up build rules to generate documentation for this module
  9. macro(_nvbio_doxygen_module name)
  10. if (DOXYGEN_FOUND)
  11. # set up paths
  12. set(doxy_in_directory "${CMAKE_CURRENT_SOURCE_DIR}/doxy")
  13. set(doxy_out_directory "${CMAKE_CURRENT_BINARY_DIR}/doxy")
  14. # set up the path to the Doxyfile.in for the current module
  15. set(doxyfile_in "${doxy_in_directory}/Doxyfile.in")
  16. # set up the path to the Doxyfile that we'll generate from Doxyfile.in
  17. set(doxyfile_out "${doxy_out_directory}/Doxyfile")
  18. # test if the current module has a Doxyfile.in
  19. if (EXISTS ${doxyfile_in})
  20. message("==> Found Doxygen file for module ${name}")
  21. # parse the Doxyfile.in with cmake to substitute build variables and generate the Doxyfile
  22. configure_file(${doxyfile_in} ${doxyfile_out} @ONLY)
  23. add_custom_target(doc_${name}_copy
  24. ${CMAKE_COMMAND} -E copy_directory ${doxy_in_directory} ${doxy_out_directory})
  25. add_custom_target(doc_${name}
  26. DEPENDS doc_${name}_copy
  27. COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile}
  28. WORKING_DIRECTORY ${doxy_out_directory}
  29. COMMENT "Generating API documentation for ${name} with Doxygen" VERBATIM)
  30. set_property(GLOBAL APPEND PROPERTY _nvbio_doxygen_target_list doc_${name})
  31. endif()
  32. endif()
  33. endmacro(_nvbio_doxygen_module)
  34. # generate the doc target
  35. # doc will depend on all doc_* targets generated for any modules with doxygen.in files
  36. macro(nvbio_doxygen)
  37. if (DOXYGEN_FOUND)
  38. get_property(_targets GLOBAL PROPERTY _nvbio_doxygen_target_list)
  39. add_custom_target(doc DEPENDS ${_targets})
  40. endif()
  41. endmacro(nvbio_doxygen)
  42. # start a new nvbio module (library or executable)
  43. # this will match a MSVC project
  44. macro(nvbio_module name)
  45. set(_current_nvbio_module ${name})
  46. set(_current_nvbio_module_srcs "")
  47. set(_current_nvbio_directory "")
  48. _nvbio_doxygen_module(${name})
  49. endmacro(nvbio_module)
  50. # add sources to the current module or directory
  51. macro(addsources)
  52. set(_src_list_TMP "")
  53. # add the directory path
  54. foreach(l ${ARGN})
  55. list(APPEND _src_list_TMP ${_current_nvbio_directory}${l})
  56. endforeach()
  57. if (NOT "${_current_nvbio_directory}" STREQUAL "")
  58. # chop the trailing '/' off the group name
  59. string(REGEX REPLACE "/$" "" _tmp_group ${_current_nvbio_directory})
  60. # convert '/' into '\\'
  61. string(REGEX REPLACE "/" "\\\\" _tmp_group ${_tmp_group})
  62. source_group(${_tmp_group} FILES ${_src_list_TMP})
  63. unset(_tmp_group)
  64. else()
  65. source_group("" FILES ${_src_list_TMP})
  66. endif()
  67. list(APPEND ${_current_nvbio_module}_srcs ${_src_list_TMP})
  68. unset(_src_list_TMP)
  69. endmacro(addsources)
  70. # add a module directory
  71. macro(nvbio_add_module_directory directory)
  72. set(_current_nvbio_directory "${directory}/")
  73. include(${directory}/CMakeLists.txt)
  74. endmacro(nvbio_add_module_directory)