[CMake] [CMake BUG] CMake (2.8.12.2) adding extraneous libraries at the end of the link command

Zaak Beekman zbeekman at gmail.com
Tue Apr 15 17:24:17 EDT 2014


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
ibeekman at princeton.edu

UMD-CP Visiting Graduate Student
Aerospace Engineering
ibeekman at umiacs.umd.edu
ibeekman at umd.edu


On Tue, Apr 15, 2014 at 10:56 AM, Zaak Beekman <zbeekman at 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
> ibeekman at princeton.edu
>
> UMD-CP Visiting Graduate Student
> Aerospace Engineering
> ibeekman at umiacs.umd.edu
> ibeekman at umd.edu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140415/d2a2235c/attachment.html>


More information about the CMake mailing list