-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Fix CMake Windows system library deps #6980
Fix CMake Windows system library deps #6980
Conversation
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 don't know enough about Windows to comment if the fundamental approach is correct, but I do have some general nitpicks with this PR:
The three CI failures ( |
Yes, these CI failures are currently a know issue. |
dd26711
to
6108832
Compare
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.
LGTM
6108832
to
b485144
Compare
When finding dependencies from CMake, use a smarter regex to determine whether or not a dependency is actually a link argument, and pass through Windows link arguments properly.
On Windows, library dependencies can be passed with no prefix or suffix; rather than -lfoo or foo.dll, they can just be passed as 'foo'. CMake handles this and suffixes the library with '.lib' or '.dll', depending on the link mode. Do the same here, and if we've been passed an unqualified non-option bare name on Windows, add the appropriate suffix and pass it through to the linker. This fixes dependencies on system libraries.
When taking library dependencies from CMake, we first attempt to look the dependency up in the target list, then fall back to treating it as a path, which we add if the path exists. As there is no check for whether or not the path is really a path, this can cause false positives; for example if a 'uuid' dependency was passed intending to be a target, but it cannot be found and the current directory also contains a file or directory named 'uuid', we will just include the string 'uuid' in library dependencies. This is particularly prevalent on Windows, where a system library called 'version' exists, and thanks to case insensitivity will match a file called 'VERSION' if found in the source root when running Meson from the source directory, or a generated file when running Meson from the build directory. Fix this check to only look up filesystem existence on absolute paths, not unqualified. This also adds a fallback warning in case an argument cannot be found, rather than silently falling back.
b485144
to
f5f3805
Compare
These three commits fix linking of system libraries when declared as dependencies of CMake targets we pick up as Meson dependencies. In particular, when linking Clang into Mesa via CMake, we were dropping all of the system library dependencies such as
ole32
anduuid
… except if Meson was executed from the source directory, in which case we would retainversion
as a bare argument (since the Mesa source root has a file calledVERSION
), which would get passed through to the linker without a suffix qualification and fail the build.This PR attempts to do something more reasonable with system-library dependencies under Windows.
cc @dcbaker @jenatali