~ubuntu-branches/ubuntu/wily/orthanc-postgresql/wily

« back to all changes in this revision

Viewing changes to CMakeLists.txt

  • Committer: Package Import Robot
  • Author(s): Sebastien Jodogne, Sebastien Jodogne, Karsten Hilbert
  • Date: 2015-08-03 09:23:28 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20150803092328-swn3mnpj0fz34v42
Tags: 1.2-1
[ Sebastien Jodogne ]
* New upstream version

[ Karsten Hilbert ]
* Enhancements for README.Debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
project(OrthancPostgreSQL)
22
22
 
23
 
set(ORTHANC_POSTGRESQL_VERSION "1.1")
 
23
set(ORTHANC_POSTGRESQL_VERSION "1.2")
24
24
 
25
25
 
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")
29
30
 
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)
39
40
 
 
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)
51
 
 
52
 
 
53
 
# Check that the Orthanc SDK headers are available or download them
 
52
 
 
53
if (BUILD_UNIT_TESTS)
 
54
  include(${ORTHANC_ROOT}/Resources/CMake/GoogleTestConfiguration.cmake)
 
55
endif()
 
56
 
 
57
 
54
58
if (STATIC_BUILD)
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)
64
 
  if (${MSVC})
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)
68
 
  endif()
 
59
  include_directories(${ORTHANC_ROOT}/Sdk-0.9.1)
69
60
else ()
70
61
  CHECK_INCLUDE_FILE_CXX(orthanc/OrthancCppDatabasePlugin.h HAVE_ORTHANC_H)
71
62
  if (NOT HAVE_ORTHANC_H)
74
65
endif()
75
66
 
76
67
 
 
68
 
 
69
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
 
70
  link_libraries(secur32)
 
71
 
 
72
  execute_process(
 
73
    COMMAND 
 
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
 
79
    )
 
80
 
 
81
  if (Failure)
 
82
    message(FATAL_ERROR "Error while computing the version information: ${Failure}")
 
83
  endif()
 
84
 
 
85
  execute_process(
 
86
    COMMAND 
 
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
 
92
    )
 
93
 
 
94
  if (Failure)
 
95
    message(FATAL_ERROR "Error while computing the version information: ${Failure}")
 
96
  endif()
 
97
 
 
98
  set(INDEX_RESOURCES ${AUTOGENERATED_DIR}/IndexVersion.rc)
 
99
  set(STORAGE_RESOURCES ${AUTOGENERATED_DIR}/StorageVersion.rc)
 
100
endif()
 
101
 
 
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")
 
104
endif()
 
105
 
 
106
 
 
107
 
77
108
# Embed the SQL files into the binaries
78
109
EmbedResources(
 
110
  --system-exception 
 
111
  --namespace=OrthancPlugins
79
112
  POSTGRESQL_PREPARE ${CMAKE_CURRENT_SOURCE_DIR}/IndexPlugin/PostgreSQLPrepare.sql
80
113
  )
81
114
 
98
131
  ${CORE_SOURCES}
99
132
  ${CMAKE_SOURCE_DIR}/StoragePlugin/PostgreSQLStorageArea.cpp
100
133
  ${CMAKE_SOURCE_DIR}/StoragePlugin/Plugin.cpp
 
134
  ${STORAGE_RESOURCES}
101
135
  )
102
136
 
103
137
add_library(OrthancPostgreSQLIndex
106
140
  ${AUTOGENERATED_SOURCES}
107
141
  ${CMAKE_SOURCE_DIR}/IndexPlugin/PostgreSQLWrapper.cpp
108
142
  ${CMAKE_SOURCE_DIR}/IndexPlugin/Plugin.cpp
 
143
  ${INDEX_RESOURCES}
109
144
  )
110
145
 
111
146
 
120
155
  LINK_FLAGS "-Wl,-soname,libOrthancPostgreSQLIndex.so.${ORTHANC_POSTGRESQL_VERSION}"
121
156
  NO_SONAME ON)
122
157
 
123
 
add_executable(UnitTests
124
 
  ${CORE_SOURCES}
125
 
  ${GTEST_SOURCES}
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
 
158
install(
 
159
  TARGETS OrthancPostgreSQLStorage OrthancPostgreSQLIndex
 
160
  RUNTIME DESTINATION lib    # Destination for Windows
 
161
  LIBRARY DESTINATION share/orthanc/plugins    # Destination for Linux
132
162
  )
 
163
 
 
164
if (BUILD_UNIT_TESTS)
 
165
  add_executable(UnitTests
 
166
    ${CORE_SOURCES}
 
167
    ${GTEST_SOURCES}
 
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
 
174
    )
 
175
endif()