@@ -32,6 +32,9 @@ find_package(microcdr REQUIRED)
3232
3333find_package (rmw REQUIRED )
3434
35+ # Build options
36+ option (BUILD_DOCUMENTATION "Use doxygen to create product documentation" OFF )
37+
3538# RMW profile options
3639option (RMW_UXRCE_GRAPH "Allows to perform graph-related operations to the user" OFF )
3740if (RMW_UXRCE_GRAPH)
@@ -104,6 +107,15 @@ endif()
104107configure_file (${PROJECT_SOURCE_DIR } /src/config.h.in
105108 ${PROJECT_BINARY_DIR } /include/rmw_microxrcedds_c/config.h )
106109
110+ # Set install directories
111+ if (WIN32 )
112+ set (DOC_DIR "doc" )
113+ else ()
114+ set (DOC_DIR "${DATA_INSTALL_DIR} /doc" )
115+ endif ()
116+
117+ set (DOC_INSTALL_DIR ${DOC_DIR} CACHE PATH "Installation directory for documentation" )
118+
107119set (SRCS
108120 src/identifiers.c
109121 src/memory.c
@@ -134,13 +146,18 @@ set(SRCS
134146 src/rmw_take.c
135147 src/rmw_topic_names_and_types.c
136148 src/rmw_trigger_guard_condition.c
137- src/rmw_uros_options.c
138149 src/rmw_wait.c
139150 src/rmw_wait_set.c
140151 src/types.c
141152 src/utils.c
142153 src/callbacks.c
143154 src/rmw_uxrce_transports.c
155+ src/rmw_microros/continous_serialization.c
156+ src/rmw_microros/init_options.c
157+ src/rmw_microros/time_sync.c
158+ src/rmw_microros/ping.c
159+ $<$<BOOL :${RMW_UXRCE_TRANSPORT_UDP} >:src /rmw_microros /discovery .c >
160+ $<$<BOOL :${RMW_UXRCE_TRANSPORT_CUSTOM} >:src /rmw_microros /custom_transport .c >
144161 $<$<BOOL :${RMW_UXRCE_GRAPH} >:src /rmw_graph .c >
145162 )
146163
@@ -259,6 +276,46 @@ if(BUILD_TESTING)
259276 add_subdirectory (test )
260277endif ()
261278
279+ # Documentation
280+ if (BUILD_DOCUMENTATION)
281+ find_package (Doxygen )
282+ if (NOT DOXYGEN_FOUND)
283+ message (FATAL_ERROR "doxygen is needed to build the documentation. Please install it correctly" )
284+ endif ()
285+ if (UNIX )
286+ find_program (DOXYFILE_MAKE make )
287+ if (DOXYFILE_MAKE)
288+ message (STATUS "Found Make: ${DOXYFILE_MAKE} " )
289+ else ()
290+ message (FATAL_ERROR "make is needed to build the documentation. Please install it correctly" )
291+ endif ()
292+ elseif (WIN32 )
293+ set (DOXYFILE_MAKE make.bat)
294+ endif ()
295+
296+ # Target to create documentation directories
297+ file (MAKE_DIRECTORY ${PROJECT_BINARY_DIR } /doc )
298+ add_custom_target (docdirs
299+ COMMAND ${CMAKE_COMMAND } -E make_directory ${PROJECT_BINARY_DIR } /doc/api_reference
300+ COMMENT "Creating documentation directory" VERBATIM )
301+
302+ ### Doxygen ########################3
303+ # Configure the template doxyfile for or specific project
304+ configure_file (doxyfile.in ${PROJECT_BINARY_DIR } /doxyfile @ONLY IMMEDIATE )
305+ # Add custom target to run doxygen when ever the project is build
306+ add_custom_target (doxygen
307+ COMMAND "${DOXYGEN_EXECUTABLE} " "${PROJECT_BINARY_DIR } /doxyfile"
308+ SOURCES "${PROJECT_BINARY_DIR } /doxyfile"
309+ COMMENT "Generating API documentation with doxygen" VERBATIM )
310+
311+ add_dependencies (doxygen docdirs )
312+
313+ add_custom_target (doc ALL
314+ COMMENT "Generated project documentation" VERBATIM )
315+
316+ add_dependencies (doc doxygen )
317+ endif ()
318+
262319ament_package ()
263320
264321# Install includes.
@@ -288,3 +345,11 @@ install(
288345 RUNTIME DESTINATION
289346 bin
290347 )
348+
349+ if (BUILD_DOCUMENTATION)
350+ # Instalation of doxygen files
351+ install (DIRECTORY ${PROJECT_BINARY_DIR } /doc/api_reference
352+ DESTINATION ${DOC_INSTALL_DIR}
353+ COMPONENT documentation
354+ )
355+ endif ()
0 commit comments