Skip to content
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 moc fails if sources have same name #3797

Open
ePirat opened this issue Jun 26, 2018 · 6 comments
Open

Qt moc fails if sources have same name #3797

ePirat opened this issue Jun 26, 2018 · 6 comments

Comments

@ePirat
Copy link
Contributor

ePirat commented Jun 26, 2018

Similar to #3791, the Qt modules fails with moc files that have the same name:

moc_sources = files('main_interface.hpp',
    'dialogs/playlist.cpp',
    'components/playlist/playlist.cpp')

qt5pre_files = qt5.preprocess(moc_sources : moc_sources)
ERROR: Multiple producers for Ninja target "modules/modules@@qt_plugin@sha/playlist.moc". Please rename your targets.
@jpakkane
Copy link
Member

The reason this happens is that the generator output name is @BASENAME@ or something similar. If you have two files with identical filenames their @BASENAME@s are the same and thus will collide.

I can't think of what the true and correct solution for this would be. In general it is considered poor form to have many files in your project with the exact same name. It is very confusing because sooner or later you will mix the two up. Obviously renaming files is not a simple solution for you.

A workaround is to compile files with identical names (in this case e.g. dialogs/playlist.cpp) in a helper static library and link that to your final target. It's a bit messy but should at least unblock your work for this.

@ePirat
Copy link
Contributor Author

ePirat commented Jun 26, 2018

Thanks for the suggested workaround, will give it a try.

I agree it can be confusing having files with the same name in different named subfolders, but I do not think meson should force such a restriction upon the user, still. So I think a proper fix for this is needed and especially for the similar problem with resources, where it is probably even more common to have files with same name in subfolders.

@equeim
Copy link
Contributor

equeim commented Jul 11, 2018

@jpakkane Yeah but if you add regular sources with same name Meson will handle it correctly. E.g.

executable('test',
           sources : ['bar.cpp', 'foo/bar.cpp'])

will compile bar.o and foo_bar.o. So moc should generate moc_bar.cpp and mod_foo_bar.cpp.

@jpakkane
Copy link
Member

That's because those use a generator and that uses @BASENAME@ which is defined to not have those path segments and people actually depend on that (I think).

@equeim
Copy link
Contributor

equeim commented Jul 12, 2018

Yeah, it will break moc_source and ui_files arguments. Maybe instead of appending directory prefixes to file names Meson should create an actual directory structure (setting correct includes to current directory), like CMake and Waf do. This will solve the issue with same file names for generators too.

@nirbheek nirbheek modified the milestones: 0.48.0, 0.49.0 Sep 20, 2018
@PPPPoint
Copy link

PPPPoint commented Jul 1, 2021

Does this promblem solve?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants