changeset 172:8c7bb94adff7

trying upgrade from libpq 9.6.1 to 13.1
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 11 Dec 2020 12:49:33 +0100
parents e712ff3eede3
children 30d3f68631d2
files Framework/PostgreSQL/PostgreSQLIncludes.h PostgreSQL/CMakeLists.txt PostgreSQL/NEWS PostgreSQL/UnitTests/UnitTestsMain.cpp Resources/CMake/DatabasesFrameworkConfiguration.cmake Resources/CMake/PostgreSQLConfiguration.cmake Resources/Orthanc/CMake/DownloadOrthancFramework.cmake Resources/PostgreSQL/CheckTypeAlignment.cmake Resources/PostgreSQL/PrepareCMakeConfigurationFile.py Resources/PostgreSQL/c_flexmember.c Resources/PostgreSQL/pg_config_ext.h Resources/PostgreSQL/printf_archetype.c
diffstat 12 files changed, 199 insertions(+), 172 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/PostgreSQL/PostgreSQLIncludes.h	Fri Nov 06 17:51:01 2020 +0100
+++ b/Framework/PostgreSQL/PostgreSQLIncludes.h	Fri Dec 11 12:49:33 2020 +0100
@@ -40,6 +40,10 @@
 // PostgreSQL includes
 #include <pg_config.h>
 
+#if !defined(PG_VERSION_NUM)
+#  error PG_VERSION_NUM is not defined
+#endif
+
 #if PG_VERSION_NUM >= 110000
 #  include <postgres.h>
 #  undef LOG  // This one comes from <postgres.h>, and conflicts with <Logging.h>
--- a/PostgreSQL/CMakeLists.txt	Fri Nov 06 17:51:01 2020 +0100
+++ b/PostgreSQL/CMakeLists.txt	Fri Dec 11 12:49:33 2020 +0100
@@ -15,11 +15,12 @@
   set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "web")
 endif()
 
+set(ENABLE_SSL ON)
 include(${CMAKE_SOURCE_DIR}/../Resources/CMake/DatabasesPluginParameters.cmake)
 
 set(ENABLE_POSTGRESQL_BACKEND ON)
-set(OPENSSL_STATIC_VERSION "1.0.2" CACHE STRING "TODO - Upgrade to OpenSSL 1.1.1" FORCE)
-  
+set(OPENSSL_STATIC_VERSION "1.1.1" CACHE STRING "Force the use of OpenSSL 1.1.1" FORCE)
+
 include(${CMAKE_SOURCE_DIR}/../Resources/CMake/DatabasesPluginConfiguration.cmake)
 
 
--- a/PostgreSQL/NEWS	Fri Nov 06 17:51:01 2020 +0100
+++ b/PostgreSQL/NEWS	Fri Dec 11 12:49:33 2020 +0100
@@ -5,6 +5,9 @@
 * Added "MaximumConnectionRetries" & "ConnectionRetryInterval" to configure 
   the retries when connecting to the DB at startup
 * Support of dynamic linking against the system-wide Orthanc framework library
+* Upgraded dependencies for static builds (notably on Windows and LSB):
+  - openssl 1.1.1g
+  - libpq 13.1
 
 
 Release 3.2 (2019-03-01)
--- a/PostgreSQL/UnitTests/UnitTestsMain.cpp	Fri Nov 06 17:51:01 2020 +0100
+++ b/PostgreSQL/UnitTests/UnitTestsMain.cpp	Fri Dec 11 12:49:33 2020 +0100
@@ -34,7 +34,7 @@
 
 TEST(PostgreSQL, Version)
 {
-  ASSERT_STREQ("9.6.1", PG_VERSION);
+  ASSERT_STREQ("13.1", PG_VERSION);
 }
 #endif
 
--- a/Resources/CMake/DatabasesFrameworkConfiguration.cmake	Fri Nov 06 17:51:01 2020 +0100
+++ b/Resources/CMake/DatabasesFrameworkConfiguration.cmake	Fri Dec 11 12:49:33 2020 +0100
@@ -28,7 +28,6 @@
 
 if (ENABLE_POSTGRESQL_BACKEND)
   set(ENABLE_CRYPTO_OPTIONS ON)
-  set(ENABLE_SSL ON)
   set(ENABLE_ZLIB ON)
 
   if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
--- a/Resources/CMake/PostgreSQLConfiguration.cmake	Fri Nov 06 17:51:01 2020 +0100
+++ b/Resources/CMake/PostgreSQLConfiguration.cmake	Fri Dec 11 12:49:33 2020 +0100
@@ -21,23 +21,38 @@
 ## PostgreSQL
 #####################################################################
 
-INCLUDE(CheckTypeSize)
 INCLUDE(CheckCSourceCompiles)
 INCLUDE(CheckFunctionExists)
+INCLUDE(CheckIncludeFiles)
 INCLUDE(CheckStructHasMember)
+INCLUDE(CheckTypeSize)
+
+
+macro(PrepareCMakeConfigurationFile Source Target)
+  execute_process(
+    COMMAND 
+    ${PYTHON_EXECUTABLE}
+    "${CMAKE_CURRENT_LIST_DIR}/../PostgreSQL/PrepareCMakeConfigurationFile.py" "${Source}" "${Target}"
+    ERROR_VARIABLE tmp
+    OUTPUT_VARIABLE out
+    )
+
+  if (tmp)
+    message(FATAL_ERROR "Cannot find ${Source}")
+  endif()
+endmacro()
 
 
 if (STATIC_BUILD OR NOT USE_SYSTEM_LIBPQ)
   add_definitions(-DORTHANC_POSTGRESQL_STATIC=1)
 
-  SET(LIBPQ_MAJOR 9)
-  SET(LIBPQ_MINOR 6)
-  SET(LIBPQ_REVISION 1)
-  SET(LIBPQ_VERSION ${LIBPQ_MAJOR}.${LIBPQ_MINOR}.${LIBPQ_REVISION})
+  SET(LIBPQ_MAJOR 13)
+  SET(LIBPQ_MINOR 1)
+  SET(LIBPQ_VERSION ${LIBPQ_MAJOR}.${LIBPQ_MINOR})
 
   SET(LIBPQ_SOURCES_DIR ${CMAKE_BINARY_DIR}/postgresql-${LIBPQ_VERSION})
   DownloadPackage(
-    "eaa7e267e89ea1ed2693d2b88d3cd290"
+    "551302a823a1ab48b4ed14166beebba9"
     "http://orthanc.osimis.io/ThirdPartyDownloads/postgresql-${LIBPQ_VERSION}.tar.gz"
     "${LIBPQ_SOURCES_DIR}")
 
@@ -59,8 +74,6 @@
   elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
     add_definitions(
       -D_GNU_SOURCE
-      -D_THREAD_SAFE
-      -D_POSIX_PTHREAD_SEMANTICS
       )
 
     configure_file(
@@ -134,131 +147,116 @@
     message(FATAL_ERROR "Cannot auto-generate the configuration file cross-compiling")
     
   else()
-    configure_file(
-      ${CMAKE_CURRENT_LIST_DIR}/../PostgreSQL/pg_config_ext.h
-      ${AUTOGENERATED_DIR}/pg_config_ext.h
-      COPYONLY
-      )
-
-    set(CMAKE_EXTRA_INCLUDE_FILES "sys/socket.h;netdb.h;sys/types.h")
+    set(PG_VERSION "\"${LIBPQ_MAJOR}.${LIBPQ_MINOR}\"")
+    math(EXPR PG_VERSION_NUM "${LIBPQ_MAJOR} * 10000 + ${LIBPQ_MINOR}")
 
     include(${CMAKE_CURRENT_LIST_DIR}/../PostgreSQL/func_accept_args.cmake)
-    set(ACCEPT_TYPE_ARG3 ${ACCEPT_TYPE_ARG3})
-
-    check_type_size("long int" SIZE_LONG_INT)
-    if (SIZE_LONG_INT EQUAL 8)
-      set(HAVE_LONG_INT_64 1)
-    endif()
-
-    check_type_size("long long int" SIZE_LONG_LONG_INT)
-    if (SIZE_LONG_LONG_INT EQUAL 8)
-      set(HAVE_LONG_LONG_INT_64 1)
-    endif()
-
-    file(READ ${CMAKE_CURRENT_LIST_DIR}/../PostgreSQL/c_flexmember.c SOURCE)
-    check_c_source_compiles("${SOURCE}" c_flexmember)
-    if (c_flexmember)
-      set(FLEXIBLE_ARRAY_MEMBER "/**/")
-    endif()
+    include(${CMAKE_CURRENT_LIST_DIR}/../PostgreSQL/CheckTypeAlignment.cmake)
 
-    if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR
-        CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR
-        CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
-      set(PG_PRINTF_ATTRIBUTE "printf")
-    else()
-      file(READ ${CMAKE_CURRENT_LIST_DIR}/../PostgreSQL/printf_archetype.c SOURCE)
-      check_c_source_compiles("${SOURCE}" printf_archetype)
-      if (printf_archetype)
-        set(PG_PRINTF_ATTRIBUTE "gnu_printf")
-      else()
-        set(PG_PRINTF_ATTRIBUTE "printf")
-      endif()
-    endif()
+    check_include_file("execinfo.h"           HAVE_EXECINFO_H) 
+    check_include_file("getopt.h"             HAVE_GETOPT_H) 
+    check_include_file("ifaddrs.h"            HAVE_IFADDRS_H) 
+    check_include_file("inttypes.h"           HAVE_INTTYPES_H) 
+    check_include_file("langinfo.h"           HAVE_LANGINFO_H)
+    check_include_file("memory.h"             HAVE_MEMORY_H) 
+    check_include_file("netinet/tcp.h"        HAVE_NETINET_TCP_H)
+    check_include_file("readline/history.h"   HAVE_READLINE_HISTORY_H)
+    check_include_file("readline/readline.h"  HAVE_READLINE_READLINE_H)
+    check_include_file("stdbool.h"            HAVE_STDBOOL_H)
+    check_include_file("stdlib.h"             HAVE_STDLIB_H)
+    check_include_file("string.h"             HAVE_STRING_H)
+    check_include_file("strings.h"            HAVE_STRINGS_H)
+    check_include_file("sys/epoll.h"          HAVE_SYS_EPOLL_H)
+    check_include_file("sys/event.h"          HAVE_SYS_EVENT_H)
+    check_include_file("sys/ipc.h"            HAVE_SYS_IPC_H)
+    check_include_file("sys/prctl.h"          HAVE_SYS_PRCTL_H)
+    check_include_file("sys/resource.h"       HAVE_SYS_RESOURCE_H)
+    check_include_file("sys/select.h"         HAVE_SYS_SELECT_H)
+    check_include_file("sys/sem.h"            HAVE_SYS_SEM_H)
+    check_include_file("sys/shm.h"            HAVE_SYS_SHM_H)
+    check_include_file("sys/stat.h"           HAVE_SYS_STAT_H)
+    check_include_file("sys/termios.h"        HAVE_SYS_TERMIOS_H)
+    check_include_file("sys/types.h"          HAVE_SYS_TYPES_H)
+    check_include_file("sys/un.h"             HAVE_SYS_UN_H)
+    check_include_file("termios.h"            HAVE_TERMIOS_H)
+    check_include_file("unistd.h"             HAVE_UNISTD_H)
+    check_include_file("wctype.h"             HAVE_WCTYPE_H)
 
-    check_function_exists("isinf" HAVE_ISINF)
-    check_function_exists("getaddrinfo" HAVE_GETADDRINFO)
-    check_function_exists("gettimeofday" HAVE_GETTIMEOFDAY)
-    check_function_exists("snprintf" HAVE_DECL_SNPRINTF)
-    check_function_exists("srandom" HAVE_SRANDOM)
-    check_function_exists("strlcat" HAVE_DECL_STRLCAT)
-    check_function_exists("strlcpy" HAVE_DECL_STRLCPY)
-    check_function_exists("unsetenv" HAVE_UNSETENV)
-    check_function_exists("vsnprintf" HAVE_DECL_VSNPRINTF)
-
-    check_type_size("struct addrinfo" SIZE_STRUCT_ADDRINFO)
-    if (HAVE_SIZE_STRUCT_ADDRINFO)
-      set(HAVE_STRUCT_ADDRINFO 1)
-    endif()
-
-    check_type_size("struct sockaddr_storage" SIZE_STRUCT_SOCKADDR_STORAGE)
-    if (HAVE_SIZE_STRUCT_SOCKADDR_STORAGE)
-      set(HAVE_STRUCT_SOCKADDR_STORAGE 1)
+    check_type_size("long long int" SIZEOF_LONG_LONG_INT)
+    if (SIZEOF_LONG_LONG_INT EQUAL 8)
+      set(HAVE_LONG_LONG_INT_64 1)
+      set(PG_INT64_TYPE "long long int")
     endif()
 
-    set(MEMSET_LOOP_LIMIT 1024)            # This is hardcoded in "postgresql-9.6.1/configure"
-    set(DEF_PGPORT 5432)                   # Default port number of PostgreSQL
-    set(DEF_PGPORT_STR "\"5432\"")         # Same as above, as a string
-    set(PG_VERSION "\"${LIBPQ_VERSION}\"") # Version of PostgreSQL, as a string
-
-    # Version of PostgreSQL, as a number
-    math(EXPR PG_VERSION_NUM "${LIBPQ_MAJOR} * 10000 + ${LIBPQ_MINOR} * 100 + ${LIBPQ_REVISION}")
+    check_type_size("long int" SIZEOF_LONG_INT)
+    if (SIZEOF_LONG_INT EQUAL 8)
+      set(HAVE_LONG_INT_64 1)
+      set(PG_INT64_TYPE "long int")
+    endif()
     
-    set(HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1)   # TODO Autodetection
-
-    # Compute maximum alignment of any basic type.
-    # We assume long's alignment is at least as strong as char, short, or int;
-    # but we must check long long (if it exists) and double.
-    check_type_size("long" SIZE_LONG)
-    check_type_size("long long" SIZE_LONG_LONG)
-    check_type_size("double" SIZE_DOUBLE)
-    set(MAXIMUM_ALIGNOF ${SIZE_LONG})
-    if(SIZE_LONG_LONG AND SIZE_LONG_LONG GREATER MAXIMUM_ALIGNOF)
-      set(MAXIMUM_ALIGNOF ${SIZE_LONG_LONG})
-    endif()
-    if(SIZE_DOUBLE GREATER MAXIMUM_ALIGNOF)
-      set(MAXIMUM_ALIGNOF ${SIZE_DOUBLE})
+    if (CMAKE_COMPILER_IS_GNUCXX OR
+        "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+      set(PG_PRINTF_ATTRIBUTE "gnu_printf")
+      set(pg_restrict "__restrict")
+    else()
+      set(pg_restrict "")
     endif()
 
-    check_include_file("poll.h" HAVE_POLL_H)
-    check_include_file("net/if.h" HAVE_NET_IF_H)
-    check_include_file("netinet/in.h" HAVE_NETINET_IN_H)
-    check_include_file("netinet/tcp.h" HAVE_NETINET_TCP_H)
-    check_include_file("sys/ioctl.h" HAVE_SYS_IOCTL_H)
-    check_include_file("sys/un.h" HAVE_SYS_UN_H)
-
-    If (NOT HAVE_NET_IF_H)  # This is the case of OpenBSD
-      unset(HAVE_NET_IF_H CACHE)
-      check_include_files("sys/socket.h;net/if.h" HAVE_NET_IF_H)
-    endif()
-
-    if (NOT HAVE_NETINET_TCP_H)  # This is the case of OpenBSD
-      unset(HAVE_NETINET_TCP_H CACHE)
-      check_include_files("sys/socket.h;netinet/tcp.h" HAVE_NETINET_TCP_H)
+    check_type_alignment(double ALIGNOF_DOUBLE)
+    check_type_alignment(int ALIGNOF_INT)
+    check_type_alignment(long ALIGNOF_LONG)
+    check_type_alignment("long long int" ALIGNOF_LONG_LONG_INT)
+    check_type_alignment(short ALIGNOF_SHORT)
+    
+    set(MAXIMUM_ALIGNOF ${ALIGNOF_LONG})
+    if (MAXIMUM_ALIGNOF LESS ALIGNOF_DOUBLE)
+      set(MAXIMUM_ALIGNOF ${ALIGNOF_DOUBLE})
     endif()
-
-    if (ENABLE_SSL)
-      set(HAVE_LIBSSL 1)
-      set(HAVE_SSL_GET_CURRENT_COMPRESSION 1)
-      set(USE_OPENSSL 1)
-    endif()
-
-    execute_process(
-      COMMAND 
-      ${PYTHON_EXECUTABLE}
-      "${CMAKE_CURRENT_LIST_DIR}/../PostgreSQL/PrepareCMakeConfigurationFile.py"
-      "${LIBPQ_SOURCES_DIR}/src/include/pg_config.h.in"
-      "${AUTOGENERATED_DIR}/pg_config.h.in"
-      ERROR_VARIABLE NO_PG_CONFIG
-      OUTPUT_VARIABLE out
-      )
-
-    if (NO_PG_CONFIG)
-      message(FATAL_ERROR "Cannot find pg_config.h.in")
+    if (HAVE_LONG_LONG_INT_64 AND (MAXIMUM_ALIGNOF LESS HAVE_LONG_LONG_INT_64))
+      set(MAXIMUM_ALIGNOF ${HAVE_LONG_LONG_INT_64})
     endif()
     
+    set(CMAKE_EXTRA_INCLUDE_FILES "sys/socket.h;netdb.h")
+    check_type_size("struct addrinfo" HAVE_STRUCT_ADDRINFO)    
+    check_type_size("struct sockaddr_storage" HAVE_STRUCT_SOCKADDR_STORAGE)
+    check_struct_has_member("struct sockaddr_storage" ss_family
+      "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY)
+    check_function_exists(unsetenv HAVE_UNSETENV)
+    check_function_exists(strchrnul HAVE_STRCHRNUL)
+    check_function_exists(random HAVE_RANDOM)
+    check_function_exists(srandom HAVE_SRANDOM)
+      
+    # Hardcoded stuff from "./configure" of libpq
+    set(MEMSET_LOOP_LIMIT 1024)
+    set(BLCKSZ 8192)
+    set(XLOG_BLCKSZ 8192)
+    set(DEF_PGPORT 5432)
+    set(DEF_PGPORT_STR "\"${DEF_PGPORT}\"")
+    set(PG_KRB_SRVNAM "\"postgres\"")
+
+    # Assume that zlib and openssl are always present
+    set(HAVE_LIBZ 1)
+    set(HAVE_LIBSSL 1)
+    set(HAVE_OPENSSL_INIT_SSL 1)
+    set(USE_OPENSSL 1)
+    set(USE_OPENSSL_RANDOM 1)
+        
+    PrepareCMakeConfigurationFile(
+      ${LIBPQ_SOURCES_DIR}/src/include/pg_config_ext.h.in
+      ${AUTOGENERATED_DIR}/pg_config_ext.h.in)
+      
+    PrepareCMakeConfigurationFile(
+      ${LIBPQ_SOURCES_DIR}/src/include/pg_config.h.in
+      ${AUTOGENERATED_DIR}/pg_config.h.in)
+          
+    configure_file(
+      ${AUTOGENERATED_DIR}/pg_config_ext.h.in
+      ${AUTOGENERATED_DIR}/pg_config_ext.h)
+
     configure_file(
       ${AUTOGENERATED_DIR}/pg_config.h.in
       ${AUTOGENERATED_DIR}/pg_config.h)
+
   endif()
 
 
@@ -272,21 +270,37 @@
     "")
 
   add_definitions(
-    -D_REENTRANT
     -DFRONTEND
-    -DUNSAFE_STAT_OK
     -DSYSCONFDIR=""
-    -DTCP_NODELAY
+    -DTCP_NODELAY    # For performance
+
+    # Must be set for OpenSSL 1.1, not for OpenSSL 1.0??
+    -DHAVE_BIO_GET_DATA=1
+    -DHAVE_BIO_METH_NEW=1
     )
 
   include_directories(
+    ${LIBPQ_SOURCES_DIR}/src/backend
     ${LIBPQ_SOURCES_DIR}/src/include
     ${LIBPQ_SOURCES_DIR}/src/include/libpq
     ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq
     )
 
   set(LIBPQ_SOURCES
-    ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-auth.c 
+    # Don't use files from the "src/backend/" folder
+    ${LIBPQ_SOURCES_DIR}/src/common/base64.c
+    ${LIBPQ_SOURCES_DIR}/src/common/encnames.c
+    ${LIBPQ_SOURCES_DIR}/src/common/ip.c
+    ${LIBPQ_SOURCES_DIR}/src/common/link-canary.c
+    ${LIBPQ_SOURCES_DIR}/src/common/md5.c
+    ${LIBPQ_SOURCES_DIR}/src/common/saslprep.c
+    ${LIBPQ_SOURCES_DIR}/src/common/scram-common.c
+    ${LIBPQ_SOURCES_DIR}/src/common/sha2_openssl.c
+    ${LIBPQ_SOURCES_DIR}/src/common/string.c
+    ${LIBPQ_SOURCES_DIR}/src/common/unicode_norm.c
+    ${LIBPQ_SOURCES_DIR}/src/common/wchar.c
+    ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-auth-scram.c
+    ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-auth.c
     ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-connect.c
     ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-exec.c
     ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-lobj.c
@@ -294,31 +308,24 @@
     ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-print.c
     ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-protocol2.c
     ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-protocol3.c
+    ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-secure-common.c
+    ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-secure-openssl.c
     ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-secure.c
     ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/libpq-events.c
     ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/pqexpbuffer.c
-
-    # libpgport C files we always use
     ${LIBPQ_SOURCES_DIR}/src/port/chklocale.c
+    ${LIBPQ_SOURCES_DIR}/src/port/explicit_bzero.c
+    ${LIBPQ_SOURCES_DIR}/src/port/getaddrinfo.c
     ${LIBPQ_SOURCES_DIR}/src/port/inet_net_ntop.c
     ${LIBPQ_SOURCES_DIR}/src/port/noblock.c
+    ${LIBPQ_SOURCES_DIR}/src/port/pg_strong_random.c
     ${LIBPQ_SOURCES_DIR}/src/port/pgstrcasecmp.c
     ${LIBPQ_SOURCES_DIR}/src/port/pqsignal.c
+    ${LIBPQ_SOURCES_DIR}/src/port/snprintf.c
+    ${LIBPQ_SOURCES_DIR}/src/port/strerror.c
     ${LIBPQ_SOURCES_DIR}/src/port/thread.c
-
-    ${LIBPQ_SOURCES_DIR}/src/backend/libpq/ip.c
-    ${LIBPQ_SOURCES_DIR}/src/backend/libpq/md5.c
-    ${LIBPQ_SOURCES_DIR}/src/backend/utils/mb/encnames.c
-    ${LIBPQ_SOURCES_DIR}/src/backend/utils/mb/wchar.c
     )
 
-  if (ENABLE_SSL)
-    list(APPEND LIBPQ_SOURCES
-      ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-secure-openssl.c
-      )
-  endif()
-
-
   if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
     LIST(APPEND LIBPQ_SOURCES
       ${LIBPQ_SOURCES_DIR}/src/port/strlcpy.c
--- a/Resources/Orthanc/CMake/DownloadOrthancFramework.cmake	Fri Nov 06 17:51:01 2020 +0100
+++ b/Resources/Orthanc/CMake/DownloadOrthancFramework.cmake	Fri Dec 11 12:49:33 2020 +0100
@@ -118,6 +118,8 @@
         set(ORTHANC_FRAMEWORK_MD5 "19fcb7c21876af86546baa048a22c6c0")
       elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.8.0")
         set(ORTHANC_FRAMEWORK_MD5 "f8ec7554ef5d23ea4ce474b1e8214de9")
+      elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.8.1")
+        set(ORTHANC_FRAMEWORK_MD5 "db094f96399cbe8b9bbdbce34884c220")
 
       # Below this point are development snapshots that were used to
       # release some plugin, before an official release of the Orthanc
@@ -129,6 +131,9 @@
       elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "ae0e3fd609df")
         # DICOMweb 1.1 (framework pre-1.6.0)
         set(ORTHANC_FRAMEWORK_MD5 "7e09e9b530a2f527854f0b782d7e0645")
+      elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "82652c5fc04f")
+        # Stone Web viewer 1.0 (framework pre-1.8.1)
+        set(ORTHANC_FRAMEWORK_MD5 "d77331d68917e66a3f4f9b807bbdab7f")
       endif()
     endif()
   endif()
@@ -524,6 +529,16 @@
       include_directories(${DCMTK_INCLUDE_DIRS})
       link_libraries(${DCMTK_LIBRARIES})
     endif()
+
+    # Optional component - OpenSSL
+    if (ENABLE_SSL)
+      include(FindOpenSSL)
+      if (NOT ${OPENSSL_FOUND})
+        message(FATAL_ERROR "Unable to find OpenSSL")
+      endif()
+      include_directories(${OPENSSL_INCLUDE_DIR})
+      link_libraries(${OPENSSL_LIBRARIES})
+    endif()
   endif()
 
   # Look for Orthanc framework shared library
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Resources/PostgreSQL/CheckTypeAlignment.cmake	Fri Dec 11 12:49:33 2020 +0100
@@ -0,0 +1,29 @@
+macro(CHECK_TYPE_ALIGNMENT TYPE NAME)
+  if(NOT ${NAME})
+    message(STATUS "Check alignment of ${TYPE}")
+    
+    set(INCLUDE_HEADERS "#include <stddef.h>
+      #include <stdio.h>
+      #include <stdlib.h>")
+
+    if(HAVE_STDINT_H)
+      set(INCLUDE_HEADERS "${INCLUDE_HEADERS}\n#include <stdint.h>\n")
+    endif(HAVE_STDINT_H)
+
+    file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/check_${NAME}_alignment.c"
+      "${INCLUDE_HEADERS}
+      int main(){
+        char diff;
+        struct foo {char a; ${TYPE} b;};
+        struct foo *p = (struct foo *) malloc(sizeof(struct foo));
+        diff = ((char *)&p->b) - ((char *)&p->a);
+        return diff;}
+    ")
+
+    try_run(${NAME} COMPILE_RESULT "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/"
+      "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/check_${NAME}_alignment.c")
+
+    message(STATUS "Check alignment of ${TYPE} - ${${NAME}}")
+
+  endif(NOT ${NAME})
+endmacro()
--- a/Resources/PostgreSQL/PrepareCMakeConfigurationFile.py	Fri Nov 06 17:51:01 2020 +0100
+++ b/Resources/PostgreSQL/PrepareCMakeConfigurationFile.py	Fri Dec 11 12:49:33 2020 +0100
@@ -6,7 +6,7 @@
 if len(sys.argv) != 3:
     raise Exception('Bad number of arguments')
 
-r = re.compile(r'^#undef ([A-Z0-9_]+)$')
+r = re.compile(r'^#undef ([a-zA-Z0-9_]+)$')
 
 with open(sys.argv[1], 'r') as f:
     with open(sys.argv[2], 'w') as g:
--- a/Resources/PostgreSQL/c_flexmember.c	Fri Nov 06 17:51:01 2020 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <stddef.h>
-struct s { int n; double d[]; };
-
-int main ()
-{
-  int m = getchar ();
-  struct s *p = malloc (offsetof (struct s, d)
-                        + m * sizeof (double));
-  p->d[0] = 0.0;
-  return p->d != (double *) NULL;
-}
--- a/Resources/PostgreSQL/pg_config_ext.h	Fri Nov 06 17:51:01 2020 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-/*
- * src/include/pg_config_ext.h.in.  This is generated manually, not by
- * autoheader, since we want to limit which symbols get defined here.
- */
-
-/* Define to the name of a signed 64-bit integer type. */
-#include <stdint.h>
-#define PG_INT64_TYPE int64_t
--- a/Resources/PostgreSQL/printf_archetype.c	Fri Nov 06 17:51:01 2020 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-extern int
-pgac_write(int ignore, const char *fmt,...)
-__attribute__((format(gnu_printf, 2, 3)));
-int
-main ()
-{
-
-  ;
-  return 0;
-}