Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: do not set c-ares_FOUND with PARENT_SCOPE
* use PC_c-ares instead of c-ares as the prefix when finding the package configurations using pkg_check_modules() * do not add c-ares::cares if it is already a target. if find_pacakge(c-ares ..) is already called, we should not add the library again. * use PC_c-ares_VERSION instead of c-ares_PC_VERSION for the VERSION_VAR. it was broken in 27c2d88 before this change, we use "c-ares" as the prefix passed to `pkg_check_modules()` when checking c-ares package configurations. this sets c-ares_FOUND variable with PARENT_SCOPE, while we still add the `c-ares::cares` library target with the scope in the directory where the find_package(c-ares ..) is called and below. the scope follows the convention of Find<Package>.cmake modules provided by CMake project. it is found that grpc project uses c-ares_FOUND before calling find_package(c-ares REQUIRED) for resolving its dependency, and skip the find_package() call if c-ares_FOUND is TRUE. the discrepancy between the scopes of c-ares_FOUND and c-ares::cares can break the build of projects using both Seastar and the projects like grpc. as the parent project would fail to link against grpc library targets without cares::c-ares defined a directory where c-ares_FOUND evaluates to "TRUE" while cares::c-ares is not defined after find_package(c-ares) is called. after this change, instead of using c-ares as the prefix of variables defined by pkg_check_modules(), use PC_c-ares as the prefix to avoid the name collision and to ensure that the scopes of c-ares_FOUND and c-ares::cares are the same, so that the former can imply the availability of the latter. Signed-off-by: Kefu Chai <tchaikov@gmail.com>
- Loading branch information