changeset 128:7b45d0d46e5a OrthancPostgreSQL-2.0

hotfix for visual studio 2015
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 06 Jan 2017 10:56:04 +0100 (2017-01-06)
parents 0d1cc4b1fbc1
children cdc12000160c
files Resources/CMake/PostgreSQLConfiguration.cmake
diffstat 1 files changed, 48 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/Resources/CMake/PostgreSQLConfiguration.cmake	Wed Dec 14 16:47:15 2016 +0100
+++ b/Resources/CMake/PostgreSQLConfiguration.cmake	Fri Jan 06 10:56:04 2017 +0100
@@ -1,6 +1,7 @@
 # Orthanc - A Lightweight, RESTful DICOM Store
-# Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics
+# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
 # Department, University Hospital of Liege, Belgium
+# Copyright (C) 2017 Osimis, Belgium
 #
 # This program is free software: you can redistribute it and/or
 # modify it under the terms of the GNU Affero General Public License
@@ -21,25 +22,27 @@
 #####################################################################
 
 if (STATIC_BUILD OR NOT USE_SYSTEM_LIBPQ)
-  SET(PQ_SOURCES_DIR ${CMAKE_BINARY_DIR}/postgresql-9.4.0)
+  add_definitions(-DORTHANC_POSTGRESQL_STATIC=1)
+
+  SET(PQ_SOURCES_DIR ${CMAKE_BINARY_DIR}/postgresql-9.6.1)
   DownloadPackage(
-    "349552802c809c4e8b09d8045a437787"
-    "http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/postgresql-9.4.0.tar.gz"
+    "eaa7e267e89ea1ed2693d2b88d3cd290"
+    "http://www.orthanc-server.com/downloads/third-party/postgresql-9.6.1.tar.gz"
     "${PQ_SOURCES_DIR}")
 
-  if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+  if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
     set(PQ_CONFIG_H ${PQ_SOURCES_DIR}/src/include/pg_config.h.win32)
 
     if (${MSVC})
       configure_file(
         ${PQ_SOURCES_DIR}/src/include/pg_config.h.win32
         ${AUTOGENERATED_DIR}/pg_config.h
-        COPY_ONLY)
+        COPYONLY)
 
       configure_file(
         ${PQ_SOURCES_DIR}/src/include/pg_config_ext.h.win32
         ${AUTOGENERATED_DIR}/pg_config_ext.h
-        COPY_ONLY)
+        COPYONLY)
 
     else()
       if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
@@ -56,9 +59,9 @@
     configure_file(
       ${PQ_SOURCES_DIR}/src/include/port/win32.h
       ${AUTOGENERATED_DIR}/pg_config_os.h
-      COPY_ONLY)
+      COPYONLY)
 
-  else()
+  elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread")
 
     if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
@@ -76,20 +79,41 @@
     configure_file(
       ${PQ_SOURCES_DIR}/src/include/port/linux.h
       ${AUTOGENERATED_DIR}/pg_config_os.h
-      COPY_ONLY)
+      COPYONLY)
+
+  elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
+    if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
+      set(PQ_CONFIG_H ${CMAKE_SOURCE_DIR}/Resources/Platforms/pg_config-darwin64.h)
+    else()
+      message(FATAL_ERROR "Support your platform here")
+    endif()
+
+    add_definitions(
+      -D_GNU_SOURCE
+      -D_THREAD_SAFE
+      -D_POSIX_PTHREAD_SEMANTICS
+      )
+
+    configure_file(
+      ${PQ_SOURCES_DIR}/src/include/port/darwin.h
+      ${AUTOGENERATED_DIR}/pg_config_os.h
+      COPYONLY)
+
+  else()
+    message(FATAL_ERROR "Support your platform here")
   endif()
 
 
   configure_file(
     ${PQ_CONFIG_H}
     ${AUTOGENERATED_DIR}/pg_config.h
-    COPY_ONLY
+    COPYONLY
     )
 
   configure_file(
     ${CMAKE_SOURCE_DIR}/Resources/Platforms/pg_config_ext.h
     ${AUTOGENERATED_DIR}/pg_config_ext.h
-    COPY_ONLY
+    COPYONLY
     )
 
   file(WRITE
@@ -134,10 +158,15 @@
     ${PQ_SOURCES_DIR}/src/backend/libpq/md5.c
     ${PQ_SOURCES_DIR}/src/backend/utils/mb/encnames.c
     ${PQ_SOURCES_DIR}/src/backend/utils/mb/wchar.c
-    ${PQ_SOURCES_DIR}/src/port/strlcpy.c
     )
 
-  if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+
+  if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
+    LIST(APPEND LIBPQ_SOURCES
+      ${PQ_SOURCES_DIR}/src/port/strlcpy.c
+      )      
+
+  elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
     include_directories(
       ${PQ_SOURCES_DIR}/src/include/port/win32
       ${PQ_SOURCES_DIR}/src/port
@@ -154,13 +183,16 @@
       ${PQ_SOURCES_DIR}/src/port/system.c 
       ${PQ_SOURCES_DIR}/src/port/win32setlocale.c
       ${PQ_SOURCES_DIR}/src/port/getaddrinfo.c
+      ${PQ_SOURCES_DIR}/src/port/strlcpy.c
       )
       
-    if (${CMAKE_COMPILER_IS_GNUCXX})
+    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 ${PQ_SOURCES_DIR}/src/port/win32error.c)
     endif()
 
-    if (${MSVC})
+    if (MSVC)
       LIST(APPEND LIBPQ_SOURCES ${PQ_SOURCES_DIR}/src/interfaces/libpq/pthread-win32.c)
     endif()
   endif()