Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrangle (some) Caffe dependencies through CMake #2240

Merged
merged 1 commit into from
May 30, 2015

Conversation

nsubtil
Copy link
Contributor

@nsubtil nsubtil commented Apr 2, 2015

Caffe has many dependencies, some of which seem quite esoteric. In order to alleviate the problem, I propose to modify the CMake build to fetch and build some dependencies as part of the Caffe build itself.

This can be done through the ExternalProject module in CMake. At build time, if a system-wide version of a given library is not found, CMake can be instructed to download and build it. Any dependencies built this way are always built as static libraries, to avoid having to pollute the user's system with extra shared libraries at install time.

Right now, this PR only handles glog and gflags. The same method can be extended to pretty much anything, although I'd recommend only doing this for libraries not commonly installed on a user's system. I've used this technique successfully in the past to tackle software that depends on, e.g., specific versions of Boost, or libraries that are not packaged yet and therefore hard to install for end users.

There are a few advantages to doing this: less dependencies to worry about when compiling Caffe, plus we can ensure that the build uses known-good versions of the libraries we depend on.

This method is not without it's drawbacks, though, and there are a few open questions: is it OK to depend on GitHub being accessible during the build? Are we concerned about bloating binary sizes due to static vs. dynamic linking? This will increase build times when our dependencies are not installed, would that be a concern for automated build systems?

Even though this is technically ready to merge, this PR is expected to be more of a starting point for discussion. Does this sound like a viable/interesting option to pursue?

This adds functionality to fetch gflags and glog from GitHub and build
them during the Caffe build. This happens only if a system-wide
installed version is not found (i.e., when find_package() fails).

If built as part of the Caffe build, gflags and glog are compiled as
position-independent static libraries. This avoids doing a system-wide
install of these libraries during the Caffe install target.
@shelhamer
Copy link
Member

glog and gflags are both available as packages on common platforms, but I imagine they aren't so easily acquired elsewhere and this would be helpful. Since this falls back to system glog and gflags this seems only positive, so I'll merge.

Are we concerned about bloating binary sizes due to static vs. dynamic linking?

I prefer dynamic linking for build size and time.

Thanks Nuno!

shelhamer added a commit that referenced this pull request May 30, 2015
Wrangle (some) Caffe dependencies through CMake
@shelhamer shelhamer merged commit df58775 into BVLC:master May 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants