[CMake] Tell find_package to look only for 32bit libs (or specify the exact location)

Michael Wild themiwi at gmail.com
Wed Aug 18 04:34:31 EDT 2010


On 18. Aug, 2010, at 9:49 , Nils wrote:

> Hi
> 
> I have to build my program 32bit on my Mac running OSX 10.6. I use
> find_package to find gtest, however it always finds the 64bit lib
> installed in /usr/local instead of the 32bit lib installed in
> $HOME/Develop/gtest32 even if I adjust the path later in cmake-gui!
> 
> So now my questions.
> 
> 1. Is there a way to tell find_package to only look for 32bit libs?
> 2. Is there a way to tell find_package to look only in a specific path?
> 
> Moreover I don't understand where OSX stores 32bit compatibility
> libraries, but this is more a mac related question.
> 
> Nils

Well, on Mac it is not usual to have separate 32 and 64 bit binaries. Apple uses so called "fat" binaries instead, where a single file contains code for multiple architectures and the loader jumps to the right offset at runtime.

I'd recommend recompiling gtest as a such a fat binary. This is the cleanest solution. You can do so by using CMake and setting the option CMAKE_OSX_ARCHITECTURES to i386;x86_64.

If you insist on specifying the exact location, set the GTEST_ROOT variable (either as an environment variable or in the cache using -DGTEST_ROOT=$HOME/Develop/gtest32).

HTH

Michael



More information about the CMake mailing list