Open marecki315 opened 3 weeks ago
This is somewhat difficult to fix ATM, because we don't have an equivalent of setting arguments on a single source, unless that source is compiled as an independent static_library, and then linked in. I have some thoughts on this, but I haven't gotten around to it yet, and the CMake portion will likely not work until we have that.
Problem
Preparing a
build.ninja
for a CMake subproject following steps are done:cmake
command is run in the subproject with -G Ninja option to generatebuild.ninja
filebuild.ninja
file is interpreted by Meson to prepare a Meson AST filebuild.ninja
file for the main project and subprojectsIn CMake individual files (or sets of files) inside one target can have their own
COMPILE_DEFINITIONS
orCOMPILE_FLAGS
set using something like:In step 1. the definitions and files are respected but in step 2. when the
build.ninja
file is interpreted by the CMake interpreter, specifically byConverterTarget
, flags and defines which are specific for individual files are accumulated for the entire target https://github.com/mesonbuild/meson/blob/1840bb02ba741fb62a8d613a71431a8d7fa86a00/mesonbuild/cmake/interpreter.py#L283Example
I've tried to build vvdec project as a subproject, but the compilation failed due to mismatch in the flags and defines.
This project uses specific defines for different groups of files in one target: https://github.com/fraunhoferhhi/vvdec/blob/v3.0.0/source/Lib/vvdec/CMakeLists.txt#L93
In the
build.ninja
generated by cmake it is respected:however, after parsing and preparing the AST file, flags and defines for each group are accumulated into
cpp_args
for the entire target:This results in compilation/linking errors.