# Provide and select Find\*.cmake file

**URL:** <https://discourse.cmake.org/t/provide-and-select-find-cmake-file/2501>\
**Category:** Code\
**Created:** [January 9, 2021, 10:11pm UTC](https://discourse.cmake.org/t/provide-and-select-find-cmake-file/2501 "2021-01-09T22:11:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gruenich](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/g/977dab/32.png) [@gruenich](https://discourse.cmake.org/u/gruenich)\
**Post date:** [January 9, 2021, 10:11pm UTC](https://discourse.cmake.org/t/provide-and-select-find-cmake-file/2501/1 "2021-01-09T22:11:58Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![hsattler](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/59ef9b/32.png) [@hsattler](https://discourse.cmake.org/u/hsattler)\
**Post date:** [January 10, 2021, 1:56am UTC](https://discourse.cmake.org/t/provide-and-select-find-cmake-file/2501/2 "2021-01-10T01:56:15Z")

</div>

Put it into its own directory and add that conditionally to CMAKE\_MODULE\_PATH based on CMake version?

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [January 11, 2021, 2:35pm UTC](https://discourse.cmake.org/t/provide-and-select-find-cmake-file/2501/3 "2021-01-11T14:35:02Z")

</div>

Note that `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):

```diff
-list(REMOVE_DUPLICATES listname)
+if (listname) # Behavior change in CMake 3.14
+ list(REMOVE_DUPLICATES listname)
+endif ()

```

in various places throughout `FindPython/Support.cmake`.

---

<div class="post-metadata">

**Author:** ![gruenich](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/g/977dab/32.png) [@gruenich](https://discourse.cmake.org/u/gruenich)\
**Post date:** [January 11, 2021, 7:48pm UTC](https://discourse.cmake.org/t/provide-and-select-find-cmake-file/2501/4 "2021-01-11T19:48:18Z")

</div>

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.
