changeset 177:02ad3ea95fca

fix build on ubuntu 16.04
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 12 Dec 2020 19:45:47 +0100
parents 0246923d4df9
children 48aa43c14bb3
files Framework/PostgreSQL/PostgreSQLIncludes.h Framework/PostgreSQL/PostgreSQLResult.cpp Resources/CMake/PostgreSQLConfiguration.cmake
diffstat 3 files changed, 25 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/PostgreSQL/PostgreSQLIncludes.h	Sat Dec 12 17:49:07 2020 +0100
+++ b/Framework/PostgreSQL/PostgreSQLIncludes.h	Sat Dec 12 19:45:47 2020 +0100
@@ -28,6 +28,13 @@
 #include <cmath>
 #include <Enumerations.h>
 
+// Get "ntohl()" defined
+#if defined(_WIN32)
+#  include <winsock.h>
+#else
+#  include <arpa/inet.h>
+#endif
+
 // PostgreSQL includes
 #include <pg_config.h>
 
@@ -35,5 +42,12 @@
 #  error PG_VERSION_NUM is not defined
 #endif
 
+#if PG_VERSION_NUM >= 110000
+#  include <catalog/pg_type_d.h>
+#else
+#  include <postgres.h>
+#  undef LOG  // This one comes from <postgres.h>, and conflicts with <Core/Logging.h>
+#  include <catalog/pg_type.h>
+#endif
+
 #include <libpq-fe.h>
-#include <catalog/pg_type_d.h>
--- a/Framework/PostgreSQL/PostgreSQLResult.cpp	Sat Dec 12 17:49:07 2020 +0100
+++ b/Framework/PostgreSQL/PostgreSQLResult.cpp	Sat Dec 12 19:45:47 2020 +0100
@@ -22,13 +22,6 @@
 #include "PostgreSQLIncludes.h"  // Must be the first
 #include "PostgreSQLResult.h"
 
-// Get "ntohl()" defined
-#if defined(_WIN32)
-#  include <winsock.h>
-#else
-#  include <arpa/inet.h>
-#endif
-
 #include "../Common/BinaryStringValue.h"
 #include "../Common/FileValue.h"
 #include "../Common/Integer64Value.h"
--- a/Resources/CMake/PostgreSQLConfiguration.cmake	Sat Dec 12 17:49:07 2020 +0100
+++ b/Resources/CMake/PostgreSQLConfiguration.cmake	Sat Dec 12 19:45:47 2020 +0100
@@ -195,9 +195,9 @@
   endif()
   
   if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
-    set(CMAKE_EXTRA_INCLUDE_FILES "sys/types.h;winsock2.h;ws2tcpip.h")
+    set(CMAKE_EXTRA_INCLUDE_FILES "sys/types.h;winsock2.h;ws2tcpip.h;float.h;math.h")
   else()
-    set(CMAKE_EXTRA_INCLUDE_FILES "sys/types.h;sys/socket.h;netdb.h")
+    set(CMAKE_EXTRA_INCLUDE_FILES "sys/types.h;sys/socket.h;netdb.h;float.h;math.h")
   endif()
 
   check_type_size("size_t" SIZEOF_SIZE_T)
@@ -221,6 +221,8 @@
   check_function_exists(strlcpy HAVE_STRLCPY)  
   check_function_exists(getpeereid HAVE_GETPEEREID)
   check_function_exists(getpeerucred HAVE_GETPEERUCRED)
+  check_function_exists(isinf HAVE_ISINF)
+  check_function_exists(isnan HAVE_ISNAN)
 
   check_symbol_exists(strlcpy "stdio.h;string.h" HAVE_DECL_STRLCPY)
   if (NOT HAVE_DECL_STRLCPY)
@@ -392,10 +394,15 @@
       ${LIBPQ_SOURCES_DIR}/src/port/open.c
       ${LIBPQ_SOURCES_DIR}/src/port/pgsleep.c
       ${LIBPQ_SOURCES_DIR}/src/port/system.c
-      ${LIBPQ_SOURCES_DIR}/src/port/win32error.c
       ${LIBPQ_SOURCES_DIR}/src/port/win32setlocale.c
       )
 
+    if (CMAKE_COMPILER_IS_GNUCXX OR 
+        (MSVC AND MSVC_VERSION GREATER 1800))
+      # Starting Visual Studio 2013 (version 1800), it is necessary to also add "win32error.c"
+      LIST(APPEND LIBPQ_SOURCES ${LIBPQ_SOURCES_DIR}/src/port/win32error.c)
+    endif()
+
     if (MSVC)
       include_directories(
         ${LIBPQ_SOURCES_DIR}/src/include/port/win32_msvc