[CMake] CMAKE_SIZEOF_VOID_P question

Thomas Nilefalk thomas at junovagen.se
Sun Apr 16 08:47:20 EDT 2017


Ghislain Vaillant skrev:
>> Next question is then why doesn't GNUInstallDirs set
>> CMAKE_INSTALL_LIBDIR as I expect on Ubuntu for the example I gave?
>>
>> I am expecting to see either lib64/lib (for 64/32 bit) or a triplet for
>> (32-bit). Now it's always 'lib'.
>
> Debian / Ubuntu injects this additional triplet for multiarch support
> [1]. As far as you are concerned, you can safely ignore this detail.
>
> [1] https://wiki.debian.org/Multiarch
>
> Ghis
I'm not sure I understand what you mean by "ignore" or exactly what I 
should ignore. All I want is that CMake installs libraries in a place 
that the linker will find them depending on the target architecture. 
With "target architecture" I mean either a 32-bit compile and link or a 
64-bit compile and link. For all 64bit unixen that I know, you can also 
compile for 32bit architectures (with GCC-compatible compilers) and run 
them on the same OS.

Do you mean I should ignore the whole "where goes my library" issue, or 
just fact that the triplet may or may not be used?

To enable a 32bit compiled application to find the 32bit version of my 
library it should install in a place where the linker looks for those:
> gcc -m32 -Xlinker --verbose  2>/dev/null | grep SEARCH | sed 
> 's/SEARCH_DIR("=\?\([^"]\+\)"); */\1\n/g'  | grep -vE '^$'
> /usr/i386-linux-gnu/lib32
> /usr/x86_64-linux-gnu/lib32
> /usr/local/lib/i386-linux-gnu
> /usr/local/lib32
> /lib/i386-linux-gnu
> /lib32
> /usr/lib/i386-linux-gnu
> /usr/lib32
> /usr/local/lib
> /lib
> /usr/lib
and dito for a 64bit version:
> gcc -m64 -Xlinker --verbose  2>/dev/null | grep SEARCH | sed 
> 's/SEARCH_DIR("=\?\([^"]\+\)"); */\1\n/g'  | grep -vE '^$'
> /usr/x86_64-linux-gnu/lib64
> /usr/local/lib/x86_64-linux-gnu
> /usr/local/lib64
> /lib/x86_64-linux-gnu
> /lib64
> /usr/lib/x86_64-linux-gnu
> /usr/lib64
> /usr/local/lib
> /lib
> /usr/lib
As we can see the triplets are there, for sure.

And since I want the two versions to exist side-by-side on the same 
system, I was hoping that GNUInstallDirs did something intelligent with 
its knowledge of the CMAKE_SIZEOF_VOID_P. And it turns out it does on 
some systems. E.g on WSL with Ubuntu 14.04 and a native (64-bit) compile 
CMAKE_INSTALL_LIBDIR is set to  "lib/x86_64-linux-gnu" and with "-m32" 
(32bit) it is set to "lib". But on Ubuntu 16.10 it seems to generate 
"lib" for both cases.

Is this a bug with GNUInstallDirs?

/Thomas



More information about the CMake mailing list