Fix gdb segfault due to CMake linker flags.

By default CMake adds the language compiler flags (CXX in this case)
as flags to the linker step. Remove the CXX compiler flags when linking
to prevent segfault in gdb.