-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
[ffmpeg] use pkgconfig to get system dependencies for cmake #17985
[ffmpeg] use pkgconfig to get system dependencies for cmake #17985
Conversation
Just a side note, not against your work of course FindFFMPEG.cmake is slowly transforming irreversibly from a CMake module that is able to find FFMPEG, independently from how it's built, to a CMake config file tailored around the specific options. |
but again, this is a route that the module took some time ago, and this is just the final step. |
Thanks for your useful and considerate feedback @cenit - I'm sorry that I didn't think of that, and in retrospect I definitely should have mentioned this in my PR as an important consideration (and maybe discussed it first via an issue). Definitely with this patch there's little reason indeed then not to go for a cmake config file. IMO, having looked for quite some time at the complexity of the configure script, I don't think it is feasible to have a fully functional FindFFMPEG script that would work reliably for all possible platforms and variations of ffmpeg builds. Anyway, I'm happy to have a discussion and if there are good reasons not to this route and thus reject this PR, I'd be interested to hear them. I note that a cmake config could be generated as part of the configure process, which could be submitted to upstream ffmpeg after some testing here in vcpkg. Dealing with upstream ffmpeg is slow but I've managed to get some small patches applied. But I'm not sure to what extent support for generating a cmake config would be welcomed by upstream ffmpeg. Another route might be for the vcpkg cmake config to be able to import the pkg-config file. I don't know how to do that however. If someone knows this is possible and can point me to some examples, I'd be happy to investigate. One question though, if folks agree we should go for the config route: should this then be turned into an unofficial cmake config (with the unofficial prefix), as in for instance https://github.com/microsoft/vcpkg/blob/master/ports/libvpx/unofficial-libvpx-config.cmake.in and other ports that provide non-upstream cmake configs? Or should we stick with FFMPEGConfig.cmake so find_package(FFMPEG) keeps working? I assume FFMPEGConfig.cmake would be preferred to keep compatibility? |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
to be totally honest, i never understood the unofficial prefix. it's just a way to ask for more patches and future work. Let's keep it this way so that you don't have to fix dozen of ports that would become broken (do not think only about ports here, but also private ports that expects to work with find_package(FFMPEG)) otoh, if you want to try to upstream the config after some testing here, for me that would be wonderful. I know it will be slow and difficult and maybe undesired by ffmpeg maintainers, but at least you had a chance of success and so you are in a better position :) |
Sounds like there's a plan then. I'd prefer this to be merged first, and then work towards a proper config at a later time, if that's ok. And thanks for rerunning CI. Looks like there's a failure of opencv4, fortunately only on linux. I tried to reproduce locally and this looks related to an issue with png detection, unrelated to this patch? Here's my local build log:
|
Opencv:x64-linux failed on CI testing:
config-x64-linux-dbg-err[1].log |
Many thanks for the logs. Somehow I'm hitting some other errors and not this one, but I think I should be able to fix this error from the log message. |
I still cannot build opencv4 locally on linux with vcpkg but I've found a way to reproduce some link errors on linux using a test application. I think it's related to the link order when linking against a large number of libraries; I'll put this back to draft status for the time being until I'm sure it's all ironed out. |
[off topic] |
Absolutely, I plan have a separate detailed look at opencv4 on x64-linux when I have some time. It's a useful port for testing the vcpkg ecosystem, especially ffmpeg, so I really would like to be able to build it myself on x64-linux for local testing. I'll do some more investigation (probably next week) and will either post an issue or PR about it. Anyway, my own test succeeds for me locally now (indeed library ordering was the problem), but azure opencv4 still isn't happy. 😕 Any chance to look again at the build logs @PhoebeHui ? |
are you sure you are building the same opencv4 as CI? |
I did that special port to test as many features as possible because otherwise they were getting rotten extremely quickly due to other updates. |
Yes, I tried precisely those features. However, I just found that after merging the latest master, opencv4[ffmpeg] locally builds successfully. 🤦 I've pushed the merge just now, hopefully that makes azure happy again. 🤞 |
@mcmtroffaes, the opencv4:x64-linux still failed with same error as before in CI testing. I will try to build it in my VM. |
Many thanks @PhoebeHui - it's odd that it gives the exact same error... I got exactly the same error compiling a test application against ffmpeg (with the same feature set as in vcpkg CI), and 4d68c69 solved that error for me. Then I ran into some linking errors which were fixed in 2049bd6. Anyway, I'm getting closer to building opencv4 locally with the same feature set as in vcpkg CI on linux. There are many system dependencies on linux for some of opencv4's requirements, which is the main thing slowing me down (and which might also explain my earlier problems). But hopefully that will tease out the error eventually. I will report once it's done. |
you can see here https://github.com/microsoft/vcpkg/blob/master/scripts/azure-pipelines/linux/provision-image.sh how linux image is provisioned in azure for the CI system (all system dependencies that are installed) |
Opencv4 cascade due to the dependency ports cascade or skip in CI testing. Some of them are feature dependent ports, so this should not affect local test, I think test the core and feature 'ffmpeg' is fine, @cenit, do you think so? The dependency ports with x64-uwp in CI testing: |
I found the culprit, it's openh264:
|
:( @mcmtroffaes I know it's misleading, but green badge sometimes just means "I had no opportunity to test so I won't tell you it's broken". With @BillyONeal I have an open issue on exactly this problem, because any cascade failure is not marked as a problem in the PR first triggering it |
I noticed that openh264 is marked as Anyway, I've added a commit to remove the feature from |
The 'supports' field only works in CI testing. |
Ah, thanks for clarifying that! |
avcpp with x64-uwp and arm-uwp failed with same error:
|
@mcmtroffaes happy that you found out that opencv was cascaded by your own modifications and that now is verified (and working) in CI not so happy that unblocking ffmpeg on uwp you now uncovered other ports that were dormant but broken |
is ffmpeg or one of those ports declarating /sdl or /we4996 ? If yes, it might just require removing those flags from the compiler flags |
Not that I know. It looks like avcpp might be the cause; see https://github.com/h4tr3d/avcpp/blob/master/src/avutils.h#L27 I'm not certain yet this is the cause but I'm working on a patch. |
Thanks so much @PhoebeHui for your patience and helping with the error logs: I appreciate your diligence. I've added a quick patch for the uwp issue, pleased to see it all green again on uwp. |
@mcmtroffaes @cenit, opencv4 with arm-uwp and x64-uwp passed in CI testing, appreciate your effort very much! @strega-nil-ms, could you please help further review? |
Merged master & bumped port version. |
LGTM thanks @mcmtroffaes :) |
Thanks so much for the merge! |
What does your PR fix?
This PR uses the config.mak file generated during the build process to get all system dependencies. This ensures that only the required system dependencies are included, and future-proofs the port against changes in such dependencies, which are a pain to track. This substantially simplifies the FindFFMPEG.cmake script and makes it more robust and easier to maintain. It also ensures that FindFFMPEG.cmake lists the same dependencies as the generated pkg-config file. I've noticed that for many builds the dependencies are slightly different (sometimes more, sometimes less) from what the old FindFFMPEG.cmake did, so presumably this PR also might fix some subtle bugs with less often used functions that need those libraries.
One change I do point out concerns non-static builds: some dependent libraries were only used in the FindFFMPEG.cmake script in static builds: see the
set(ENABLE_* ${STATIC_LINKAGE})
lines in the original portfile. This is not what the upstream pkgconfig file does, however. With this PR, dependencies will be listed exactly as in the pkgconfig file. I think it's a price worth paying for keeping things simple.Finally, I note that many past pull requests for the ffmpeg port have been concerned with fixing dependencies across platforms. My hope is that this PR will result in a more stable port in the long term, and less time wasted on chasing dependency fixes.
I've thoroughly tested the PR on linux, osx, and windows triplets (see https://travis-ci.com/github/mcmtroffaes/ffmpeg-msvc-build/builds/225915669 - this has one failure but that's addressed in [openh264] only build shared or static library #17592 and also https://ci.appveyor.com/project/mcmtroffaes/ffmpeg-msvc-build/builds/39162659).
Which triplets are supported/not supported? Have you updated the CI baseline?
No changes to baseline. No changes to supported triplets.
Does your PR follow the maintainer guide?
Yes, to the best of my knowledge.
If you have added/updated a port: Have you run
./vcpkg x-add-version --all
and committed the result?Yes.