check_ipo_supported is broken for multiple languages
Consider this case:
- CMAKE_C_COMPILER=clang
- CMAKE_Fortran_COMPILER=gfortran
check_ipo_supported(RESULT IPO_SUPPORTED LANGUAGES C Fortran)
IIUC, this would return true because individually, each language is supported. However, if a library has both C and fortran objects, people will check that IPO is supported, compile both clang and gfortran objects with lto, and then link with clang.
The solution to this problem is that check_ipo_supported
should link with the C compiler if given multiple languages (more specifically, link with the compiler that would be used if adding sources with multiple languages to a library).