Commit 7e70a927 authored by notoriousPig's avatar notoriousPig Committed by Davis E. King

pybind11: cmake: ignore the check between host-python and cross-compiler (#1848)

When dlib is compiling, cmake will compare python architecture and target
architecture. So in cross-compiling case, it is irrevelant because host and
target architecture often differs. The main problem come from checking python
architecture on host and not on target.

Here is an error when compiling dlib from x86_64 to arm 32-bit target :
```
Python config failure: Python is 64-bit, chosen compiler is 32-bit
```

So :
- Skipping the comparation when cross-compiling is enabled.
Signed-off-by: 's avatarRomain Naour <romain.naour@smile.fr>
Signed-off-by: 's avatarAlexandre PAYEN <alexandre.payen@smile.fr>
parent 05cbfc6d
...@@ -113,9 +113,11 @@ list(GET _PYTHON_VALUES 7 PYTHON_LIBRARY_SUFFIX) ...@@ -113,9 +113,11 @@ list(GET _PYTHON_VALUES 7 PYTHON_LIBRARY_SUFFIX)
list(GET _PYTHON_VALUES 8 PYTHON_LIBDIR) list(GET _PYTHON_VALUES 8 PYTHON_LIBDIR)
list(GET _PYTHON_VALUES 9 PYTHON_MULTIARCH) list(GET _PYTHON_VALUES 9 PYTHON_MULTIARCH)
# Make sure the Python has the same pointer-size as the chosen compiler # Ignore this test while crosscompiling otherwise it will use the host python.
# Skip if CMAKE_SIZEOF_VOID_P is not defined IF(NOT CMAKE_CROSSCOMPILING)
if(CMAKE_SIZEOF_VOID_P AND (NOT "${PYTHON_SIZEOF_VOID_P}" STREQUAL "${CMAKE_SIZEOF_VOID_P}")) # Make sure the Python has the same pointer-size as the chosen compiler
# Skip if CMAKE_SIZEOF_VOID_P is not defined
if(CMAKE_SIZEOF_VOID_P AND (NOT "${PYTHON_SIZEOF_VOID_P}" STREQUAL "${CMAKE_SIZEOF_VOID_P}"))
if(PythonLibsNew_FIND_REQUIRED) if(PythonLibsNew_FIND_REQUIRED)
math(EXPR _PYTHON_BITS "${PYTHON_SIZEOF_VOID_P} * 8") math(EXPR _PYTHON_BITS "${PYTHON_SIZEOF_VOID_P} * 8")
math(EXPR _CMAKE_BITS "${CMAKE_SIZEOF_VOID_P} * 8") math(EXPR _CMAKE_BITS "${CMAKE_SIZEOF_VOID_P} * 8")
...@@ -125,6 +127,7 @@ if(CMAKE_SIZEOF_VOID_P AND (NOT "${PYTHON_SIZEOF_VOID_P}" STREQUAL "${CMAKE_SIZE ...@@ -125,6 +127,7 @@ if(CMAKE_SIZEOF_VOID_P AND (NOT "${PYTHON_SIZEOF_VOID_P}" STREQUAL "${CMAKE_SIZE
endif() endif()
set(PYTHONLIBS_FOUND FALSE) set(PYTHONLIBS_FOUND FALSE)
return() return()
endif()
endif() endif()
# The built-in FindPython didn't always give the version numbers # The built-in FindPython didn't always give the version numbers
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment