find_package(Cython 0.10 REQUIRED) detects bash script called "cython", ignores version constraints

pyenv is a rather common virtualization tool in Python (15% of people that use venvs use pyenv) and it creates a global shim for every binary that is installed in any virtual env. When you are in an env that doesn’t have cython installed, the shim is still active but produces the following output if invoked:

pyenv: cython: command not found

The `cython' command exists in these Python versions:

For some reason CMake’s find_package still accepts this script, that always echoes that output as a valid “Cython”, even when ludicrous version requirements are given:

find_package(Cython 500.10 REQUIRED)

-- Found Cython: /home/robin/.pyenv/shims/cython (Required is at least version "500.10")

And later on in the build this ofcourse causes errors. From this it seems like CMake isn’t even trying to determine the version … How does find_package usually determine the version and what can I do to make CMake check that some random executable file it finds called “cython” actually is a Cython of the correct version?

It really depends on what FindCython.cmake is doing. CMake doesn’t ship such a file, so finding out where it comes from would be the first step here.

Thanks! I had no idea that that wasn’t shipped with CMake! I always thought it was astonishing how much tiny package specific modules CMake had! This makes more sense, I found the file in the upstream project’s repository and can submit a PR there!