comparison CMakeLists.txt @ 0:39585ba26f20

initial commit
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 15 Jun 2023 09:48:46 +0200
parents
children 8c1fe0ca24f5
comparison
equal deleted inserted replaced
-1:000000000000 0:39585ba26f20
1 # SPDX-FileCopyrightText: 2023 Sebastien Jodogne, UCLouvain, Belgium
2 # SPDX-License-Identifier: GPL-3.0-or-later
3
4
5 # OHIF 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(OrthancOHIF)
24
25 set(ORTHANC_OHIF_VERSION "mainline")
26
27 if (ORTHANC_OHIF_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_OHIF_VERSION="${ORTHANC_OHIF_VERSION}"
112 )
113
114 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR
115 ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" OR
116 ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
117 link_libraries(rt)
118
119 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
120 execute_process(
121 COMMAND
122 ${PYTHON_EXECUTABLE} ${ORTHANC_FRAMEWORK_ROOT}/../Resources/WindowsResources.py
123 ${ORTHANC_OHIF_VERSION} "OrthancOHIF" OrthancOHIF.dll "OHIF plugin for Orthanc"
124 ERROR_VARIABLE Failure
125 OUTPUT_FILE ${AUTOGENERATED_DIR}/Version.rc
126 )
127
128 if (Failure)
129 message(FATAL_ERROR "Error while computing the version information: ${Failure}")
130 endif()
131
132 list(APPEND AUTOGENERATED_SOURCES ${AUTOGENERATED_DIR}/Version.rc)
133 endif()
134
135 if (APPLE)
136 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework CoreFoundation")
137 SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -framework CoreFoundation")
138 endif()
139
140
141 #####################################################################
142 ## Create the autogenerated files
143 #####################################################################
144
145 EmbedResources(
146 APP_CONFIG_SYSTEM ${CMAKE_SOURCE_DIR}/Sources/app-config-system.js
147 APP_CONFIG_USER ${CMAKE_SOURCE_DIR}/Sources/app-config-user.js
148 ORTHANC_EXPLORER ${CMAKE_SOURCE_DIR}/Sources/OrthancExplorer.js
149 )
150
151 add_custom_command(
152 OUTPUT
153 ${AUTOGENERATED_DIR}/StaticAssets.cpp
154 COMMAND
155 ${PYTHON_EXECUTABLE}
156 ${CMAKE_SOURCE_DIR}/Resources/EmbedStaticAssets.py
157 ${CMAKE_SOURCE_DIR}/OHIF/dist
158 ${AUTOGENERATED_DIR}/StaticAssets.cpp
159 DEPENDS
160 ${CMAKE_SOURCE_DIR}/OHIF/dist
161 ${CMAKE_SOURCE_DIR}/Resources/EmbedStaticAssets.py
162 )
163
164 list(APPEND AUTOGENERATED_SOURCES
165 ${AUTOGENERATED_DIR}/StaticAssets.cpp
166 )
167
168 add_custom_target(
169 AutogeneratedTarget
170 DEPENDS
171 ${AUTOGENERATED_SOURCES}
172 )
173
174
175 #####################################################################
176 ## Create the plugin
177 #####################################################################
178
179 add_library(OrthancOHIF SHARED
180 Sources/Plugin.cpp
181 ${AUTOGENERATED_SOURCES}
182 ${CMAKE_SOURCE_DIR}/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp
183 ${ORTHANC_CORE_SOURCES_DEPENDENCIES}
184 ${ORTHANC_CORE_SOURCES_INTERNAL}
185 ${ORTHANC_OHIF_SOURCES}
186 )
187
188 add_dependencies(OrthancOHIF AutogeneratedTarget)
189
190 message("Setting the version of the library to ${ORTHANC_OHIF_VERSION}")
191
192 set_target_properties(OrthancOHIF PROPERTIES
193 VERSION ${ORTHANC_OHIF_VERSION}
194 SOVERSION ${ORTHANC_OHIF_VERSION})
195
196 install(
197 TARGETS OrthancOHIF
198 RUNTIME DESTINATION lib # Destination for Windows
199 LIBRARY DESTINATION share/orthanc/plugins # Destination for Linux
200 )