Building with external/altinstall python3 cmake error finding python interpreter version 1.4

ROOT Version: 6.20.04
Platform: Centos7
Compiler: Devtoolsel7 (gcc 7.3.1)
CMake: 3.12 compiled from source
Python: 3.8.0 compiled from source


Since I couldn’t find the right answer and it took a bit of digging in order to find what the actual issue was:

Root fails to find the standalone version of python3 despite explicitely passing them to CMake

+ cmake -Dgdml=ON -Dexplicitlink=ON -Dpython3=ON -DPYTHON_EXECUTABLE=/opt/python3.8/python3 -DPYTHON_INCLUDE_DIR=/opt/python3.8/include/python3.8/ -DPYTHON_LIBRARY=/opt/python3.8/lib/libpython3.so -DCMAKE_INSTALL_PREFIX=/opt/root-6.20.04 -Dcxx17=ON ../root-6.20.04
-- The C compiler identification is GNU 7.3.1
-- The CXX compiler identification is GNU 7.3.1
-- Check for working C compiler: /opt/rh/devtoolset-7/root/usr/bin/cc
-- Check for working C compiler: /opt/rh/devtoolset-7/root/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /opt/rh/devtoolset-7/root/usr/bin/c++
-- Check for working CXX compiler: /opt/rh/devtoolset-7/root/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Git: /bin/git (found version "1.8.3.1")
-- Looking for python
-- Found PythonInterp: /opt/python3.8/python3 (found version "1.4")
-- Found PythonLibs: /opt/python3.8/lib/libpython3.so (found version "3.8.0")
CMake Error at cmake/modules/SearchRootCoreDeps.cmake:90 (message):
  Version mismatch between Python interpreter (1.4) and libraries (3.8.0).

  ROOT cannot work with this configuration.  Please specify only
  PYTHON_EXECUTABLE to CMake with an absolute path to ensure matching
  versions are found.
Call Stack (most recent call first):
  CMakeLists.txt:120 (include)


-- Configuring incomplete, errors occurred!
See also "/buildroot/root-cmake-build/CMakeFiles/CMakeOutput.log".
FATAL:   failed to execute %post proc: exit status 1
FATAL:   While performing build: while running engine: while running /usr/libexec/singularity/bin/starter: exit status 255

Note that even giving the executable didn’t work in this case (hence why I added the exact location of all the libraries)

This bug is occurring when using an older version of CMake, for some reason it was picking a nonsensical version of the interpreter (1.4), to solve it, use a newer version of CMake, I don’t have an exact version number where it’s starting to work since I jumped directly to CMake 3.17.3 which solved all issues.

So the solution is, upgrade CMake.

Cheers,
Geoffrey.

Thank you for posting the problem and the solution
Cheers

Lorenzo