try_run: No LINKER_LANGUAGE option
As noted in Discourse try_run()
is intended for single targets and there is a need to specify LINKER_LANGUAGE as CMake's arbitrary heuristic isn't always adequate. A specific problem across compilers is targets that are Fortran main program using C++ library. I would like try_run() to work like:
try_run(abi_run abi_compile
SOURCES main.f90 lib.cpp
LINKER_LANGUAGE Fortran
)
I want to use this try_run()
to ensure at CMake configure that C++ exception handling is working correctly with a Fortran main program. This is a problem when using compilers with ABI-compatibility issues like AppleClang with GFortran on macOS for example.
An example of a significant project for this is fortran-filesystem that uses C++17 filesystem stdlib from Fortran programs. If I can use C++ exception handling, it considerably simplifies the C++ code inside fortran-filesystem. Right now, I'm afraid to use C++ exception handling because the default macOS compiler is AppleClang with GFortran, where C++ exception handling is shaky, but fine with GCC + GFortran.
With this try_run()
I could warn users to use GCC with GFortran dynamically as needed.