Mercurial > hg > orthanc-java
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3ecef5782f2c |
---|---|
1 # SPDX-FileCopyrightText: 2023 Sebastien Jodogne, UCLouvain, Belgium | |
2 # SPDX-License-Identifier: GPL-3.0-or-later | |
3 | |
4 # Java plugin for Orthanc | |
5 # Copyright (C) 2023 Sebastien Jodogne, UCLouvain, Belgium | |
6 # | |
7 # This program is free software: you can redistribute it and/or | |
8 # modify it under the terms of the GNU General Public License as | |
9 # published by the Free Software Foundation, either version 3 of the | |
10 # License, or (at your option) any later version. | |
11 # | |
12 # This program is distributed in the hope that it will be useful, but | |
13 # WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 # General Public License for more details. | |
16 # | |
17 # You should have received a copy of the GNU General Public License | |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | |
20 | |
21 cmake_minimum_required(VERSION 3.0) | |
22 | |
23 project(OrthancJavaPlugin) | |
24 | |
25 set(PLUGIN_VERSION "mainline") | |
26 | |
27 include(CheckIncludeFileCXX) | |
28 include(FindPythonInterp) | |
29 | |
30 include(${CMAKE_SOURCE_DIR}/../Resources/Orthanc/CMake/AutoGeneratedCode.cmake) | |
31 include(${CMAKE_SOURCE_DIR}/../Resources/Orthanc/CMake/Compiler.cmake) | |
32 include(${CMAKE_SOURCE_DIR}/../Resources/Orthanc/CMake/DownloadPackage.cmake) | |
33 | |
34 include(${CMAKE_SOURCE_DIR}/../Resources/Orthanc/Plugins/OrthancPluginsExports.cmake) | |
35 | |
36 # Support of static compilation | |
37 set(ALLOW_DOWNLOADS OFF CACHE BOOL "Allow CMake to download packages") | |
38 set(STATIC_BUILD OFF CACHE BOOL "Static build of the third-party libraries (necessary for Windows)") | |
39 set(USE_SYSTEM_JSONCPP ON CACHE BOOL "Use the system version of JsonCpp") | |
40 set(USE_SYSTEM_JNI ON CACHE BOOL "Use the system version of JsonCpp") | |
41 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)") | |
42 | |
43 include(${CMAKE_SOURCE_DIR}/../Resources/Orthanc/CMake/JsonCppConfiguration.cmake) | |
44 | |
45 | |
46 include_directories(BEFORE | |
47 ${CMAKE_SOURCE_DIR}/../Resources/Orthanc/Sdk-1.10.0/ | |
48 ) | |
49 | |
50 if (CMAKE_SYSTEM_NAME STREQUAL "Windows" AND | |
51 (STATIC_BUILD OR NOT USE_SYSTEM_JNI)) | |
52 if (CMAKE_SIZEOF_VOID_P EQUAL 8) | |
53 include_directories( | |
54 ${CMAKE_SOURCE_DIR}/../Resources/jdk8u382-b05-win64/include | |
55 ${CMAKE_SOURCE_DIR}/../Resources/jdk8u382-b05-win64/include/win32 | |
56 ) | |
57 link_libraries( | |
58 ${CMAKE_SOURCE_DIR}/../Resources/jdk8u382-b05-win64/lib/jvm.lib | |
59 ) | |
60 elseif (CMAKE_SIZEOF_VOID_P EQUAL 4) | |
61 include_directories( | |
62 ${CMAKE_SOURCE_DIR}/../Resources/jdk8u382-b05-win32/include | |
63 ${CMAKE_SOURCE_DIR}/../Resources/jdk8u382-b05-win32/include/win32 | |
64 ) | |
65 link_libraries( | |
66 ${CMAKE_SOURCE_DIR}/../Resources/jdk8u382-b05-win32/lib/jvm.lib | |
67 ) | |
68 else() | |
69 message(FATAL_ERROR "Unknown architecture") | |
70 endif() | |
71 else() | |
72 if (NOT USE_SYSTEM_JNI) | |
73 message(FATAL_ERROR "Cannot statically link against JNI on this platform") | |
74 endif() | |
75 | |
76 include(FindJNI) | |
77 if (NOT JNI_FOUND) | |
78 message(FATAL_ERROR "Unable to find JNI") | |
79 endif() | |
80 | |
81 link_libraries(${JNI_LIBRARIES}) | |
82 include_directories(${JNI_INCLUDE_DIRS}) | |
83 endif() | |
84 | |
85 if (CMAKE_SYSTEM_NAME STREQUAL "Windows") | |
86 execute_process( | |
87 COMMAND | |
88 ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/../Resources/Orthanc/CMake/WindowsResources.py | |
89 ${PLUGIN_VERSION} OrthancJava OrthancJava.dll "Java plugin for Orthanc" | |
90 ERROR_VARIABLE Failure | |
91 OUTPUT_FILE ${AUTOGENERATED_DIR}/OrthancJava.rc | |
92 ) | |
93 | |
94 if (Failure) | |
95 message(FATAL_ERROR "Error while computing the version information: ${Failure}") | |
96 endif() | |
97 | |
98 list(APPEND PLUGIN_RESOURCES ${AUTOGENERATED_DIR}/OrthancJava.rc) | |
99 endif() | |
100 | |
101 | |
102 add_definitions( | |
103 -DPLUGIN_VERSION="${PLUGIN_VERSION}" | |
104 ) | |
105 | |
106 add_library(OrthancJava SHARED | |
107 Plugin.cpp | |
108 Mutex.cpp | |
109 ${JSONCPP_SOURCES} | |
110 ${PLUGIN_RESOURCES} | |
111 ) | |
112 | |
113 set_target_properties( | |
114 OrthancJava PROPERTIES | |
115 VERSION ${PLUGIN_VERSION} | |
116 SOVERSION ${PLUGIN_VERSION} | |
117 SKIP_BUILD_RPATH ON | |
118 ) | |
119 | |
120 install( | |
121 TARGETS OrthancJava | |
122 RUNTIME DESTINATION lib # Destination for Windows | |
123 LIBRARY DESTINATION share/orthanc/plugins # Destination for Linux | |
124 ) |