]> granicus.if.org Git - json-c/commitdiff
add doc target on cmake
authordota17 <chenguopingdota@163.com>
Wed, 26 Feb 2020 07:39:27 +0000 (15:39 +0800)
committerdota17 <chenguopingdota@163.com>
Wed, 26 Feb 2020 10:18:07 +0000 (18:18 +0800)
CMakeLists.txt
README.md

index b1f6f69b5c1fd428d2b3a9ae0a6e370e012039fe..c7b5195d9bd1532649b0301f3115a16a1d5d561f 100644 (file)
@@ -317,6 +317,24 @@ set(JSON_C_SOURCES
 include_directories(${PROJECT_SOURCE_DIR})
 include_directories(${PROJECT_BINARY_DIR})
 
+# generate doxygen documentation for json-c API
+
+find_package(Doxygen)
+option(BUILD_DOCUMENTATION "Create and install the HTML based API documentation(requires Doxygen)" ${DOXYGEN_FOUND})
+
+if (DOXYGEN_FOUND)
+
+       add_custom_target(doc
+       COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile
+               WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+       
+       # request to configure the file
+       configure_file(Doxyfile Doxyfile)
+
+else (DOXYGEN_FOUND)
+       message("Doxygen need to be installed to generate the doxygen documentation")
+endif(DOXYGEN_FOUND)
+
 # XXX for a normal full distribution we'll need to figure out
 # XXX how to build both shared and static libraries.
 # Probably leverage that to build a local VALGRIND=1 library for testing too.
index 766d9e7c7060750f11c5d9ea6ff0d5ea78220c50..b794fcb700e8485e872d75109eed6c772fba5851 100644 (file)
--- a/README.md
+++ b/README.md
@@ -230,6 +230,14 @@ JSONC_TEST_TRACE=1 make test
 ```
 and check the log files again.
 
+To get doxygen documentation
+
+The libray documentation can be generated directly from the source codes using Doxygen tool:
+
+```sh
+make doc
+google-chrome ../doc/html/index.html
+```
 
 
 Linking to `libjson-c` <a name="linking">