From 53efe6283c4328f175635cf607abff803e54f1e0 Mon Sep 17 00:00:00 2001
From: Pascal Palenda <pascal.palenda@akustik.rwth-aachen.de>
Date: Tue, 14 Feb 2023 16:58:29 +0100
Subject: [PATCH] Add doc for ihta_add_library

---
 src/IhtaAddLibrary.cmake | 101 +++++++++++++++++++++++++++++++++++----
 1 file changed, 92 insertions(+), 9 deletions(-)

diff --git a/src/IhtaAddLibrary.cmake b/src/IhtaAddLibrary.cmake
index 8025915..f458d49 100644
--- a/src/IhtaAddLibrary.cmake
+++ b/src/IhtaAddLibrary.cmake
@@ -3,23 +3,106 @@ include_guard ()
 #[=======================================================================[.rst:
 ..command:: ihta_add_library
 
-	Macro to generate doxygen documentation with custom logo and style sheet.
+	Macro to create a library including most of the common settings/setups.
+
+	This macro also allows to create a unit test executable with the same command.
+
+	In most cases, after this command only link libraries have to be set and 
+	optionally install directives.
+
+	Note: when using generated export headers from cmake, these have to be added
+	to the lib and test targets manually.
 
 	::
 
-		build_doc(
-			SOURCES <documentation-folder...>
-			[README_MAINPAGE <readme-file-for-main-page>]
-			[COLOR_STYLE <css-style-sheet>]
-			[LOGO <logo-file>]
-			[ADD_DEV_SECTION]
-			[SIDEBAR_ONLY]
+		ihta_add_library(
+			NAME <library-name>
+			SOURCES <library-source-files...>
+			[LIBRARY_TYPE <STATIC|SHARED>]
+			[NAMESPACE <target-alias-namespace>]
+			[IDE_FOLDER <folder-name-for-IDE>]
+			[INCLUDE_DIR <library-include-dir>]
+			[INSTALL_INCLUDE_DIR <library-install-include-dir>]
+			[OUT_VAR <output-library-target-name-variable>]
+			[TEST_SOURCES <test-source-files...>]
+			[TEST_INTERNALS]
+			[SRC_DIR <library-source-dir>]
+			[OBJECT_LIB_POSTFIX <object-lib-postfix>]
 		)
 
-	.. variable:: SIDEBAR_ONLY
+	.. variable:: NAME
 
 		Specifies, that the `doxygen-awesome-css` sidebar ony style should be used.
 
+	.. variable:: SOURCES
+
+		Source files for the library.
+
+		If you are using `target_sources` you can use `""` as the sources.
+		Todo: test this!
+
+	.. variable:: LIBRARY_TYPE
+
+		Optionally specify the library type. Either `STATIC` or `SHARED`.
+
+		If not specified, this macro behaves similarly to `add_library` in that it
+		assumes the type to be `STATIC` unless `BUILD_SHARED_LIBS` is turned on.
+
+	.. variable:: NAMESPACE
+
+		Optional namespace for the alias target of the library.
+
+		At least NAMESPACE or IDE_FOLDER must be given. If only one is given, the other 
+		one will be set to the value of the given one.
+
+	.. variable:: IDE_FOLDER
+
+		Optional IDE folder for the library target(s).
+
+		At least NAMESPACE or IDE_FOLDER must be given. If only one is given, the other 
+		one will be set to the value of the given one.
+
+	.. variable:: INCLUDE_DIR
+
+		Optionally specify the libraries include directory.
+		Default is `${CMAKE_CURRENT_SOURCE_DIR}/include`.
+
+	.. variable:: INSTALL_INCLUDE_DIR
+
+		Optionally specify the install include directory for the library.
+		If not specified, the install expects the same include folder structure as in the
+		libraries include folder.
+
+	.. variable:: OUT_VAR
+
+		Variable name into which the library target name will be set.
+
+		This can be useful when testing the internals and an object library is created,
+		onto which most further settings must be applied.
+
+	.. variable:: TEST_SOURCES
+
+		Sources files for the optional unit test executable.
+
+	.. variable:: TEST_INTERNALS
+
+		Specifies if the unit test should be able to test the internals of the library.
+
+		Under the hood, this then creates an object library for both the library and
+		the test to save on compilation time.
+
+		See `cmake_registertest <https://github.com/pthom/cmake_registertest>`_
+
+	.. variable:: SRC_DIR
+
+		Optionally specify the libraries source directory.
+		Default is `${CMAKE_CURRENT_SOURCE_DIR}/src`.
+		This should be given if TEST_INTERNALS is given and one wants to test the internals.
+
+	.. variable:: OBJECT_LIB_POSTFIX
+
+		Optionally specify a postfix for the object library if TEST_INTERNALS is specified.
+		The default is `_object`.
 
 #]=======================================================================]
 macro (ihta_add_library)
-- 
GitLab