facebook/hhvm — pull request #2778 by paravoid (2014-05-27 16:25:13+00:00)
Title: CMake links based on .so presence instead of header detection

The build system is a bit naive and picks linker arguments based on the presence of libraries (shared objects) and not based on the library choice that was made earlier which in turn, was based on the availability of development headers.

This has the effect that if you have both libedit and libreadline installed on the system but only libedit-dev, HHVM will get built with the libedit headers but linking will be attempted against libreadline which will obviously fail. This is particularly important since libreadline is typically available on systems, but we want to prefer linking against libedit for licensing reasons.

On the Debian packaging I've worked around this with the following patch which is just a hack: it just swaps the order or libedit/libreadline. While it doesn't fix the true bug, it may be sensible considering the licensing implications of linking with libreadline (PHP/GPL mixture = undistributable) and the wide availability of libreadline on systems.

The real bug here is the total disconnect between header detection/library choices and linking arguments and remains even after this patch.