[CMake] Finding dynamic libraries with major interface revision numbers (2)

Jean-Christophe Fillion-Robin jchris.fillionr at kitware.com
Wed Apr 13 17:18:18 EDT 2011


Thanks Michael

Doing the following ends up working ...

IF(UNIX)
  # If the faster 'gold' linker is used, to avoid complaints about undefined
symbol
  # '_gfortran_concat_string', '_gfortran_pow_i4_i4', ... , let's link
against gfortran libraries.
  # These errors happen while linking against VTK static built with R
support
  SET(CMAKE_FIND_LIBRARY_SUFFIXES_SAVED ${CMAKE_FIND_LIBRARY_SUFFIXES}) #
Backup
  LIST(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".so.3")
  FIND_LIBRARY(GFortran_LIBRARY gfortran)
  SET(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_SAVED}) #
Restore
  LIST(APPEND EXTRA_LIBRARIES ${GFortran_LIBRARY})
ENDIF()

Thanks
Jc


On Wed, Apr 13, 2011 at 4:08 PM, Michael Hertling <mhertling at online.de>wrote:

> On 04/13/2011 09:26 PM, Brad King wrote:
> > On 04/13/2011 02:44 PM, Jean-Christophe Fillion-Robin wrote:
> >> Is there a solution to find a library having a revision number ?
> >
> > You can specify the actual library file name "libgfortran.so.3".
>
> AFAIK, this is not sufficient because FIND_LIBRARY() only looks for
> library files - specified literally or not - which end with a suffix
> mentioned in FIND_LIBRARY_SUFFIXES. See the following CMakeLists.txt:
>
> CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
> PROJECT(XYZ NONE)
> SET(CMAKE_VERBOSE_MAKEFILE ON)
> FILE(WRITE ${CMAKE_BINARY_DIR}/libxyz.so.3 "")
> SET(CMAKE_FIND_LIBRARY_SUFFIXES ".so.3")
> FIND_LIBRARY(XYZ libxyz.so.3 PATHS ${CMAKE_BINARY_DIR} NO_DEFAULT_PATH)
> MESSAGE("XYZ: ${XYZ}")
>
> First, ${CMAKE_BINARY_DIR}/libxyz.so.3 is found, but if you remove the
> SET(CMAKE_FIND_LIBRARY_SUFFIXES ...) command and unset the XYZ cache
> entry, you'll probably see libxyz.so.3 not being found anymore. It is
> cmFindLibraryHelper::SetName() that implements this behaviour, if I'm
> not mistaken. So, a possible workaround is to temporarily add ".so.3"
> or whatever is desired to CMAKE_FIND_LIBRARY_SUFFIXES before calling
> FIND_LIBRARY(), cf. [1].
>
> Regards,
>
> Michael
>
> [1] http://www.mail-archive.com/cmake@cmake.org/msg35219.html
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>



-- 
+1 919 869 8849
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110413/68b4f16f/attachment.htm>


More information about the CMake mailing list