You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CreateDoxygen.cmake-skeleton 7.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. # Author Yann Renard / INRIA
  2. # Date 2008-10-15
  3. #
  4. # this CMake script iterates over several source documentation directories in
  5. # order to compile it with doxygen. It has the ability to configure the
  6. # doxyfile depending on some variables and to build documentation sources from
  7. # computer generated templates (.dox-skeleton) and hand written documentation
  8. # parts (.dox-part)
  9. MESSAGE(STATUS "Launching Create Doxygen CMake script")
  10. SET(RESOURCE_FILES "@RESOURCE_FILES@")
  11. SET(ov_doxy_final "@ov_doxy_final@")
  12. SET(ov_doxy_version "@ov_doxy_version@")
  13. SET(ov_doxy_input "@ov_doxy_input@")
  14. SET(CURRENT_PROJECTS "@CURRENT_PROJECTS@")
  15. SET(CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@")
  16. MESSAGE(STATUS "Running plugin inspector")
  17. #MESSAGE(STATUS "@CMAKE_INSTALL_FULL_BINDIR@/../lib/")
  18. IF(UNIX)
  19. EXECUTE_PROCESS(
  20. COMMAND @CMAKE_INSTALL_FULL_BINDIR@/../openvibe-plugin-inspector.sh
  21. -d "@CMAKE_CURRENT_BINARY_DIR@" -p @CMAKE_INSTALL_FULL_BINDIR@/../lib/
  22. -k "@CMAKE_INSTALL_FULL_BINDIR@/../lib/"
  23. -c "@CMAKE_INSTALL_FULL_BINDIR@/../share/openvibe/kernel/openvibe.conf"
  24. WORKING_DIRECTORY "@CMAKE_INSTALL_FULL_BINDIR@/"
  25. )
  26. ELSEIF(WIN32)
  27. EXECUTE_PROCESS(
  28. COMMAND @CMAKE_INSTALL_FULL_BINDIR@/../openvibe-plugin-inspector.cmd
  29. -d "@CMAKE_CURRENT_BINARY_DIR@" -p @CMAKE_INSTALL_FULL_BINDIR@
  30. -k "@CMAKE_INSTALL_FULL_BINDIR@"
  31. -c "@CMAKE_INSTALL_FULL_BINDIR@/../share/openvibe/kernel/openvibe.conf"
  32. WORKING_DIRECTORY "@CMAKE_INSTALL_FULL_BINDIR@/"
  33. )
  34. ENDIF(UNIX)
  35. #go through all of the .dox-part files we have found previously and extract information
  36. FOREACH(dox @DOX_PART_FILES@)
  37. GET_FILENAME_COMPONENT(dox_filename ${dox} NAME_WE)
  38. MESSAGE(STATUS " Documentation part found ${dox}")
  39. SET(dox_tag_name NOTFOUND)
  40. # iterates on each line of the file to look after begin/end tags
  41. # "dox_tag_name" stores the name of the variable
  42. # to use to configure the skeleton file. It is computed from the
  43. # begin tag.
  44. FILE(READ ${dox} dox_lines)
  45. # replaces empty cariage returns with semi colons to be compliant
  46. # with CMake lists. note the space before and after the semi
  47. # colon, this is for CMake not to skip empty lines
  48. STRING(REPLACE "\n" " ; " dox_lines " ${dox_lines} ")
  49. FOREACH(dox_line ${dox_lines})
  50. # this regex removes the spaces we added before the loop
  51. STRING(REGEX REPLACE "^ (.*) $" "\\1" dox_line ${dox_line})
  52. # we initialize several variables that will be used in
  53. # this loop
  54. SET(dox_line_processed FALSE)
  55. SET(dox_tag_begin NOTFOUND)
  56. SET(dox_tag_end NOTFOUND)
  57. SET(dox_tag NOTFOUND)
  58. # and look for a new tag in this line
  59. STRING(REGEX MATCH "\\|[a-zA-Z0-9_]+\\|" dox_tag "${dox_line}")
  60. IF(dox_tag)
  61. # a tag is found, so we want to know if it is a
  62. # OVP_DocBegin* or OVP_DocEnd* tag
  63. STRING(REGEX MATCH "\\|OVP_DocBegin_[a-zA-Z0-9_]*\\|" dox_tag_begin "${dox_line}")
  64. STRING(REGEX MATCH "\\|OVP_DocEnd_[a-zA-Z0-9_]*\\|" dox_tag_end "${dox_line}")
  65. # in case we already have something in
  66. # dox_tag_name, it means that begin tag has
  67. # already been processed, so either we terminate with end
  68. # tag, either we continue with come content to add in the
  69. # variable
  70. IF(dox_tag_name AND dox_tag_end)
  71. # in case we find end tag, we just terminate cleaning
  72. # the tag and what follows. We then terminate and
  73. # create a new CMake variable with the content of this
  74. # begin/end tagged things.
  75. STRING(REGEX REPLACE ".*\\|OVP_DocEnd_([a-zA-Z0-9_]*)\\|.*" "\\1" dox_tag_name_check ${dox_line})
  76. STRING(REGEX REPLACE "\\|OVP_DocEnd_([a-zA-Z0-9_]*)\\|.*" "" dox_line "${dox_line}")
  77. # MESSAGE(STATUS " - Completed tag pair |${dox_tag_name}|")
  78. SET(dox_tag_name_value "${dox_tag_name_value}\n${dox_line}")
  79. SET("Doc_${dox_tag_name}_Content" ${dox_tag_name_value})
  80. SET(dox_tag_name NOTFOUND)
  81. SET(dox_line_processed TRUE)
  82. ENDIF(dox_tag_name AND dox_tag_end)
  83. # in case dox_tag_name is empty, it means
  84. # that begin tag has not yet been found, so we just look at it
  85. # or skip to next line
  86. IF(NOT dox_tag_name AND dox_tag_begin)
  87. # in case we find begin tag, we just start saving the
  88. # CMake variable name, and clean the tag and what
  89. # comes before. We then intialize the content of the
  90. # begin/end tagged thing with what comes after begin
  91. # tag.
  92. STRING(REGEX REPLACE ".*\\|OVP_DocBegin_([a-zA-Z0-9_]*)\\|.*" "\\1" dox_tag_name ${dox_line})
  93. STRING(REGEX REPLACE ".*\\|OVP_DocBegin_([a-zA-Z0-9_]*)\\|" "" dox_line "${dox_line}")
  94. SET(dox_tag_name_value "${dox_line}")
  95. SET(dox_line_processed TRUE)
  96. ENDIF(NOT dox_tag_name AND dox_tag_begin)
  97. # in case dox tag is not OVP_DocBegin* or OVP_DocEnd*
  98. # just print a warning and continue
  99. IF(NOT dox_line_processed)
  100. MESSAGE(STATUS " - Unexpected tag ${dox_tag} in ${dox} will be ignored")
  101. ENDIF(NOT dox_line_processed)
  102. ENDIF(dox_tag)
  103. # in case this line was not processed, either because it does
  104. # not have any tag, either because the tag was unexpected, we
  105. # just append the whole line to the content of the current
  106. # variable
  107. IF(dox_tag_name AND NOT dox_line_processed)
  108. # in case we don't find the end tag, just append this
  109. # new line to the current content
  110. SET(dox_tag_name_value "${dox_tag_name_value}\n${dox_line}")
  111. ENDIF(dox_tag_name AND NOT dox_line_processed)
  112. ENDFOREACH(dox_line)
  113. ENDFOREACH(dox)
  114. # install the remaining resource files
  115. # now we have stored all the begin/end tagged things in variable, we just
  116. # have to configure the skeleton configuration files with those variables.
  117. # note that the skeleton files should be prepared to receive the CMake
  118. # variables with anywhere it is needed.
  119. #
  120. # in order to do so, we look after all the (.dox-skeleton) files and call
  121. # the configure command to build the final documentation (.dox) file.
  122. MESSAGE(STATUS "Current bin dir: @CMAKE_CURRENT_BINARY_DIR@")
  123. FILE(GLOB_RECURSE dox_skeletons "@CMAKE_CURRENT_BINARY_DIR@/*.dox-skeleton")
  124. FOREACH(dox_skeleton ${dox_skeletons})
  125. GET_FILENAME_COMPONENT(dox_skeleton_filename ${dox_skeleton} NAME_WE)
  126. CONFIGURE_FILE(
  127. "${dox_skeleton}"
  128. "@CMAKE_CURRENT_BINARY_DIR@/${dox_skeleton_filename}.dox"
  129. @ONLY)
  130. # MESSAGE(STATUS " [ OK ] Configured skeleton ${dox_skeleton}")
  131. ENDFOREACH(dox_skeleton)
  132. CONFIGURE_FILE(
  133. "@CMAKE_CURRENT_SOURCE_DIR@/doxyfile-skeleton"
  134. ${ov_doxy_final}
  135. @ONLY)
  136. # and a post-build command is added in order to run doxygen
  137. MESSAGE(STATUS "Running doxygen")
  138. EXECUTE_PROCESS(
  139. COMMAND "@doxygen_bin@" "@ov_doxy_final@"
  140. WORKING_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@"
  141. )
  142. # 'patch' the docs, this takes some time, is it worth doing it?
  143. # original linux-build directive:
  144. # find $target_dist/doc -name *.html -exec sed -i -e "s/\xC2\?\xA7OpenViBE\xC2\?\xA7/OpenViBE/g" "{}" \;
  145. # \xC2\?\xA7 is the character that has been put everywhere to clearly make the distinction between the project and the software
  146. #MESSAGE(STATUS "Patching special characters in HTML docs ...")
  147. #FILE(GLOB_RECURSE HTML_DOCS "${CMAKE_CURRENT_BINARY_DIR}/../doc/html/*.html")
  148. #MESSAGE(STATUS "IAMIN ${CMAKE_CURRENT_BINARY_DIR}/../doc/html/")
  149. #MESSAGE(STATUS "got ${HTML_DOCS}")
  150. #FOREACH(HTML_DOC ${HTML_DOCS})
  151. # MESSAGE(STATUS "Processing ${HTML_DOC}")
  152. # FILE(READ ${HTML_DOC} ORIG_FILE)
  153. # STRING(REGEX REPLACE "[^ a-zA-Z0-9:.,]OpenViBE[^ a-zA-Z0-9:.,]" "OpenViBE" TRANSLATED_FILE ${ORIG_FILE})
  154. # FILE(WRITE ${HTML_DOC} ${TRANSLATED_FILE})
  155. #ENDFOREACH(HTML_DOC)
  156. FILE(GLOB_RECURSE resource_files_tmp "@CMAKE_CURRENT_BINARY_DIR@/*.png")
  157. SET(RESOURCE_FILES ${RESOURCE_FILES} ${resource_files_tmp})
  158. # hax to install all files under the doc/html folder in the script-launched installer
  159. FILE(GLOB_RECURSE resource_files_tmp "@CMAKE_CURRENT_BINARY_DIR@/../doc/html/*.*")
  160. SET(RESOURCE_FILES ${RESOURCE_FILES} ${resource_files_tmp})
  161. IF(RESOURCE_FILES)
  162. FILE(INSTALL FILES ${RESOURCE_FILES} DESTINATION "@CMAKE_INSTALL_FULL_DOCDIR@")
  163. ENDIF(RESOURCE_FILES)