Build dependencies by using cmake in a separate dir

Change-Id: I1aafa1aa55c20aa35c6eb43f7fe36bf72ad0debe
Reviewed-on: http://review.couchbase.org/29292
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>