-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Vcpkg root fix #10904
Vcpkg root fix #10904
Conversation
This fixes a build error on the GitHub Ubuntu 22.4 workflow runner which has comes with VCPKG preinstaled
I think the proper fix would be to unset VCPKG_ROOT in the GitHub workflow file (or set it to empty string), not hack around in our cmakelists. If someone really wants to use vcpkg on Linux, I see no reason why we should disallow it. |
If you like to use VCPKG on Linux you can still do this by This way it happens explicit and not randomly only because someone has the environment variable VCPKG_ROOT set for another project. Finding out the root cause in this case took me many hours and I want to avoid do this ever again. |
I have also considered to not at all depend on |
I agree that this would be unfortunate. On the other hand, the current solution is pretty surprising, because it magically picks up the VCPKG_ROOT from the environment except on Linux. To keep stuff consistent across all OSes while still avoiding changing build setups, I'd rather override the env var on CI and leave the |
Let's see if this would even work. I pushed a POC here: https://github.com/Holzhaus/mixxx/tree/vcpkg-ci-fix |
For me it is not clear which use case you are targeting with your proposal. Please explain. Your solution unsettling VCPKG_ROOT works only on the GitHub workflow runner, but not at home. I think a default When I read this https://vcpkg.io/en/getting-started.html, it is obvious mandatory that the user has to set So it was probably wrong to make the whole block depending on VCPKG I think we should make sure this works on Linux as well and we are in a good shape. |
This PR also fixes an issue when you switch from main to the 2.3 branch on macOS. |
After the latest commit, we can build with any vcpkg installation via I have tested this here successfully with Ubuntu 20.4 and libmad and libopus installed with vcpkg see:
|
4ca9a12
to
98909cf
Compare
98909cf
to
86ad6b1
Compare
My main issue with your PR is that cmake picks up VCPKG_ROOT from the environment on Windows, but not on the OSes. From the user's perspective this is surprising and there is no obvious reason for this - in fact the only reason for this is that our CI setup uses vcpkg on only Windows, which is pure coincidence. I'd really like to avoid accumulating non-obvious special cases on the different OS which our users/contributors have to remember, especially when there is no actual reason for this. If we want to keep this consistent, which is what I'm advocating for, we have 2 options:
As you pointed out, breaking the build setups for our contributors would be unfortunate, so I'd suggest we use the latter approach.
Good point, we should unset that variable in the 2.3 buildenv script. |
Since we have not yet a real use case the discussion about whether picking up is surprising or not, it is kind of virtual. It is obvious that we must not pick up the environment variable of the system installed vcpkg of GitHub. That this exists, proves the assumption that the purpose of the VCPKG_ROOT variable is to find the system wide installation. It can be surprising if we pick it up on Linux since it is not supported in the same way as if we pick it not up because we do on Windows. The original intention matters. We have the following imaginative users:
Interestingly our non standard approach dealing with This gives me the idea how to help both. We can check whether the overlay folders exist. If not it is likely not our vcpkg tree and using VCPKG_ROOT surprising and unnecessary anyway. @Holzhaus Does this work for you? |
3eaa39b
to
556da26
Compare
It works. Now a plain |
@Holzhaus can you have another look. |
Thanks for looking into this, unfortunately the proposed solution still suffers from the same underlying issue. Now setting VCPKG_ROOT from env works if and only if the VCPK_ROOT directory coincidentally has an
Let's take a step back and reassess what the actual root problem that we are trying to solve is:
We could unset the variable in the GitHub virtual environments (I proposed this here: #10904 (comment)), but you correctly pointed out that this would not fix if someone has the variable set outside of the CI context. The only reason why this happens is that we use the VCPKG_ROOT variable for something that it was not originally intended for. We cannot get rid of the env variable configurtation altogether because it would break user's build setups and would also require OS-specific build instructions ("if you're using windows, you also need to pass As I explained above, I also don't think we should attempt to do heuristics to detect if the variable is set to an "expected" value (i.e. points to *our custom vcpkg root instead of a different one) as you proposed. I thought some more about this, and since we control both setting the variable from our buildenv script and reading the variable from CMake, we can just use a different environment variable (e.g., What do you think? |
Good idea |
Pre-commit fails due to trailing whitespace. |
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.
Pre-commit still complains about trailing whitespace.
tools/windows_buildenv.bat
Outdated
@@ -1,6 +1,6 @@ | |||
@ECHO OFF | |||
SETLOCAL ENABLEDELAYEDEXPANSION | |||
REM this � is just to force some editors to recognize this file as ANSI, not UTF8. | |||
REM this � is just to force some editors to recognize this file as ANSI, not UTF8. |
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 may have slipped in by mistake, or is this intentional?
LGTM except for the minor issues I pointed out in my review. Thanks! |
and fail build early in case it is not correctly set
0d9c522
to
3415b85
Compare
Thank you for review. The remaining issues are now fixed and squashed into the last commit. |
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, thank you.
@daschuer can you take care of merging to main? If not, I'll have a look tomorrow. |
Done, thank you. |
Use the VCPKG_ROOT environment variable only on windows. This fixes a build error on the GitHub Ubuntu 22.4 workflow runner which has comes with VCPKG preinstalled.
See: actions/runner-images@07e2db9