Use try_link to test compiler flags instead of checking for gcc specifically.