getdnsapi / getdns

A modern asynchronous DNS API https://getdnsapi.net/
Other
467 stars 126 forks source link

Use FindPkgConfig module to look for dependencies #487

Closed madebr closed 2 years ago

madebr commented 4 years ago

Currently, dependencies are detected using custom FindXXX modules in cmake/modules. But this breaks when the dependencies are static libraries which can have dependencies on their own, or require compile definitions.

This is e.g. the case with libidn2, which has a dependency on iconv. The current build system works fine when all dependencies are shared libraries, but one should not assume that is always the case.

I googled a bit and all dependencies provide a .pc file. So I propose to, in all FindXXX.cmake scripts, first try detecting the dependencies using FindPkgConfig. And if that fails, use the current approach.

banburybill commented 4 years ago

I completely agree that the current dependency detection is problematic.

I've avoided using FindPkgConfig so far simply because it doesn't work on Windows. It would help somewhat on some/most Unixes, but I'm wary of solutions that work on some platforms but leave Windows broken, as I fear that over time this will cause the Windows support to rot.

madebr commented 4 years ago

I opened this issue as part of my work on writing a conan recipe for getdns at conan-center-index. See https://github.com/conan-io/conan-center-index/pull/2903 for the pull request. I added a patch for the FindXXX.cmake modules of getdns that will first try pkg-config, and if that fails, uses the current approach. Maybe it can be used as a base for pkg-config support. I think it should also work on windows, with or without a working pkg-config environment.

(Please don't mind the openssl related change in the patch, that is related to a conan inssue.)

madebr commented 4 years ago

I've opened #488 to address this problem.