function(setup_documentation source_dir output_dir)
    find_package(Doxygen)
    option(BUILD_DOCUMENTATION "Create and install the HTML documentation (requires Doxygen)." ${DOXYGEN_FOUND})

    if(BUILD_DOCUMENTATION)
        if(NOT DOXYGEN_FOUND)
            message(FATAL_ERROR "Doxygen is needed to build the documentation.")
        endif()

        set( DOXYGEN_OUTPUT_DIRECTORY ${output_dir} )
        set( DOXYGEN_COLLABORATION_GRAPH YES )
        set( DOXYGEN_EXTRACT_ALL YES )
        set( DOXYGEN_CLASS_DIAGRAMS YES )
        set( DOXYGEN_HIDE_UNDOC_RELATIONS NO )
        set( DOXYGEN_HAVE_DOT YES )
        set( DOXYGEN_CLASS_GRAPH YES )
        set( DOXYGEN_CALL_GRAPH YES )
        set( DOXYGEN_CALLER_GRAPH YES )
        set( DOXYGEN_COLLABORATION_GRAPH YES )
        set( DOXYGEN_BUILTIN_STL_SUPPORT YES )
        set( DOXYGEN_EXTRACT_PRIVATE YES )
        set( DOXYGEN_EXTRACT_PACKAGE YES )
        set( DOXYGEN_EXTRACT_STATIC YES )
        set( DOXYGEN_EXTRACT_LOCALMETHODS YES )
        set( DOXYGEN_UML_LOOK YES )
        set( DOXYGEN_UML_LIMIT_NUM_FIELDS 50 )
        set( DOXYGEN_TEMPLATE_RELATIONS YES )
        set( DOXYGEN_DOT_GRAPH_MAX_NODES 100 )
        set( DOXYGEN_MAX_DOT_GRAPH_DEPTH 0 )
        set( DOXYGEN_DOT_TRANSPARENT YES )

        doxygen_add_docs( docs ${source_dir} ALL )

    else()
        message( "Doxygen need to be installed to generate the doxygen documentation" )
    endif()

endfunction()
