Customizing linker and redirecting the STDIO to a file

Have a look at the CMAKE_<LANG>_LINKER_LAUNCHER variable.