Rebasing #1148 on top of current cmake branch Related to #1047 --------- Co-authored-by: Bartek Zdanowski <bartek.zdanowski@gmail.com> Co-authored-by: Joey Parrish <joeyparrish@google.com>