build CHANGE separated build type for building docs without dependencies

Let the user build doxygen documentation without need of other compile
dependencies.

Moves the docs build into a separated cmake functions in CMakeModules.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 851acf7..9b85da2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,6 +11,7 @@
 include(CheckCSourceCompiles)
 include(CheckIncludeFile)
 include(UseCompat)
+include(Doc)
 
 if(POLICY CMP0075)
     cmake_policy(SET CMP0075 NEW)
@@ -40,6 +41,8 @@
   set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Build Type" FORCE)
 elseif ("${BUILD_TYPE_UPPER}" STREQUAL "RELWITHDEBUG")
   set(CMAKE_BUILD_TYPE "RelWithDebug" CACHE STRING "Build Type" FORCE)
+elseif ("${BUILD_TYPE_UPPER}" STREQUAL "DOCONLY")
+  set(CMAKE_BUILD_TYPE "DocOnly" CACHE STRING "Build Type" FORCE)
 endif()
 
 add_compile_options(-Wall -Wextra -fvisibility=hidden -std=gnu99)
@@ -119,6 +122,11 @@
     src/session_server.h
     src/session_server_ch.h)
 
+if("${BUILD_TYPE_UPPER}" STREQUAL "DOCONLY")
+    libnetconf_doc()
+    return()
+endif()
+
 # use compat
 use_compat()
 
@@ -235,14 +243,7 @@
 endif()
 
 # generate doxygen documentation for libnetconf2 API
-find_package(Doxygen)
-if(DOXYGEN_FOUND)
-    set(DOXYGEN_SKIP_DOT TRUE)
-    add_custom_target(doc
-            COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile
-            WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
-    configure_file(Doxyfile.in Doxyfile)
-endif()
+libnetconf_doc()
 
 # install library
 install(TARGETS netconf2 DESTINATION ${CMAKE_INSTALL_LIBDIR})