[CMake] How can I place a 64bit library build into /usr/lib64?
Matthew Woehlke
matthew.woehlke at kitware.com
Mon Jul 29 13:08:17 EDT 2013
On 2013-07-29 10:04, Theodore Papadopoulo wrote:
> cmake knows the difference for its internal search for libraries...
> I use this knowledge in the following manner:
>
> get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
>
> if ("${LIB64}" STREQUAL "TRUE")
I wouldn't recommend this. It probably will not be the case here, but if
the contents of "LIB64" happen to have another variable name (or if I am
mean and nasty and build your project with -DTRUE=FALSE), you will get
incorrect behavior.
Instead, just use:
if(LIB64)
> set(LIBSUFFIX 64)
> else()
> set(LIBSUFFIX "")
> endif()
>
> set(INSTALL_LIB_DIR lib${LIBSUFFIX} CACHE PATH "Installation
> directory for libraries")
> mark_as_advanced(INSTALL_LIB_DIR)
I would encourage you to instead use the more common LIB_SUFFIX
(expecting the user to set it), or include(GNUInstallDirs) as
recommended by Gregor.
> It would be good if cmake was automatically doing such an adjustement....
Maybe, and maybe not. If everyone was just in the habit of saying
'lib${LIB_SUFFIX}' for their install destinations, there wouldn't be an
issue :-). (Besides that it would break compatibility, I can imagine
there being cases where an automatic substitution would not be desired.)
--
Matthew
More information about the CMake
mailing list