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
Qt compile_moc() doesn't support files with the same name #10955
Comments
Updated to meson 0.63.3. Problem remains. |
Given a non-qt project:
You can see that the folder name is prefixing the pidfile.c name in the private dir. I think all the moc stuff needs to do is something similar |
The bug is located right around here https://github.com/mesonbuild/meson/blob/master/mesonbuild/modules/qt.py#L463 |
Aye, that's what I thought. Because, as mentioned in the issue, I recognize that something like "one_value.moc" would be more mesonic, but that is not what Qt developers would expect! Traditionally, these generated moc files would be #included as "value.moc" inside of the cpp file. However, if the filename is extended with directory prefixes that doesn't work anymore ... So, would an implementation for this issue be free to create subdirectories inside the private directory and append those to the include directories? I hope I'm making myself clear enough ... ;) |
So you have something like this?
And both generate the same file name in |
Yes, even if I place individual However, I am convinced that both approaches should be handled correctly by meson:
|
Regardless of everything else, I highly recommend adopting a naming scheme that prohibits having multiple headers of the same name. Murphy's law says that eventually you will get that wrong and include the wrong header from the wrong place. The only real protection against that is to have unique names. |
@punytroll the obvious solution to me seems to be generating the files into |
In general, that might be a sensible recommendation. On the other hand, structuring your code in subdirectories accoring to your namespace names and files according to your class names is not that absurd an idea. And it's only a matter of time until some (dreaded) Manager, Parser or Value class comes along ... If the developer team gets big enough or the project gets complex enough, I don't think you can sensibly enforce this rule. And in any case, namespaces provide good protection against accidentally including and using the wrong header without the compiler complaining. I don't think protecting against that falls into the realm of responsibilities for the build system. |
@tristan957 I think so as well, but I wanted to make sure, that subdirectories in the build directory are an OK thing to do. I will have a stab at it. |
@punytroll generally writing output files to the mirrored build directory is the right thing to do |
app.p is a per-target private directory. If this were handled via manual running of It's perfectly reasonable to argue that the builtin moc should always do that too. |
Would make sense to me |
Or it could have the preserve kwarg so people could opt into it. Changing the default would break things for existing projects. |
Since we are talking about generated |
Hmm. Wait, does |
Well, that depends on how you look at that:
In the latter case, the name of the generated file should definitely not be changed from the expected file name ( |
I have to agree with @eli-schwartz: As this pertains to generated files only, is there any chance it could break something for existing projects? As long as the created subdirectories are appended to the target's include_directories, the same file names should be visible to the compiler to include ... |
I had a quick glance at this: It seems passing On the other hand, when using the Any thoughts on this? Should I provide a tiny PR with passing the |
I think that is very reasonable. |
I have an open PR that adds the preserve_paths keyword argument: #11795. |
Describe the bug
When using Qt's compile_moc(), files that have the same file name, while being placed in different sub directories in the source tree, produce a configure-time error:
or
depending on whether one is using the
headers
orsources
keyword argument.To Reproduce
This minimal meson.build file:
Files
one/value.h
andtwo/value.h
must exist, but can, for this error at configure time, be empty.Expected behavior
There is no technical reason, why this shouldn't work. CMake can do it and a handcrafted Makefile certainly can as well. The moc files need either be placed in separate directories (CMake creates unique build directories for this) and the include paths to these directories have to be provided at compile time. Or the filenames have to be prefixed with the directory ('one_value.moc' / 'two_value.moc'), which seems more mesonic, but creates a problem when you want to include these files again ('#include "one_value.moc"' instead of the canonic '#include "value.moc"' in both files, trusting the include paths to be correct.)
system parameters
The text was updated successfully, but these errors were encountered: