build: make an OpenImageIO_Util_static library and target #4190
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add a
OpenImageIO_BUILD_STATIC_UTIL_LIBRARY
CMake variable that, if enabled, will build a separately named static version of the OpenImageIO_Util library, in addition to the dynamic one. It has a separate name, libOpenImageIO_Util_static, and a separate exported cmake target,OpenImgaeIO::OpenImageIO_Util_static.
This can be a help to applications that only need OpenImageIO_Util, and not the main OpenImageIO library, and furthermore would prefer a static library so they don't need a runtime dependency on our dynamic libraries.
Cavat emptor: Beware that there are singletons inside ustring, the oiio thread pool, and possibly others I'm not remembering at the moment. It could be a bad thing to have an application that contains both the static and dynamic versions of libOpenImageIO_Util, or to have multiple copies of the static library inside the same executable (including transitively through dependency libraries that were built independently). You have been warned!
Note also that this is swimming upstream in cmake land. For reasons I never quite understood, cmake assumes that a project wants to build either static or dynamic libraries, but provides little direct support for doing both in the same build. So we're taking the matter into our own hands, perhaps. If somebody thinks the way I'm proposing is very wrong, please do speak up.