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

Cannot add library build directory to include_directories #13065

Open
mardy opened this issue Apr 10, 2024 · 0 comments
Open

Cannot add library build directory to include_directories #13065

mardy opened this issue Apr 10, 2024 · 0 comments

Comments

@mardy
Copy link

mardy commented Apr 10, 2024

Describe the bug

Meson 0.6.3.

I'm trying to build a static library including all the moc files that are needed in our test suite (the reason is that, otherwise, meson generates thousands of build targets, since these moc files are needed by every test binary):

moc_library = static_library('all_mocs',
    qt5.compile_moc(sources: all_sources, headers: all_headers),                      
    dependencies: test_core_dependencies,
    include_directories: include_directories('.'),                                                    
)                                                                                                     
moc_library_dep = declare_dependency(                                                                 
    include_directories: include_directories('.'),
    link_with: moc_library,                                                                           
)                                                                                                     

The problem is that the files generated by moc are written into a liball_mocs.a.p subdirectory (of tests/Core), which is not added to the include path. So, when the main target files are built, they cannot find the moc-generated files:

# (command edited with line breaks for readability)
c++ -Itests/Core/test_task_launcher.p -Itests/Core -I../tests/Core -Isrc/common \
    -I../src/common -Isrc/service -I../src/service \
    -I/usr/include/qt5/QtDBus -I/usr/include/qt5 -I/usr/include/qt5/QtCore \
    -I/usr/include/qt5/QtNetwork -I/usr/include/qt5/QtTest \
    -DUNIT_TESTS -MD -MQ \
    tests/Core/test_task_launcher.p/_home_mardy_src_git_runtime-manager_src_service_Core_task_launcher.cpp.o \
    -MF tests/Core/test_task_launcher.p/_home_mardy_src_git_runtime-manager_src_service_Core_task_launcher.cpp.o.d \
    -o tests/Core/test_task_launcher.p/_home_mardy_src_git_runtime-manager_src_service_Core_task_launcher.cpp.o \
    -c /home/mardy/src/git/runtime-manager/src/service/Core/task_launcher.cpp
/home/mardy/src/git/runtime-manager/src/service/Core/task_launcher.cpp:340:10: fatal error: task_launcher.moc: No such file or directory
  340 | #include "task_launcher.moc"
      |          ^~~~~~~~~~~~~~~~~~~
compilation terminated.

If I use include_directories: include_directories('./liball_mocs.a.p'), then following builds do work, but the first clean build won't, because meson complains that the directory does not exist. It's not clear to me why include_directories('.') does not work in this case.

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

No branches or pull requests

1 participant