From 8098fc925f94d08332f9fdd42741386c72e3c388 Mon Sep 17 00:00:00 2001
From: Ivan Romanov <drizt@land.ru>
Date: Fri, 3 Jan 2014 15:34:53 +0600
Subject: [PATCH] Added cmake doc target

Do not use doxygen directly. Often cmake build out-of-source.
So it usefult to have doc make target. It is required to generate
documentation for generating header file (qca_version.h) which places
in build tree.
---
 CMakeLists.txt                    | 10 ++++++
 Doxyfile => Doxyfile.in           | 53 ++++++++++++++++---------------
 include/QtCrypto/qca_version.h.in |  2 +-
 3 files changed, 38 insertions(+), 27 deletions(-)
 rename Doxyfile => Doxyfile.in (96%)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6d3ab7cb..8af80866 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,6 +17,8 @@ option(BUILD_TOOLS "Compile mozcerts and qcatool" ON)
 set(BUILD_PLUGINS "auto" CACHE STRING "Plugins for building (also possible values: none, all and auto)")
 option(SHARED_LIBRARY "Build shared library" ON)
 
+find_package(Doxygen)
+
 string(TOLOWER "${BUILD_PLUGINS}" BUILD_PLUGINS)
 if(NOT BUILD_PLUGINS)
   set(BUILD_PLUGINS "none")
@@ -271,6 +273,14 @@ if(BUILD_TOOLS)
   add_subdirectory(tools)
 endif(BUILD_TOOLS)
 
+if(DOXYGEN_FOUND)
+  configure_file(${CMAKE_SOURCE_DIR}/Doxyfile.in ${CMAKE_BINARY_DIR}/Doxyfile @ONLY)
+  add_custom_target(doc
+    ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile
+    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+    COMMENT "Generating API documentation with Doxygen" VERBATIM)
+endif(DOXYGEN_FOUND)
+
 # /usr/local is traditional path for installing apps on POSIX-systems.
 # I consciously break this. Qt by default looks plugins and features only in
 # own directory. So by default install libs in Qt prefix it is a best choice.
diff --git a/Doxyfile b/Doxyfile.in
similarity index 96%
rename from Doxyfile
rename to Doxyfile.in
index a681524d..fe2fed90 100644
--- a/Doxyfile
+++ b/Doxyfile.in
@@ -462,9 +462,10 @@ WARN_LOGFILE           =
 # directories like "/usr/src/myproject". Separate the files or directories 
 # with spaces.
 
-INPUT                  = examples \
-                         . \
-                         include/QtCrypto
+INPUT                  = @CMAKE_SOURCE_DIR@/examples \
+                         @CMAKE_SOURCE_DIR@ \
+                         @CMAKE_SOURCE_DIR@/include/QtCrypto \
+                         @CMAKE_BINARY_DIR@/qca_version.h
 
 # This tag can be used to specify the character encoding of the source files that 
 # doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default 
@@ -494,7 +495,7 @@ RECURSIVE              = NO
 # excluded from the INPUT source files. This way you can easily exclude a 
 # subdirectory from a directory tree whose root is specified with the INPUT tag.
 
-EXCLUDE                = 
+EXCLUDE                = @CMAKE_BINARY_DIR@/import_plugins.h
 
 # The EXCLUDE_SYMLINKS tag can be used select whether or not files or 
 # directories that are symbolic links (a Unix filesystem feature) are excluded 
@@ -526,27 +527,27 @@ EXCLUDE_SYMBOLS        =
 # directories that contain example code fragments that are included (see 
 # the \include command).
 
-EXAMPLE_PATH           = examples/aes-cmac \
-                         examples/base64test \
-                         examples/certtest \
-                         examples/ciphertest \
-                         examples/cms \
-                         examples/cmssigner \
-                         examples/eventhandlerdemo \
-                         examples/hashtest \
-                         examples/hextest \
-                         examples/keyloader \
-                         examples/mactest \
-                         examples/md5crypt \
-                         examples/providertest \
-                         examples/publickeyexample \
-                         examples/randomtest \
-                         examples/rsatest \
-                         examples/saslclient \
-                         examples/saslserver \
-                         examples/ssltest \
-                         examples/sslservtest \
-                         examples/tlssocket
+EXAMPLE_PATH           = @CMAKE_SOURCE_DIR@/examples/aes-cmac \
+                         @CMAKE_SOURCE_DIR@/examples/base64test \
+                         @CMAKE_SOURCE_DIR@/examples/certtest \
+                         @CMAKE_SOURCE_DIR@/examples/ciphertest \
+                         @CMAKE_SOURCE_DIR@/examples/cms \
+                         @CMAKE_SOURCE_DIR@/examples/cmssigner \
+                         @CMAKE_SOURCE_DIR@/examples/eventhandlerdemo \
+                         @CMAKE_SOURCE_DIR@/examples/hashtest \
+                         @CMAKE_SOURCE_DIR@/examples/hextest \
+                         @CMAKE_SOURCE_DIR@/examples/keyloader \
+                         @CMAKE_SOURCE_DIR@/examples/mactest \
+                         @CMAKE_SOURCE_DIR@/examples/md5crypt \
+                         @CMAKE_SOURCE_DIR@/examples/providertest \
+                         @CMAKE_SOURCE_DIR@/examples/publickeyexample \
+                         @CMAKE_SOURCE_DIR@/examples/randomtest \
+                         @CMAKE_SOURCE_DIR@/examples/rsatest \
+                         @CMAKE_SOURCE_DIR@/examples/saslclient \
+                         @CMAKE_SOURCE_DIR@/examples/saslserver \
+                         @CMAKE_SOURCE_DIR@/examples/ssltest \
+                         @CMAKE_SOURCE_DIR@/examples/sslservtest \
+                         @CMAKE_SOURCE_DIR@/examples/tlssocket
 
 # If the value of the EXAMPLE_PATH tag contains directories, you can use the 
 # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
@@ -1098,7 +1099,7 @@ SKIP_FUNCTION_MACROS   = YES
 # If a tag file is not located in the directory in which doxygen 
 # is run, you must also specify the path to the tagfile here.
 
-TAGFILES               = src/qt.tag
+TAGFILES               = @CMAKE_SOURCE_DIR@/src/qt.tag
 
 # When a file name is specified after GENERATE_TAGFILE, doxygen will create 
 # a tag file that is based on the input files it reads.
diff --git a/include/QtCrypto/qca_version.h.in b/include/QtCrypto/qca_version.h.in
index 3e3cfa12..15d5f306 100644
--- a/include/QtCrypto/qca_version.h.in
+++ b/include/QtCrypto/qca_version.h.in
@@ -57,7 +57,7 @@
 #define QCA_VERSION_STR "@QCA_LIB_VERSION_STRING@"
 
 /**
-   Can be used like #if (QCA_VERSION >= QCA_VERSION_CHECK(2, 0, 3))
+   Can be used like #if (QCA_VERSION >= %QCA_VERSION_CHECK(2, 0, 3))
 
    \param major part of the version
    \param minor part of the version