0

I want to create a module that allows a target to include multiple static libraries stored in the same directory.

The end goal is to allow a target to include -L<library dir> -l<staticlib-1> -l<staticlib-2> ... -l<staticlib-n> when linking.

I've tried using target_link_libraries like the following, which didn't worked:

    add_library(SomeTargetName INTERFACE)
    target_link_libraries(SomeTargetName INTERFACE "-L${SOME_TARGET_LIBRARY_DIR}" )

The above snippet causes the following error message:

INTERFACE_LIBRARY targets may only have whitelisted properties. The property "LINK_DIRECTORIES" is not allowed.

Does cmake support this kind of usecase? If so, how is it done?

RAM
  • 2,257
  • 2
  • 19
  • 41
  • `-L${SOME_TARGET_LIBRARY_DIR}` is no library. That's an option. `target_link_options`. And no, create a normal library. – KamilCuk Dec 17 '20 at 22:38
  • `target_link_options` was only made available since cmake v3.13, thus there must be a way to do this with without using it. And obviously yes, `-L` is not a library but a option [to add a directory to the search path](https://clang.llvm.org/docs/ClangCommandLineReference.html) which was the reason it was there to begin with and used as an example. – RAM Dec 17 '20 at 23:16

0 Answers0