[CMake] Fortran MinGW on Windows
Alain Leblanc
aalebl at gmail.com
Fri May 31 13:35:51 EDT 2013
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.)
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
find_library(GFORTRAN gfortran ...)
...
target_link_library(myProj $(GFORTRAN) ...)
(Maybe not best practice, but works)
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.
I'm wondering if you may not have this issue, where libgfortran.so exists
on your linux system, but not yet on your MinGW.
a
2013/5/31 Brad King <brad.king at kitware.com>
> On 05/31/2013 05:47 AM, Leek, Jim wrote:
> > Oh, if there any cmake way to get the fortran link flags
> > I need to pass to g++? I know -lgfortran is all I need in
> > this case, but if there was a generic way to get cmake to
> > figure it out for me, that would be nice.
>
> CMake is supposed to figure this out automatically.
>
> Whenever CMake enables a language (project or enable_language)
> such as C, CXX, or Fortran it detects the implicit link info
> that the compiler front-end passes to the linker for executables.
> It records this info in CMakeFiles/$v/CMake*Compiler.cmake
> files.
>
> Later when one uses add_library to create a Fortran library
> and then add_executable to create a CXX executable that
> links to the Fortran library, CMake knows that the link
> step will need both C++ and Fortran implicit libraries. It
> uses the C++ compiler front-end to invoke the link step but
> adds any implicit link information that it knows the Fortran
> objects will need and that the C++ front-end does not add.
> The -lgfortran flag is an example.
>
> I just checked and this does work on MinGW, at least with the
> MSYS Makefiles generator, g++, and gfortran.
>
> * What version of CMake are you using?
>
> * What generator are you using?
>
> * What is in the CMakeFiles/*/CMake*Compiler.cmake files
> for values like CMAKE_C_IMPLICIT_LINK_LIBRARIES?
>
> * Can you post a complete source example where it fails?
>
> -Brad
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130531/8a18ab91/attachment.htm>
More information about the CMake
mailing list