<div dir="ltr">What happens when enable_language(Fortran) is invoked and CMake can not find the gfortran shared libraries? Would an error message be issued?(Of course I could just write a test case.)<div><br></div><div style>
I'm asking because I'm using a couple of Fortran programs in a big C++ project, and I don't use enable_language() but just use</div><div style>find_library(GFORTRAN gfortran ...)</div><div style>...</div><div style>
target_link_library(myProj $(GFORTRAN) ...)</div><div style><br></div><div style><br></div><div style>(Maybe not best practice, but works)</div><div style><br></div><div style>but in order to make it run I first need to go to the library director (/usr/lib64) and create a symbolic link from libgfortran.so.3 to libgfortran.so in order for the find_library() line to work. I think this issue has been discussed previously on this list.</div>
<div style><br></div><div style>I'm wondering if you may not have this issue, where libgfortran.so exists on your linux system, but not yet on your MinGW.</div><div style><br></div><div style>a</div><div style><br></div>
<div style><br></div><div style><br></div><div style><br></div><div style><br></div><div style><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/5/31 Brad King <span dir="ltr"><<a href="mailto:brad.king@kitware.com" target="_blank">brad.king@kitware.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 05/31/2013 05:47 AM, Leek, Jim wrote:<br>
> Oh, if there any cmake way to get the fortran link flags<br>
> I need to pass to g++? I know -lgfortran is all I need in<br>
> this case, but if there was a generic way to get cmake to<br>
> figure it out for me, that would be nice.<br>
<br>
</div>CMake is supposed to figure this out automatically.<br>
<br>
Whenever CMake enables a language (project or enable_language)<br>
such as C, CXX, or Fortran it detects the implicit link info<br>
that the compiler front-end passes to the linker for executables.<br>
It records this info in CMakeFiles/$v/CMake*Compiler.cmake<br>
files.<br>
<br>
Later when one uses add_library to create a Fortran library<br>
and then add_executable to create a CXX executable that<br>
links to the Fortran library, CMake knows that the link<br>
step will need both C++ and Fortran implicit libraries. It<br>
uses the C++ compiler front-end to invoke the link step but<br>
adds any implicit link information that it knows the Fortran<br>
objects will need and that the C++ front-end does not add.<br>
The -lgfortran flag is an example.<br>
<br>
I just checked and this does work on MinGW, at least with the<br>
MSYS Makefiles generator, g++, and gfortran.<br>
<br>
* What version of CMake are you using?<br>
<br>
* What generator are you using?<br>
<br>
* What is in the CMakeFiles/*/CMake*Compiler.cmake files<br>
for values like CMAKE_C_IMPLICIT_LINK_LIBRARIES?<br>
<br>
* Can you post a complete source example where it fails?<br>
<span class="HOEnZb"><font color="#888888"><br>
-Brad<br>
</font></span><div class="HOEnZb"><div class="h5">--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</div></div></blockquote></div><br></div>