build: check c++ compliler flags seperately

Flags for C and C++ compiler need to be checked seperately since
the c and c++ compiler might not support the same flags (even if
they are the same version).
build: define -D__FILE__ only for Release builds
Merge pull request #1829 from bmiklautz/fix/cxxflags

Detect and set CXX flags separately