1

I have a precompiled libary that also employes dynamically loaded plugins.

  • Library L (compoesd ba a library.lib and library.dll)
  • Plugin P (composed only by a plugin.dll)

I am defining the imported target of L as:

add_library(L SHARED IMPORTED)
set_target_properties(L PROPERTIES
  IMPORTED_LOCATION_RELEASE library.dll
  IMPLIB_LOCATION_RELEASE library.lib
)

set_target_properties(L PROPERTIES 
  INTERFACE_LINK_LIBRARIES P
)

How do I define the imported target for P and its properties?

If I define it as:

add_library(P MODULE IMPORTED)
set_target_properties(P PROPERTIES 
  IMPORTED_LOCATION_RELEASE plugin.dll
)

Then the generated projects using L will erroneously consider plugin.dll as the lib to be linked. I would like instead to keep the dependency (so that I can transitively install plugin.dll) but avoid L to link target P

Pierluigi
  • 2,162
  • 1
  • 24
  • 39

1 Answers1

1

I have ended up solving this by not linking L to P using INTERFACE_LINK_LIBRARIES.

I am configuring L by adding an additional variable containing its plugins:

LIST(APPEND L_PLUGINS P)

The targets using L can get access to its plugins by simply using the variable ${L_PLUGIN} (e.g. in order to install its files)

NB: This is the same approach used by Qt plugin components

Pierluigi
  • 2,162
  • 1
  • 24
  • 39