From 38c97bc9341be469db04badf9713c72bca7d9b91 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Sat, 13 Mar 2021 22:17:24 -0600 Subject: [PATCH] Check for PYTHON_LIBRARY only on windows --- cmake/FindPython.cmake | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/cmake/FindPython.cmake b/cmake/FindPython.cmake index 4cb97cc5..16dc5af2 100644 --- a/cmake/FindPython.cmake +++ b/cmake/FindPython.cmake @@ -37,15 +37,17 @@ message(STATUS "Python version: ${PYTHON_VERSION}") string(REPLACE "." "" PYTHON_VERSION_WITHOUT_DOTS ${PYTHON_VERSION}) -FIND_LIBRARY(PYTHON_LIBRARY NAMES +if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + FIND_LIBRARY(PYTHON_LIBRARY NAMES python${PYTHON_VERSION} python${PYTHON_VERSION}m python${PYTHON_VERSION_WITHOUT_DOTS} - PATHS ${PYTHON_LIB_PATH} ${PYTHON_PREFIX_PATH}/lib ${PYTHON_PREFIX_PATH}/libs - PATH_SUFFIXES ${CMAKE_LIBRARY_ARCHITECTURE} - NO_DEFAULT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - ) + PATHS ${PYTHON_LIB_PATH} ${PYTHON_PREFIX_PATH}/lib ${PYTHON_PREFIX_PATH}/libs + PATH_SUFFIXES ${CMAKE_LIBRARY_ARCHITECTURE} + NO_DEFAULT_PATH + NO_SYSTEM_ENVIRONMENT_PATH + ) +endif() execute_process( COMMAND ${PYTHON_BIN} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())" @@ -66,7 +68,12 @@ set(PYTHON_EXTENSION_SOABI ${PYTHON_EXTENSION_SOABI_tmp} CACHE STRING "Suffix for python extensions") INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Python DEFAULT_MSG PYTHON_LIBRARY PYTHON_INCLUDE_PATH PYTHON_INSTALL_PATH) + +if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + FIND_PACKAGE_HANDLE_STANDARD_ARGS(Python DEFAULT_MSG PYTHON_LIBRARY PYTHON_INCLUDE_PATH PYTHON_INSTALL_PATH) +else () + FIND_PACKAGE_HANDLE_STANDARD_ARGS(Python DEFAULT_MSG PYTHON_INCLUDE_PATH PYTHON_INSTALL_PATH) +endif () # Links a Python extension module.