view CMakeLists.txt @ 14:13589c36243d OrthancPython-1.0

OrthancPython-1.0
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 01 Apr 2020 09:45:03 +0200
parents 952e969a2240
children c4c3590e2024 777b677cc9fc
line wrap: on
line source

cmake_minimum_required(VERSION 2.8)
project(OrthancPython)

set(PLUGIN_VERSION "1.0")


set(PYTHON_VERSION "3.6" CACHE STRING "Version of Python to be used")
set(PYTHON_WINDOWS_ROOT "" CACHE STRING "")
set(USE_SYSTEM_BOOST ON CACHE BOOL "Use the system version of Boost")
set(USE_SYSTEM_JSONCPP ON CACHE BOOL "Use the system version of JsonCpp")
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)")

include(CheckIncludeFile)
include(CheckIncludeFileCXX)
include(CheckIncludeFiles)
include(CheckLibraryExists)

if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
  set(PYTHON_INCLUDE_DIRS ${PYTHON_WINDOWS_ROOT}/include)
  set(PYTHON_LIBRARIES ${PYTHON_WINDOWS_ROOT}/libs/libpython27.a)
  
else()
  find_package(PkgConfig REQUIRED)
  pkg_check_modules(PYTHON_1 python-${PYTHON_VERSION}-embed)

  if (PYTHON_1_FOUND)
    set(PYTHON_INCLUDE_DIRS ${PYTHON_1_INCLUDE_DIRS})
    set(PYTHON_LIBRARIES ${PYTHON_1_LIBRARIES})
  else()
    pkg_check_modules(PYTHON_2 REQUIRED python-${PYTHON_VERSION})
    set(PYTHON_INCLUDE_DIRS ${PYTHON_2_INCLUDE_DIRS})
    set(PYTHON_LIBRARIES ${PYTHON_2_LIBRARIES})
  endif()
endif()

set(ORTHANC_ROOT ${CMAKE_SOURCE_DIR}/Resources/Orthanc)
include(${ORTHANC_ROOT}/Resources/CMake/Compiler.cmake)
include(${ORTHANC_ROOT}/Resources/CMake/DownloadPackage.cmake)
include(${ORTHANC_ROOT}/Resources/CMake/BoostConfiguration.cmake)
include(${ORTHANC_ROOT}/Resources/CMake/JsonCppConfiguration.cmake)

include_directories(
  ${ORTHANC_ROOT}/Sdk-1.5.7
  )

add_definitions(
  -DHAS_ORTHANC_EXCEPTION=0
  )

include_directories(
  ${ORTHANC_ROOT}/Plugins/Samples/Common
  ${PYTHON_INCLUDE_DIRS}
  )

add_library(OrthancPython SHARED
  ${BOOST_SOURCES}
  ${JSONCPP_SOURCES}
  ${ORTHANC_ROOT}/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp
  Sources/Autogenerated/sdk.cpp
  Sources/OnChangeCallback.cpp
  Sources/OnStoredInstanceCallback.cpp
  Sources/Plugin.cpp
  Sources/PythonFunction.cpp
  Sources/PythonLock.cpp
  Sources/PythonModule.cpp
  Sources/PythonObject.cpp
  Sources/PythonString.cpp
  Sources/RestCallbacks.cpp
  )

target_link_libraries(OrthancPython ${PYTHON_LIBRARIES})

add_definitions(-DPLUGIN_VERSION="${PLUGIN_VERSION}")

set_target_properties(OrthancPython PROPERTIES 
  VERSION ${PLUGIN_VERSION} 
  SOVERSION ${PLUGIN_VERSION}
  )

install(
  TARGETS OrthancPython
  RUNTIME DESTINATION lib    # Destination for Windows
  LIBRARY DESTINATION share/orthanc/plugins    # Destination for Linux
  )