I have figured out what the link command should look like on Mac, in order that gfortran48 builds a mixed language (C & Fortran, main program in Fortran) binary that is statically linked to all required gcc libraries. The link line should look like this:
gfortran48 -static-libgfortran -lgfortran -lgcc -lSystem -nodefaultlibs /absolute/path/to/libquadmath.a -mmacosx-version-min=10.6 -fbacktrace -O3 <object files> -o <executable name> It seems to me that the best way to do this in CMake is to use target_link_libraries ( targtet_exe /absolute/path/to/libquadmath.a ) along with set_target_properties ( target_exe PROPERTIES LINK_FLAGS "-static-libgfortran -lgfortran -lgcc -lSystem -nodefaultlibs -mmacosx-version-min=10.6 -fbacktrace -O3" ) both inside an if ( APPLE ) and if ( "${CMAKE_Fortran_COMPILER" MATCHES "GNU" ). Does this sound sane? Is there a better wa y to do this? Izaak Beekman =================================== (301)244-9367 Princeton University Doctoral Candidate Mechanical and Aerospace Engineering ibeek...@princeton.edu UMD-CP Visiting Graduate Student Aerospace Engineering ibeek...@umiacs.umd.edu ibeek...@umd.edu On Tue, Apr 15, 2014 at 5:24 PM, Zaak Beekman <zbeek...@gmail.com> wrote: > I have a problem with the static build on Mac OS X using gcc and gfortran > now, and I think the issue is with gfortran/Apple, not with CMake. (Things > work fine with the intel compilers too.) However, on the off chance that > someone has a fix or some advice I thought I would run the issue past all > of you. > > On Mac the -static flag doesn't work because there is no way to statically > link against crt0.o and libSystem.dylib, but that's fine, these should be > present on any reasonable OS X system. AFAICT, gfortran and gcc have no > flag to specify that libquadmath should be statically linked. This library > is distributed with gfortran, and there is no guarantee that it will be > present on the end user's system. (I'd like to just be able to distribute > the compiled binary without the sources, build system, etc.) Also, moving > to an older version of gfortran is not an option since many new features > are required by the software. A static version of libquadmath is > distributed with gcc/gfortran and is available > at: /opt/local/lib/gcc48/libquadmath.a > > What is the best way to setup my link command using CMake so that the > binary executable is linked against the static libquadmath.a instead of the > .dylib version? (I couldn't find any examples or solutions via an extensive > search online.) > > After spending nearly the entire afternoon trying to create a statically > linked executable on Mac, now using gcc and gfortran instead of the Intel > compilers, I can understand the wisdom in not attempting to fully support > static builds: they are a royal pain! > > > > Izaak Beekman > =================================== > (301)244-9367 > Princeton University Doctoral Candidate > Mechanical and Aerospace Engineering > ibeek...@princeton.edu > > UMD-CP Visiting Graduate Student > Aerospace Engineering > ibeek...@umiacs.umd.edu > ibeek...@umd.edu > > > On Tue, Apr 15, 2014 at 10:56 AM, Zaak Beekman <zbeek...@gmail.com> wrote: > >> Brad, thanks so much for your help! From the online documentation it can >> be hard to figure out which variable/property controls certain features as >> someone with limited CMake experience. >> >> One strange detail I forgot was that this problem does not appear on >> Mac/OS X for the same project using the intel 13.x compilers. It seems on >> Mac all the implicit link libraries exist in static form. I'm going to poke >> around some more now that I know where to look and which variables to >> watch, etc. and I may file a bug report and/or submit a patch if I can >> determine a better but still safe way to detect required implicit link >> libraries. >> >> Thanks again for your help >> >> Izaak Beekman >> =================================== >> (301)244-9367 >> Princeton University Doctoral Candidate >> Mechanical and Aerospace Engineering >> ibeek...@princeton.edu >> >> UMD-CP Visiting Graduate Student >> Aerospace Engineering >> ibeek...@umiacs.umd.edu >> ibeek...@umd.edu >> > >
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake