[vtkusers] use FIND_LIBRARY to find multiple libraries

Dr. X xunlei at renci.org
Mon Feb 7 13:12:55 EST 2011


Hi All,
Can I use FIND_LIBRARY to find multiple libraries? This is what I want 
to do.
> FIND_LIBRARY(VTK_LIBRARIES_DEBUG
>     NAMES vtkCommon vtkIO vtkFiltering vtkGraphics vtkViews vtkRendering
>     PATHS ${VTK_LIBRARY_DIRS_DEBUG}
>     HINTS ${VTK_LIBRARY_DIRS_DEBUG}
>     REQUIRED
> )
CMake only find the first match - vtkCommon.lib.
This pagehttp://www.cmake.org/Wiki/CMake:How_To_Find_Libraries shows 
that you can handle multiple libraries with a single FIND_LIBRARY call.
> # - Try to find LibXml2
> # Once done this will define
> #  LIBXML2_FOUND - System has LibXml2
> #  LIBXML2_INCLUDE_DIRS - The LibXml2 include directories
> #  LIBXML2_LIBRARIES - The libraries needed to use LibXml2
> #  LIBXML2_DEFINITIONS - Compiler switches required for using LibXml2
>
> find_package(PkgConfig)
> pkg_check_modules(PC_LIBXML QUIET libxml-2.0)
> set(LIBXML2_DEFINITIONS ${PC_LIBXML_CFLAGS_OTHER})
>
> find_path(LIBXML2_INCLUDE_DIR libxml/xpath.h
>            HINTS ${PC_LIBXML_INCLUDEDIR} ${PC_LIBXML_INCLUDE_DIRS}
>            PATH_SUFFIXES libxml2 )
>
> find_library(LIBXML2_LIBRARY NAMES xml2 libxml2
>               HINTS ${PC_LIBXML_LIBDIR} ${PC_LIBXML_LIBRARY_DIRS} )
>
> set(LIBXML2_LIBRARIES ${LIBXML2_LIBRARY} )
> set(LIBXML2_INCLUDE_DIRS ${LIBXML2_INCLUDE_DIR} )
>
> include(FindPackageHandleStandardArgs)
> # handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE
> # if all listed variables are TRUE
> find_package_handle_standard_args(LibXml2  DEFAULT_MSG
>                                    LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR)
>
> mark_as_advanced(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARY )
>
However, this thread tells me otherwise. 
http://www.mail-archive.com/cmake@cmake.org/msg21545.html
> AFAIK, no. The usual way to do this is simply using find_library(
> TBB_LIBRARY tbb ) and additionally find_library( TBBMALLOC_LIBRARY
> tbbmalloc) and then produce the _LIBRARIES variable by putting the two
> together.
Would you please clarify? Thanks a lot.
x


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110207/a8b775ac/attachment.htm>


More information about the vtkusers mailing list