Proper support for static vs dynamic dependencies in find_package and (Find|configure)-scripts
When building a project, one sometime needs to declare dependencies on a shared/dynamically-loaded variant of some library, sometimes on its static variant, and sometimes - on both.
However:
-
find_package()does not accept a parameter saying which of the variants is necessary. - AFAICT, a single target doesn't have both a "static aspect" and a "dynamic aspect"; nor is there a default naming scheme for static vs dynamic target names (e.g.
libfoo::libfoo_staticvslibfoo::libfoo_dynamicorlibfoo::static::libfoovslibfoo::dynamic::libfooor bikeshed this to your heart's content). - CMake-generation package configure scripts do not, by default, explicitly report/expose the staticness/dynamicness of the deployed package.
At the moment, some Find-scripts have a kind of jerry-rigged support for this, via pairs of targets, use of CMake options to control the Find-script behavior, etc. Otherwise, users can change CMAKE_FIND_LIBRARY_SUFFIXES - albeit in a platform-specific way - and have CMake only look for static variable files.
I request that:
-
find_package()support a staticness/dynamicness parameter similarly to the version requirement: Find any variant, find a static variant, find a dynamic variant, find both a dynamic and a static variant. This will be supported both in module mode and in configure mode. - Each find module / find script and each generated configure script be made able to handle the staticness requirement (with a minimal kind of handling being failing immediately saying "I don't know how to handle staticness".)
Bikeshedding:
- The exact parameter for
find_package()could beDYANMIC=<value>with<value>being one ofANY,STATIC,SHARED,BOTHand aliasesSHARED,YES,NO. Another possibility could be usingSHAREDorSTATICas the parameter name. A non-name-value option could be just any one or both of the keywordSTATICSHARED, and when none is specified - the search is for either static or shared. - Up to you whether to expose different targets or a single target which has a static and dynamic aspect to it. The latter option would agree more with the second, related bug I'm about to open.
Related StackOverflow questions:
Edited by Eyal Rozenberg