[CMake] Question about if/else in Cmake

Marcel Loose loose at astron.nl
Wed Mar 11 04:32:51 EDT 2009


Hi Sascha,

I recently ported our existing autotool tests for lib vs. lib64 to
CMake. I haven't thoroughly tested it yet, but I think it will suit your
needs. I use the CMake global property FIND_LIBRARY_USE_LIB64_PATHS to
record the use of either lib or lib64. Hope it helps.

Regards,
Marcel Loose.

<code>
  # Determine if lib64 has to be used. This is somewhat tricky for the
default
  # case, because: Debian puts 64-bit libs in /lib and 32-bit libs
in /lib32,
  # but SuSE and RedHat put 64-bit libs in /lib64 and 32-bit libs
in /lib.
  # We cannot use `uname -s`, since all distros return "Linux", hence we
must
  # test for the presence of these lib directories instead. To further
  # complicate matters, Debian distros may create a symlink /lib64;
therefore
  # we should make sure that /lib64 is a "real" directory, not a
symlink.
  if(DEFINED ENABLE_LIB64)
    if(ENABLE_LIB64)
      set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE)
    else(ENABLE_LIB64)
      set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)
    endif(ENABLE_LIB64)
  else(DEFINED ENABLE_LIB64)
    execute_process(COMMAND test -d /lib64 -a ! -L /lib64
RESULT_VARIABLE result
)
    if(NOT result)
      set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE)
    else(NOT result)
      set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)
    endif(NOT result)
  endif(DEFINED ENABLE_LIB64)
</code>


On Tue, 2009-03-10 at 21:27 +0100, Sascha 'saigkill' Manns wrote:

> Hello Alexander,
> 
> is this right?
> 
> SET( CONFIGFILE_PATH /etc/freeremoted CACHE PATH "Path find config file" 
> FORCE )
> SET( MODULEFILE_PATH /usr/lib CACHE PATH "Path find module file" FORCE)
> option(USE_LIB64_DIR "Enable this option to use lib64 instead of lib/" 
> FALSE)
> 
> Or must i run this Option extra?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090311/3d6daf9f/attachment.htm>


More information about the CMake mailing list