Suppose project Foo depends on a library Bar that uses C++ internally, but was not properly linked, so foo would need to be linked with<div><br></div><div>1. $CC -shared -o libfoo.so *.o -lbar -lstdc++</div><div><br></div>
<div>or</div><div><br></div><div>2. $CXX -shared -o libfoo.so *.o -lbar</div><div><br></div><div><br></div><div>Note that</div><div><br></div><div>find_library (LIBSTDCXX NAMES stdc++)</div><div><br></div><div>does not work because this library is often not in a public directory, so a full path cannot be resolved. My understanding is that current recommended practice is to use option 2 above, but this breaks down if Foo also needs to link some Fortran libraries because you can't link using both the C++ compiler and the Fortran compiler.</div>
<div><br></div><div>If the Fortran and C++ compilers come from the same suite, passing a literal "-lstdc++" will generally work, but this is not robust if they come from different suites. Is there a way to mark a library as depending on a language or some other internal compiler library, so that CMake will sort out how to do the multi-language link in the same way it does if the project has source files in each language?</div>