Port macros from first cmake attempt over.

Reference commit is d54c9f6 if it still exists.