Browse Source

generate doxygen with cmake

Julius Pfrommer 9 years ago
parent
commit
eca33ebd6d
3 changed files with 138 additions and 108 deletions
  1. 128 98
      CMakeLists.txt
  2. 9 9
      doc/Doxyfile.in
  3. 1 1
      tools/generate_namespace.py

+ 128 - 98
CMakeLists.txt

@@ -1,117 +1,147 @@
-cmake_minimum_required (VERSION 2.6)
-project (open62541)
-set (open62541_VERSION_MAJOR 0)
-set (open62541_VERSION_MINOR 1)
+cmake_minimum_required(VERSION 2.6)
 
-set (CMAKE_VERBOSE_MAKEFILE on )
-if (CMAKE_COMPILER_IS_GNUCC)
-set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -pedantic -pipe -fstack-protector -Wall -Wextra -Wno-unused-parameter -Wno-unused-function -Wno-unused-label -Wpointer-arith -Wformat -Wreturn-type -Wsign-compare -Wmultichar -Wformat-nonliteral -Winit-self -Wuninitialized -Wno-deprecated -Wformat-security -Werror -ffunction-sections -fdata-sections -Wl,--gc-sections")
-endif (CMAKE_COMPILER_IS_GNUCC)
+project(open62541)
+
+set(open62541_VERSION_MAJOR 0)
+set(open62541_VERSION_MINOR 1)
+
+set(CMAKE_VERBOSE_MAKEFILE on )
+if(CMAKE_COMPILER_IS_GNUCC)
+add_definitions(-std=c99 -pedantic -pipe -fstack-protector -Wall -Wextra
+                 -Wno-unused-parameter -Wno-unused-function -Wno-unused-label
+                 -Wpointer-arith -Wformat -Wreturn-type -Wsign-compare -Wmultichar
+                 -Wformat-nonliteral -Winit-self -Wuninitialized -Wno-deprecated
+                 -Wformat-security -Werror -ffunction-sections -fdata-sections
+                 -Wl,--gc-sections)
+endif(CMAKE_COMPILER_IS_GNUCC)
 
 # multithreading
-set (MULTITHREADING OFF CACHE BOOL "Enable multithreading")
-if (MULTITHREADING)
-    find_package (Threads REQUIRED)
-endif (MULTITHREADING)
+set(MULTITHREADING OFF CACHE BOOL "Enable multithreading")
+if(MULTITHREADING)
+    find_package(Threads REQUIRED)
+endif(MULTITHREADING)
 
 # encodings
-set (UA_ENCODING_AMOUNT 1) # binary encoding
+set(UA_ENCODING_AMOUNT 1) # binary encoding
 
-set (UA_ENCODING_XML OFF CACHE BOOL "Enable XML-encoding of the UA types")
-if (UA_ENCODING_XML)
+set(UA_ENCODING_XML OFF CACHE BOOL "Enable XML-encoding of the UA types")
+if(UA_ENCODING_XML)
     MATH(EXPR UA_ENCODING_AMOUNT "${UA_ENCODING_AMOUNT}+1")
-    find_package (EXPAT REQUIRED)
-    if (EXPAT_FOUND)
-        include_directories (${EXPAT_INCLUDE_DIRS})
-    else (EXPAT_FOUND)
-        message (FATAL_ERROR "Expat library not found.")
-    endif (EXPAT_FOUND)
-endif (UA_ENCODING_XML)
-
-set (UA_ENCODING_JSON OFF CACHE BOOL "Enable JSON-encoding of the UA types")
-if (UA_ENCODING_JSON)
+    find_package(EXPAT REQUIRED)
+    if(EXPAT_FOUND)
+        include_directories(${EXPAT_INCLUDE_DIRS})
+    else(EXPAT_FOUND)
+        message(FATAL_ERROR "Expat library not found.")
+    endif(EXPAT_FOUND)
+endif(UA_ENCODING_XML)
+
+set(UA_ENCODING_JSON OFF CACHE BOOL "Enable JSON-encoding of the UA types")
+if(UA_ENCODING_JSON)
     MATH(EXPR UA_ENCODING_AMOUNT "${UA_ENCODING_AMOUNT}+1")
-endif (UA_ENCODING_JSON)
+endif(UA_ENCODING_JSON)
+
+# gcov
+option(USE_GCOV "Enable gcov support" OFF)
+if(USE_GCOV)
+    message(STATUS "Enabling gcov support")
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
+    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
+    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage")
+endif()
 
 # directory for generated source files
-file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/src_generated")
-include_directories ("${PROJECT_BINARY_DIR}/src_generated") 
+file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/src_generated")
+include_directories("${PROJECT_BINARY_DIR}/src_generated") 
 
 # build the library
-configure_file ("src/ua_config.h.in" "${PROJECT_BINARY_DIR}/src_generated/ua_config.h")
-
-include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/src")
-include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/src/util")
-
-set (lib_sources src/ua_types.c
-                 src/ua_types_encoding_binary.c
-				 src/ua_application.c
-				 src/ua_transport.c
-				 src/ua_transport_binary.c
-				 src/ua_transport_binary_secure.c
-				 src/ua_services_attribute.c
-				 src/ua_services_session.c
-				 src/ua_services_discovery.c
-				 src/ua_services_securechannel.c
-				 src/ua_services_nodemanagement.c
-				 src/ua_services_view.c
-				 src/ua_services_subscription.c
-				 src/ua_services_monitoreditems.c
-				 src/util/ua_util.c
-				 src/util/ua_list.c
-				 src/util/ua_indexedList.c
-				 src/util/ua_base64.c
-				 ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.c
-				 ${PROJECT_BINARY_DIR}/src_generated/ua_namespace_0.c)
-
-if (MULTITHREADING)
-    list (APPEND lib_sources src/ua_namespace_concurrent.c)
-else ()
-    list (APPEND lib_sources src/ua_namespace.c)
-endif (MULTITHREADING)
-
-set (generate_options "")
-
-if (UA_ENCODING_XML)
-    list (APPEND lib_sources src/ua_types_encoding_xml.c
-                             src/ua_namespace_xml.c
-                             src/ua_xml.c)
-    set (generate_options "${generate_options}--with-xml")
-endif (UA_ENCODING_XML)
-
-if (UA_ENCODING_JSON)
-    list (APPEND lib_sources src/ua_types_encoding_json.c)
-    set (generate_options "${generate_options}--with-json")
-endif (UA_ENCODING_JSON)
-
-add_library (open62541 ${lib_sources})
+configure_file("src/ua_config.h.in" "${PROJECT_BINARY_DIR}/src_generated/ua_config.h")
+
+include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src")
+include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/util")
+
+set(lib_sources src/ua_types.c
+                src/ua_types_encoding_binary.c
+                src/ua_application.c
+                src/ua_transport.c
+                src/ua_transport_binary.c
+                src/ua_transport_binary_secure.c
+                src/ua_services_attribute.c
+                src/ua_services_session.c
+                src/ua_services_discovery.c
+                src/ua_services_securechannel.c
+                src/ua_services_nodemanagement.c
+                src/ua_services_view.c
+                src/ua_services_subscription.c
+                src/ua_services_monitoreditems.c
+                src/util/ua_util.c
+                src/util/ua_list.c
+                src/util/ua_indexedList.c
+                src/util/ua_base64.c
+                ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.c
+                ${PROJECT_BINARY_DIR}/src_generated/ua_namespace_0.c)
+
+if(MULTITHREADING)
+    list(APPEND lib_sources src/ua_namespace_concurrent.c)
+else()
+    list(APPEND lib_sources src/ua_namespace.c)
+endif(MULTITHREADING)
+
+set(generate_src_options "")
+
+if(UA_ENCODING_XML)
+    list(APPEND lib_sources src/ua_types_encoding_xml.c
+                            src/ua_namespace_xml.c
+                            src/ua_xml.c)
+    set(generate_src_options "${generate_src_options}--with-xml")
+endif(UA_ENCODING_XML)
+
+if(UA_ENCODING_JSON)
+    list(APPEND lib_sources src/ua_types_encoding_json.c)
+    set(generate_src_options "${generate_src_options}--with-json")
+endif(UA_ENCODING_JSON)
+
+add_library(open62541 ${lib_sources})
 
 # generate data structures
-add_custom_command (OUTPUT ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.c
-                           ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.h
-                    COMMAND python ${PROJECT_SOURCE_DIR}/tools/generate_builtin.py ${generate_options} ${PROJECT_SOURCE_DIR}/schema/Opc.Ua.Types.bsd ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated
-                    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/generate_builtin.py
-                            ${CMAKE_CURRENT_SOURCE_DIR}/schema/Opc.Ua.Types.bsd)
-
-add_custom_command (OUTPUT ${PROJECT_BINARY_DIR}/src_generated/ua_namespace_0.c
-                           ${PROJECT_BINARY_DIR}/src_generated/ua_namespace_0.h
-                    COMMAND python ${PROJECT_SOURCE_DIR}/tools/generate_namespace.py ${generate_options} ${PROJECT_SOURCE_DIR}/schema/NodeIds.csv ${PROJECT_BINARY_DIR}/src_generated/ua_namespace_0
-                    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/generate_namespace.py
-                            ${CMAKE_CURRENT_SOURCE_DIR}/schema/NodeIds.csv)
+add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.c
+                          ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.h
+                   COMMAND python ${PROJECT_SOURCE_DIR}/tools/generate_builtin.py ${generate_src_options} ${PROJECT_SOURCE_DIR}/schema/Opc.Ua.Types.bsd ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated
+                   DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/generate_builtin.py
+                           ${CMAKE_CURRENT_SOURCE_DIR}/schema/Opc.Ua.Types.bsd)
+
+add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/ua_namespace_0.c
+                          ${PROJECT_BINARY_DIR}/src_generated/ua_namespace_0.h
+                   COMMAND python ${PROJECT_SOURCE_DIR}/tools/generate_namespace.py ${generate_src_options} ${PROJECT_SOURCE_DIR}/schema/NodeIds.csv ${PROJECT_BINARY_DIR}/src_generated/ua_namespace_0
+                   DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/generate_namespace.py
+                           ${CMAKE_CURRENT_SOURCE_DIR}/schema/NodeIds.csv)
 
 # download queue.h if required
-if (WIN32)
-	if (NOT EXISTS "${PROJECT_BINARY_DIR}/src_generated/queue.h")
-        file (DOWNLOAD "http://openbsd.cs.toronto.edu/cgi-bin/cvsweb/~checkout~/src/sys/sys/queue.h" "${PROJECT_BINARY_DIR}/src_generated/queue.h" STATUS result)
-		list (GET result 0 download_ok)
-		if (NOT ${download_ok} MATCHES 0)
-			file (REMOVE "${PROJECT_BINARY_DIR}/src_generated/queue.h") # remove empty file if created
-			message (FATAL_ERROR "queue.h could not be downloaded")
-		endif ()
-	endif ()
-endif (WIN32)
+if(WIN32)
+    if(NOT EXISTS "${PROJECT_BINARY_DIR}/src_generated/queue.h")
+        file(DOWNLOAD "http://openbsd.cs.toronto.edu/cgi-bin/cvsweb/~checkout~/src/sys/sys/queue.h" "${PROJECT_BINARY_DIR}/src_generated/queue.h" STATUS result)
+        list(GET result 0 download_ok)
+        if(NOT ${download_ok} MATCHES 0)
+            file(REMOVE "${PROJECT_BINARY_DIR}/src_generated/queue.h") # remove empty file if created
+            message(FATAL_ERROR "queue.h could not be downloaded")
+        endif()
+    endif()
+endif(WIN32)
 
 # build example implementations
 add_executable(exampleServer examples/src/opcuaServer.c
-                             examples/src/networklayer.c)
-target_link_libraries (exampleServer open62541) 
+                              examples/src/networklayer.c)
+target_link_libraries(exampleServer open62541) 
+
+# generate documentation
+option(GENERATE_DOCUMENTATION "Generate doxygen documentation" OFF)
+if(GENERATE_DOCUMENTATION)
+    find_package(Doxygen)
+        if(NOT DOXYGEN_FOUND)
+            message(FATAL_ERROR "Doxygen is not installed or not properly configured")
+        endif(NOT DOXYGEN_FOUND)
+    configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
+    add_custom_target(doc
+                      ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
+                      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+                      COMMENT "Generating API documentation with Doxygen")
+endif(GENERATE_DOCUMENTATION)

+ 9 - 9
doc/Doxyfile.in

@@ -58,7 +58,7 @@ PROJECT_LOGO           =
 # entered, it will be relative to the location where doxygen was started. If
 # left blank the current directory will be used.
 
-OUTPUT_DIRECTORY       =
+OUTPUT_DIRECTORY       = @PROJECT_BINARY_DIR@/doc
 
 # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub-
 # directories (in 2 levels) under the output directory of each output format and
@@ -694,7 +694,7 @@ CITE_BIB_FILES         =
 # messages are off.
 # The default value is: NO.
 
-QUIET                  = NO
+QUIET                  = YES
 
 # The WARNINGS tag can be used to turn on/off the warning messages that are
 # generated to standard error ( stderr) by doxygen. If WARNINGS is set to YES
@@ -754,7 +754,7 @@ WARN_LOGFILE           =
 # spaces.
 # Note: If this tag is empty the current directory is searched.
 
-INPUT                  = @top_srcdir@
+INPUT                  = @CMAKE_CURRENT_SOURCE_DIR@/doc @CMAKE_CURRENT_SOURCE_DIR@/src  @PROJECT_BINARY_DIR@/src_generated
 
 # This tag can be used to specify the character encoding of the source files
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@@ -1019,7 +1019,7 @@ GENERATE_HTML          = YES
 # The default directory is: html.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
-HTML_OUTPUT            = html
+HTML_OUTPUT            = .
 
 # The HTML_FILE_EXTENSION tag can be used to specify the file extension for each
 # generated HTML page (for example: .htm, .php, .asp).
@@ -1046,7 +1046,7 @@ HTML_FILE_EXTENSION    = .html
 # of the possible markers and block names see the documentation.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
-HTML_HEADER            = style/header.html
+HTML_HEADER            = @CMAKE_CURRENT_SOURCE_DIR@/doc/style/header.html
 
 # The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
 # generated HTML page. If the tag is left blank doxygen will generate a standard
@@ -1056,7 +1056,7 @@ HTML_HEADER            = style/header.html
 # that doxygen normally uses.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
-HTML_FOOTER            = style/footer.html
+HTML_FOOTER            = @CMAKE_CURRENT_SOURCE_DIR@/doc/style/footer.html
 
 # The HTML_STYLESHEET tag can be used to specify a user-defined cascading style
 # sheet that is used by each HTML page. It can be used to fine-tune the look of
@@ -1068,7 +1068,7 @@ HTML_FOOTER            = style/footer.html
 # obsolete.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
-HTML_STYLESHEET        = style/doxygen.css
+HTML_STYLESHEET        = @CMAKE_CURRENT_SOURCE_DIR@/doc/style/doxygen.css
 
 # The HTML_EXTRA_STYLESHEET tag can be used to specify an additional user-
 # defined cascading style sheet that is included after the standard style sheets
@@ -1089,8 +1089,8 @@ HTML_EXTRA_STYLESHEET  =
 # files will be copied as-is; there are no commands or markers available.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
-HTML_EXTRA_FILES       = style/jquery-1.11.1.min.js \
-                         style/load-style.js
+HTML_EXTRA_FILES       = @CMAKE_CURRENT_SOURCE_DIR@/doc/style/jquery-1.11.1.min.js \
+                         @CMAKE_CURRENT_SOURCE_DIR@/doc/style/load-style.js
 
 # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
 # will adjust the colors in the stylesheet and background images according to

+ 1 - 1
tools/generate_namespace.py

@@ -94,7 +94,7 @@ printh('''/**********************************************************
 /**
  * @brief maps namespace zero nodeId to index into UA_VTable
  *
- * @param[in] ns0Id The namespace zero nodeId
+ * @param[in] id The namespace zero nodeId
  *
  * @retval UA_ERR_INVALID_VALUE whenever ns0Id could not be mapped
  * @retval the corresponding index into UA_VTable