Update CMakeLists.txt to fix gcc/clang++ issue (#5863)
This resolves an issue where using GCC as your C compiler but, say, clang++ as your CXX compiler produces
`error: unknown warning option '-Wno-dangling-reference' [-Werror,-Wunknown-warning-option]`
Co-authored-by: Kim Kulling <[email protected]>