Find libavahi with cmake

I need to add libavahi-client3 to cmake dependencies of my project. It is also necessary to verify the existence of libavahi-client3 and libavahi-common3. Problems only with the current library (avahi)

Trying to do the following:

find_package(libavahi-common3) if(NOT libavahi-common3_FOUND) message(ERROR " libavahi-common3 is not found") endif(NOT libavahi-common3_FOUND) 

OR this option:

 find_library(AVAHI_COMMON_LIBRARY NAMES libavahi-common3) if(NOT AVAHI_COMMON_LIBRARY_FOUND) message(ERROR " libavahi-common3 is not found") endif(NOT AVAHI_COMMON_LIBRARY_FOUND) 

Both do not work, I was looking for something like findAvahi.cmake, but did not find anything. So should I write my own search module or is there another better option?

+1
cmake avahi
source share
1 answer

There is currently no script found to send avahi using CMake, so your first example does not work. It is important to understand that find_package simply runs the external find script, it does not perform any searches on its own.

Your second example is broken by mixing idioms from find_library and find_package . Please check out the find_library and find_path documentation to help you find the libraries you need and include paths.

If you want, you can include this again in the find script (look at the scripts in the CMake module directory to get an idea of ​​what such a script should look like), which allows you to use the more compact find_package to search the library again. Note that finding find script, which works well across platforms, is a complex task that will require some research to understand.

+1
source share

All Articles