Mercurial > hg > orthanc-python
view CMakeLists.txt @ 31:abe6dcd7f35e
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 12 May 2020 12:20:39 +0200 |
parents | ec7860ac40e9 |
children | ce5b6116e6cd |
line wrap: on
line source
cmake_minimum_required(VERSION 2.8) project(OrthancPython) set(PLUGIN_VERSION "mainline") set(PYTHON_VERSION "3.6" CACHE STRING "Version of Python to be used") set(PYTHON_WINDOWS_ROOT "" CACHE STRING "") 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)") 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) include(FindPythonInterp) string(REGEX REPLACE "^([0-9]*)\\.([0-9]*)$" "\\1" PYTHON_VERSION_MAJOR ${PYTHON_VERSION}) string(REGEX REPLACE "^([0-9]*)\\.([0-9]*)$" "\\2" PYTHON_VERSION_MINOR ${PYTHON_VERSION}) if (NOT PYTHON_VERSION STREQUAL "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}") message(FATAL_ERROR "Error in the (x.y) format of the Python version: ${PYTHON_VERSION}") endif() if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") if (MSVC) set(Prefix "") set(Suffix ".lib") if(PYTHON_WINDOWS_USE_RELEASE_LIBS) add_definitions(-DORTHANC_PYTHON_WINDOWS_USE_RELEASE_LIBS=1) endif() else() list(GET CMAKE_FIND_LIBRARY_PREFIXES 0 Prefix) set(Suffix ".a") endif() set(PYTHON_LIBRARY_NAME ${Prefix}python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}${Suffix}) set(PYTHON_INCLUDE_DIRS ${PYTHON_WINDOWS_ROOT}/include) set(PYTHON_LIBRARIES ${PYTHON_WINDOWS_ROOT}/libs/${PYTHON_LIBRARY_NAME}) 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) if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") execute_process( COMMAND ${PYTHON_EXECUTABLE} ${ORTHANC_ROOT}/Resources/WindowsResources.py ${PLUGIN_VERSION} "Python plugin" OrthancPython.dll "Plugin to create Orthanc plugins using Python" ERROR_VARIABLE Failure OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/Version.rc ) if (Failure) message(FATAL_ERROR "Error while computing the version information: ${Failure}") endif() set(WINDOWS_RESOURCES ${CMAKE_CURRENT_BINARY_DIR}/Version.rc) endif() 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 ${WINDOWS_RESOURCES} 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 )