FortranCInterface_VERIFY(CXX) fails to find flang fortran in the context of the large project
These lines
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.5)
PROJECT(Foo Fortran C CXX)
enable_language(Fortran)
enable_language(C)
enable_language(CXX)
include(FortranCInterface)
FortranCInterface_VERIFY(CXX)
succeed when they are run alone with FC=flang:
/usr/bin/c++ -O3 -DNDEBUG CMakeFiles/VerifyFortranC.dir/main.c.o CMakeFiles/VerifyFortranC.dir/VerifyC.c.o CMakeFiles/VerifyFortranC.dir/VerifyCXX.cxx.o -o VerifyFortranC -L/usr/local/flang/lib libVerifyFortran.a -lflangmain -lflang -lflangmain -lflangrti -lompstub -lexecinfo
However, when Trilinos (https://github.com/trilinos/Trilinos) runs the same lines from the depths of their cmake fines, internal testcase compilation fails there:
/usr/bin/c++ -O2 -pipe -fno-omit-frame-pointer -fstack-protector -fno-strict-aliasing -fno-omit-frame-pointer -O2 -pipe -fno-omit-frame-pointer -fstack-protector -fno-strict-aliasing -fno-omit-frame-pointer CMakeFiles/VerifyFortranC.dir/main.c.o CMakeFiles/VerifyFortranC.dir/VerifyC.c.o CMakeFiles/VerifyFortranC.dir/VerifyCXX.cxx.o -o VerifyFortranC libVerifyFortran.a -lflangmain -lflangmain -lflangrti -lompstub
/usr/bin/ld: cannot find -lflangmain
The command line in Trilinos run doesn't contain -L/usr/local/flang/lib
, this is the problem.
I have no idea where does it come from, and why is it missing, hence this bug report.
But the function FortranCInterface_VERIFY(CXX)
should work the same in any reasonable context.