-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathCMakeLists.txt
117 lines (102 loc) · 4.76 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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})
# check version
if( DEFINED ORTHANC_VERSION )
if( ${ORTHANC_VERSION} VERSION_LESS 0.8.6 )
message(FATAL_ERROR "The Orthanc version cannot be lower than 0.8.6.")
endif()
else()
set(ORTHANC_VERSION "default" CACHE STRING "The linked version of Orthanc.")
endif()
# the plugin header file in the repo
set(ORTHANC_PLUGIN_REPO_H "${ORTHANC_PLUGIN_H}")
# set header url
if( ${ORTHANC_VERSION} VERSION_EQUAL 0.8.6 )
set(ORTHANC_COMMIT "6e275e35d01c296a537ecab34dc5d806a7f1e846")
set(ORTHANC_PLUGIN_REPO_H "OrthancCPlugin.h")
elseif( ${ORTHANC_VERSION} VERSION_EQUAL 0.9.0 )
set(ORTHANC_COMMIT "823e82ee43bbee37033609789848de0daee9028e")
set(ORTHANC_PLUGIN_REPO_H "OrthancCPlugin.h")
elseif( ${ORTHANC_VERSION} VERSION_EQUAL 0.9.1 )
set(ORTHANC_COMMIT "d659b6a4e736e56394a760054a37c6bdc38d65c8")
elseif( ${ORTHANC_VERSION} VERSION_EQUAL 0.9.2 )
set(ORTHANC_COMMIT "0bde293d7ba0e04a6c16e5cd5d24391470be8c5f")
elseif( ${ORTHANC_VERSION} VERSION_EQUAL 0.9.3 )
set(ORTHANC_COMMIT "46b2794042d6ff6cf35c932a00d66e47dd1143fb")
elseif( ${ORTHANC_VERSION} VERSION_EQUAL 0.9.4 )
set(ORTHANC_COMMIT "a49aacb21a40efdf0a7936dc6571a0bfb231160e")
elseif( ${ORTHANC_VERSION} VERSION_EQUAL 0.9.5 )
set(ORTHANC_COMMIT "2684ded7c7b3a0176af645476eb9ad56a36e48e4")
elseif( ${ORTHANC_VERSION} VERSION_EQUAL 0.9.6 )
set(ORTHANC_COMMIT "b4e8a031b0d86caf89e1a99fb7b86bb94d00c6a8")
elseif( ${ORTHANC_VERSION} VERSION_EQUAL 1.0.0 )
set(ORTHANC_COMMIT "74cf1f350b45473e847fed4116c1b428fa3d7352")
elseif( ${ORTHANC_VERSION} VERSION_EQUAL 1.1.0 )
set(ORTHANC_COMMIT "2fd8c1fa60762d0d9526e6da0f665002d7ef0422")
elseif( ${ORTHANC_VERSION} VERSION_EQUAL 1.2.0 )
set(ORTHANC_COMMIT "2bdc29af95895479178be61a219977e861c90645")
elseif( ${ORTHANC_VERSION} VERSION_EQUAL 1.3.0 )
set(ORTHANC_COMMIT "ed050cfd5898523069a3304daee76a1822769ba1")
elseif( ${ORTHANC_VERSION} VERSION_EQUAL 1.4.0 )
set(ORTHANC_COMMIT "a2536c0d72deda960f2908e7bdcc56929837a0bf")
elseif( ${ORTHANC_VERSION} VERSION_EQUAL 1.4.2 )
set(ORTHANC_COMMIT "afb581263e1d79e67ebf2fc1ca85780f9f3783e5")
elseif( ${ORTHANC_VERSION} VERSION_EQUAL 1.5.0 )
set(ORTHANC_COMMIT "38b71a1006fd22750bb8f9ada9d2c6085bfe26de")
elseif( ${ORTHANC_VERSION} VERSION_EQUAL 1.5.1 )
set(ORTHANC_COMMIT "870d19e7ea593126b5e7994cbc870847e09843fa")
else()
message(WARNING "Unknown version of Orthanc, using the default/latest one.")
set(ORTHANC_COMMIT "default")
endif()
# the plugin header file path in the repo
set(ORTHANC_PLUGIN_REPO_H_PATH "Plugins/Include/${ORTHANC_PLUGIN_REPO_H}")
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_REPO_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()
# create resources file
include(FindPythonInterp)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/AutoGeneratedCode.cmake)
EmbedResources(DWV_EXPLORER ${CMAKE_CURRENT_SOURCE_DIR}/Explorer --no-upcase-check)
# 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()