Mercurial > hg > orthanc-python
comparison CMakeLists.txt @ 36:fd58eb5749ed
CMake simplification using DownloadOrthancFramework.cmake
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 06 Jul 2020 17:37:30 +0200 |
parents | ce5b6116e6cd |
children | 393d2da0722a |
comparison
equal
deleted
inserted
replaced
35:77f4e165e535 | 36:fd58eb5749ed |
---|---|
1 cmake_minimum_required(VERSION 2.8) | 1 cmake_minimum_required(VERSION 2.8) |
2 project(OrthancPython) | 2 project(OrthancPython) |
3 | 3 |
4 set(PLUGIN_VERSION "mainline") | 4 set(PLUGIN_VERSION "mainline") |
5 | |
6 if (PLUGIN_VERSION STREQUAL "mainline") | |
7 set(ORTHANC_FRAMEWORK_DEFAULT_VERSION "mainline") | |
8 set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "hg") | |
9 else() | |
10 set(ORTHANC_FRAMEWORK_DEFAULT_VERSION "1.7.0") | |
11 set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "web") | |
12 endif() | |
5 | 13 |
6 | 14 |
7 set(PYTHON_VERSION "3.6" CACHE STRING "Version of Python to be used") | 15 set(PYTHON_VERSION "3.6" CACHE STRING "Version of Python to be used") |
8 set(PYTHON_WINDOWS_ROOT "" CACHE STRING "") | 16 set(PYTHON_WINDOWS_ROOT "" CACHE STRING "") |
9 set(PYTHON_LIBRARY_NAME "" CACHE STRING "") | 17 set(PYTHON_LIBRARY_NAME "" CACHE STRING "") |
10 set(PYTHON_WINDOWS_USE_RELEASE_LIBS ON CACHE BOOL "Use the release Python libraries when building with Microsoft Visual Studio, even when compiling in _DEBUG mode (set it to OFF if you require linking to a Python debug build)") | 18 set(PYTHON_WINDOWS_USE_RELEASE_LIBS ON CACHE BOOL "Use the release Python libraries when building with Microsoft Visual Studio, even when compiling in _DEBUG mode (set it to OFF if you require linking to a Python debug build)") |
11 set(USE_SYSTEM_BOOST ON CACHE BOOL "Use the system version of Boost") | 19 |
12 set(USE_SYSTEM_JSONCPP ON CACHE BOOL "Use the system version of JsonCpp") | 20 |
13 set(USE_LEGACY_JSONCPP OFF CACHE BOOL "Use the old branch 0.x.y of JsonCpp, that does not require a C++11 compiler (for LSB and old versions of Visual Studio)") | 21 # Parameters of the build |
22 set(STATIC_BUILD OFF CACHE BOOL "Static build of the third-party libraries (necessary for Windows)") | |
23 set(ALLOW_DOWNLOADS OFF CACHE BOOL "Allow CMake to download packages") | |
24 set(ORTHANC_FRAMEWORK_SOURCE "${ORTHANC_FRAMEWORK_DEFAULT_SOURCE}" CACHE STRING "Source of the Orthanc framework (can be \"system\", \"hg\", \"archive\", \"web\" or \"path\")") | |
25 set(ORTHANC_FRAMEWORK_VERSION "${ORTHANC_FRAMEWORK_DEFAULT_VERSION}" CACHE STRING "Version of the Orthanc framework") | |
26 set(ORTHANC_FRAMEWORK_ARCHIVE "" CACHE STRING "Path to the Orthanc archive, if ORTHANC_FRAMEWORK_SOURCE is \"archive\"") | |
27 set(ORTHANC_FRAMEWORK_ROOT "" CACHE STRING "Path to the Orthanc source directory, if ORTHANC_FRAMEWORK_SOURCE is \"path\"") | |
28 | |
29 # Advanced parameters to fine-tune linking against system libraries | |
30 set(USE_SYSTEM_ORTHANC_SDK ON CACHE BOOL "Use the system version of the Orthanc plugin SDK") | |
31 set(ORTHANC_FRAMEWORK_STATIC OFF CACHE BOOL "If linking against the Orthanc framework system library, indicates whether this library was statically linked") | |
32 mark_as_advanced(ORTHANC_FRAMEWORK_STATIC) | |
33 | |
34 | |
35 # Download and setup the Orthanc framework | |
36 include(${CMAKE_SOURCE_DIR}/Resources/Orthanc/CMake/DownloadOrthancFramework.cmake) | |
37 | |
38 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "system") | |
39 #link_libraries(${ORTHANC_FRAMEWORK_LIBRARIES}) | |
40 | |
41 else() | |
42 include(${ORTHANC_FRAMEWORK_ROOT}/Resources/CMake/OrthancFrameworkParameters.cmake) | |
43 | |
44 #set(ENABLE_MODULE_IMAGES OFF CACHE INTERNAL "") | |
45 #set(ENABLE_MODULE_JOBS OFF CACHE INTERNAL "") | |
46 #set(ENABLE_MODULE_DICOM OFF CACHE INTERNAL "") | |
47 | |
48 include(${ORTHANC_FRAMEWORK_ROOT}/Resources/CMake/OrthancFrameworkConfiguration.cmake) | |
49 include_directories(${ORTHANC_FRAMEWORK_ROOT}/Sources) | |
50 endif() | |
51 | |
52 | |
53 include(${CMAKE_SOURCE_DIR}/Resources/Orthanc/Plugins/OrthancPluginsExports.cmake) | |
54 | |
14 | 55 |
15 include(CheckIncludeFile) | 56 include(CheckIncludeFile) |
16 include(CheckIncludeFileCXX) | 57 include(CheckIncludeFileCXX) |
17 include(CheckIncludeFiles) | 58 include(CheckIncludeFiles) |
18 include(CheckLibraryExists) | 59 include(CheckLibraryExists) |
64 set(PYTHON_INCLUDE_DIRS ${PYTHON_2_INCLUDE_DIRS}) | 105 set(PYTHON_INCLUDE_DIRS ${PYTHON_2_INCLUDE_DIRS}) |
65 set(PYTHON_LIBRARIES ${PYTHON_2_LIBRARIES}) | 106 set(PYTHON_LIBRARIES ${PYTHON_2_LIBRARIES}) |
66 endif() | 107 endif() |
67 endif() | 108 endif() |
68 | 109 |
69 set(ORTHANC_ROOT ${CMAKE_SOURCE_DIR}/Resources/Orthanc) | |
70 include(${ORTHANC_ROOT}/Resources/CMake/Compiler.cmake) | |
71 include(${ORTHANC_ROOT}/Resources/CMake/DownloadPackage.cmake) | |
72 include(${ORTHANC_ROOT}/Resources/CMake/BoostConfiguration.cmake) | |
73 include(${ORTHANC_ROOT}/Resources/CMake/JsonCppConfiguration.cmake) | |
74 | |
75 | 110 |
76 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") | 111 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") |
77 execute_process( | 112 execute_process( |
78 COMMAND | 113 COMMAND |
79 ${PYTHON_EXECUTABLE} ${ORTHANC_ROOT}/Resources/WindowsResources.py | 114 ${PYTHON_EXECUTABLE} ${ORTHANC_FRAMEWORK_ROOT}/Resources/WindowsResources.py |
80 ${PLUGIN_VERSION} "Python plugin" OrthancPython.dll | 115 ${PLUGIN_VERSION} "Python plugin" OrthancPython.dll |
81 "Plugin to create Orthanc plugins using Python" | 116 "Plugin to create Orthanc plugins using Python" |
82 ERROR_VARIABLE Failure | 117 ERROR_VARIABLE Failure |
83 OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/Version.rc | 118 OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/Version.rc |
84 ) | 119 ) |
90 set(WINDOWS_RESOURCES ${CMAKE_CURRENT_BINARY_DIR}/Version.rc) | 125 set(WINDOWS_RESOURCES ${CMAKE_CURRENT_BINARY_DIR}/Version.rc) |
91 endif() | 126 endif() |
92 | 127 |
93 | 128 |
94 include_directories( | 129 include_directories( |
95 ${ORTHANC_ROOT}/Sdk-1.5.7 | 130 ${CMAKE_SOURCE_DIR}/Resources/Orthanc/Sdk-1.5.7 |
96 ) | 131 ) |
97 | 132 |
98 add_definitions( | 133 add_definitions( |
99 -DHAS_ORTHANC_EXCEPTION=0 | 134 -DHAS_ORTHANC_EXCEPTION=0 |
100 ) | 135 ) |
101 | 136 |
102 include_directories( | 137 include_directories( |
103 ${ORTHANC_ROOT}/Plugins/Samples/Common | |
104 ${PYTHON_INCLUDE_DIRS} | 138 ${PYTHON_INCLUDE_DIRS} |
105 ) | 139 ) |
106 | 140 |
107 add_library(OrthancPython SHARED | 141 add_library(OrthancPython SHARED |
108 Sources/Autogenerated/sdk.cpp | 142 Sources/Autogenerated/sdk.cpp |
115 Sources/PythonObject.cpp | 149 Sources/PythonObject.cpp |
116 Sources/PythonString.cpp | 150 Sources/PythonString.cpp |
117 Sources/RestCallbacks.cpp | 151 Sources/RestCallbacks.cpp |
118 | 152 |
119 # Third-party sources | 153 # Third-party sources |
120 ${ORTHANC_ROOT}/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp | 154 ${CMAKE_SOURCE_DIR}/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp |
121 ${BOOST_SOURCES} | 155 ${BOOST_SOURCES} |
122 ${JSONCPP_SOURCES} | 156 ${JSONCPP_SOURCES} |
123 ${WINDOWS_RESOURCES} | 157 ${WINDOWS_RESOURCES} |
124 ) | 158 ) |
125 | 159 |