CMake 3.20 will introduce
Python3_FIND_UNVERSIONED_NAMES and its evaluation are just a couple of lines from
Modules/FindPython/Support.cmake. I need this change in my project but I cannot require CMake 3.20, I have to stick with 3.13.
I thought about including FindPython3.cmake and Support.cmake into my project. Then this is called instead of the file coming with (older) CMake installations. But for users with a newer CMake (3.20.1, 3.21, …), I don’t them to be forced to the older file provided by my project.
Is there a way to select / define which Find*.cmake file is used?
Put it into its own directory and add that conditionally to CMAKE_MODULE_PATH based on CMake version?
FindPython uses features from newer versions than 3.13. You should test with 3.13 at least. The compatibility patches aren’t too difficult (basically this diff):
+if (listname) # Behavior change in CMake 3.14
+ list(REMOVE_DUPLICATES listname)
in various places throughout
D’oh, I placed the copy of FindPython3.cmake in a directory that was already part of CMAKE_MODULE_PATH. Thank your for the hint! I moved it to a sub-directory and conditionally include the sub-directory. With Ben’s suggestion and some further tweaks, it works like a charm.