<div dir="ltr"><div>Hi</div><div><br></div><div>We are testing CMake compilation, and we are having a problem with python, in particular doing Cross Compilation in macOS x86_64 to M1 (arm) architecture. Python is found, but the x86_64 (that is not usable here), even when we disable Python bindings.<br></div><div><br></div><div>We use this options:<br><span style="font-family:monospace">GDAL_USE_EXTERNAL_LIBS=OFF<br>GDAL_USE_GEOTIFF=ON</span></div><div><span style="font-family:monospace">BUILD_PYTHON_BINDINGS=OFF</span></div><div><br></div><div>The error I get is</div><div><br></div><div><span style="font-family:monospace">[ 82%] Linking CXX executable pytest_runner<br>ld: warning: ignoring file /Library/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7m.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64<br>Undefined symbols for architecture arm64:<br>  "_PyRun_SimpleStringFlags", referenced from:<br>      _main in pytest_runner.cpp.o<br>  "_Py_DecodeLocale", referenced from:<br>      _main in pytest_runner.cpp.o<br>  "_Py_Finalize", referenced from:<br>      _main in pytest_runner.cpp.o<br>  "_Py_Initialize", referenced from:<br>      _main in pytest_runner.cpp.o<br>  "_Py_SetProgramName", referenced from:<br>      _main in pytest_runner.cpp.o<br>ld: symbol(s) not found for architecture arm64<br>clang: error: linker command failed with exit code 1 (use -v to see invocation)<br>make[2]: *** [autotest/pytest_runner] Error 1<br>make[1]: *** [autotest/CMakeFiles/pytest_runner.dir/all] Error 2<br>make[1]: *** Waiting for unfinished jobs....</span></div><div><br></div><div>As a fix, I added an "if" statement in CMakeLists.txt ("# added line" below) to consider the case when BUILD_PYTHON_BINDINGS is not enabled.<br></div><div><br></div><div><span style="font-family:monospace">if (BUILD_PYTHON_BINDINGS)  # added line<br></span></div><div><span style="font-family:monospace">if (Python_LOOKUP_VERSION)<br>  set(Python_FIND_STRATEGY VERSION)<br>  find_package(Python ${Python_LOOKUP_VERSION} EXACT COMPONENTS Interpreter Development NumPy)<br>else ()<br>  set(Python_FIND_STRATEGY LOCATION)<br>  find_package(Python 3.6 COMPONENTS Interpreter Development NumPy)<br>endif ()</span></div><div><span style="font-family:monospace">endif ()  # added line</span></div><div><br></div><div>But maybe there is a better solution.</div><div>If that is Ok for you, I can create a PR.</div><div><br></div><div>Best regards,</div><div>Javier<br></div><div><br></div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">.___ ._ ..._ .. . ._.  .___ .. __ . _. . __..  ... .... ._ .__<br>Entre dos pensamientos racionales <br>hay infinitos pensamientos irracionales.<br><br></div></div></div></div>