I'm trying to loop over a list with library names in CMake. In each iteration I search the library with find_library
:
set(LIB_NAMES "TKBO;TKBRep;")
set(LIBS_DIR /usr/local/OCCT/7.2.0/libd)
FOREACH(LIB_NAME ${LIB_NAMES})
FIND_LIBRARY(LIB ${LIB_NAME} PATHS ${LIBS_DIR})
MESSAGE("<<${LIB_NAME}>>")
MESSAGE("<<${LIB}>>")
target_link_libraries(mySharedLib ${LIB})
ENDFOREACH()
For the above, I get the output:
<<TKBO>>
<</usr/local/OCCT/7.2.0/libd/libTKBO.dylib>>
<<TKBRep>>
<</usr/local/OCCT/7.2.0/libd/libTKBO.dylib>>
While LIB_NAME updates, FIND_LIBRARY
seems to be using an outdated value. I also tried to explicitly UNSET(LIB_NAME)
at the end of the loop but that didn't help either.
What could I be overlooking?