diff Plugin/CMakeLists.txt @ 0:3ecef5782f2c

initial commit
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 18 Oct 2023 17:59:44 +0200
parents
children 76114d03e318
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Plugin/CMakeLists.txt	Wed Oct 18 17:59:44 2023 +0200
@@ -0,0 +1,124 @@
+# SPDX-FileCopyrightText: 2023 Sebastien Jodogne, UCLouvain, Belgium
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+# Java plugin for Orthanc
+# Copyright (C) 2023 Sebastien Jodogne, UCLouvain, Belgium
+#
+# This program is free software: you can redistribute it and/or
+# modify it under the terms of the GNU 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
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+cmake_minimum_required(VERSION 3.0)
+
+project(OrthancJavaPlugin)
+
+set(PLUGIN_VERSION "mainline")
+
+include(CheckIncludeFileCXX)
+include(FindPythonInterp)
+
+include(${CMAKE_SOURCE_DIR}/../Resources/Orthanc/CMake/AutoGeneratedCode.cmake)
+include(${CMAKE_SOURCE_DIR}/../Resources/Orthanc/CMake/Compiler.cmake)
+include(${CMAKE_SOURCE_DIR}/../Resources/Orthanc/CMake/DownloadPackage.cmake)
+
+include(${CMAKE_SOURCE_DIR}/../Resources/Orthanc/Plugins/OrthancPluginsExports.cmake)
+
+# Support of static compilation
+set(ALLOW_DOWNLOADS OFF CACHE BOOL "Allow CMake to download packages")
+set(STATIC_BUILD OFF CACHE BOOL "Static build of the third-party libraries (necessary for Windows)")
+set(USE_SYSTEM_JSONCPP ON CACHE BOOL "Use the system version of JsonCpp")
+set(USE_SYSTEM_JNI ON CACHE BOOL "Use the system version of JsonCpp")
+set(USE_LEGACY_JSONCPP OFF CACHE BOOL "Use the old branch 0.x.y of JsonCpp, that does not require a C++11 compiler (for LSB and old versions of Visual Studio)")
+
+include(${CMAKE_SOURCE_DIR}/../Resources/Orthanc/CMake/JsonCppConfiguration.cmake)
+
+
+include_directories(BEFORE
+  ${CMAKE_SOURCE_DIR}/../Resources/Orthanc/Sdk-1.10.0/
+  )
+
+if (CMAKE_SYSTEM_NAME STREQUAL "Windows" AND
+    (STATIC_BUILD OR NOT USE_SYSTEM_JNI))
+  if (CMAKE_SIZEOF_VOID_P EQUAL 8)
+    include_directories(
+      ${CMAKE_SOURCE_DIR}/../Resources/jdk8u382-b05-win64/include
+      ${CMAKE_SOURCE_DIR}/../Resources/jdk8u382-b05-win64/include/win32
+      )
+    link_libraries(
+      ${CMAKE_SOURCE_DIR}/../Resources/jdk8u382-b05-win64/lib/jvm.lib
+      )
+  elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
+    include_directories(
+      ${CMAKE_SOURCE_DIR}/../Resources/jdk8u382-b05-win32/include
+      ${CMAKE_SOURCE_DIR}/../Resources/jdk8u382-b05-win32/include/win32
+      )
+    link_libraries(
+      ${CMAKE_SOURCE_DIR}/../Resources/jdk8u382-b05-win32/lib/jvm.lib
+      )
+  else()
+    message(FATAL_ERROR "Unknown architecture")
+  endif()
+else()
+  if (NOT USE_SYSTEM_JNI)
+    message(FATAL_ERROR "Cannot statically link against JNI on this platform")
+  endif()
+  
+  include(FindJNI)
+  if (NOT JNI_FOUND)
+    message(FATAL_ERROR "Unable to find JNI")
+  endif()
+  
+  link_libraries(${JNI_LIBRARIES})
+  include_directories(${JNI_INCLUDE_DIRS})
+endif()
+
+if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
+  execute_process(
+    COMMAND 
+    ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/../Resources/Orthanc/CMake/WindowsResources.py
+    ${PLUGIN_VERSION} OrthancJava OrthancJava.dll "Java plugin for Orthanc"
+    ERROR_VARIABLE Failure
+    OUTPUT_FILE ${AUTOGENERATED_DIR}/OrthancJava.rc
+    )
+  
+  if (Failure)
+    message(FATAL_ERROR "Error while computing the version information: ${Failure}")
+  endif()
+  
+  list(APPEND PLUGIN_RESOURCES ${AUTOGENERATED_DIR}/OrthancJava.rc)
+endif()
+
+
+add_definitions(
+  -DPLUGIN_VERSION="${PLUGIN_VERSION}"
+  )
+
+add_library(OrthancJava SHARED
+  Plugin.cpp
+  Mutex.cpp
+  ${JSONCPP_SOURCES}
+  ${PLUGIN_RESOURCES}
+  )
+
+set_target_properties(
+  OrthancJava PROPERTIES 
+  VERSION ${PLUGIN_VERSION} 
+  SOVERSION ${PLUGIN_VERSION}
+  SKIP_BUILD_RPATH ON
+  )
+
+install(
+  TARGETS OrthancJava
+  RUNTIME DESTINATION lib    # Destination for Windows
+  LIBRARY DESTINATION share/orthanc/plugins    # Destination for Linux
+  )