comparison CMakeLists.txt @ 0:3f1cf4a8e31f

initial commit
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 22 Mar 2023 10:16:47 +0100
parents
children 6002fc2c98cf
comparison
equal deleted inserted replaced
-1:000000000000 0:3f1cf4a8e31f
1 # SPDX-FileCopyrightText: 2023 Sebastien Jodogne, UCLouvain, Belgium
2 # SPDX-License-Identifier: GPL-3.0-or-later
3
4
5 # Kitware's VolView 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(OrthancVolView)
24
25 set(ORTHANC_VOLVIEW_VERSION "mainline")
26
27 if (ORTHANC_VOLVIEW_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.10.1")
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)
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_VOLVIEW_VERSION="${ORTHANC_VOLVIEW_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_VOLVIEW_VERSION} "OrthancVolView" OrthancVolView.dll "Kitware's VolView 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 ORTHANC_EXPLORER ${CMAKE_SOURCE_DIR}/Sources/OrthancExplorer.js
147 )
148
149 add_custom_command(
150 OUTPUT
151 ${AUTOGENERATED_DIR}/StaticAssets.cpp
152 COMMAND
153 ${CMAKE_SOURCE_DIR}/Resources/EmbedStaticAssets.py
154 ${CMAKE_SOURCE_DIR}/VolView/dist
155 ${AUTOGENERATED_DIR}/StaticAssets.cpp
156 DEPENDS
157 ${CMAKE_SOURCE_DIR}/VolView/dist
158 ${CMAKE_SOURCE_DIR}/Resources/EmbedStaticAssets.py
159 )
160
161 list(APPEND AUTOGENERATED_SOURCES
162 ${AUTOGENERATED_DIR}/StaticAssets.cpp
163 )
164
165 add_custom_target(
166 AutogeneratedTarget
167 DEPENDS
168 ${AUTOGENERATED_SOURCES}
169 )
170
171
172 #####################################################################
173 ## Create the plugin
174 #####################################################################
175
176 add_library(OrthancVolView SHARED
177 Sources/Plugin.cpp
178 ${AUTOGENERATED_SOURCES}
179 ${CMAKE_SOURCE_DIR}/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp
180 ${ORTHANC_CORE_SOURCES_DEPENDENCIES}
181 ${ORTHANC_CORE_SOURCES_INTERNAL}
182 ${ORTHANC_VOLVIEW_SOURCES}
183 )
184
185 add_dependencies(OrthancVolView AutogeneratedTarget)
186
187 message("Setting the version of the library to ${ORTHANC_VOLVIEW_VERSION}")
188
189 set_target_properties(OrthancVolView PROPERTIES
190 VERSION ${ORTHANC_VOLVIEW_VERSION}
191 SOVERSION ${ORTHANC_VOLVIEW_VERSION})
192
193 install(
194 TARGETS OrthancVolView
195 RUNTIME DESTINATION lib # Destination for Windows
196 LIBRARY DESTINATION share/orthanc/plugins # Destination for Linux
197 )