diff --git a/CMakeLists.txt b/CMakeLists.txt
index 437a690..022cb50 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -29,7 +29,7 @@ ENDIF(LIBTINS_BUILD_SHARED)
# The version number.
SET(LIBTINS_VERSION_MAJOR 3)
SET(LIBTINS_VERSION_MINOR 1)
-SET(LIBTINS_CPP_VERSION "${LIBTINS_VERSION_MAJOR}.${LIBTINS_VERSION_MINOR}")
+SET(LIBTINS_VERSION "${LIBTINS_VERSION_MAJOR}.${LIBTINS_VERSION_MINOR}")
# Required Packages
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
@@ -81,6 +81,22 @@ IF(LIBTINS_ENABLE_DOT11)
ENDIF(LIBTINS_ENABLE_WPA2)
ENDIF(LIBTINS_ENABLE_DOT11)
+# add a target to generate API documentation with Doxygen
+FIND_PACKAGE(Doxygen QUIET)
+IF(DOXYGEN_FOUND)
+ CONFIGURE_FILE(
+ ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in
+ ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
+ @ONLY
+ )
+ ADD_CUSTOM_TARGET(
+ docs
+ ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ COMMENT "Generating API documentation with Doxygen" VERBATIM
+ )
+ENDIF(DOXYGEN_FOUND)
+
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
diff --git a/Doxyfile b/Doxyfile.in
similarity index 99%
rename from Doxyfile
rename to Doxyfile.in
index 5114c54..3a0bc70 100644
--- a/Doxyfile
+++ b/Doxyfile.in
@@ -31,14 +31,14 @@ PROJECT_NAME = libtins
# This could be handy for archiving the generated documentation or
# if some version control system is used.
-PROJECT_NUMBER = 3.2
+PROJECT_NUMBER = @LIBTINS_VERSION@
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
# If a relative path is entered, it will be relative to the location
# where doxygen was started. If left blank the current directory will be used.
-OUTPUT_DIRECTORY = ../docs/
+OUTPUT_DIRECTORY = @CMAKE_CURRENT_BINARY_DIR@/docs/
# 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
@@ -581,7 +581,7 @@ WARN_LOGFILE =
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
-INPUT = include src
+INPUT = @CMAKE_CURRENT_SOURCE_DIR@/include @CMAKE_CURRENT_SOURCE_DIR@/src @CMAKE_CURRENT_SOURCE_DIR@/mainpage.dox
# 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
diff --git a/mainpage.dox b/mainpage.dox
new file mode 100644
index 0000000..3cf936d
--- /dev/null
+++ b/mainpage.dox
@@ -0,0 +1,29 @@
+/**
+ * \mainpage Documentation
+ *
+ * \section intro_sec Introduction
+ *
+ * libtins is a high-level, multiplatform C++ network packet
+ * sniffing and crafting library.
+ *
+ * Its main purpose is to provide the C++ developer an easy, efficient,
+ * platform and endianess-independent way to create tools which need to
+ * send, receive and manipulate network packets.
+ *
+ * \section install_sec Installation
+ *
+ * Please visit the downloads
+ * section in order to see the installation instructions.
+ *
+ * \section tutorials_sec Tutorials
+ *
+ * If you want to learn about how the library works, please visit the
+ * tutorials section.
+ *
+ * \section examples_sec Examples
+ *
+ * Make sure to visit the
+ * examples section to see some short but illustrative examples on how
+ * to send and sniff packets using libtins.
+ *
+ */
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c1266c7..1a6299a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -62,7 +62,7 @@ ADD_LIBRARY(
TARGET_LINK_LIBRARIES(tins ${PCAP_LIBRARY} ${OPENSSL_LIBRARIES} ${LIBTINS_OS_LIBS})
SET_TARGET_PROPERTIES(tins PROPERTIES OUTPUT_NAME tins )
-SET_TARGET_PROPERTIES(tins PROPERTIES VERSION ${LIBTINS_CPP_VERSION} SOVERSION ${LIBTINS_CPP_VERSION} )
+SET_TARGET_PROPERTIES(tins PROPERTIES VERSION ${LIBTINS_VERSION} SOVERSION ${LIBTINS_VERSION} )
# Install instructions for this target
INSTALL(