Skip to content

Commit

Permalink
CMake: Fix some special cases regarding generation of docs
Browse files Browse the repository at this point in the history
Ignore error if docs are not generated using a git working tree, for
  instance from a downloaded tarball or zip file. This is only a
  temporary solution for issue #499 (see "FIXME" comment).

Execute doxygen only if it is available. i.e. found by CMake.
  • Loading branch information
Albrecht Schlosser committed Oct 3, 2022
1 parent 30efed7 commit 5646522
Showing 1 changed file with 32 additions and 12 deletions.
44 changes: 32 additions & 12 deletions documentation/CMakeLists.txt
Expand Up @@ -16,6 +16,9 @@

set (DOCS)
set (GENERATE_DOCS FALSE)
set (GIT_REVISION "")
set (YEAR "")
set (CURRENT_DATE "")

if (OPTION_BUILD_HTML_DOCUMENTATION OR OPTION_BUILD_PDF_DOCUMENTATION)
set (GENERATE_DOCS TRUE)
Expand Down Expand Up @@ -44,24 +47,33 @@ if (GENERATE_DOCS)
OUTPUT_VARIABLE CURRENT_DATE
)

# find git revision

# FIXME: This must also work with tarballs where git is not available.
# For now we just ignore errors and set GIT_REVISION = "unkown".
# In the future tarball/zip generation should create a file
# that contains the git revision.

execute_process (COMMAND
git --git-dir=${CMAKE_SOURCE_DIR}/.git rev-parse --short=10 HEAD
OUTPUT_VARIABLE GIT_REVISION
ERROR_QUIET
)
# strip trailing newline from git revision
string (REPLACE "\n" "" GIT_REVISION "${GIT_REVISION}")
# set to "'unkown'" if git is not available
if (GIT_REVISION STREQUAL "")
set (GIT_REVISION "'unkown'")
endif()

# strip trailing newline
string (REPLACE "\n" "" GIT_REVISION ${GIT_REVISION})

execute_process (COMMAND doxygen --version
OUTPUT_VARIABLE DOXYGEN_VERSION_SHORT
)

# strip trailing git revision if doxygen was built from source
string (REGEX REPLACE " .*$" "" DOXYGEN_VERSION_SHORT ${DOXYGEN_VERSION_SHORT})
# find doxygen version

## fl_debug_var (GIT_REVISION)
## fl_debug_var (DOXYGEN_EXECUTABLE)
## fl_debug_var (DOXYGEN_VERSION_SHORT)
if (DOXYGEN_FOUND)
# strip trailing git revision if doxygen was built from source
string (REGEX REPLACE " .*$" "" DOXYGEN_VERSION_SHORT ${DOXYGEN_VERSION})
# strip trailing newline
string (REPLACE "\n" "" DOXYGEN_VERSION_SHORT "${DOXYGEN_VERSION_SHORT}")
endif (DOXYGEN_FOUND)

# configure copyright.dox (includes current year)
configure_file (
Expand All @@ -77,6 +89,14 @@ if (GENERATE_DOCS)
@ONLY
)

if (0) # debug
fl_debug_var (GIT_REVISION)
fl_debug_var (DOXYGEN_FOUND)
fl_debug_var (DOXYGEN_EXECUTABLE)
fl_debug_var (DOXYGEN_VERSION)
fl_debug_var (DOXYGEN_VERSION_SHORT)
endif ()

endif (GENERATE_DOCS)

#--------------------------
Expand Down

0 comments on commit 5646522

Please sign in to comment.