fix(cmake): Make the cmake config files always pull in the required libraries#5211
fix(cmake): Make the cmake config files always pull in the required libraries#5211DarkDefender wants to merge 1 commit into
Conversation
|
|
…ibraries Without doing this, we could get link time errors as openimageio doesn't pull in the libraries correctly when using modern cmake targets. It would work when libraries have been installed globally on the system. But we shouldn't rely on the linker automagically finding the libraries in `/usr/lib` for example. Signed-off-by: Sebastian Parborg <sebastian@blender.org>
61368b8 to
c9cbf03
Compare
|
I'm a little confused about the circumstances we're talking about. These libraries are not exposed in the public headers of OIIO, so projects downstream do not need to know where to find the include files, etc. The theory was that for static library libOpenImageIO.a, static libs don't inherently know about their link needs, so the downstream app using OIIO needs to know about those targets in order to know to link the libraries to the final app. For dynamic library libOpenImageIO.so, it knows where which libraries it in turn needs, so our belief was that this takes care of it all and the downstream didn't need to know about the targets. So we only did the But you're saying: no, libOpenImageIO.so might know it needs to link against libtbb.so (say), but it doesn't know where to find it if it's not in a standard place. So even for dynamic libOpenImageIO, it would be better for the exported cmake config to establish and use the targets for all the dependencies. OK, I can buy that. But in that case, I think the solution is to just get rid of the |
|
Oh, and it's probably worse than that, all the CI is failing. How does this happen? Did you not run CI at all prior to submitting the PR? |
Not all of the CI pipeline is failing. Out of all 30 checks 8 is failing. If I read the logs correctly it seems like it fails because it can't find some image files? I looked at the contribution guidelines and there it says that if the majority for the CI tests pass (which I think 22 passing out of 30 is the majority), then it is OK to submit a PR and figure out what is wrong in the PR. I'm not really sure why this cmake change would make the tests fail they way they are. I would think that there would be at least some cmake output hinting that it can't find the required libraries if that were the case. Do you have any clue what is going on?
Some of the libraries have exposed symbols in the
Ah, I see! I thought this was on purpose. I guess then perhaps the correct solution is to not expose these symbols in the OpenImageIO library and only expose OpenImageIO specific APIs? |
|
You can check the exported symbols on linux with For example you can see that the libOpenImageIO.so does export OpenEXR functions: There is also opencolorio, imath, and other library symbols in there. |
|
No, that's just the downstream symptom. The tests that are failing are cmake-consumer and docs-examples-cpp. These are the two tests that try to build something as if it were a downstream project, and thus consuming the exported cmake config that you altered. (Whereas all the 200+ other tests are just using the OIIO build components directly, within the OIIO build system so to speak, rather than acting like a separate project that doesn't have access to our own build scripts.) If you download the saved artifacts from those jobs, it also contains the build logs from those secondary builds, and for example cmake-consumer looks like: So we can make sure the export contains
I believe they do not. They only have recorded OpenImageIO's need for those symbols to be resolved. They are not exported symbols.
We already do that. I think you cannot use that from downstream apps, because there are no function declarations for those OpenEXR functions anywhere in OIIO's header files, and OpenImageIO library doesn't provide the implementations. But the fact that a downstream project can't use those definitions directly is not an important detail here, because it's still true that libOpenImageIO needs those symbols to be resolved at runtime so that IT can call the functions internally. It needs to be found at load time in order to execute. The libOpenImageIO.so library itself knows it needs libOpenColorIO.so (whereas libOpenImageIO.a, as a static library, would not), but it still assumes that there are enough clues at runtime to FIND that library. This is the function of the I believe that is the key here. I think that changing the cmake exports is not really going to fully solve the problem (and may create new ones). I think the real solution is that if you are going to store required libraries in a nonstandard place, you should expect to need to put those nonstandard locations in your |
Without these changes, we could get link time errors as openimageio doesn't pull in the libraries correctly when using modern cmake targets. It would work when libraries have been installed globally on the system. But I don't think we should rely on the linker automagically finding the libraries in
/usr/libfor example.Especially because we can make this a lot better by warning/erroring out in the cmake setup step when we can't find all required libraries.
I added the libraries that I saw show up in
OpenImageIOTargets-release.cmakeunder theOpenImageIO::OpenImageIOtarget properties on my system.Minimal test example
Create a text project with this C++ file called
main.cxx:And this
CMakeLists.txtfile:ENSURE that you do not have OpenColorIO or OpenEXR installed globally on your system.
Make sure that you have
git-lfsinstalled and configured on your system and then clone the precompiled linux libraries from blender into alibsdirectory next to the other files:git clone https://projects.blender.org/blender/lib-linux_x64.git libsNow if you run cmake and then try to build you will get a lot of errors like the ones below at link time:
Go and edit the
libs/openimageio/lib/cmake/OpenImageIO/OpenImageIOConfig.cmakefile and add the following on line 42:Clean out the cmake build files and rerun cmake and try to build again.
Notice that the build finishes without any linker errors.
I don't know if there is any easy way to add tests for this in the test suite, so that is why I left that box unchecked.
Checklist:
and if I used AI coding assistants, I have an
Assisted-by: TOOL / MODELline in the pull request description above.
behavior.
PR, by pushing the changes to my fork and seeing that the automated CI
passed there. (Exceptions: If most tests pass and you can't figure out why
the remaining ones fail, it's ok to submit the PR and ask for help. Or if
any failures seem entirely unrelated to your change; sometimes things break
on the GitHub runners.)
fixed any problems reported by the clang-format CI test.
corresponding Python bindings. If altering ImageBufAlgo functions, I also
exposed the new functionality as oiiotool options.