Struggeling to create a FindWebP.cmake file

I tried to follow this guide but I’m having trouble understanding it. Would I not simply give the path to the library were it is on my system?

I’ve created a file FindWebP.cmake with this content:

FindWebP
--------

WebP_INCLUDE_DIRS=/opt/local/include/
WebP_LIBRARIES=/opt/local/lib/

This doesn’t even produce an error but is completely ignored. Yes, I put the file in the folder that I exported for CMAKE_MODULE_PATH.

Reading the guide above it seems like it’s actually a lot more complicated. What’s the point of calling find_package again in the FindWebP.cmake file?

Here’s an example of about how simple it can get. You can probably skip the version extraction logic.

https://gitlab.kitware.com/vtk/vtk/-/blob/master/CMake/FindGL2PS.cmake

Note that the content you posted isn’t valid CMake code. You can use the --debug-find flag when configuring to inspect what’s going on when CMake is searching for such things.