Details
Description
The current CMake builds for Shiboken, PySide, and pyside-tools all fail when passed an explicit Python interpreter due to syntax errors in the CMakeLists.txt and the bundled FindPythonInterp* CMake modules.
The problem is caused by calls to Python -c similar to this (take from FindPythonInterpWithDebug.cmake in the Shiboken repo):
execute_process( COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; \\ print(sysconfig.get_python_lib(1,0,prefix='${CMAKE_INSTALL_PREFIX}'))" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
When the -DPYTHON_EXECUTABLE flag is passed to CMake during configuration, it results in errors similar to the following:
File "<string>", line 1 from distutils import sysconfig; \ ^ SyntaxError: unexpected character after line continuation character CMake Error at CMakeLists.txt:43 (message): Could not detect Python module installation directory. -- Configuring incomplete, errors occurred!
I believe this is because CMake does not support splitting of strings across multiple lines. Ensuring that the Python command string is continuous fixes the problem. For example:
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c
"from distutils import sysconfig; print(sysconfig.get_python_lib(1,0,prefix='${CMAKE_INSTALL_PREFIX}'))"
OUTPUT_VARIABLE PYTHON_SITE_PACKAGES
OUTPUT_STRIP_TRAILING_WHITESPACE)