[CMake] Statically link OpenMP on Mac gcc
Rob McDonald
rob.a.mcdonald at gmail.com
Sat May 2 11:22:37 EDT 2015
On a Mac, using GCC's global -static is bad, so that doesn't work out.
However, as it turns out, -static-libgcc implies all parts of libgcc,
including libgomp. So, building with -static-libgcc -static-libstdc++
looks like the best solution.
Rob
On Thu, Apr 30, 2015 at 2:19 PM, Rob McDonald <rob.a.mcdonald at gmail.com> wrote:
> I'm using MacPorts GCC 4.8 and CMake 3.2.
>
> I use 'FIND_PACKAGE( OpenMP )', and then use OpenMP_C_FLAGS and
> OpenMP_CXX_FLAGS appropriately.
>
> My application works on the machine that I build on. However, users
> without MacPorts GCC installed can't find libgomp.1.dylib on their
> machine.
>
> I'd like to tell GCC to statically link libgomp. I think the global
> -static flag may do this, but it seems like a fairly brutish way of
> getting the job done.
>
> Is there a way to get CMake to tell GCC to statically link libgomp?
> Or to have more fine grained control over which libraries are static
> vs. dynamic?
>
> Is there any reason to not want to use the global -static?
>
> FindOpenMP.cmake isn't like most other Find*.cmake scripts -- instead
> of searching for a *.h, *.a, *.so, or *.dylib file, it checks various
> flags to the compiler -fopenmp, /openmp, etc. From that, it
> determines the appropriate flags, but there isn't any
> ${OPENMP_LIBRARIES} to use in a later TARGET_LINK_LIBRARIES later on.
>
> Thanks,
>
> Rob
More information about the CMake
mailing list