Solved the issue by running cmake inside a pipenv environment with python3.10. Still set the configuration variables to the global python environment. This made cmake detect a python 3.10 version while still building and installing it into the global python3.10 environment.