21
21
project(OrthancPostgreSQL)
23
set(ORTHANC_POSTGRESQL_VERSION "1.1")
23
set(ORTHANC_POSTGRESQL_VERSION "1.2")
26
26
# Parameters of the build
27
27
set(STATIC_BUILD OFF CACHE BOOL "Static build of the third-party libraries (necessary for Windows)")
28
28
set(ALLOW_DOWNLOADS OFF CACHE BOOL "Allow CMake to download packages")
29
set(BUILD_UNIT_TESTS ON CACHE BOOL "Build UnitTests")
30
31
# Advanced parameters to fine-tune linking against system libraries
31
32
set(USE_SYSTEM_JSONCPP ON CACHE BOOL "Use the system version of JsonCpp")
37
38
set(USE_GTEST_DEBIAN_SOURCE_PACKAGE OFF CACHE BOOL "Use the sources of Google Test shipped with libgtest-dev (Debian only)")
38
39
mark_as_advanced(USE_GTEST_DEBIAN_SOURCE_PACKAGE)
41
set(ORTHANC_ROOT ${CMAKE_SOURCE_DIR}/Orthanc)
40
42
include(CheckIncludeFiles)
41
43
include(CheckIncludeFileCXX)
42
44
include(CheckLibraryExists)
43
45
include(FindPythonInterp)
44
include(${CMAKE_SOURCE_DIR}/Resources/CMake/Compiler.cmake)
45
include(${CMAKE_SOURCE_DIR}/Resources/CMake/AutoGeneratedCode.cmake)
46
include(${CMAKE_SOURCE_DIR}/Resources/CMake/DownloadPackage.cmake)
47
include(${CMAKE_SOURCE_DIR}/Resources/CMake/BoostConfiguration.cmake)
46
include(${ORTHANC_ROOT}/Resources/CMake/Compiler.cmake)
47
include(${ORTHANC_ROOT}/Resources/CMake/AutoGeneratedCode.cmake)
48
include(${ORTHANC_ROOT}/Resources/CMake/DownloadPackage.cmake)
49
include(${ORTHANC_ROOT}/Resources/CMake/BoostConfiguration.cmake)
50
include(${ORTHANC_ROOT}/Resources/CMake/JsonCppConfiguration.cmake)
48
51
include(${CMAKE_SOURCE_DIR}/Resources/CMake/PostgreSQLConfiguration.cmake)
49
include(${CMAKE_SOURCE_DIR}/Resources/CMake/JsonCppConfiguration.cmake)
50
include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleTestConfiguration.cmake)
53
# Check that the Orthanc SDK headers are available or download them
54
include(${ORTHANC_ROOT}/Resources/CMake/GoogleTestConfiguration.cmake)
55
set(ORTHANC_SDK_URL "http://orthanc.googlecode.com/hg")
56
#set(ORTHANC_SDK_URL "http://orthanc.googlecode.com/hg-history/Orthanc-0.9.0")
57
file(MAKE_DIRECTORY ${AUTOGENERATED_DIR}/orthanc)
58
file(DOWNLOAD "${ORTHANC_SDK_URL}/Plugins/Include/orthanc/OrthancCPlugin.h"
59
"${AUTOGENERATED_DIR}/orthanc/OrthancCPlugin.h" SHOW_PROGRESS)
60
file(DOWNLOAD "${ORTHANC_SDK_URL}/Plugins/Include/orthanc/OrthancCDatabasePlugin.h"
61
"${AUTOGENERATED_DIR}/orthanc/OrthancCDatabasePlugin.h" SHOW_PROGRESS)
62
file(DOWNLOAD "${ORTHANC_SDK_URL}/Plugins/Include/orthanc/OrthancCppDatabasePlugin.h"
63
"${AUTOGENERATED_DIR}/orthanc/OrthancCppDatabasePlugin.h" SHOW_PROGRESS)
65
add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)
66
file(DOWNLOAD "${ORTHANC_SDK_URL}/Resources/ThirdParty/VisualStudio/stdint.h"
67
"${AUTOGENERATED_DIR}/stdint.h" SHOW_PROGRESS)
59
include_directories(${ORTHANC_ROOT}/Sdk-0.9.1)
70
61
CHECK_INCLUDE_FILE_CXX(orthanc/OrthancCppDatabasePlugin.h HAVE_ORTHANC_H)
71
62
if (NOT HAVE_ORTHANC_H)
69
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
70
link_libraries(secur32)
74
${PYTHON_EXECUTABLE} ${ORTHANC_ROOT}/Resources/WindowsResources.py
75
${ORTHANC_POSTGRESQL_VERSION} "PostgreSQL storage plugin" OrthancPostgreSQLStorage.dll
76
"PostgreSQL as a database back-end to Orthanc (storage area)"
77
ERROR_VARIABLE Failure
78
OUTPUT_FILE ${AUTOGENERATED_DIR}/StorageVersion.rc
82
message(FATAL_ERROR "Error while computing the version information: ${Failure}")
87
${PYTHON_EXECUTABLE} ${ORTHANC_ROOT}/Resources/WindowsResources.py
88
${ORTHANC_POSTGRESQL_VERSION} "PostgreSQL index plugin" OrthancPostgreSQLIndex.dll
89
"PostgreSQL as a database back-end to Orthanc (index area)"
90
ERROR_VARIABLE Failure
91
OUTPUT_FILE ${AUTOGENERATED_DIR}/IndexVersion.rc
95
message(FATAL_ERROR "Error while computing the version information: ${Failure}")
98
set(INDEX_RESOURCES ${AUTOGENERATED_DIR}/IndexVersion.rc)
99
set(STORAGE_RESOURCES ${AUTOGENERATED_DIR}/StorageVersion.rc)
102
if (CMAKE_COMPILER_IS_GNUCXX)
103
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--version-script=${CMAKE_SOURCE_DIR}/Orthanc/Plugins/Samples/Common/VersionScript.map -Wl,--no-undefined")
77
108
# Embed the SQL files into the binaries
111
--namespace=OrthancPlugins
79
112
POSTGRESQL_PREPARE ${CMAKE_CURRENT_SOURCE_DIR}/IndexPlugin/PostgreSQLPrepare.sql
120
155
LINK_FLAGS "-Wl,-soname,libOrthancPostgreSQLIndex.so.${ORTHANC_POSTGRESQL_VERSION}"
123
add_executable(UnitTests
126
${AUTOGENERATED_SOURCES}
127
${CMAKE_SOURCE_DIR}/IndexPlugin/PostgreSQLWrapper.cpp
128
${CMAKE_SOURCE_DIR}/StoragePlugin/PostgreSQLStorageArea.cpp
129
${CMAKE_SOURCE_DIR}/UnitTestsSources/UnitTestsMain.cpp
130
${CMAKE_SOURCE_DIR}/UnitTestsSources/PostgreSQLTests.cpp
131
${CMAKE_SOURCE_DIR}/UnitTestsSources/PostgreSQLWrapperTests.cpp
159
TARGETS OrthancPostgreSQLStorage OrthancPostgreSQLIndex
160
RUNTIME DESTINATION lib # Destination for Windows
161
LIBRARY DESTINATION share/orthanc/plugins # Destination for Linux
164
if (BUILD_UNIT_TESTS)
165
add_executable(UnitTests
168
${AUTOGENERATED_SOURCES}
169
${CMAKE_SOURCE_DIR}/IndexPlugin/PostgreSQLWrapper.cpp
170
${CMAKE_SOURCE_DIR}/StoragePlugin/PostgreSQLStorageArea.cpp
171
${CMAKE_SOURCE_DIR}/UnitTestsSources/UnitTestsMain.cpp
172
${CMAKE_SOURCE_DIR}/UnitTestsSources/PostgreSQLTests.cpp
173
${CMAKE_SOURCE_DIR}/UnitTestsSources/PostgreSQLWrapperTests.cpp