comparison Odbc/CMakeLists.txt @ 329:b5fb8b77ce4d

initial commit of ODBC framework
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 10 Aug 2021 20:08:53 +0200
parents
children 8f17f23c9af7
comparison
equal deleted inserted replaced
328:6a49c495c940 329:b5fb8b77ce4d
1 # Orthanc - A Lightweight, RESTful DICOM Store
2 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
3 # Department, University Hospital of Liege, Belgium
4 # Copyright (C) 2017-2021 Osimis S.A., Belgium
5 #
6 # This program is free software: you can redistribute it and/or
7 # modify it under the terms of the GNU Affero General Public License
8 # as published by the Free Software Foundation, either version 3 of
9 # the License, or (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Affero General Public License for more details.
15 #
16 # You should have received a copy of the GNU Affero General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19
20 cmake_minimum_required(VERSION 2.8)
21 project(OrthancODBC)
22
23 set(ORTHANC_PLUGIN_VERSION "mainline")
24
25 set(ORTHANC_OPTIMAL_VERSION_MAJOR 1)
26 set(ORTHANC_OPTIMAL_VERSION_MINOR 9)
27 set(ORTHANC_OPTIMAL_VERSION_REVISION 2)
28
29 if (ORTHANC_PLUGIN_VERSION STREQUAL "mainline")
30 set(ORTHANC_FRAMEWORK_VERSION "mainline")
31 set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "hg")
32 else()
33 set(ORTHANC_FRAMEWORK_VERSION "1.9.6")
34 set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "web")
35 endif()
36
37 include(${CMAKE_SOURCE_DIR}/../Resources/CMake/DatabasesPluginParameters.cmake)
38
39 set(ENABLE_ODBC_BACKEND ON)
40
41 include(${CMAKE_SOURCE_DIR}/../Resources/CMake/DatabasesPluginConfiguration.cmake)
42
43
44 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
45 execute_process(
46 COMMAND
47 ${PYTHON_EXECUTABLE} ${ORTHANC_FRAMEWORK_ROOT}/../Resources/WindowsResources.py
48 ${ORTHANC_PLUGIN_VERSION} "ODBC storage area plugin" OrthancODBCStorage.dll
49 "ODBC as a database back-end to Orthanc (storage area)"
50 ERROR_VARIABLE Failure
51 OUTPUT_FILE ${AUTOGENERATED_DIR}/StorageVersion.rc
52 )
53
54 if (Failure)
55 message(FATAL_ERROR "Error while computing the version information: ${Failure}")
56 endif()
57
58 execute_process(
59 COMMAND
60 ${PYTHON_EXECUTABLE} ${ORTHANC_FRAMEWORK_ROOT}/../Resources/WindowsResources.py
61 ${ORTHANC_PLUGIN_VERSION} "ODBC index plugin" OrthancODBCIndex.dll
62 "ODBC as a database back-end to Orthanc (index)"
63 ERROR_VARIABLE Failure
64 OUTPUT_FILE ${AUTOGENERATED_DIR}/IndexVersion.rc
65 )
66
67 if (Failure)
68 message(FATAL_ERROR "Error while computing the version information: ${Failure}")
69 endif()
70
71 set(INDEX_RESOURCES ${AUTOGENERATED_DIR}/IndexVersion.rc)
72 set(STORAGE_RESOURCES ${AUTOGENERATED_DIR}/StorageVersion.rc)
73 endif()
74
75
76 EmbedResources(
77 ODBC_PREPARE_INDEX ${CMAKE_SOURCE_DIR}/Plugins/PrepareIndex.sql
78 ODBC_PREPARE_STORAGE ${CMAKE_SOURCE_DIR}/Plugins/PrepareStorage.sql
79 )
80
81 add_custom_target(
82 AutogeneratedTarget
83 DEPENDS
84 ${AUTOGENERATED_SOURCES}
85 )
86
87 add_library(FrameworkForPlugins STATIC
88 ${AUTOGENERATED_SOURCES}
89 ${DATABASES_SOURCES}
90 ${LTDL_SOURCES}
91 ${UNIX_ODBC_SOURCES}
92
93 ${ORTHANC_DATABASES_ROOT}/Framework/Plugins/PluginInitialization.cpp
94 Plugins/OdbcIndex.cpp
95 )
96
97 set_target_properties(FrameworkForPlugins PROPERTIES
98 POSITION_INDEPENDENT_CODE ON
99 COMPILE_FLAGS -DORTHANC_ENABLE_LOGGING_PLUGIN=1
100 )
101
102 add_library(OrthancODBCIndex SHARED
103 ${INDEX_RESOURCES}
104 Plugins/IndexPlugin.cpp
105 )
106
107 add_library(OrthancODBCStorage SHARED
108 ${STORAGE_RESOURCES}
109 Plugins/StoragePlugin.cpp
110 )
111
112 add_dependencies(FrameworkForPlugins AutogeneratedTarget)
113
114 target_link_libraries(OrthancODBCIndex FrameworkForPlugins)
115 target_link_libraries(OrthancODBCStorage FrameworkForPlugins)
116
117 message("Setting the version of the libraries to ${ORTHANC_PLUGIN_VERSION}")
118
119 add_definitions(
120 -DORTHANC_PLUGIN_VERSION="${ORTHANC_PLUGIN_VERSION}"
121 )
122
123 set_target_properties(OrthancODBCStorage PROPERTIES
124 VERSION ${ORTHANC_PLUGIN_VERSION}
125 SOVERSION ${ORTHANC_PLUGIN_VERSION}
126 COMPILE_FLAGS -DORTHANC_ENABLE_LOGGING_PLUGIN=1
127 )
128
129 set_target_properties(OrthancODBCIndex PROPERTIES
130 VERSION ${ORTHANC_PLUGIN_VERSION}
131 SOVERSION ${ORTHANC_PLUGIN_VERSION}
132 COMPILE_FLAGS -DORTHANC_ENABLE_LOGGING_PLUGIN=1
133 )
134
135 install(
136 TARGETS OrthancODBCIndex OrthancODBCStorage
137 RUNTIME DESTINATION lib # Destination for Windows
138 LIBRARY DESTINATION share/orthanc/plugins # Destination for Linux
139 )
140
141
142 add_executable(UnitTests
143 ${AUTOGENERATED_SOURCES}
144 ${DATABASES_SOURCES}
145 ${GOOGLE_TEST_SOURCES}
146 ${LTDL_SOURCES}
147 ${UNIX_ODBC_SOURCES}
148
149 Plugins/OdbcIndex.cpp
150 UnitTests/UnitTestsMain.cpp
151 )
152
153 add_dependencies(UnitTests AutogeneratedTarget)
154
155 target_link_libraries(UnitTests ${GOOGLE_TEST_LIBRARIES})
156 set_target_properties(UnitTests PROPERTIES
157 COMPILE_FLAGS -DORTHANC_ENABLE_LOGGING_PLUGIN=0
158 )