Mercurial > hg > orthanc-stl
comparison CMakeLists.txt @ 0:4e889a8e8be2
initial commit of the viewer plugin
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 04 Jul 2023 19:15:27 +0200 |
parents | |
children | 0f03a8a0bd6f |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4e889a8e8be2 |
---|---|
1 # SPDX-FileCopyrightText: 2023 Sebastien Jodogne, UCLouvain, Belgium | |
2 # SPDX-License-Identifier: GPL-3.0-or-later | |
3 | |
4 | |
5 # STL plugin for Orthanc | |
6 # Copyright (C) 2023 Sebastien Jodogne, UCLouvain, Belgium | |
7 # | |
8 # This program is free software: you can redistribute it and/or | |
9 # modify it under the terms of the GNU General Public License as | |
10 # published by the Free Software Foundation, either version 3 of the | |
11 # License, or (at your option) any later version. | |
12 # | |
13 # This program is distributed in the hope that it will be useful, but | |
14 # WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 # General Public License for more details. | |
17 # | |
18 # You should have received a copy of the GNU General Public License | |
19 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 | |
21 | |
22 cmake_minimum_required(VERSION 2.8) | |
23 project(OrthancSTL) | |
24 | |
25 set(ORTHANC_STL_VERSION "mainline") | |
26 | |
27 if (ORTHANC_STL_VERSION STREQUAL "mainline") | |
28 set(ORTHANC_FRAMEWORK_DEFAULT_VERSION "mainline") | |
29 set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "hg") | |
30 else() | |
31 set(ORTHANC_FRAMEWORK_DEFAULT_VERSION "1.12.0") | |
32 set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "web") | |
33 endif() | |
34 | |
35 | |
36 ##################################################################### | |
37 ## Parameters of the build | |
38 ##################################################################### | |
39 | |
40 # Generic parameters | |
41 SET(STATIC_BUILD OFF CACHE BOOL "Static build of the third-party libraries (necessary for Windows)") | |
42 SET(ALLOW_DOWNLOADS OFF CACHE BOOL "Allow CMake to download packages") | |
43 set(ORTHANC_FRAMEWORK_SOURCE "${ORTHANC_FRAMEWORK_DEFAULT_SOURCE}" CACHE STRING "Source of the Orthanc framework (can be \"system\", \"hg\", \"archive\", \"web\" or \"path\")") | |
44 set(ORTHANC_FRAMEWORK_VERSION "${ORTHANC_FRAMEWORK_DEFAULT_VERSION}" CACHE STRING "Version of the Orthanc framework") | |
45 set(ORTHANC_FRAMEWORK_ARCHIVE "" CACHE STRING "Path to the Orthanc archive, if ORTHANC_FRAMEWORK_SOURCE is \"archive\"") | |
46 set(ORTHANC_FRAMEWORK_ROOT "" CACHE STRING "Path to the Orthanc source directory, if ORTHANC_FRAMEWORK_SOURCE is \"path\"") | |
47 | |
48 # Advanced parameters to fine-tune linking against system libraries | |
49 SET(USE_SYSTEM_ORTHANC_SDK ON CACHE BOOL "Use the system version of the Orthanc plugin SDK") | |
50 | |
51 | |
52 ##################################################################### | |
53 ## Download and setup the Orthanc framework | |
54 ##################################################################### | |
55 | |
56 include(${CMAKE_SOURCE_DIR}/Resources/Orthanc/CMake/DownloadOrthancFramework.cmake) | |
57 | |
58 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "system") | |
59 if (ORTHANC_FRAMEWORK_USE_SHARED) | |
60 include(FindBoost) | |
61 find_package(Boost COMPONENTS system thread) | |
62 | |
63 if (NOT Boost_FOUND) | |
64 message(FATAL_ERROR "Unable to locate Boost on this system") | |
65 endif() | |
66 | |
67 link_libraries(${Boost_LIBRARIES} jsoncpp) | |
68 endif() | |
69 | |
70 link_libraries(${ORTHANC_FRAMEWORK_LIBRARIES}) | |
71 | |
72 else() | |
73 include(${ORTHANC_FRAMEWORK_ROOT}/../Resources/CMake/OrthancFrameworkParameters.cmake) | |
74 | |
75 set(ENABLE_LOCALE OFF) # Disable support for locales (notably in Boost) | |
76 set(ENABLE_ZLIB ON) | |
77 | |
78 set(ENABLE_MODULE_DICOM OFF CACHE INTERNAL "") | |
79 set(ENABLE_MODULE_IMAGES OFF CACHE INTERNAL "") | |
80 set(ENABLE_MODULE_JOBS OFF CACHE INTERNAL "") | |
81 | |
82 include(${ORTHANC_FRAMEWORK_ROOT}/../Resources/CMake/OrthancFrameworkConfiguration.cmake) | |
83 include_directories(${ORTHANC_FRAMEWORK_ROOT}) | |
84 endif() | |
85 | |
86 include(${CMAKE_SOURCE_DIR}/Resources/Orthanc/Plugins/OrthancPluginsExports.cmake) | |
87 | |
88 | |
89 ##################################################################### | |
90 ## Find the Orthanc SDK | |
91 ##################################################################### | |
92 | |
93 if (STATIC_BUILD OR NOT USE_SYSTEM_ORTHANC_SDK) | |
94 include_directories(${CMAKE_SOURCE_DIR}/Resources/Orthanc/Sdk-1.0.0) | |
95 else () | |
96 CHECK_INCLUDE_FILE_CXX(orthanc/OrthancCPlugin.h HAVE_ORTHANC_H) | |
97 if (NOT HAVE_ORTHANC_H) | |
98 message(FATAL_ERROR "Please install the headers of the Orthanc plugins SDK") | |
99 endif() | |
100 endif() | |
101 | |
102 | |
103 ##################################################################### | |
104 ## Platform-specific configuration | |
105 ##################################################################### | |
106 | |
107 add_definitions( | |
108 -DHAS_ORTHANC_EXCEPTION=1 | |
109 -DORTHANC_ENABLE_LOGGING_PLUGIN=1 | |
110 -DORTHANC_FRAMEWORK_BUILDING_PLUGIN=1 | |
111 -DORTHANC_STL_VERSION="${ORTHANC_STL_VERSION}" | |
112 -DMETADATA_VERSION=${METADATA_VERSION} | |
113 ) | |
114 | |
115 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR | |
116 ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" OR | |
117 ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") | |
118 link_libraries(rt) | |
119 | |
120 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") | |
121 execute_process( | |
122 COMMAND | |
123 ${PYTHON_EXECUTABLE} ${ORTHANC_FRAMEWORK_ROOT}/../Resources/WindowsResources.py | |
124 ${ORTHANC_STL_VERSION} "OrthancSTL" OrthancSTL.dll "STL plugin for Orthanc" | |
125 ERROR_VARIABLE Failure | |
126 OUTPUT_FILE ${AUTOGENERATED_DIR}/Version.rc | |
127 ) | |
128 | |
129 if (Failure) | |
130 message(FATAL_ERROR "Error while computing the version information: ${Failure}") | |
131 endif() | |
132 | |
133 list(APPEND AUTOGENERATED_SOURCES ${AUTOGENERATED_DIR}/Version.rc) | |
134 endif() | |
135 | |
136 if (APPLE) | |
137 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework CoreFoundation") | |
138 SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -framework CoreFoundation") | |
139 endif() | |
140 | |
141 | |
142 ##################################################################### | |
143 ## Create the autogenerated files | |
144 ##################################################################### | |
145 | |
146 EmbedResources( | |
147 VIEWER_HTML ${CMAKE_SOURCE_DIR}/Sources/viewer.html | |
148 VIEWER_JS ${CMAKE_SOURCE_DIR}/Sources/viewer.js | |
149 ORTHANC_EXPLORER ${CMAKE_SOURCE_DIR}/Sources/OrthancExplorer.js | |
150 ) | |
151 | |
152 add_custom_command( | |
153 OUTPUT | |
154 ${AUTOGENERATED_DIR}/StaticAssets.cpp | |
155 COMMAND | |
156 ${PYTHON_EXECUTABLE} | |
157 ${CMAKE_SOURCE_DIR}/Resources/EmbedStaticAssets.py | |
158 ${CMAKE_SOURCE_DIR}/Three/dist | |
159 ${AUTOGENERATED_DIR}/StaticAssets.cpp | |
160 DEPENDS | |
161 ${CMAKE_SOURCE_DIR}/Three/dist | |
162 ${CMAKE_SOURCE_DIR}/Resources/EmbedStaticAssets.py | |
163 ) | |
164 | |
165 list(APPEND AUTOGENERATED_SOURCES | |
166 ${AUTOGENERATED_DIR}/StaticAssets.cpp | |
167 ) | |
168 | |
169 add_custom_target( | |
170 AutogeneratedTarget | |
171 DEPENDS | |
172 ${AUTOGENERATED_SOURCES} | |
173 ) | |
174 | |
175 | |
176 ##################################################################### | |
177 ## Create the plugin | |
178 ##################################################################### | |
179 | |
180 add_library(OrthancSTL SHARED | |
181 Sources/Plugin.cpp | |
182 ${AUTOGENERATED_SOURCES} | |
183 ${CMAKE_SOURCE_DIR}/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp | |
184 ${ORTHANC_CORE_SOURCES_DEPENDENCIES} | |
185 ${ORTHANC_CORE_SOURCES_INTERNAL} | |
186 ${ORTHANC_STL_SOURCES} | |
187 ) | |
188 | |
189 add_dependencies(OrthancSTL AutogeneratedTarget) | |
190 | |
191 message("Setting the version of the library to ${ORTHANC_STL_VERSION}") | |
192 | |
193 set_target_properties(OrthancSTL PROPERTIES | |
194 VERSION ${ORTHANC_STL_VERSION} | |
195 SOVERSION ${ORTHANC_STL_VERSION}) | |
196 | |
197 install( | |
198 TARGETS OrthancSTL | |
199 RUNTIME DESTINATION lib # Destination for Windows | |
200 LIBRARY DESTINATION share/orthanc/plugins # Destination for Linux | |
201 ) |