comparison CMakeLists.txt @ 0:7ed502b17b8f

initial commit
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 26 Mar 2020 18:47:01 +0100
parents
children e3128420249d
comparison
equal deleted inserted replaced
-1:000000000000 0:7ed502b17b8f
1 cmake_minimum_required(VERSION 2.8)
2 project(OrthancPython)
3
4 set(PLUGIN_VERSION "mainline")
5
6
7 set(PYTHON_VERSION "3.6" CACHE STRING "Version of Python to be used")
8 set(PYTHON_WINDOWS_ROOT "" CACHE STRING "")
9 set(USE_SYSTEM_BOOST ON CACHE BOOL "Use the system version of Boost")
10 set(USE_SYSTEM_JSONCPP ON CACHE BOOL "Use the system version of JsonCpp")
11 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)")
12 set(USE_SYSTEM_ORTHANC_SDK ON CACHE BOOL "Use the system version of the Orthanc plugin SDK")
13
14
15 include(CheckIncludeFile)
16 include(CheckIncludeFileCXX)
17 include(CheckIncludeFiles)
18 include(CheckLibraryExists)
19
20 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
21 set(PYTHON_INCLUDE_DIRS ${PYTHON_WINDOWS_ROOT}/include)
22 set(PYTHON_LIBRARIES ${PYTHON_WINDOWS_ROOT}/libs/libpython27.a)
23
24 else()
25 find_package(PkgConfig REQUIRED)
26 pkg_check_modules(PYTHON_1 python-${PYTHON_VERSION}-embed)
27
28 if (PYTHON_1_FOUND)
29 set(PYTHON_INCLUDE_DIRS ${PYTHON_1_INCLUDE_DIRS})
30 set(PYTHON_LIBRARIES ${PYTHON_1_LIBRARIES})
31 else()
32 pkg_check_modules(PYTHON_2 REQUIRED python-${PYTHON_VERSION})
33 set(PYTHON_INCLUDE_DIRS ${PYTHON_2_INCLUDE_DIRS})
34 set(PYTHON_LIBRARIES ${PYTHON_2_LIBRARIES})
35 endif()
36 endif()
37
38 set(ORTHANC_ROOT ${CMAKE_SOURCE_DIR}/Resources/Orthanc)
39 include(${ORTHANC_ROOT}/Resources/CMake/Compiler.cmake)
40 include(${ORTHANC_ROOT}/Resources/CMake/DownloadPackage.cmake)
41 include(${ORTHANC_ROOT}/Resources/CMake/BoostConfiguration.cmake)
42 include(${ORTHANC_ROOT}/Resources/CMake/JsonCppConfiguration.cmake)
43
44 if (STATIC_BUILD OR NOT USE_SYSTEM_ORTHANC_SDK)
45 include_directories(
46 ${ORTHANC_ROOT}/Sdk-1.5.7
47 )
48 else()
49 CHECK_INCLUDE_FILE_CXX(orthanc/OrthancCPlugin.h HAVE_ORTHANC_H)
50 if (NOT HAVE_ORTHANC_H)
51 message(FATAL_ERROR "Please install the headers of the Orthanc plugins SDK")
52 endif()
53 endif()
54
55 add_definitions(
56 -DHAS_ORTHANC_EXCEPTION=0
57 )
58
59 include_directories(
60 ${ORTHANC_ROOT}/Plugins/Include
61 ${ORTHANC_ROOT}/Plugins/Samples/Common
62 ${PYTHON_INCLUDE_DIRS}
63 )
64
65 add_library(OrthancPython SHARED
66 ${BOOST_SOURCES}
67 ${JSONCPP_SOURCES}
68 ${ORTHANC_ROOT}/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp
69 Sources/Autogenerated/sdk.cpp
70 Sources/OnChangeCallback.cpp
71 Sources/OnStoredInstanceCallback.cpp
72 Sources/Plugin.cpp
73 Sources/PythonFunction.cpp
74 Sources/PythonLock.cpp
75 Sources/PythonModule.cpp
76 Sources/PythonObject.cpp
77 Sources/PythonString.cpp
78 Sources/RestCallbacks.cpp
79 )
80
81 target_link_libraries(OrthancPython ${PYTHON_LIBRARIES})
82
83 add_definitions(-DPLUGIN_VERSION="${PLUGIN_VERSION}")
84
85 set_target_properties(OrthancPython PROPERTIES
86 VERSION ${PLUGIN_VERSION}
87 SOVERSION ${PLUGIN_VERSION}
88 )
89
90 install(
91 TARGETS OrthancPython
92 RUNTIME DESTINATION lib # Destination for Windows
93 LIBRARY DESTINATION share/orthanc/plugins # Destination for Linux
94 )