From 83508b80bd2a018781884f2b5773ce2118959d0f Mon Sep 17 00:00:00 2001 From: Joerg Hofrichter Date: Fri, 24 Jul 2020 12:09:49 +0200 Subject: cmake: don't try to determine runtime python version when cross compiling When cross compiling, the architecture of the runtime python interpreter does not match the host architecture. Therefore, don't try to detect it and set it to the min. supported python version instead. --- host/cmake/Modules/UHDPython.cmake | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'host/cmake/Modules') diff --git a/host/cmake/Modules/UHDPython.cmake b/host/cmake/Modules/UHDPython.cmake index 87b974083..453b7678c 100644 --- a/host/cmake/Modules/UHDPython.cmake +++ b/host/cmake/Modules/UHDPython.cmake @@ -81,9 +81,22 @@ message(STATUS "Override with: -DPYTHON_EXECUTABLE=") #this allows the user to override RUNTIME_PYTHON_EXECUTABLE if(NOT RUNTIME_PYTHON_EXECUTABLE) - #default to the buildtime interpreter - set(RUNTIME_PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE}) - set(RUNTIME_PYTHON_VERSION ${PYTHON_VERSION}) + if(CMAKE_CROSSCOMPILING) + message(STATUS "Cross compiling, setting python runtime to /usr/bin/python3") + message(STATUS "and interpreter to min. required version ${PYTHON_MIN_VERSION}") + message(STATUS "If this is not what you want, please set RUNTIME_PYTHON_EXECUTABLE") + message(STATUS "and RUNTIME_PYTHON_VERSION manually") + set(RUNTIME_PYTHON_EXECUTABLE "/usr/bin/python3") + set(RUNTIME_PYTHON_VERSION ${PYTHON_MIN_VERSION}) + set(EXACT_ARGUMENT "") + else(CMAKE_CROSSCOMPILING) + #default to the buildtime interpreter + set(RUNTIME_PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE}) + set(RUNTIME_PYTHON_VERSION ${PYTHON_VERSION}) + set(EXACT_ARGUMENT "EXACT") + endif(CMAKE_CROSSCOMPILING) +else(NOT RUNTIME_PYTHON_EXECUTABLE) + set(EXACT_ARGUMENT "EXACT") endif(NOT RUNTIME_PYTHON_EXECUTABLE) if(NOT RUNTIME_PYTHON_VERSION) @@ -144,11 +157,11 @@ endmacro(PYTHON_CHECK_MODULE) # - See if Python3_LIBRARIES is already set (or Python2_LIBRARIES) if(NOT PYTHON_LIBRARIES OR NOT PYTHON_INCLUDE_DIRS) message(STATUS "Finding Python Libraries...") - find_package(PythonLibs ${RUNTIME_PYTHON_VERSION} EXACT QUIET) - if(RUNTIME_PYTHON_VERSION VERSION_LESS 3) + find_package(PythonLibs ${RUNTIME_PYTHON_VERSION} ${EXACT_ARGUMENT} QUIET) + if(NOT RUNTIME_PYTHON_VERSION VERSION_LESS 3) if(NOT PYTHON_LIBRARIES OR NOT PYTHON_INCLUDE_DIRS) find_package(Python3 ${RUNTIME_PYTHON_VERSION} - EXACT + ${EXACT_ARGUMENT} QUIET COMPONENTS Interpreter Development) if(Python3_Development_FOUND) @@ -156,10 +169,10 @@ if(NOT PYTHON_LIBRARIES OR NOT PYTHON_INCLUDE_DIRS) set(PYTHON_INCLUDE_DIRS ${Python3_INCLUDE_DIRS}) endif(Python3_Development_FOUND) endif(NOT PYTHON_LIBRARIES OR NOT PYTHON_INCLUDE_DIRS) - else(RUNTIME_PYTHON_VERSION VERSION_LESS 3) + else(NOT RUNTIME_PYTHON_VERSION VERSION_LESS 3) if(NOT PYTHON_LIBRARIES OR NOT PYTHON_INCLUDE_DIRS) find_package(Python2 ${RUNTIME_PYTHON_VERSION} - EXACT + ${EXACT_ARGUMENT} QUIET COMPONENTS Interpreter Development) if(Python2_Development_FOUND) @@ -167,7 +180,7 @@ if(NOT PYTHON_LIBRARIES OR NOT PYTHON_INCLUDE_DIRS) set(PYTHON_INCLUDE_DIRS ${Python2_INCLUDE_DIRS}) endif(Python2_Development_FOUND) endif(NOT PYTHON_LIBRARIES OR NOT PYTHON_INCLUDE_DIRS) - endif(RUNTIME_PYTHON_VERSION VERSION_LESS 3) + endif(NOT RUNTIME_PYTHON_VERSION VERSION_LESS 3) if(NOT PYTHON_LIBRARIES OR NOT PYTHON_INCLUDE_DIRS) message(STATUS "Could not find Python Libraries.") endif(NOT PYTHON_LIBRARIES OR NOT PYTHON_INCLUDE_DIRS) -- cgit v1.2.3