Reenterable FindPython/multiple versions of Python in one pass
Dear CMake developers,
Recently I was trying to simplify the builds of C++/C python extensions. The goal was to be able to configure builds for multiple python versions in one pass. Unfortunately running find_package(Python ....)
multiple times with different arguments does not produce the desired results, as the stock FindPython
modules cache the related python variables. It looks the easiest way to achieve the desired behaviour is to modify the FindPython
modules to disable the caching.
A sample project with disabled caching of python variables (brute-force commented) is attached.
To configure the builds for multiple python versions in one pass, build the extensions and run the tests in the project one can use
cmake3 -Dsample_PYTHON_VERSIONS=3.6,3.4 -Dsample_ENABLE_TEST=ON -S../pythoncmake -B.
make
ctest .
which is quite convenient.
Would you consider implementing reenterable FindPython
in CMake with this or any other approach? Or a flag to disable caching in the FindPython
?
This could be really useful for projects building python bindings with multiple python versions.
Best regards,
Andrii