Mercurial > hg > orthanc-python
comparison CMakeLists.txt @ 33:ce5b6116e6cd
New builders for Windows: Supporting 32 / 64bit with Python 2.7 / 3.7 / 3.8
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 28 May 2020 18:05:18 +0200 |
parents | ec7860ac40e9 |
children | fd58eb5749ed |
comparison
equal
deleted
inserted
replaced
32:30161a429a91 | 33:ce5b6116e6cd |
---|---|
4 set(PLUGIN_VERSION "mainline") | 4 set(PLUGIN_VERSION "mainline") |
5 | 5 |
6 | 6 |
7 set(PYTHON_VERSION "3.6" CACHE STRING "Version of Python to be used") | 7 set(PYTHON_VERSION "3.6" CACHE STRING "Version of Python to be used") |
8 set(PYTHON_WINDOWS_ROOT "" CACHE STRING "") | 8 set(PYTHON_WINDOWS_ROOT "" CACHE STRING "") |
9 set(PYTHON_LIBRARY_NAME "" CACHE STRING "") | |
9 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)") | 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)") |
10 set(USE_SYSTEM_BOOST ON CACHE BOOL "Use the system version of Boost") | 11 set(USE_SYSTEM_BOOST ON CACHE BOOL "Use the system version of Boost") |
11 set(USE_SYSTEM_JSONCPP ON CACHE BOOL "Use the system version of JsonCpp") | 12 set(USE_SYSTEM_JSONCPP ON CACHE BOOL "Use the system version of JsonCpp") |
12 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)") | 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)") |
13 | 14 |
24 "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}") | 25 "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}") |
25 message(FATAL_ERROR "Error in the (x.y) format of the Python version: ${PYTHON_VERSION}") | 26 message(FATAL_ERROR "Error in the (x.y) format of the Python version: ${PYTHON_VERSION}") |
26 endif() | 27 endif() |
27 | 28 |
28 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") | 29 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") |
29 if (MSVC) | 30 if ("${PYTHON_LIBRARY_NAME}" STREQUAL "") |
30 set(Prefix "") | 31 if (MSVC) |
31 set(Suffix ".lib") | 32 set(Prefix "") |
32 if(PYTHON_WINDOWS_USE_RELEASE_LIBS) | 33 set(Suffix ".lib") |
33 add_definitions(-DORTHANC_PYTHON_WINDOWS_USE_RELEASE_LIBS=1) | 34 if(PYTHON_WINDOWS_USE_RELEASE_LIBS) |
35 add_definitions(-DORTHANC_PYTHON_WINDOWS_USE_RELEASE_LIBS=1) | |
36 endif() | |
37 else() | |
38 list(GET CMAKE_FIND_LIBRARY_PREFIXES 0 Prefix) | |
39 set(Suffix ".a") | |
34 endif() | 40 endif() |
35 else() | 41 |
36 list(GET CMAKE_FIND_LIBRARY_PREFIXES 0 Prefix) | 42 set(PYTHON_LIBRARY_NAME ${Prefix}python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}${Suffix}) |
37 set(Suffix ".a") | |
38 endif() | 43 endif() |
39 | 44 |
40 set(PYTHON_LIBRARY_NAME ${Prefix}python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}${Suffix}) | 45 if (CMAKE_COMPILER_IS_GNUCXX AND |
46 "${CMAKE_SIZEOF_VOID_P}" STREQUAL "8" AND | |
47 "${PYTHON_VERSION}" STREQUAL "2.7") | |
48 # Fix for MinGW 64bit: https://stackoverflow.com/a/19867426/881731 | |
49 add_definitions(-DMS_WIN64) | |
50 endif() | |
51 | |
41 set(PYTHON_INCLUDE_DIRS ${PYTHON_WINDOWS_ROOT}/include) | 52 set(PYTHON_INCLUDE_DIRS ${PYTHON_WINDOWS_ROOT}/include) |
42 set(PYTHON_LIBRARIES ${PYTHON_WINDOWS_ROOT}/libs/${PYTHON_LIBRARY_NAME}) | 53 set(PYTHON_LIBRARIES ${PYTHON_WINDOWS_ROOT}/libs/${PYTHON_LIBRARY_NAME}) |
43 | 54 |
44 else() | 55 else() |
45 find_package(PkgConfig REQUIRED) | 56 find_package(PkgConfig REQUIRED) |
92 ${ORTHANC_ROOT}/Plugins/Samples/Common | 103 ${ORTHANC_ROOT}/Plugins/Samples/Common |
93 ${PYTHON_INCLUDE_DIRS} | 104 ${PYTHON_INCLUDE_DIRS} |
94 ) | 105 ) |
95 | 106 |
96 add_library(OrthancPython SHARED | 107 add_library(OrthancPython SHARED |
97 ${BOOST_SOURCES} | |
98 ${JSONCPP_SOURCES} | |
99 ${ORTHANC_ROOT}/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp | |
100 ${WINDOWS_RESOURCES} | |
101 Sources/Autogenerated/sdk.cpp | 108 Sources/Autogenerated/sdk.cpp |
102 Sources/OnChangeCallback.cpp | 109 Sources/OnChangeCallback.cpp |
103 Sources/OnStoredInstanceCallback.cpp | 110 Sources/OnStoredInstanceCallback.cpp |
104 Sources/Plugin.cpp | 111 Sources/Plugin.cpp |
105 Sources/PythonFunction.cpp | 112 Sources/PythonFunction.cpp |
106 Sources/PythonLock.cpp | 113 Sources/PythonLock.cpp |
107 Sources/PythonModule.cpp | 114 Sources/PythonModule.cpp |
108 Sources/PythonObject.cpp | 115 Sources/PythonObject.cpp |
109 Sources/PythonString.cpp | 116 Sources/PythonString.cpp |
110 Sources/RestCallbacks.cpp | 117 Sources/RestCallbacks.cpp |
118 | |
119 # Third-party sources | |
120 ${ORTHANC_ROOT}/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp | |
121 ${BOOST_SOURCES} | |
122 ${JSONCPP_SOURCES} | |
123 ${WINDOWS_RESOURCES} | |
111 ) | 124 ) |
112 | 125 |
113 target_link_libraries(OrthancPython ${PYTHON_LIBRARIES}) | 126 target_link_libraries(OrthancPython ${PYTHON_LIBRARIES}) |
114 | 127 |
115 add_definitions(-DPLUGIN_VERSION="${PLUGIN_VERSION}") | 128 add_definitions(-DPLUGIN_VERSION="${PLUGIN_VERSION}") |