Remove code duplication on CMake link macros.