build.ninja is missing dependencies present in cmake subproject
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 6.6k
- Forks
- 1.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 33
Description
Describe the bug
I have a cmake project that I can build with cmake+ninja using cmake -G Ninja -S src -B build; ninja -C build that I cannot build from meson with a simple wrapper. The meson generated build.ninja is missing dependencies that are present in the cmake genearted build.ninja, which seems to be the cause of the meson compile failure.
The missing dependencies are for generated header files and are defined in CMake with set_source_files_properties().
To Reproduce
Create sample meson project:
mkdir -p project/subprojects
cat > project/meson.build << 'EOF'
project('experiment', ['c'], version: '1.0.0', meson_version: '>=0.58.0', )
cmake = import('cmake')
uncrustify_options = cmake.subproject_options()
uncrustify_options.add_cmake_defines({ 'NoGitVersionString': true })
uncrustify_proj = cmake.subproject('uncrustify', options: uncrustify_options)
EOF
cat > project/subprojects/uncrustify.wrap << 'EOF'
[wrap-git]
url = https://github.com/alex-tomlinson/uncrustify.git
revision = alex-fix-deps-01
EOF
Building with meson fails:
meson setup project build1
ninja -C build1
Error output:
../project/subprojects/uncrustify/src/punctuators.cpp:34:10: fatal error: punctuator_table.h: No such file or directory
34 | #include "punctuator_table.h"
Building with cmake is successful:
cmake -G Ninja -S project/subprojects/uncrustify -B build2
ninja -C build2
Compare entry for punctuator.cpp.o in each build.ninja file. Note punctuator_table.h and some others are missing from meson's build.ninja file.
$ grep '^build.*punctuators.*o:' build1/build.ninja build2/build.ninja
build1/build.ninja:build subprojects/uncrustify/cm_uncrustify.p/src_punctuators.cpp.o: cpp_COMPILER ../project/subprojects/uncrustify/src/punctuators.cpp || subprojects/uncrustify/option_enum.h
build2/build.ninja:build CMakeFiles/uncrustify.dir/src/punctuators.cpp.o: CXX_COMPILER__uncrustify_ /home/atomlinson/xxmeson/project/subprojects/uncrustify/src/punctuators.cpp | token_names.h uncrustify_version.h src/option_enum.h src/punctuator_table.h || cmake_object_order_depends_target_uncrustify
Expected behavior
Expect meson setup/compile to succeed.
system parameters
- Is this a cross build or just a plain native build (for the same computer)?
native - what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.)
Fedora 34 - what Python version are you using e.g. 3.8.0
Python 3.9.2 - what
meson --version
0.58.2 - what
ninja --versionif it's a Ninja build
1.10.0.git.kitware.jobserver-1 - Other
cmake version 3.19.7
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the provided Meson wrapper and compare the generated build1/build.ninja entry for punctuators.cpp.o with the CMake-generated build2/build.ninja entry. Start by tracing Meson's cmake.subproject() handling of CMake set_source_files_properties() dependencies. Done means Meson-generated Ninja dependencies include the generated headers and the native setup/compile succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, python
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100