alexcrichton/git2-rs — pull request #19 by IvanUkhov (2014-11-14 12:17:57+00:00)
Title: Add a CMake module for detecting libssh2 via pkg-config

Hello,

`cmake` has [its own mechanisms][1] of searching for libraries, which differ from the ones that `pkg-config` has. As a result, `pkg-config` might be able to find some library while `cmake` might fail to do so, and vice versa.

In this regard, I’ve encountered the following problem. I’m on a mac, and I’ve installed `libssh2` using Homebrew; `libssh2` got installed in some subdirectory of my home directory. Since my `DYLD_LIBRARY_PATH` is set properly, `pkg-config` works just fine. When compiling `libgit2`, however, `cmake` fails to find `libssh2` and, therefore, [does not turn on][2] the SSH support. Consequently, even though `ssh2-rs` gets compiled and so on, `git2-rs` ends up without SSH.

The solution that I came up with can be seen in the pull request. However, this problem is more general: it concerns any Cargo’s build script that involves a mixture of `cmake` and `pkg-config`.

I would be happy to hear any feedback. Thank you.

Regards,
Ivan

[1]: http://www.cmake.org/Wiki/CMake:How_To_Find_Libraries
[2]: https://github.com/alexcrichton/libgit2/blob/156208bd5b43860d0cd1eda5cd2ce1b6ca95341e/CMakeLists.txt#L235