| 
									
										
										
										
											2023-01-14 20:37:42 +01:00
										 |  |  | if(NOT FTXUI_BUILD_DOCS)
 | 
					
						
							|  |  |  |   return()
 | 
					
						
							|  |  |  | endif()
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-25 01:34:13 +02:00
										 |  |  | find_package(Doxygen)
 | 
					
						
							| 
									
										
										
										
											2023-01-14 20:37:42 +01:00
										 |  |  | if (NOT DOXYGEN_FOUND)
 | 
					
						
							|  |  |  |   message("Doxygen need to be installed to generate the doxygen documentation")
 | 
					
						
							|  |  |  |   return()
 | 
					
						
							|  |  |  | endif()
 | 
					
						
							| 
									
										
										
										
											2021-07-23 12:10:47 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-20 14:35:17 +02:00
										 |  |  | include(FetchContent)
 | 
					
						
							|  |  |  | FetchContent_Declare( | 
					
						
							|  |  |  |     doxygen-awesome-css
 | 
					
						
							|  |  |  |     GIT_REPOSITORY https://github.com/jothepro/doxygen-awesome-css.git
 | 
					
						
							|  |  |  |     GIT_TAG v2.3.4
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | )
 | 
					
						
							|  |  |  | FetchContent_MakeAvailable(doxygen-awesome-css)
 | 
					
						
							|  |  |  | FetchContent_GetProperties(doxygen-awesome-css SOURCE_DIR AWESOME_CSS_DIR)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-14 20:37:42 +01:00
										 |  |  | # Generate example list for documentation
 | 
					
						
							| 
									
										
										
										
											2025-05-20 14:35:17 +02:00
										 |  |  | set(DOM_EXAMPLES "")
 | 
					
						
							|  |  |  | set(COMPONENT_EXAMPLES "")
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-14 20:37:42 +01:00
										 |  |  | get_property(EXAMPLES GLOBAL PROPERTY FTXUI::EXAMPLES)
 | 
					
						
							| 
									
										
										
										
											2025-05-20 14:35:17 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | foreach(example IN LISTS EXAMPLES)
 | 
					
						
							|  |  |  |   if(example MATCHES "^dom/.*")
 | 
					
						
							|  |  |  |     list(APPEND DOM_EXAMPLES "${example}")
 | 
					
						
							|  |  |  |   elseif(example MATCHES "^component/.*")
 | 
					
						
							|  |  |  |     list(APPEND COMPONENT_EXAMPLES "${example}")
 | 
					
						
							|  |  |  |   else()
 | 
					
						
							|  |  |  |     message(ERROR "Unknown example '${example}'")
 | 
					
						
							|  |  |  |   endif()
 | 
					
						
							|  |  |  | endforeach()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | macro(write_example_list file title page examples)
 | 
					
						
							| 
									
										
										
										
											2025-05-31 23:19:18 +02:00
										 |  |  |   file(WRITE "${file}" "@page ${page} ${title}\n")
 | 
					
						
							| 
									
										
										
										
											2025-05-20 14:35:17 +02:00
										 |  |  |   file(APPEND "${file}" "@tableofcontents\n")
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   foreach(example IN LISTS ${examples})
 | 
					
						
							|  |  |  |     get_filename_component(name "${example}" NAME_WE)
 | 
					
						
							|  |  |  |     file(APPEND "${file}" "# ${name}\n")
 | 
					
						
							| 
									
										
										
										
											2025-05-31 23:19:18 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Add a markdown  to the demo. URL example:
 | 
					
						
							|  |  |  |     # https://arthursonzogni.github.io/FTXUI/examples/?file=component/canvas_animated
 | 
					
						
							|  |  |  |     file(APPEND "${file}" "[Demo](https://arthursonzogni.github.io/FTXUI/examples/?file=${example})\n")
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-20 14:35:17 +02:00
										 |  |  |     file(APPEND "${file}" "@include examples/${example}.cpp\n")
 | 
					
						
							| 
									
										
										
										
											2025-05-31 23:19:18 +02:00
										 |  |  |     file(APPEND "${file}" "\n")
 | 
					
						
							| 
									
										
										
										
											2025-05-20 14:35:17 +02:00
										 |  |  |   endforeach()
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-31 23:19:18 +02:00
										 |  |  |   # Reference to the examples
 | 
					
						
							|  |  |  |   foreach(example IN LISTS ${examples})
 | 
					
						
							|  |  |  |     get_filename_component(name "${example}" NAME_WE)
 | 
					
						
							|  |  |  |     file(APPEND "${file}" "@example examples/${example}.cpp\n")
 | 
					
						
							|  |  |  |   endforeach()
 | 
					
						
							| 
									
										
										
										
											2025-05-20 14:35:17 +02:00
										 |  |  | endmacro()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | write_example_list("${CMAKE_CURRENT_BINARY_DIR}/dom_examples.md" | 
					
						
							|  |  |  |   "Example"
 | 
					
						
							|  |  |  |   module-dom-examples
 | 
					
						
							|  |  |  |   DOM_EXAMPLES)
 | 
					
						
							|  |  |  | write_example_list("${CMAKE_CURRENT_BINARY_DIR}/component_examples.md" | 
					
						
							|  |  |  |   "Example"
 | 
					
						
							|  |  |  |   module-component-examples
 | 
					
						
							|  |  |  |   COMPONENT_EXAMPLES)
 | 
					
						
							| 
									
										
										
										
											2020-05-25 01:34:13 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-14 20:37:42 +01:00
										 |  |  | configure_file(Doxyfile.in Doxyfile @ONLY)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # note the option ALL which allows to build the docs together with the application
 | 
					
						
							|  |  |  | add_custom_target(doc | 
					
						
							|  |  |  |   COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
 | 
					
						
							|  |  |  |   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
 | 
					
						
							|  |  |  |   COMMENT "Generating API documentation with Doxygen"
 | 
					
						
							|  |  |  |   VERBATIM
 | 
					
						
							|  |  |  |   )
 |