Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: make an OpenImageIO_Util_static library and target #4190

Merged
merged 1 commit into from
Mar 23, 2024

Conversation

lgritz
Copy link
Collaborator

@lgritz lgritz commented Mar 17, 2024

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.

For the OpenImageIO_Util library, build a separately named static
version, even if otherwise we are building dynamic libraries.

This can be a help to applications that only need OpenImageIO_Util,
and not the whole 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 ustring in particular has singletons inside!
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. Beware particularly
about linking multiple libraries, which each might contain a static
OpenImageIO_util_static use the static util library in an application.
You have been warned!

Signed-off-by: Larry Gritz <[email protected]>
@lgritz
Copy link
Collaborator Author

lgritz commented Mar 19, 2024

Any opinions on this? Bad idea? Good idea? Or "ok idea, but let's make the default be OFF for now?"

@lgritz
Copy link
Collaborator Author

lgritz commented Mar 22, 2024

Objections? I'd like to merge this today if there's nothing standing in the way. We can always revise if anybody thinks the default should be to not build a static library.

@lgritz
Copy link
Collaborator Author

lgritz commented Mar 23, 2024

No objections -> merging

@lgritz lgritz merged commit d743c61 into AcademySoftwareFoundation:master Mar 23, 2024
26 checks passed
@lgritz lgritz deleted the lg-staticutil branch March 23, 2024 03:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant