Skip to content
Commits on Source (4)
repo: 7cea966b682978aa285eb9b3a7a9cff81df464b3
node: deab01d8e1c85149e9059194bec266abd038c152
branch: OrthancPostgreSQL-3.0
node: 3424a54ca2ee52448369fd249af954d225164e62
branch: OrthancPostgreSQL-3.1
latesttag: null
latesttagdistance: 90
changessincelatesttag: 100
latesttagdistance: 112
changessincelatesttag: 124
......@@ -21,6 +21,8 @@
#include "DatabaseManager.h"
#include <Plugins/Samples/Common/OrthancPluginCppWrapper.h>
#include <Core/Logging.h>
#include <Core/OrthancException.h>
......@@ -510,6 +512,18 @@ namespace OrthancDatabases
}
assert(statement_ != NULL);
/*
TODO - Sample code to monitor the execution time of each
cached statement, and publish it as an Orthanc metrics
#if HAS_ORTHANC_PLUGIN_METRICS == 1
std::string name = (std::string(location_.GetFile()) + "_" +
boost::lexical_cast<std::string>(location_.GetLine()));
OrthancPlugins::MetricsTimer timer(name.c_str());
#endif
*/
SetResult(GetTransaction().Execute(*statement_, parameters));
}
catch (Orthanc::OrthancException& e)
......
......@@ -1951,4 +1951,108 @@ namespace OrthancDatabases
statement.Execute(args);
}
}
#if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in 1.3.1
# if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 4)
// New primitive since Orthanc 1.5.4
bool IndexBackend::LookupResourceAndParent(int64_t& id,
OrthancPluginResourceType& type,
std::string& parentPublicId,
const char* publicId)
{
DatabaseManager::CachedStatement statement(
STATEMENT_FROM_HERE, manager_,
"SELECT resource.internalId, resource.resourceType, parent.publicId "
"FROM Resources AS resource LEFT JOIN Resources parent ON parent.internalId=resource.parentId "
"WHERE resource.publicId=${id}");
statement.SetParameterType("id", ValueType_Utf8String);
Dictionary args;
args.SetUtf8Value("id", publicId);
statement.Execute(args);
if (statement.IsDone())
{
return false;
}
else
{
if (statement.GetResultFieldsCount() != 3)
{
throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
}
statement.SetResultFieldType(0, ValueType_Integer64);
statement.SetResultFieldType(1, ValueType_Integer64);
statement.SetResultFieldType(2, ValueType_Utf8String);
id = ReadInteger64(statement, 0);
type = static_cast<OrthancPluginResourceType>(ReadInteger32(statement, 1));
const IValue& value = statement.GetResultField(2);
switch (value.GetType())
{
case ValueType_Null:
parentPublicId.clear();
break;
case ValueType_Utf8String:
parentPublicId = dynamic_cast<const Utf8StringValue&>(value).GetContent();
break;
default:
throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
}
assert((statement.Next(), statement.IsDone()));
return true;
}
}
# endif
#endif
#if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in 1.3.1
# if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 4)
// New primitive since Orthanc 1.5.4
void IndexBackend::GetAllMetadata(std::map<int32_t, std::string>& result,
int64_t id)
{
DatabaseManager::CachedStatement statement(
STATEMENT_FROM_HERE, manager_,
"SELECT type, value FROM Metadata WHERE id=${id}");
statement.SetReadOnly(true);
statement.SetParameterType("id", ValueType_Integer64);
Dictionary args;
args.SetIntegerValue("id", id);
statement.Execute(args);
result.clear();
if (!statement.IsDone())
{
if (statement.GetResultFieldsCount() != 2)
{
throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
}
statement.SetResultFieldType(0, ValueType_Integer64);
statement.SetResultFieldType(1, ValueType_Utf8String);
while (!statement.IsDone())
{
result[ReadInteger32(statement, 0)] = ReadString(statement, 1);
statement.Next();
}
}
}
# endif
#endif
}
......@@ -283,5 +283,23 @@ namespace OrthancDatabases
int32_t metadata);
virtual void TagMostRecentPatient(int64_t patient);
#if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in 1.3.1
# if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 4)
// New primitive since Orthanc 1.5.4
virtual bool LookupResourceAndParent(int64_t& id,
OrthancPluginResourceType& type,
std::string& parentPublicId,
const char* publicId);
# endif
#endif
#if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in 1.3.1
# if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 4)
// New primitive since Orthanc 1.5.4
virtual void GetAllMetadata(std::map<int32_t, std::string>& result,
int64_t id);
# endif
#endif
};
}
......@@ -82,7 +82,8 @@ namespace OrthancPlugins
AllowedAnswers_DicomTag,
AllowedAnswers_ExportedResource,
AllowedAnswers_MatchingResource,
AllowedAnswers_String
AllowedAnswers_String,
AllowedAnswers_Metadata
};
OrthancPluginContext* context_;
......@@ -534,6 +535,23 @@ namespace OrthancPlugins
virtual int64_t GetLastChangeIndex() = 0;
virtual void TagMostRecentPatient(int64_t patientId) = 0;
#if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in 1.3.1
# if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 4)
// NB: "parentPublicId" must be cleared if the resource has no parent
virtual bool LookupResourceAndParent(int64_t& id,
OrthancPluginResourceType& type,
std::string& parentPublicId,
const char* publicId) = 0;
# endif
#endif
#if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in 1.3.1
# if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 4)
virtual void GetAllMetadata(std::map<int32_t, std::string>& result,
int64_t id) = 0;
# endif
#endif
};
......@@ -1650,6 +1668,77 @@ namespace OrthancPlugins
}
#if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in 1.3.1
# if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 4)
// New primitive since Orthanc 1.5.4
static OrthancPluginErrorCode GetAllMetadata(OrthancPluginDatabaseContext* context,
void* payload,
int64_t resourceId)
{
IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_Metadata);
try
{
std::map<int32_t, std::string> result;
backend->GetAllMetadata(result, resourceId);
for (std::map<int32_t, std::string>::const_iterator
it = result.begin(); it != result.end(); ++it)
{
OrthancPluginDatabaseAnswerMetadata(backend->GetOutput().context_,
backend->GetOutput().database_,
resourceId, it->first, it->second.c_str());
}
return OrthancPluginErrorCode_Success;
}
ORTHANC_PLUGINS_DATABASE_CATCH
}
# endif
#endif
#if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in 1.3.1
# if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 4)
// New primitive since Orthanc 1.5.4
static OrthancPluginErrorCode LookupResourceAndParent(OrthancPluginDatabaseContext* context,
uint8_t* isExisting,
int64_t* id,
OrthancPluginResourceType* type,
void* payload,
const char* publicId)
{
IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_String);
try
{
std::string parent;
if (backend->LookupResourceAndParent(*id, *type, parent, publicId))
{
*isExisting = 1;
if (!parent.empty())
{
OrthancPluginDatabaseAnswerString(backend->GetOutput().context_,
backend->GetOutput().database_,
parent.c_str());
}
}
else
{
*isExisting = 0;
}
return OrthancPluginErrorCode_Success;
}
ORTHANC_PLUGINS_DATABASE_CATCH
}
# endif
#endif
public:
/**
* Register a custom database back-end written in C++.
......@@ -1741,8 +1830,15 @@ namespace OrthancPlugins
{
extensions.createInstance = CreateInstance; // Fast creation of resources
}
#endif
#if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in 1.3.1
# if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 4)
// Optimizations brought by Orthanc 1.5.4
extensions.lookupResourceAndParent = LookupResourceAndParent;
extensions.getAllMetadata = GetAllMetadata;
performanceWarning = false;
# endif
#endif
if (performanceWarning)
......@@ -1751,7 +1847,7 @@ namespace OrthancPlugins
sprintf(info,
"Performance warning: The database index plugin was compiled "
"against an old version of the Orthanc SDK (%d.%d.%d): "
"Consider upgrading to version 1.5.2 of the Orthanc SDK",
"Consider upgrading to version 1.5.4 of the Orthanc SDK",
ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER,
ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER,
ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER);
......
......@@ -65,7 +65,7 @@ namespace OrthancDatabases
return false;
}
if (OrthancPluginCheckVersionAdvanced(context, 1, 4, 0) == 1)
if (OrthancPluginCheckVersionAdvanced(context, 1, 5, 4) == 1)
{
ImplicitTransaction::SetErrorOnDoubleExecution(true);
isOptimal = true;
......@@ -111,8 +111,8 @@ namespace OrthancDatabases
int revision = boost::lexical_cast<int>(tokens[2]);
isOptimal = (major > 1 ||
(major == 1 && minor > 4) ||
(major == 1 && minor == 4 && revision >= 0));
(major == 1 && minor > 5) ||
(major == 1 && minor == 5 && revision >= 4));
}
}
......@@ -121,7 +121,7 @@ namespace OrthancDatabases
{
LOG(WARNING) << "Performance warning in " << dbms
<< " index: Your version of Orthanc ("
<< context->orthancVersion << ") should be upgraded to 1.4.0 "
<< context->orthancVersion << ") should be upgraded to 1.5.4 "
<< "to benefit from best performance";
}
......
......@@ -19,6 +19,7 @@
**/
#include "PostgreSQLIncludes.h" // Must be the first
#include "PostgreSQLDatabase.h"
#include "PostgreSQLResult.h"
......@@ -26,23 +27,11 @@
#include "PostgreSQLTransaction.h"
#include "../Common/ImplicitTransaction.h"
#include <pg_config.h>
#if PG_VERSION_NUM >= 110000
# include <postgres.h>
# undef LOG // This one comes from <postgres.h>, and conflicts with <Core/Logging.h>
#endif
#include <Core/Logging.h>
#include <Core/OrthancException.h>
#include <boost/lexical_cast.hpp>
// PostgreSQL includes
#include <libpq-fe.h>
#include <c.h>
#include <catalog/pg_type.h>
namespace OrthancDatabases
{
......
/**
* Orthanc - A Lightweight, RESTful DICOM Store
* Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
* Department, University Hospital of Liege, Belgium
* Copyright (C) 2017-2019 Osimis S.A., Belgium
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
#pragma once
// These includes are necessary for compilation on OS X
#include <unistd.h>
#include <vector>
#include <map>
#include <cmath>
#include <Core/Enumerations.h>
/**
* This include must be before including "c.h" from PostgreSQL,
* otherwise the function "static bool
* boost::date_time::special_values_parser<date_type,
* charT>::__builtin_expect()" from Boost clashes with macro
* "__builtin_expect()" used by PostgreSQL 11.
**/
#include <boost/date_time/posix_time/posix_time.hpp>
// PostgreSQL includes
#include <pg_config.h>
#if PG_VERSION_NUM >= 110000
# include <postgres.h>
# undef LOG // This one comes from <postgres.h>, and conflicts with <Core/Logging.h>
#endif
#include <libpq-fe.h>
#include <c.h>
#include <catalog/pg_type.h>
......@@ -21,6 +21,7 @@
// http://www.postgresql.org/docs/9.1/static/lo-interfaces.html#AEN33102
#include "PostgreSQLIncludes.h" // Must be the first
#include "PostgreSQLLargeObject.h"
#include <Core/Logging.h>
......
......@@ -19,6 +19,7 @@
**/
#include "PostgreSQLIncludes.h" // Must be the first
#include "PostgreSQLResult.h"
#include "../Common/BinaryStringValue.h"
......@@ -27,26 +28,13 @@
#include "../Common/NullValue.h"
#include "../Common/Utf8StringValue.h"
#include <pg_config.h>
#if PG_VERSION_NUM >= 110000
# include <postgres.h>
# undef LOG // This one comes from <postgres.h>, and conflicts with <Core/Logging.h>
#endif
#include <Core/OrthancException.h>
#include <Core/Logging.h>
#include <Core/Endianness.h>
#include <cassert>
#include <boost/lexical_cast.hpp>
// PostgreSQL includes
#include <libpq-fe.h>
#include <c.h>
#include <catalog/pg_type.h>
#include <Core/Endianness.h>
namespace OrthancDatabases
{
......
......@@ -19,6 +19,7 @@
**/
#include "PostgreSQLIncludes.h" // Must be the first
#include "PostgreSQLStatement.h"
#include "../Common/BinaryStringValue.h"
......@@ -29,26 +30,13 @@
#include "../Common/Utf8StringValue.h"
#include "PostgreSQLResult.h"
#include <pg_config.h>
#if PG_VERSION_NUM >= 110000
# include <postgres.h>
# undef LOG // This one comes from <postgres.h>, and conflicts with <Core/Logging.h>
#endif
#include <Core/Logging.h>
#include <Core/OrthancException.h>
#include <Core/Toolbox.h>
#include <Core/Endianness.h>
#include <cassert>
// PostgreSQL includes
#include <libpq-fe.h>
#include <c.h>
#include <catalog/pg_type.h>
#include <Core/Endianness.h>
namespace OrthancDatabases
{
......
cmake_minimum_required(VERSION 2.8)
project(OrthancPostgreSQL)
set(ORTHANC_PLUGIN_VERSION "3.0")
set(ORTHANC_PLUGIN_VERSION "3.1")
if (ORTHANC_PLUGIN_VERSION STREQUAL "mainline")
set(ORTHANC_FRAMEWORK_VERSION "mainline")
set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "hg")
else()
set(ORTHANC_FRAMEWORK_VERSION "1.5.2")
set(ORTHANC_FRAMEWORK_VERSION "1.5.4")
set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "web")
endif()
......
......@@ -2,6 +2,15 @@ Pending changes in the mainline
===============================
Release 3.1 (2019-02-08)
========================
* Fix build on Debian Buster
* Remove "ASSERT" in SQL for compatibility with older releases of PostgreSQL
* Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
* Performance: Defining option "TCP_NODELAY" if libpq is linked statically
Release 3.0 (2019-01-21)
========================
......
......@@ -29,40 +29,51 @@ BEGIN
IF patientKey IS NULL THEN
-- Must create a new patient
ASSERT studyKey IS NULL;
ASSERT seriesKey IS NULL;
ASSERT instanceKey IS NULL;
IF NOT (studyKey IS NULL AND seriesKey IS NULL AND instanceKey IS NULL) THEN
RAISE EXCEPTION 'Broken invariant';
END IF;
INSERT INTO Resources VALUES (DEFAULT, 0, patient, NULL) RETURNING internalId INTO patientKey;
isNewPatient := 1;
ELSE
isNewPatient := 0;
END IF;
ASSERT NOT patientKey IS NULL;
IF (patientKey IS NULL) THEN
RAISE EXCEPTION 'Broken invariant';
END IF;
IF studyKey IS NULL THEN
-- Must create a new study
ASSERT seriesKey IS NULL;
ASSERT instanceKey IS NULL;
IF NOT (seriesKey IS NULL AND instanceKey IS NULL) THEN
RAISE EXCEPTION 'Broken invariant';
END IF;
INSERT INTO Resources VALUES (DEFAULT, 1, study, patientKey) RETURNING internalId INTO studyKey;
isNewStudy := 1;
ELSE
isNewStudy := 0;
END IF;
ASSERT NOT studyKey IS NULL;
IF (studyKey IS NULL) THEN
RAISE EXCEPTION 'Broken invariant';
END IF;
IF seriesKey IS NULL THEN
-- Must create a new series
ASSERT instanceKey IS NULL;
IF NOT (instanceKey IS NULL) THEN
RAISE EXCEPTION 'Broken invariant';
END IF;
INSERT INTO Resources VALUES (DEFAULT, 2, series, studyKey) RETURNING internalId INTO seriesKey;
isNewSeries := 1;
ELSE
isNewSeries := 0;
END IF;
ASSERT NOT seriesKey IS NULL;
ASSERT instanceKey IS NULL;
IF (seriesKey IS NULL OR NOT instanceKey IS NULL) THEN
RAISE EXCEPTION 'Broken invariant';
END IF;
INSERT INTO Resources VALUES (DEFAULT, 3, instance, seriesKey) RETURNING internalId INTO instanceKey;
isNewInstance := 1;
......
......@@ -29,6 +29,8 @@ if (STATIC_BUILD OR NOT USE_SYSTEM_ORTHANC_SDK)
include_directories(${ORTHANC_DATABASES_ROOT}/Resources/Orthanc/Sdk-1.4.0)
elseif (ORTHANC_SDK_VERSION STREQUAL "1.5.2")
include_directories(${ORTHANC_DATABASES_ROOT}/Resources/Orthanc/Sdk-1.5.2)
elseif (ORTHANC_SDK_VERSION STREQUAL "1.5.4")
include_directories(${ORTHANC_DATABASES_ROOT}/Resources/Orthanc/Sdk-1.5.4)
elseif (ORTHANC_SDK_VERSION STREQUAL "framework")
include_directories(${ORTHANC_ROOT}/Plugins/Include)
else()
......
......@@ -25,7 +25,7 @@ set(ORTHANC_FRAMEWORK_ROOT "" CACHE STRING "Path to the Orthanc source directory
# Advanced parameters to fine-tune linking against system libraries
set(USE_SYSTEM_ORTHANC_SDK ON CACHE BOOL "Use the system version of the Orthanc plugin SDK")
set(ORTHANC_SDK_VERSION "1.5.2" CACHE STRING "Version of the Orthanc plugin SDK to use, if not using the system version (can be \"0.9.5\", \"1.4.0\", \"1.5.2\" or \"framework\")")
set(ORTHANC_SDK_VERSION "1.5.4" CACHE STRING "Version of the Orthanc plugin SDK to use, if not using the system version (can be \"0.9.5\", \"1.4.0\", \"1.5.2\", \"1.5.4\" or \"framework\")")
include(${CMAKE_CURRENT_LIST_DIR}/DatabasesFrameworkParameters.cmake)
......
# - Find the PostgreSQL installation.
# In Windows, we make the assumption that, if the PostgreSQL files are installed, the default directory
# will be C:\Program Files\PostgreSQL.
#
# This module defines
# PostgreSQL_LIBRARIES - the PostgreSQL libraries needed for linking
# PostgreSQL_INCLUDE_DIRS - the directories of the PostgreSQL headers
# PostgreSQL_VERSION_STRING - the version of PostgreSQL found (since CMake 2.8.8)
#=============================================================================
# Copyright 2004-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
# ----------------------------------------------------------------------------
# History:
# This module is derived from the module originally found in the VTK source tree.
#
# ----------------------------------------------------------------------------
# Note:
# PostgreSQL_ADDITIONAL_VERSIONS is a variable that can be used to set the
# version mumber of the implementation of PostgreSQL.
# In Windows the default installation of PostgreSQL uses that as part of the path.
# E.g C:\Program Files\PostgreSQL\8.4.
# Currently, the following version numbers are known to this module:
# "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0"
#
# To use this variable just do something like this:
# set(PostgreSQL_ADDITIONAL_VERSIONS "9.2" "8.4.4")
# before calling find_package(PostgreSQL) in your CMakeLists.txt file.
# This will mean that the versions you set here will be found first in the order
# specified before the default ones are searched.
#
# ----------------------------------------------------------------------------
# You may need to manually set:
# PostgreSQL_INCLUDE_DIR - the path to where the PostgreSQL include files are.
# PostgreSQL_LIBRARY_DIR - The path to where the PostgreSQL library files are.
# If FindPostgreSQL.cmake cannot find the include files or the library files.
#
# ----------------------------------------------------------------------------
# The following variables are set if PostgreSQL is found:
# PostgreSQL_FOUND - Set to true when PostgreSQL is found.
# PostgreSQL_INCLUDE_DIRS - Include directories for PostgreSQL
# PostgreSQL_LIBRARY_DIRS - Link directories for PostgreSQL libraries
# PostgreSQL_LIBRARIES - The PostgreSQL libraries.
#
# ----------------------------------------------------------------------------
# If you have installed PostgreSQL in a non-standard location.
# (Please note that in the following comments, it is assumed that <Your Path>
# points to the root directory of the include directory of PostgreSQL.)
# Then you have three options.
# 1) After CMake runs, set PostgreSQL_INCLUDE_DIR to <Your Path>/include and
# PostgreSQL_LIBRARY_DIR to wherever the library pq (or libpq in windows) is
# 2) Use CMAKE_INCLUDE_PATH to set a path to <Your Path>/PostgreSQL<-version>. This will allow find_path()
# to locate PostgreSQL_INCLUDE_DIR by utilizing the PATH_SUFFIXES option. e.g. In your CMakeLists.txt file
# set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "<Your Path>/include")
# 3) Set an environment variable called ${PostgreSQL_ROOT} that points to the root of where you have
# installed PostgreSQL, e.g. <Your Path>.
#
# ----------------------------------------------------------------------------
set(PostgreSQL_INCLUDE_PATH_DESCRIPTION "top-level directory containing the PostgreSQL include directories. E.g /usr/local/include/PostgreSQL/8.4 or C:/Program Files/PostgreSQL/8.4/include")
set(PostgreSQL_INCLUDE_DIR_MESSAGE "Set the PostgreSQL_INCLUDE_DIR cmake cache entry to the ${PostgreSQL_INCLUDE_PATH_DESCRIPTION}")
set(PostgreSQL_LIBRARY_PATH_DESCRIPTION "top-level directory containing the PostgreSQL libraries.")
set(PostgreSQL_LIBRARY_DIR_MESSAGE "Set the PostgreSQL_LIBRARY_DIR cmake cache entry to the ${PostgreSQL_LIBRARY_PATH_DESCRIPTION}")
set(PostgreSQL_ROOT_DIR_MESSAGE "Set the PostgreSQL_ROOT system variable to where PostgreSQL is found on the machine E.g C:/Program Files/PostgreSQL/8.4")
set(PostgreSQL_KNOWN_VERSIONS ${PostgreSQL_ADDITIONAL_VERSIONS}
"11" "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0")
# Define additional search paths for root directories.
if ( WIN32 )
foreach (suffix ${PostgreSQL_KNOWN_VERSIONS} )
set(PostgreSQL_ADDITIONAL_SEARCH_PATHS ${PostgreSQL_ADDITIONAL_SEARCH_PATHS} "C:/Program Files/PostgreSQL/${suffix}" )
endforeach()
else()
foreach (suffix ${PostgreSQL_KNOWN_VERSIONS} )
set(PostgreSQL_ADDITIONAL_SEARCH_PATHS ${PostgreSQL_ADDITIONAL_SEARCH_PATHS} "/usr/include/postgresql/${suffix}" "/usr/local/include/postgresql/${suffix}")
endforeach()
endif()
set( PostgreSQL_ROOT_DIRECTORIES
ENV PostgreSQL_ROOT
${PostgreSQL_ROOT}
${PostgreSQL_ADDITIONAL_SEARCH_PATHS}
)
#
# Look for an installation.
#
find_path(PostgreSQL_INCLUDE_DIR
NAMES libpq-fe.h
PATHS
# Look in other places.
${PostgreSQL_ROOT_DIRECTORIES}
PATH_SUFFIXES
pgsql
postgresql
include
# Help the user find it if we cannot.
DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}"
)
find_path(PostgreSQL_TYPE_INCLUDE_DIR
NAMES catalog/pg_type.h
PATHS
# Look in other places.
${PostgreSQL_ROOT_DIRECTORIES}
PATH_SUFFIXES
postgresql
pgsql/server
postgresql/server
include/server
server
# Help the user find it if we cannot.
DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}"
)
# The PostgreSQL library.
set (PostgreSQL_LIBRARY_TO_FIND pq)
# Setting some more prefixes for the library
set (PostgreSQL_LIB_PREFIX "")
if ( WIN32 )
set (PostgreSQL_LIB_PREFIX ${PostgreSQL_LIB_PREFIX} "lib")
set ( PostgreSQL_LIBRARY_TO_FIND ${PostgreSQL_LIB_PREFIX}${PostgreSQL_LIBRARY_TO_FIND})
endif()
find_library( PostgreSQL_LIBRARY
NAMES ${PostgreSQL_LIBRARY_TO_FIND}
PATHS
${PostgreSQL_ROOT_DIRECTORIES}
PATH_SUFFIXES
lib
)
get_filename_component(PostgreSQL_LIBRARY_DIR ${PostgreSQL_LIBRARY} PATH)
if (PostgreSQL_INCLUDE_DIR AND EXISTS "${PostgreSQL_INCLUDE_DIR}/pg_config.h")
file(STRINGS "${PostgreSQL_INCLUDE_DIR}/pg_config.h" pgsql_version_str
REGEX "^#define[\t ]+PG_VERSION[\t ]+\".*\"")
string(REGEX REPLACE "^#define[\t ]+PG_VERSION[\t ]+\"([^\"]*)\".*" "\\1"
PostgreSQL_VERSION_STRING "${pgsql_version_str}")
unset(pgsql_version_str)
endif()
# Did we find anything?
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PostgreSQL
REQUIRED_VARS PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR
VERSION_VAR PostgreSQL_VERSION_STRING)
set( PostgreSQL_FOUND ${POSTGRESQL_FOUND})
# Now try to get the include and library path.
if(PostgreSQL_FOUND)
set(PostgreSQL_INCLUDE_DIRS ${PostgreSQL_INCLUDE_DIR} ${PostgreSQL_TYPE_INCLUDE_DIR} )
set(PostgreSQL_LIBRARY_DIRS ${PostgreSQL_LIBRARY_DIR} )
set(PostgreSQL_LIBRARIES ${PostgreSQL_LIBRARY_TO_FIND})
#message("Final PostgreSQL include dir: ${PostgreSQL_INCLUDE_DIRS}")
#message("Final PostgreSQL library dir: ${PostgreSQL_LIBRARY_DIRS}")
#message("Final PostgreSQL libraries: ${PostgreSQL_LIBRARIES}")
endif()
mark_as_advanced(PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR PostgreSQL_LIBRARY )
......@@ -276,6 +276,7 @@ if (STATIC_BUILD OR NOT USE_SYSTEM_LIBPQ)
-DFRONTEND
-DUNSAFE_STAT_OK
-DSYSCONFDIR=""
-DTCP_NODELAY
)
include_directories(
......@@ -376,7 +377,19 @@ if (STATIC_BUILD OR NOT USE_SYSTEM_LIBPQ)
source_group(ThirdParty\\PostgreSQL REGULAR_EXPRESSION ${LIBPQ_SOURCES_DIR}/.*)
else()
include(${CMAKE_CURRENT_LIST_DIR}/FindPostgreSQL.cmake)
set(PostgreSQL_ADDITIONAL_VERSIONS
"11" "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0")
if (NOT WIN32)
foreach (suffix ${PostgreSQL_ADDITIONAL_VERSIONS})
list(APPEND PostgreSQL_ADDITIONAL_SEARCH_PATHS
"/usr/include/postgresql/${suffix}"
"/usr/include/postgresql/${suffix}/server"
"/usr/local/include/postgresql/${suffix}"
)
endforeach()
endif()
include(FindPostgreSQL)
include_directories(
${PostgreSQL_INCLUDE_DIR}
${PostgreSQL_TYPE_INCLUDE_DIR}
......
......@@ -97,6 +97,10 @@ if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "hg" OR
set(ORTHANC_FRAMEWORK_MD5 "099671538865e5da96208b37494d6718")
elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.5.2")
set(ORTHANC_FRAMEWORK_MD5 "8867050f3e9a1ce6157c1ea7a9433b1b")
elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.5.3")
set(ORTHANC_FRAMEWORK_MD5 "bf2f5ed1adb8b0fc5f10d278e68e1dfe")
elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.5.4")
set(ORTHANC_FRAMEWORK_MD5 "404baef5d4c43e7c5d9410edda8ef5a5")
endif()
endif()
endif()
......