]> git.ipfire.org Git - thirdparty/git.git/commit
meson: ensure correct version-def.h is used
authorToon Claes <toon@iotcl.com>
Tue, 14 Jan 2025 11:15:23 +0000 (12:15 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 14 Jan 2025 19:14:54 +0000 (11:14 -0800)
commit4771501c0a125dd3560391cbd716c63a281e8244
treefd7ed6ba9a1dbba20cab6ff4c4c53265e768c776
parentfbe8d3079d4a96aeb4e4529cc93cc0043b759a05
meson: ensure correct version-def.h is used

To build the libgit-version library, Meson first generates
`version-def.h` in the build directory. Then it compiles `version.c`
into a library. During compilation, Meson tells to include both the
build directory and the project root directory.

However, when the user previously has compiled Git using Make, they will
have a `version-def.h` file in project root directory as well. Because
`version-def.h` is included in `version.c` using the #include directive
with double quotes, some preprocessors will look for the header file in
the same directory as the source file. This will cause compilation of
`version.c` ran by Meson to include `version-def.h` previously made by
Make, which might be out of date.

To explicitly tell the preprocessor which `version-def.h` to use, pass
the absolute path of this file as macro GIT_VERSION_H to the
preprocessor using option `-D` and have `version.c` `#include
GIT_VERSION_H`. To remain working with other build systems than Meson,
include "version-def.h" if that macro is not defined.

Co-authored-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Toon Claes <toon@iotcl.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
meson.build
version.c