c-ares provides CMake targets: find_package(c-ares CONFIG REQUIRED) target_link_libraries(main PRIVATE c-ares::cares)