How do I specify different binaries to link against for Visual Studio debug and release, but be able to select either

How do I specify in CMAKE that binary file A is for debug and B is for release when linking, but in such a way I can still toggle between the two in VS and not have to do cmake … each time I need to switch between the two.

What do you mean by binaries?

Do you mean targets or system libraries?

target_link_libraries(consumer debug A optimized B)

See relevant docs.

This is the same thing with generator expressions and using PRIVATE to hide the dependencies.

target_link_libraries(foo PRIVATE


Are you sure the genex will survive the line breaks?

I have similar code in my own project.

:stuck_out_tongue: should have known it was just a parameter in target_link_libraries. Was thinking I had to put in a special logic block specifying it as for release. Thanks guys.

No problem just make sure to mark the question as answered.