-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Support for disabling optional dependencies even if they can be found. #8224
Comments
"But people don't implement the ability to choose in their meson.build, therefore let's add new core meson features" is not really a convincing argument IMO. FWIW, I was initially introduced to the fact that this cmake "feature" exists, by someone who was calmly explaining to me why "our project does not need options, see, you could just use CMAKE_DISABLE_FIND_PACKAGE for everything if you know which dependencies are internally used by the features you don't want". I took a hard pass on that one. :( |
Yeah but what if there is something in there I don't want meson to pick up.
From experience it is the only effective one to disable package lookup completely. It is not spooky. Spooky is all the optional dependencies getting picked up by "build order" in vcpkg due to not being able to properly disable those deps or adding them as required dependencies to "correct" the build order (although they are optional).
It is. In the end user inability needs to be taken into account.
Read the docs: https://cmake.org/cmake/help/latest/module/FeatureSummary.html. In the end it doesn't matter how good a build system claims to be if the users writing the build scripts don't know how to do it properly. On the other hand the people packaging such libraries need escape hatches to not patch the hell out of every stupid build script they encounter (and no I don't have the time to correct every build script and submit the required changes upstream.). |
Them logically you don't want to tell meson where it can be found, you want to tell meson not to find it.
... of course you are. So DIR would be a duplicate, unneeded functionality if DISABLE_FIND_PACKAGE exists.
The root of the problem is people deliberately lying in their build descriptions. And if they're marking it "required" then meson is going to darn well respect that, so DISABLE_FIND_PACKAGE would lead to a configure time error due to missing required dependencies you manually told meson should be set as missing.
No, mildly tweaking the wording in order to say the same thing is still not a convincing argument. It's a convincing explanation of why you decided you want it, no more, no less. And it's still a project bug which is refusing to give the user an ability. Ask for feature options to toggle optional features.
That requires the project to both agree to support printing options/packages (and annotate them extensively) and not care about doing it properly with options. It also requires you to do a full configure cycle, get it wrong, then figure out what to do next time. |
I have actually, for real, told people "cmake sucks, don't use cmake. Cmake lets you do nonsense like DISABLE_FIND_PACKAGE instead of proper options. Use meson instead." It would feel pretty weird to me if meson then went around and added support for this misfeature. |
All packages are installed into the same installed dir so not setting the PKG_CONFIG_PATH would result in meson not finding any dependency so that is not an option.
You did not read my issue well enough. "On a different but related issue:". So no discussion about _DIR vars required.
disabling required packages is in general not possible and leads to an expected error. This is also the case in CMake.
no setup required. It will just not print a description in that case.
it is actually the same for meson in my case. (And it is actually the only correct way to do it.)
It is not nonsense it is just your inability to understand and use it correctly. People will always write bad build scripts no matter which buildsystem is used. I have seen my fair share of broken buildscripts in cmake/meson/autotools/qmake/plain make. It doesn't matter in the end. |
So, if I understand correctly, the main issue here is that some projects do stuff like: someDep = dependency('someDep', required: false)
if someDep.found()
# Do stuff you want to explicitly disable even if someDep is found
# and the user did not provide another toggle for this condition
endif If this is the case, I would suggest trying to find a solution for this particular use case, instead of arguing why/if exactly, |
I said "in order to achieve value out of FeatureSummary, you need to do setup". Your response is "you don't need to do setup if you don't use it at all"? I'm confused by your reply.
You might not have been aware, but it is NOT the same for meson. cmake does not support this. cmake only supports printing fully configured statuses after running the full configure cycle. I blame this on the fact that cmake does not HAVE options. Only internal state variables (used in turing-complete user scripting performing common snippets of library probing) within the cmake AST, which you can define on the command line.
It is my inability to philosophically view it as a good thing. Please don't tell me I don't "understand" it -- I understand it just fine. |
I can think of two solutions to fix this:
You should be, theoretically, already be able to do what you want with project('root', ['c'])
meson.override_dependency('zlib', dependency('erferfergwrrgbwrbwr', required: false))
subproject('p1') project('p1', ['c'])
dep = dependency('zlib', required: false)
if dep.found()
message('P1: FOUND')
else
message('P1: NOT FOUND')
endif This is obviously not an ideal solution, but it shows that meson can theoretically already do this. Also, can we please stop arguing about what CMake does, whether it is correct, arguing about semantics, and focus on actually fixing the issue by providing a solution. |
Given the actual ticket we are in explicitly says to use And, my entire argument is "here are the reasons why we don't want to do something about it, because it's bad when cmake does it and it will be bad if meson does it too". There are two different ways to solve this in meson today:
|
@mensinda exactly unfortunately some meson.builds try very hard in finding optional deps e.g. (as seen in gtk 4.0.1):
so I need a way to deactivate the @eli-schwartz hate on CMake all you like.... due to your response I cannot take you seriously any more and will simply ignore you. |
If I understand the use case here correctly, it is for integrating meson projects with vcpkg (or any other packaging system) and not about one or two external meson projects you want to build by hand. In this case, I would argue that submitting patches upstream is unreasonable to ask (while I agree that this would be the ideal solution of course). Also, patching the
OK, fair point. As I said previously I agree that implementing feature options is the ideal way to go. My point is to rather focus on the problem I described in my first comment and trying to find any solution for this since this is the actual issue here and not implementing Not doing this is essentially equivalent to telling packaging maintainers: We don't want to deal with this problem, either go ask 100+ repos to fix their stuff or invest a lot of time to patch their builds. We can of course go with this message as a project, but this would essentially be us admitting that there is a real-world problem (users not doing dependencies correctly by not using the tools we provide) which is likely (at least partially) because of our design decisions.
I 100% agree that we should avoid this scenario at all costs.
Uff, also deactivating
I am not exactly sure how to handle this, because while my workaround works, it is arguably abusing the
I know that this is a heated discussion, but can we please stop with stuff like this? Another question would be: Do we really need I am fully aware that this change would take years to have any effect and offers no short term solution. |
Also, @Neumann-A could you please update your first comment (and maybe also the title of this issue) with a better description of this issue so other people have a better understanding of what it actually is you want to solve here? |
@mensinda Better? Otherwise supply me with a text I should add ;)
In CMake I consider raw |
Yes, thanks.
Meson does not have modules. Using the A common use case is |
it does you are just not aware of it.
|
I guess this depends on the definition of module. We don't have modules in the way that there is no way to include custom meson code that does arbitrary (and potentially stupid) stuff to look up a dependency. We try our best to encourage the use of For your last to points: Ideally yes, but we would have to maintain a lot of additional code in this case if we want to support all/most common libraries like this. And even worse: We would most likely just end up calling |
Yeah your way seems to be to define a superproject to do the "extra" stuff (#8224 (comment)) ;)
*.pc files are nice but also potentially broken. vcpkg fixes that by not requiring
Which is symbol lookup (e.g. AC_SEARCH_LIBS)? I would say something like this and the attached logic should always be encapsulated outside a
Mark my words: It will happen sooner or later..... if your internal dependency lookup is unstable users want that. You are otherwise locking in users to a certain version of meson, especially since you don't fear breaking existing meson.build files. (and this is only one reason they exist in CMake) So enough time invested in meson, I know return to the things I care more about ;) |
Why is it different to build one project in vcpkg vs. building the same meson.build by hand? Surely it does the same dependency lookups, reads the same command-line options, and respects the same Is there ever a time when it's "unreasonable" to submit patches upstream? Why would these patches not be generically useful?
It doesn't speak for the qualities of meson, either positively or negatively. It does speak (negatively) for the quality of one specific meson.build that is "doing the wrong stuff". I specifically suggested "or you could sed the meson.build" as a response to "I know I want to disable this specific dependency lookup but I have no time to submit an upstream project bug report requesting a feature option".
I was with you here all the way through real-world problems, telling package maintainers to invest time in patching things, etc... until you got to "which is likely at least partly due to our design decisions". Can you please explain this? How is "users not doing dependencies correctly by not using the tools we provide" (read: users refusing to use meson_options.txt and get_option to implement configure-time choices) fallout from meson design decisions? What design decision are you blaming here?
Fortunately, I kind of avoided that scenario too. Even though the person I referenced, directly NACKed adding cmake -DOPTION variables to control enabling features ("they're inelegant, DISABLE_FIND_PACKAGE is the best"), someone else went and added -DOPTION variables for all features and was able to get it merged despite lack of support from... certain sides. It's still something I would like to make actually 100% impossible though. :p
We definitely need it. Example from one of my projects
Or one might look for Both of these cherry-picked examples are fixed in later versions of meson by special-casing config-tool handling or |
I was more referring to the amount of work involved for doing so compared to manually building a few projects. It is practically unreasonable to ask package maintainers to submit patches for every project upstream due to the amount of work involved. Of course, submitting patches upstream would be the ideal solution, I didn't try to imply otherwise.
I was trying to say that we should strive to make it impossible (or at least very hard) for users to make mistakes. Especially since it is currently just more convenient to not bother about adding options since there is more work involved.
Fair point, I was hoping that #4595 might help here (in 99% of all cases)... |
ah yes..... that nonsense looks exactly like the things Qt5 does. |
Nothing to do here. Meson provides feature options for this. |
more precise description in: #8224 (comment)
continuation of #2452
Seems like this is not solved. #2411 was closed and not merged.
Even with #3376 it actually requires
meson.build
to do the correct thing (which it often does not or the build script is a mix of correct and wrong).You probably want to have a look at
CMAKE_DISABLE_FIND_PACKAGE_<PackageName>
from CMake to actually learn from it.On a different but related issue: I also saw people suggesting/looking for something like
<PackageName>_DIR
from CMakeThe text was updated successfully, but these errors were encountered: