[cmake-developers] [PATCH] Allow LIB_SUFFIX be used as find path

Christian Schmidbauer ch.schmidbauer at gmail.com
Wed Jan 4 17:12:55 EST 2017


On Fri, Jun 17, 2016 at 8:10 PM, Brad King <brad.king at kitware.com> wrote:
> On 06/17/2016 01:33 PM, Christian Schmidbauer wrote:
>>> CMake sets the lib32/lib64 ones in its own
>>> platform modules for the relevant platforms so user code never
>>> needs to do it.  Where in user code would it be done?
>>
>> In my setup, I would create a custom my-config.cmake file
>
> And that is included from CMakeLists.txt files?
>
>> SET (FIND_LIBRARY_USE_CUSTOM_PATHS TRUE CACHE BOOL "force libx32 search path" FORCE)
>
> I think you meant to use set_property here.  It is not a cache entry.
> However, see below.
>
>> This way I can overwrite cmake's default lib32/lib64 search folders.
>> Why do you ask? Do you have a specific opinion about this?
>
> If the goal is to be able to override it for a local build then
> we shouldn't have to modify the project CMake code.  Setting the
> global property requires editing code.  The existing properties
> FIND_LIBRARY_USE_LIB{32,64}_PATHS make sense because they are
> configured by CMake as properties of the current system.
>
> Instead we could activate this behavior through a variable that
> could then be added to the cache on the command line via -D.
> That would allow local builds to configure any project to search
> this way.  For example:
>
>   cmake ../src -DCMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX=x32
>
> -Brad
>

I did not intend to use it for a local build. My idea of
"FIND_LIBRARY_USE_CUSTOM_PATHS" was the following:

Currently, cmake tries to detect the naming scheme for
lib/lib32/lib64, hence making the life of a distribution with
non-standard library folders very hard. This patch should allow a
distribution to set the naming scheme of the lib<qual> folder to
whatever they want (allowed should be anything, see [1]).

I don't have enough insight into cmake in order to say what would be
the "proper" way to achieve this. I went ahead and followed the logic
from Gentoo's portage (see [2] line 531-533) and tried to expand it
such that you can specify any string for <qual>.

If you have a better way to achieve this, I am all ears.

Best regards,
Chris

[1] http://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s10.html
[2] https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/cmake-utils.eclass?revision=1.114&view=markup


More information about the cmake-developers mailing list