comparison CMakeLists.txt @ 1:d5d3cb00556a

initial release
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 22 Mar 2017 16:13:52 +0100
parents
children 7ee79efd8b3f
comparison
equal deleted inserted replaced
0:decac5df19c4 1:d5d3cb00556a
1 # Advanced authorization plugin for Orthanc
2 # Copyright (C) 2017 Osimis, Belgium
3 #
4 # This program is free software: you can redistribute it and/or
5 # modify it under the terms of the GNU Affero General Public License
6 # as published by the Free Software Foundation, either version 3 of
7 # the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Affero General Public License for more details.
13 #
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17
18 cmake_minimum_required(VERSION 2.8)
19
20 project(OrthancAuthorization)
21
22 set(ORTHANC_AUTHORIZATION_VERSION "mainline")
23
24 # Parameters of the build
25 set(STATIC_BUILD OFF CACHE BOOL "Static build of the third-party libraries (necessary for Windows)")
26 SET(STANDALONE_BUILD ON CACHE BOOL "Standalone build (all the resources are embedded, necessary for releases)")
27 set(ALLOW_DOWNLOADS OFF CACHE BOOL "Allow CMake to download packages")
28
29 # Advanced parameters to fine-tune linking against system libraries
30 set(USE_SYSTEM_BOOST ON CACHE BOOL "Use the system version of Boost")
31 set(USE_SYSTEM_JSONCPP ON CACHE BOOL "Use the system version of JsonCpp")
32 set(USE_SYSTEM_ORTHANC_SDK ON CACHE BOOL "Use the system version of the Orthanc plugin SDK")
33
34 set(ORTHANC_ROOT ${CMAKE_SOURCE_DIR}/Resources/Orthanc)
35 set(ORTHANC_DISABLE_PATCH ON) # No need for the "patch" command-line tool
36 include(CheckIncludeFiles)
37 include(CheckIncludeFileCXX)
38 include(CheckLibraryExists)
39 include(FindPythonInterp)
40 include(${ORTHANC_ROOT}/Resources/CMake/Compiler.cmake)
41 include(${ORTHANC_ROOT}/Resources/CMake/AutoGeneratedCode.cmake)
42 include(${ORTHANC_ROOT}/Resources/CMake/DownloadPackage.cmake)
43
44 include(${ORTHANC_ROOT}/Resources/CMake/BoostConfiguration.cmake)
45 include(${ORTHANC_ROOT}/Resources/CMake/JsonCppConfiguration.cmake)
46
47
48 # Check that the Orthanc SDK headers are available
49 if (STATIC_BUILD OR NOT USE_SYSTEM_ORTHANC_SDK)
50 include_directories(${ORTHANC_ROOT}/Sdk-1.1.0)
51 else ()
52 CHECK_INCLUDE_FILE_CXX(orthanc/OrthancCPlugin.h HAVE_ORTHANC_H)
53 if (NOT HAVE_ORTHANC_H)
54 message(FATAL_ERROR "Please install the headers of the Orthanc plugins SDK")
55 endif()
56 endif()
57
58
59 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR
60 ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" OR
61 ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
62 link_libraries(rt)
63 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
64 SET(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lws2_32")
65
66 execute_process(
67 COMMAND
68 ${PYTHON_EXECUTABLE} ${ORTHANC_ROOT}/Resources/WindowsResources.py
69 ${ORTHANC_AUTHORIZATION_VERSION} "OrthancAuthorization" OrthancAuthorization.dll "Advanced authorization plugin for Orthanc"
70 ERROR_VARIABLE Failure
71 OUTPUT_FILE ${AUTOGENERATED_DIR}/Version.rc
72 )
73
74 if (Failure)
75 message(FATAL_ERROR "Error while computing the version information: ${Failure}")
76 endif()
77
78 list(APPEND AUTOGENERATED_SOURCES ${AUTOGENERATED_DIR}/Version.rc)
79 endif()
80
81 if (APPLE)
82 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework CoreFoundation")
83 SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -framework CoreFoundation")
84 endif()
85
86 add_definitions(
87 -DHAS_ORTHANC_EXCEPTION=1
88 -DORTHANC_ENABLE_MD5=0
89 -DORTHANC_ENABLE_BASE64=0
90 -DORTHANC_ENABLE_LOGGING=1
91 -DORTHANC_ENABLE_LOGGING_PLUGIN=1
92 -DORTHANC_ENABLE_PUGIXML=0
93 -DORTHANC_SANDBOXED=0
94 )
95
96 add_library(OrthancAuthorization SHARED
97 ${CMAKE_SOURCE_DIR}/Plugin/AccessedResource.cpp
98 ${CMAKE_SOURCE_DIR}/Plugin/AssociativeArray.cpp
99 ${CMAKE_SOURCE_DIR}/Plugin/AuthorizationParserBase.cpp
100 ${CMAKE_SOURCE_DIR}/Plugin/AuthorizationWebService.cpp
101 ${CMAKE_SOURCE_DIR}/Plugin/CachedAuthorizationService.cpp
102 ${CMAKE_SOURCE_DIR}/Plugin/DefaultAuthorizationParser.cpp
103 ${CMAKE_SOURCE_DIR}/Plugin/Enumerations.cpp
104 ${CMAKE_SOURCE_DIR}/Plugin/MemoryCache.cpp
105 ${CMAKE_SOURCE_DIR}/Plugin/OrthancResource.cpp
106 ${CMAKE_SOURCE_DIR}/Plugin/Plugin.cpp
107 ${CMAKE_SOURCE_DIR}/Plugin/ResourceHierarchyCache.cpp
108 ${CMAKE_SOURCE_DIR}/Plugin/Token.cpp
109
110 ${ORTHANC_ROOT}/Core/Logging.cpp
111 ${ORTHANC_ROOT}/Core/Enumerations.cpp
112 ${ORTHANC_ROOT}/Core/Toolbox.cpp
113 ${ORTHANC_ROOT}/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp
114
115 ${BOOST_SOURCES}
116 ${SQLITE_SOURCES}
117 ${JSONCPP_SOURCES}
118 )
119
120
121 message("Setting the version of the plugin to ${ORTHANC_AUTHORIZATION_VERSION}")
122 add_definitions(-DORTHANC_AUTHORIZATION_VERSION="${ORTHANC_AUTHORIZATION_VERSION}")
123
124 set_target_properties(OrthancAuthorization PROPERTIES
125 VERSION ${ORTHANC_AUTHORIZATION_VERSION}
126 SOVERSION ${ORTHANC_AUTHORIZATION_VERSION})
127
128 install(
129 TARGETS OrthancAuthorization
130 RUNTIME DESTINATION lib # Destination for Windows
131 LIBRARY DESTINATION share/orthanc/plugins # Destination for Linux
132 )