[CMake] foreach and find_library
Werner Smekal
smekal at iap.tuwien.ac.at
Thu Feb 22 16:09:02 EST 2007
Hi,
try to unset/clear FOUND_LIB with
SET(FOUND_LIB)
before the find_library call - if this variable is set, find_library
just returns (at least I think so).
Werner
bpwlist at cox.net wrote:
> Hi,
>
> I'm trying to construct a list of external libraries. This list needs to include the full path and name of each library. This list is to be used with the INSTALL(FILE) command. I'm trying to use FIND_LIBRARY inside a FOREACH loop command to accomplish this. For example:
>
> SET (LIBS ${OSG_LIBRARIES})
> SET (SEARCH_PATHS ${OSG_LIBRARY_DIR})
> FOREACH (LIB ${LIBS})
> FIND_LIBRARY(FOUND_LIB ${LIB} PATHS ${SEARCH_PATHS})
> MESSAGE("Lib: ${LIB}")
> MESSAGE("Found Lib: ${FOUND_LIB}")
> ENDFOREACH(LIB)
>
> This yields the folowing output:
>
> Lib: osg
> Found Lib: /proj/visual/OSG/OpenSceneGraph/lib/Linux32/libosg.so
> Lib: osgUtil
> Found Lib: /proj/visual/OSG/OpenSceneGraph/lib/Linux32/libosg.so
> Lib: osgDB
> Found Lib: /proj/visual/OSG/OpenSceneGraph/lib/Linux32/libosg.so
> Lib: osgGA
> Found Lib: /proj/visual/OSG/OpenSceneGraph/lib/Linux32/libosg.so
> Lib: osgFX
> Found Lib: /proj/visual/OSG/OpenSceneGraph/lib/Linux32/libosg.so
> Lib: osgSim
> Found Lib: /proj/visual/OSG/OpenSceneGraph/lib/Linux32/libosg.so
> Lib: osgParticle
> Found Lib: /proj/visual/OSG/OpenSceneGraph/lib/Linux32/libosg.so
> Lib: osgText
> Found Lib: /proj/visual/OSG/OpenSceneGraph/lib/Linux32/libosg.so
> Lib: OpenThreads
> Found Lib: /proj/visual/OSG/OpenSceneGraph/lib/Linux32/libosg.so
>
> The code only finds the first library. If I unroll the variable by hand and use a different output variable name with each FIND_LIBRARY, it produces the correct output. Is this some weird scoping problem with variables? Is there a better way of accomplishing this?
>
> Thanks,
>
> Bryan Walsh
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
More information about the CMake
mailing list