comparison CMakeLists.txt @ 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 3848f5b1d993
children 874a3fef26ff
comparison
equal deleted inserted replaced
20:5466d9340fc7 21:67f48fc2fd69
14 include(CheckIncludeFileCXX) 14 include(CheckIncludeFileCXX)
15 include(CheckIncludeFiles) 15 include(CheckIncludeFiles)
16 include(CheckLibraryExists) 16 include(CheckLibraryExists)
17 include(FindPythonInterp) 17 include(FindPythonInterp)
18 18
19 string(REGEX REPLACE "^([0-9]*)\\.([0-9]*)$" "\\1" PYTHON_VERSION_MAJOR ${PYTHON_VERSION})
20 string(REGEX REPLACE "^([0-9]*)\\.([0-9]*)$" "\\2" PYTHON_VERSION_MINOR ${PYTHON_VERSION})
21
22 if (NOT PYTHON_VERSION STREQUAL
23 "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
24 message(FATAL_ERROR "Error in the (x.y) format of the Python version: ${PYTHON_VERSION}")
25 endif()
26
19 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") 27 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
28 set(PYTHON_LIBRARY_NAME libpython${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.a)
20 set(PYTHON_INCLUDE_DIRS ${PYTHON_WINDOWS_ROOT}/include) 29 set(PYTHON_INCLUDE_DIRS ${PYTHON_WINDOWS_ROOT}/include)
21 set(PYTHON_LIBRARIES ${PYTHON_WINDOWS_ROOT}/libs/libpython27.a) 30 set(PYTHON_LIBRARIES ${PYTHON_WINDOWS_ROOT}/libs/${PYTHON_LIBRARY_NAME})
22 31
23 else() 32 else()
24 find_package(PkgConfig REQUIRED) 33 find_package(PkgConfig REQUIRED)
25 pkg_check_modules(PYTHON_1 python-${PYTHON_VERSION}-embed) 34 pkg_check_modules(PYTHON_1 python-${PYTHON_VERSION}-embed)
26 35