changeset 3128:972cc98959a3 db-changes

fix build of civetweb for Visual Studio 2008 and LSB
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 16 Jan 2019 12:14:30 +0100
parents e678a2b1a25b
children 5c0d3df52b05
files Core/Compression/ZipWriter.cpp Core/DicomNetworking/TimeoutDicomConnectionManager.cpp Core/SerializationToolbox.cpp Resources/CMake/CivetwebConfiguration.cmake Resources/Patches/civetweb-1.11.patch
diffstat 5 files changed, 51 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/Core/Compression/ZipWriter.cpp	Wed Jan 16 09:53:45 2019 +0100
+++ b/Core/Compression/ZipWriter.cpp	Wed Jan 16 12:14:30 2019 +0100
@@ -59,9 +59,9 @@
   ptime midnight(today);
 
   time_duration sinceMidnight = now - midnight;
-  zfi.tmz_date.tm_sec = sinceMidnight.seconds();  // seconds after the minute - [0,59]
-  zfi.tmz_date.tm_min = sinceMidnight.minutes();  // minutes after the hour - [0,59]
-  zfi.tmz_date.tm_hour = sinceMidnight.hours();  // hours since midnight - [0,23]
+  zfi.tmz_date.tm_sec = static_cast<unsigned int>(sinceMidnight.seconds());  // seconds after the minute - [0,59]
+  zfi.tmz_date.tm_min = static_cast<unsigned int>(sinceMidnight.minutes());  // minutes after the hour - [0,59]
+  zfi.tmz_date.tm_hour = static_cast<unsigned int>(sinceMidnight.hours());  // hours since midnight - [0,23]
 
   // http://www.boost.org/doc/libs/1_35_0/doc/html/boost/gregorian/greg_day.html
   zfi.tmz_date.tm_mday = today.day();  // day of the month - [1,31]
--- a/Core/DicomNetworking/TimeoutDicomConnectionManager.cpp	Wed Jan 16 09:53:45 2019 +0100
+++ b/Core/DicomNetworking/TimeoutDicomConnectionManager.cpp	Wed Jan 16 12:14:30 2019 +0100
@@ -97,7 +97,7 @@
 
   unsigned int TimeoutDicomConnectionManager::GetTimeout()
   {
-    return timeout_.total_milliseconds();
+    return static_cast<unsigned int>(timeout_.total_milliseconds());
   }
 
 
--- a/Core/SerializationToolbox.cpp	Wed Jan 16 09:53:45 2019 +0100
+++ b/Core/SerializationToolbox.cpp	Wed Jan 16 12:14:30 2019 +0100
@@ -53,7 +53,7 @@
         tag = FromDcmtkBridge::ParseTag(name);
         return true;
       }
-      catch (OrthancException& e)
+      catch (OrthancException&)
       {
         return false;
       }
--- a/Resources/CMake/CivetwebConfiguration.cmake	Wed Jan 16 09:53:45 2019 +0100
+++ b/Resources/CMake/CivetwebConfiguration.cmake	Wed Jan 16 12:14:30 2019 +0100
@@ -3,8 +3,25 @@
   set(CIVETWEB_URL "http://www.orthanc-server.com/downloads/third-party/civetweb-1.11.tar.gz")
   set(CIVETWEB_MD5 "b6d2175650a27924bccb747cbe084cd4")
 
+  if (IS_DIRECTORY "${CIVETWEB_SOURCES_DIR}")
+    set(FirstRun OFF)
+  else()
+    set(FirstRun ON)
+  endif()
+
   DownloadPackage(${CIVETWEB_MD5} ${CIVETWEB_URL} "${CIVETWEB_SOURCES_DIR}")
 
+  execute_process(
+    COMMAND ${PATCH_EXECUTABLE} -p0 -N -i
+    ${ORTHANC_ROOT}/Resources/Patches/civetweb-1.11.patch
+    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+    RESULT_VARIABLE Failure
+    )
+
+  if (FirstRun AND Failure)
+    message(FATAL_ERROR "Error while patching a file")
+  endif()
+  
   include_directories(
     ${CIVETWEB_SOURCES_DIR}/include
     )
@@ -13,7 +30,6 @@
     ${CIVETWEB_SOURCES_DIR}/src/civetweb.c
     )
 
-
   if (ENABLE_SSL)
     add_definitions(
       -DNO_SSL_DL=1
@@ -29,13 +45,6 @@
       )
   endif()
 
-
-  if (CMAKE_SYSTEM_NAME STREQUAL "Windows" AND
-      CMAKE_COMPILER_IS_GNUCXX)
-    # This is a patch for MinGW64
-    add_definitions(-D_TIMESPEC_DEFINED=1)
-  endif()
-
   source_group(ThirdParty\\Civetweb REGULAR_EXPRESSION ${CIVETWEB_SOURCES_DIR}/.*)
 
 else()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Resources/Patches/civetweb-1.11.patch	Wed Jan 16 12:14:30 2019 +0100
@@ -0,0 +1,29 @@
+diff -urEb civetweb-1.11.orig/src/civetweb.c civetweb-1.11/src/civetweb.c
+--- civetweb-1.11.orig/src/civetweb.c	2019-01-16 10:52:21.313348500 +0100
++++ civetweb-1.11/src/civetweb.c	2019-01-16 11:59:58.995605655 +0100
+@@ -20,6 +20,14 @@
+  * THE SOFTWARE.
+  */
+ 
++
++#if defined(__LSB_VERSION__)
++// These definitions are mandatory for Linux Standard Base
++#  define NO_CACHING
++#  define NO_ALTERNATIVE_QUEUE
++#  define NO_THREAD_NAME
++#endif
++  
+ #if defined(__GNUC__) || defined(__MINGW32__)
+ #define GCC_VERSION                                                            \
+ 	(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
+@@ -536,6 +544,10 @@
+ #if !defined(EWOULDBLOCK)
+ #define EWOULDBLOCK WSAEWOULDBLOCK
+ #endif /* !EWOULDBLOCK */
++#if !defined(ECONNRESET)
++// Macro ECONNRESET is not always defined (e.g. on Visual Studio 2008)
++#  define ECONNRESET WSAECONNRESET
++#endif /* !ECONNRESET */
+ #define _POSIX_
+ #define INT64_FMT "I64d"
+ #define UINT64_FMT "I64u"