changeset 4686:d28eab3994f9 Orthanc-0.8.6

hotpatch to make Orthanc 0.8.6 compile on Ubuntu 18.04
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 09 Jun 2021 14:57:16 +0200
parents 6784a119484d
children
files Resources/CMake/GoogleLogConfiguration.cmake Resources/Patches/glog-ubuntu-18.04.diff
diffstat 2 files changed, 41 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Resources/CMake/GoogleLogConfiguration.cmake	Thu Oct 15 13:56:50 2020 +0200
+++ b/Resources/CMake/GoogleLogConfiguration.cmake	Wed Jun 09 14:57:16 2021 +0200
@@ -1,10 +1,30 @@
 if (STATIC_BUILD OR NOT USE_SYSTEM_GOOGLE_LOG)
   SET(GOOGLE_LOG_SOURCES_DIR ${CMAKE_BINARY_DIR}/glog-0.3.2)
+
+  if (IS_DIRECTORY "${GOOGLE_LOG_SOURCES_DIR}")
+    set(FirstRun OFF)
+  else()
+    set(FirstRun ON)
+  endif()
+
   DownloadPackage(
     "897fbff90d91ea2b6d6e78c8cea641cc"
     "http://www.orthanc-server.com/downloads/third-party/glog-0.3.2.tar.gz"
     "${GOOGLE_LOG_SOURCES_DIR}")
 
+  if (FirstRun)
+    find_program(PATCH_EXECUTABLE patch)
+    execute_process(
+      COMMAND ${PATCH_EXECUTABLE} -p0 -N -i
+      ${CMAKE_CURRENT_LIST_DIR}/../Patches/glog-ubuntu-18.04.diff
+      WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+      RESULT_VARIABLE Failure
+      )
+
+    if (Failure)
+      message(FATAL_ERROR "Error while patching a file")
+    endif()
+  endif()
 
   # Glog 0.3.3 fails to build with old versions of MinGW, such as the
   # one installed on our Continuous Integration Server that runs
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Resources/Patches/glog-ubuntu-18.04.diff	Wed Jun 09 14:57:16 2021 +0200
@@ -0,0 +1,21 @@
+diff -urEb glog-0.3.2.orig/src/demangle.cc glog-0.3.2/src/demangle.cc
+--- glog-0.3.2.orig/src/demangle.cc	2021-06-09 14:45:34.648501148 +0200
++++ glog-0.3.2/src/demangle.cc	2021-06-09 14:46:07.376532698 +0200
+@@ -167,7 +167,7 @@
+ // Returns true if "str" has at least "n" characters remaining.
+ static bool AtLeastNumCharsRemaining(const char *str, int n) {
+   for (int i = 0; i < n; ++i) {
+-    if (str == '\0') {
++    if (str[i] == '\0') {
+       return false;
+     }
+   }
+@@ -223,7 +223,7 @@
+ // Returns true and advances "mangled_cur" if we find any character in
+ // "char_class" at "mangled_cur" position.
+ static bool ParseCharClass(State *state, const char *char_class) {
+-  if (state->mangled_cur == '\0') {
++  if (state->mangled_cur[0] == '\0') {
+     return false;
+   }
+   const char *p = char_class;