My question is related to Link library based on build configuration and Debug and Release Library Linking with CMAKE (VISUAL STUDIO), however the answers were not satisfying.
My goal is to have one variable where to specify the path to libraries similar to
SET(LINK_LIBRARY optimized Foo debug Foo_d)
target_link_libraries(MyEXE ${LINK_LIBRARY})
But what I want is to have one variable for a bunch of libraries, that I can dispatch to a single call to target_link_libaries()
. So something like
SET(LINK_LIBRARIES optimized Foo Foo1 Foo2 debug Foo_d Foo1_d Foo2_d)
target_link_libraries(MyEXE ${LINK_LIBRARIES})
But all over the internet I find that this is not possible in this way, i.e. that I always have to write
target_link_libraries(MyEXE optimized Foo optimized Foo1 debug Foo_d debug Foo1_d)
which means I can't just put all the libraries in one single variable LINK_LIBRARIES
, but need FOO_LIBRARY
, FOO1_LIBRARY
aso.
Is there a way to do this or do I always have to create one variable per single library?