forked from ivmartel/dwv-orthanc-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
101 lines (91 loc) · 4.53 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
cmake_minimum_required(VERSION 2.8)
project(DwvOrthancPlugin)
if(${CMAKE_COMPILER_IS_GNUCXX})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror")
endif()
# Orthanc SDK plugin header
set(ORTHANC_PLUGIN_H "orthanc/OrthancCPlugin.h")
option(FORCE_ORTHANC_PLUGIN_H_DOWNLOAD OFF)
# Check if available on the system
include(CheckIncludeFileCXX)
check_include_file_cxx(${ORTHANC_PLUGIN_H} HAVE_ORTHANC_H)
# If not on the system, check AUTOGENERATED
set(AUTOGENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/AUTOGENERATED")
if( NOT HAVE_ORTHANC_H AND NOT FORCE_ORTHANC_PLUGIN_H_DOWNLOAD)
if( EXISTS "${AUTOGENERATED_DIR}/${ORTHANC_PLUGIN_H}" )
include_directories(${AUTOGENERATED_DIR})
set(HAVE_ORTHANC_H TRUE)
endif()
endif()
# If not in AUTOGENERATED, download it
if( NOT HAVE_ORTHANC_H )
# include AUTOGENERATED anyway
include_directories(${AUTOGENERATED_DIR})
# default version
set(ORTHANC_VERSION "0.8.6" CACHE STRING "The linked version of Orthanc.")
# check version
if( ${ORTHANC_VERSION} VERSION_LESS 0.8.6 )
message(FATAL_ERROR "The Orthanc version cannot be lower than 0.8.6.")
elseif( ${ORTHANC_VERSION} VERSION_GREATER 0.8.5 )
# set header url
if( ${ORTHANC_VERSION} VERSION_EQUAL 0.8.6 )
set(ORTHANC_COMMIT "6e275e35d01c296a537ecab34dc5d806a7f1e846")
set(ORTHANC_PLUGIN_H_PATH "Plugins/Include/OrthancCPlugin.h")
elseif( ${ORTHANC_VERSION} VERSION_EQUAL 0.9.0 )
set(ORTHANC_COMMIT "823e82ee43bbee37033609789848de0daee9028e")
set(ORTHANC_PLUGIN_H_PATH "Plugins/Include/OrthancCPlugin.h")
elseif( ${ORTHANC_VERSION} VERSION_EQUAL 0.9.1 )
set(ORTHANC_COMMIT "d659b6a4e736e56394a760054a37c6bdc38d65c8")
set(ORTHANC_PLUGIN_H_PATH "Plugins/Include/${ORTHANC_PLUGIN_H}")
elseif( ${ORTHANC_VERSION} VERSION_EQUAL 0.9.2 )
set(ORTHANC_COMMIT "0bde293d7ba0e04a6c16e5cd5d24391470be8c5f")
set(ORTHANC_PLUGIN_H_PATH "Plugins/Include/${ORTHANC_PLUGIN_H}")
elseif( ${ORTHANC_VERSION} VERSION_EQUAL 0.9.3 )
set(ORTHANC_COMMIT "46b2794042d6ff6cf35c932a00d66e47dd1143fb")
set(ORTHANC_PLUGIN_H_PATH "Plugins/Include/${ORTHANC_PLUGIN_H}")
elseif( ${ORTHANC_VERSION} VERSION_EQUAL 0.9.4 )
set(ORTHANC_COMMIT "a49aacb21a40efdf0a7936dc6571a0bfb231160e")
set(ORTHANC_PLUGIN_H_PATH "Plugins/Include/${ORTHANC_PLUGIN_H}")
elseif( ${ORTHANC_VERSION} VERSION_EQUAL 0.9.5 )
set(ORTHANC_COMMIT "2684ded7c7b3a0176af645476eb9ad56a36e48e4")
set(ORTHANC_PLUGIN_H_PATH "Plugins/Include/${ORTHANC_PLUGIN_H}")
elseif( ${ORTHANC_VERSION} VERSION_EQUAL 0.9.6 )
set(ORTHANC_COMMIT "b4e8a031b0d86caf89e1a99fb7b86bb94d00c6a8")
set(ORTHANC_PLUGIN_H_PATH "Plugins/Include/${ORTHANC_PLUGIN_H}")
elseif( ${ORTHANC_VERSION} VERSION_EQUAL 1.0.0 )
set(ORTHANC_COMMIT "74cf1f350b45473e847fed4116c1b428fa3d7352")
set(ORTHANC_PLUGIN_H_PATH "Plugins/Include/${ORTHANC_PLUGIN_H}")
elseif( ${ORTHANC_VERSION} VERSION_EQUAL 1.1.0 )
set(ORTHANC_COMMIT "0b6464320aac9a10db22a74e33b8b828c8fa7a9d")
set(ORTHANC_PLUGIN_H_PATH "Plugins/Include/${ORTHANC_PLUGIN_H}")
else()
message(ERROR " Unknown version of Orthanc, \n please download the plugin header manually and copy it to the 'build/autogenerated/orthanc' folder.")
endif()
if( ORTHANC_COMMIT )
set(ORTHANC_SDK_URL "https://bitbucket.org/sjodogne/orthanc/raw/${ORTHANC_COMMIT}")
set(ORTHANC_PLUGIN_H_URL "${ORTHANC_SDK_URL}/${ORTHANC_PLUGIN_H_PATH}")
# create folder and download
file(MAKE_DIRECTORY "${AUTOGENERATED_DIR}/orthanc")
message(STATUS "Downloading Orthanc Plugin SDK v${ORTHANC_VERSION}")
file(DOWNLOAD ${ORTHANC_PLUGIN_H_URL}
"${AUTOGENERATED_DIR}/${ORTHANC_PLUGIN_H}" SHOW_PROGRESS STATUS status)
# download all good?
list(GET status 0 error_code)
if( error_code )
message(FATAL_ERROR "Error while downloading Orthanc plugin file from '${ORTHANC_PLUGIN_H_URL}'.")
file( REMOVE "${AUTOGENERATED_DIR}/${ORTHANC_PLUGIN_H}" )
endif()
endif()
endif()
endif()
# create resources file
include(${CMAKE_SOURCE_DIR}/Resources/CMake/AutoGeneratedCode.cmake)
EmbedResources(DWV_EXPLORER ${CMAKE_CURRENT_SOURCE_DIR}/Explorer )
# create library
add_library(${PROJECT_NAME} SHARED Plugin.cpp ${AUTOGENERATED_SOURCES})
if( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" )
# Linking with "pthread" is necessary, otherwise the software crashes
# http://sourceware.org/bugzilla/show_bug.cgi?id=10652#c17
target_link_libraries(${PROJECT_NAME} pthread dl)
endif()