-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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] FindFFMPEG.cmake needs to handle dependencies on libs from the WindowsSDK #38401
base: master
Are you sure you want to change the base?
Conversation
IMO this SDK setup doesn't belong into the domain of a particular port. |
probably better to add a |
No, this doesn't solve the problem of the library directory. |
We don't need the find_library call really, The linker will find the libraries it self, we can just pass in the lib files,. Something like this also works:
My main issue here is that I need to hard code the list of lib from the WindowsSDK, and the capitalization is off.. althoguh that seems to work anyway... Thoughts? |
Looks like you are mixing MinGW and Windows here? The gcc stuff should be implicitly linked except for stdc++ and atomic. If it is not implicitly linked that is your problem
These paths should be on a env variable which makes the linker lookup work. If it is not your build environment is not correctly configured. You probably want to configure env variable LIBS for your build environment. |
@Neumann-A We often run the cmake-gui without any starting it from a msvc developer console. This is what you get if you just start it from the start menu. When you do that the Windows SDK env variables will not be set. And hence the find_library will fail. I strongly support this usage, One should definitively not have to start cmake from a developer console. The relevant part in the code above for the MSVC build is just. (From the installed FindFFMPEG.cmake, vcpkg/ports/ffmpeg/FindFFMPEG.cmake.in Lines 44 to 75 in 90a5b03
The function append_dependencies is used for all platforms... but the exceptions put in there are mostly for non windows I guess Basically what needs to be done is to bypass the find_library call for the WindowsSDK libs. We don't need to provide absolute paths to them since the MSVC linker has the WindowsSDK path implicitly from my understanding. |
Which generator do you use? |
The MSVC one ("Visual Studio 17 2022") |
The generator should know about the used Windows SDK
|
So you are generating VS Solution from that. VS itself knows how to add the correct search paths. In that case |
Added the pragmas would work for getting the linker to link the lib. Although I would rather not have to figure out which of ffmpegs headers to add that to. Also seems quite invasive, to modify the headers to solve this link issue. And the issue with the find_library is still there. since the current solution in vcpkg it so gather those up from the pc files. so we still need to address that part to avoid having cmake file its configure set. |
If you want |
I rather avoid the call to find_library. My main question is who to know which libs that I should have by bass the call |
I can't answer the last question, but when it comes to the standard windows libs (
|
If it adds windows libs to the pc file it should do it verbatim, e.g. |
FFMpeg does add them verbatim to the pc file: for example libavdecice.pc
And x_vcpkg_pkgconfig_get_modules will pull in all of those, which later then gets added the to the FIndFFMPEG.cmake.
There is not any easy way to pick out windows libs here... |
Why? |
Because: After looking at the pc files is there a specific reason those libs are even listed in the pc file? They should probably be removed if they are intended to be linked by default on windows. |
seems CMAKE_C_STANDARD_LIBRARIES_INIT covers some of the libs from the WindowsSDK but not all |
What I want is a different behavior of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should just add psapi.lib. It's the toolset provider's responsibility to provide a working Windows SDK.
The written change assuming that the Windows SDK is in Program Files is not OK and will fail for many customers who do that deployment themselves to a different location.
31ffbd1
to
5d6f8d3
Compare
I've pushed a new version that just bypasses the find_library for the Win SDK libs, avoiding any need of find the winsdk path etc. Similar to how pthread etc is bypassed. |
ports/ffmpeg/FindFFMPEG.cmake.in
Outdated
elseif(lib_name IN_LIST windowsSDKLibs) | ||
list(APPEND ${out} "${lib_name}.lib") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks mingw.
(Why does this function transform these libs at all? IIUC the output goes to CMake, so literal atomic
, ws2_32
etc. should be fine. And CMake will transform it when generating link commands for a particular generator. This function just needs a single list of values which shall be passed literally instead of going through find_library
. And I probably removed the sources of gcc, gcc_s, stdc++ in #39077)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the PR to just pass the libs through without any modifications
5d6f8d3
to
eaa55e3
Compare
@@ -50,6 +50,7 @@ function(append_dependencies out) | |||
set(config RELEASE) | |||
set(path "${CURRENT_INSTALLED_DIR}/lib/") | |||
endif() | |||
set(windowsSDKLibs psapi uuid oleaut32 shlwapi gdi32 vfw32 secur32 ws2_32 mfuuid strmiids ole32 user32 bcrypt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set(windowsSDKLibs psapi uuid oleaut32 shlwapi gdi32 vfw32 secur32 ws2_32 mfuuid strmiids ole32 user32 bcrypt) | |
set(windowsSDKLibs psapi uuid oleaut32 shlwapi gdi32 vfw32 secur32 ws2_32 mfuuid strmiids ole32 user32 bcrypt) | |
cmake_policy(SET CMP0057 NEW) |
for IN_LIST.
(Push/pop/save/restore as you like, but IN_LIST should rarely be a problem.)
Lib list adopted for #39703. |
Fixes #23021
I quite my self from #23021 (comment)
I have created a solution that searched for the WindowsSDK using some poor heuristics.
And adds that as a PATH hint to the
find_library
calls mentioned above.If any one know of a better way to do this? suggestions are welcome.
./vcpkg x-add-version --all
and committing the result.