FLTK logo

[master] 5646522 - CMake: Fix some special cases regarding generation of docs

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] 5646522 - CMake: Fix some special cases regarding generation of docs "Albrecht Schlosser" Oct 03, 2022  
 
commit 5646522985896c21ff24c2552f9111091371c547
Author:     Albrecht Schlosser <albrechts.fltk@online.de>
AuthorDate: Mon Oct 3 10:49:43 2022 +0200
Commit:     Albrecht Schlosser <albrechts.fltk@online.de>
CommitDate: Mon Oct 3 10:49:43 2022 +0200

    CMake: Fix some special cases regarding generation of docs
    
    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.

 documentation/CMakeLists.txt | 44 ++++++++++++++++++++++++++++++++------------
 1 file changed, 32 insertions(+), 12 deletions(-)

diff --git documentation/CMakeLists.txt documentation/CMakeLists.txt
index df23668..e5d358e 100644
--- documentation/CMakeLists.txt
+++ documentation/CMakeLists.txt
@@ -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)
@@ -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 (
@@ -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)
 
 #--------------------------
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.