There is currently no find script for avahi shipping with CMake, which is why your first example does not work. It is important to understand that find_package
simply runs an external find script, it does not perform any searching by itself.
Your second example is broken, mixing idioms from find_library
and find_package
. Please read up on the documentation of find_library and find_path which will help you find the required libraries and include paths.
If you want you can turn that into a find script later (look at the scripts in CMake's module directory to get an idea what such a script should look like), which will allow you to use the more compact find_package for locating the library again. Note that writing a find script that works reasonably well on different platforms is a complex task that will require some research effort to get it right.