diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Odbc/CMakeLists.txt	Tue Aug 10 20:08:53 2021 +0200
@@ -0,0 +1,158 @@
+# Orthanc - A Lightweight, RESTful DICOM Store
+# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+# Department, University Hospital of Liege, Belgium
+# Copyright (C) 2017-2021 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/>.
+
+
+cmake_minimum_required(VERSION 2.8)
+project(OrthancODBC)
+
+set(ORTHANC_PLUGIN_VERSION "mainline")
+
+set(ORTHANC_OPTIMAL_VERSION_MAJOR    1)
+set(ORTHANC_OPTIMAL_VERSION_MINOR    9)
+set(ORTHANC_OPTIMAL_VERSION_REVISION 2)
+
+if (ORTHANC_PLUGIN_VERSION STREQUAL "mainline")
+  set(ORTHANC_FRAMEWORK_VERSION "mainline")
+  set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "hg")
+else()
+  set(ORTHANC_FRAMEWORK_VERSION "1.9.6")
+  set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "web")
+endif()
+
+include(${CMAKE_SOURCE_DIR}/../Resources/CMake/DatabasesPluginParameters.cmake)
+
+set(ENABLE_ODBC_BACKEND ON)
+
+include(${CMAKE_SOURCE_DIR}/../Resources/CMake/DatabasesPluginConfiguration.cmake)
+
+
+if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+  execute_process(
+    COMMAND 
+    ${PYTHON_EXECUTABLE} ${ORTHANC_FRAMEWORK_ROOT}/../Resources/WindowsResources.py
+    ${ORTHANC_PLUGIN_VERSION} "ODBC storage area plugin" OrthancODBCStorage.dll
+    "ODBC as a database back-end to Orthanc (storage area)"
+    ERROR_VARIABLE Failure
+    OUTPUT_FILE ${AUTOGENERATED_DIR}/StorageVersion.rc
+    )
+
+  if (Failure)
+    message(FATAL_ERROR "Error while computing the version information: ${Failure}")
+  endif()
+
+  execute_process(
+    COMMAND 
+    ${PYTHON_EXECUTABLE} ${ORTHANC_FRAMEWORK_ROOT}/../Resources/WindowsResources.py
+    ${ORTHANC_PLUGIN_VERSION} "ODBC index plugin" OrthancODBCIndex.dll
+    "ODBC as a database back-end to Orthanc (index)"
+    ERROR_VARIABLE Failure
+    OUTPUT_FILE ${AUTOGENERATED_DIR}/IndexVersion.rc
+    )
+
+  if (Failure)
+    message(FATAL_ERROR "Error while computing the version information: ${Failure}")
+  endif()
+
+  set(INDEX_RESOURCES ${AUTOGENERATED_DIR}/IndexVersion.rc)
+  set(STORAGE_RESOURCES ${AUTOGENERATED_DIR}/StorageVersion.rc)
+endif()
+
+
+EmbedResources(
+  ODBC_PREPARE_INDEX    ${CMAKE_SOURCE_DIR}/Plugins/PrepareIndex.sql
+  ODBC_PREPARE_STORAGE  ${CMAKE_SOURCE_DIR}/Plugins/PrepareStorage.sql
+  )
+
+add_custom_target(
+  AutogeneratedTarget
+  DEPENDS 
+  ${AUTOGENERATED_SOURCES}
+  )
+
+add_library(FrameworkForPlugins STATIC
+  ${AUTOGENERATED_SOURCES}
+  ${DATABASES_SOURCES}
+  ${LTDL_SOURCES}
+  ${UNIX_ODBC_SOURCES}
+
+  ${ORTHANC_DATABASES_ROOT}/Framework/Plugins/PluginInitialization.cpp
+  Plugins/OdbcIndex.cpp
+  )
+
+set_target_properties(FrameworkForPlugins PROPERTIES
+  POSITION_INDEPENDENT_CODE ON
+  COMPILE_FLAGS -DORTHANC_ENABLE_LOGGING_PLUGIN=1
+  )
+
+add_library(OrthancODBCIndex SHARED
+  ${INDEX_RESOURCES}
+  Plugins/IndexPlugin.cpp
+  )
+
+add_library(OrthancODBCStorage SHARED
+  ${STORAGE_RESOURCES}
+  Plugins/StoragePlugin.cpp
+  )
+
+add_dependencies(FrameworkForPlugins AutogeneratedTarget)
+
+target_link_libraries(OrthancODBCIndex FrameworkForPlugins)
+target_link_libraries(OrthancODBCStorage FrameworkForPlugins)
+
+message("Setting the version of the libraries to ${ORTHANC_PLUGIN_VERSION}")
+
+add_definitions(
+  -DORTHANC_PLUGIN_VERSION="${ORTHANC_PLUGIN_VERSION}"
+  )
+
+set_target_properties(OrthancODBCStorage PROPERTIES 
+  VERSION ${ORTHANC_PLUGIN_VERSION} 
+  SOVERSION ${ORTHANC_PLUGIN_VERSION}
+  COMPILE_FLAGS -DORTHANC_ENABLE_LOGGING_PLUGIN=1
+  )
+
+set_target_properties(OrthancODBCIndex PROPERTIES 
+  VERSION ${ORTHANC_PLUGIN_VERSION} 
+  SOVERSION ${ORTHANC_PLUGIN_VERSION}
+  COMPILE_FLAGS -DORTHANC_ENABLE_LOGGING_PLUGIN=1
+  )
+
+install(
+  TARGETS OrthancODBCIndex OrthancODBCStorage
+  RUNTIME DESTINATION lib    # Destination for Windows
+  LIBRARY DESTINATION share/orthanc/plugins    # Destination for Linux
+  )
+
+
+add_executable(UnitTests
+  ${AUTOGENERATED_SOURCES}
+  ${DATABASES_SOURCES}
+  ${GOOGLE_TEST_SOURCES}
+  ${LTDL_SOURCES}
+  ${UNIX_ODBC_SOURCES}
+
+  Plugins/OdbcIndex.cpp
+  UnitTests/UnitTestsMain.cpp
+  )
+
+add_dependencies(UnitTests AutogeneratedTarget)
+
+target_link_libraries(UnitTests ${GOOGLE_TEST_LIBRARIES})
+set_target_properties(UnitTests PROPERTIES
+  COMPILE_FLAGS -DORTHANC_ENABLE_LOGGING_PLUGIN=0
+  )