diff options
author | Joerg Hofrichter <joerg.hofrichter@ni.com> | 2020-07-24 12:09:49 +0200 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2020-08-04 07:38:40 -0500 |
commit | 83508b80bd2a018781884f2b5773ce2118959d0f (patch) | |
tree | c7d74c5f321f6882b54b62ccc5efc55fd0284b63 /host/cmake/Modules | |
parent | 2bc89c8f1da93fd1c513a6b940ab4f405cfe0042 (diff) | |
download | uhd-83508b80bd2a018781884f2b5773ce2118959d0f.tar.gz uhd-83508b80bd2a018781884f2b5773ce2118959d0f.tar.bz2 uhd-83508b80bd2a018781884f2b5773ce2118959d0f.zip |
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.
Diffstat (limited to 'host/cmake/Modules')
-rw-r--r-- | host/cmake/Modules/UHDPython.cmake | 31 |
1 files changed, 22 insertions, 9 deletions
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=<path-to-python>") #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) |