changeset 178:48aa43c14bb3

definition of isinf() and isnan() in msvc2008
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sun, 13 Dec 2020 12:37:30 +0100
parents 02ad3ea95fca
children 9b500ad566c0 5e604adfd41f
files Resources/CMake/PostgreSQLConfiguration.cmake
diffstat 1 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Resources/CMake/PostgreSQLConfiguration.cmake	Sat Dec 12 19:45:47 2020 +0100
+++ b/Resources/CMake/PostgreSQLConfiguration.cmake	Sun Dec 13 12:37:30 2020 +0100
@@ -62,11 +62,33 @@
   ##
   
   if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
+    if (EXISTS ${AUTOGENERATED_DIR}/pg_config_os.h)
+      set(FirstRun OFF)
+    else()
+      set(FirstRun ON)
+    endif()
+
     configure_file(
       ${LIBPQ_SOURCES_DIR}/src/include/port/win32.h
       ${AUTOGENERATED_DIR}/pg_config_os.h
       COPYONLY)
 
+    if (FirstRun)
+      # This is needed on MSVC2008 to have an implementation of "isinf()" and "isnan()"
+      file(APPEND ${AUTOGENERATED_DIR}/pg_config_os.h "
+#if defined(_MSC_VER)
+#  include <math.h>
+#  include <float.h>
+#  if !defined(isinf)
+#    define isinf(d) ((_fpclass(d) == _FPCLASS_PINF) ? 1 : ((_fpclass(d) == _FPCLASS_NINF) ? -1 : 0))
+#  endif
+#  if !defined(isnan)
+#    define isnan(d) (_isnan(d))
+#  endif
+#endif
+")
+    endif()
+
   elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
     add_definitions(
       -D_GNU_SOURCE