Mercurial > hg > orthanc-python
changeset 21:67f48fc2fd69
fix linking with Python on Windows
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 03 Apr 2020 10:45:43 +0200 |
parents | 5466d9340fc7 |
children | 04b8a44b2717 |
files | CMakeLists.txt |
diffstat | 1 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/CMakeLists.txt Wed Apr 01 11:01:20 2020 +0200 +++ b/CMakeLists.txt Fri Apr 03 10:45:43 2020 +0200 @@ -16,9 +16,18 @@ 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") + set(PYTHON_LIBRARY_NAME libpython${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.a) set(PYTHON_INCLUDE_DIRS ${PYTHON_WINDOWS_ROOT}/include) - set(PYTHON_LIBRARIES ${PYTHON_WINDOWS_ROOT}/libs/libpython27.a) + set(PYTHON_LIBRARIES ${PYTHON_WINDOWS_ROOT}/libs/${PYTHON_LIBRARY_NAME}) else() find_package(PkgConfig REQUIRED)