Let me describe what I think is a sufficiently common use case, that it should be supported. Consider a project which consists of a library and a set of executable that use that library. A straightforward approach is to add_library, followed by a sequence of add_executable() target_link_lib() pairs.
This is a lot of boilerplate coding. It would be nice to able to do something like set(PROJECT_LINK_LIBS, lib1 ...), and have cmake remove the extra boilerplate.
Thinking on this more, I realize I would like a link_libraries function that behaves similarly to include_directories. I would argue that this:
Is there anything like this?
As mentioned at https://stackoverflow.com/a/50295894/129550 the requested link_libraries(example example2)
function is actually now a part of cmake.
This answer might be obsolete:
Check the new set of variables CMAKE_<LANG>_STANDARD_LIBRARIES
Original Answer:
It appears that now a CMAKE_STANDARD_LIBRARIES
variable exists, where you can append the libraries according to your need. However, this variable seemingly expect full path to the libraries.
See here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With