From: "SZEDER Gábor" <szeder.dev@gmail.com>
To: git@vger.kernel.org
Cc: "SZEDER Gábor" <szeder.dev@gmail.com>
Subject: [PATCH 2/4] cmake: remove any "$(*_OBJS)" variables when parsing Makefile for sources
Date: Wed, 9 Sep 2026 21:50:04 +0200 [thread overview]
Message-ID: <20260909195006.2179119-3-szeder.dev@gmail.com> (raw)
In-Reply-To: <20260909195006.2179119-1-szeder.dev@gmail.com>
To get various lists of files, CMake parses our Makefile looking for
lines matching e.g. "list_var += ...". In case of LIB_OBJS this
picks up the line "LIB_OBJS += $(COMPAT_OBJS)" as well, so the parsing
macro has a specific instruction to remove "$(COMPAT_OBJS)" from the
resulting list.
Currently this is the only such Makefile variable to be removed from
the list, but the next patches will (re)introduce more variables
containing lists of object files, so let's generalize that removing
instruction to remove any "$(*_OBJS)" Makefile variable as well.
Note that we can't make the pattern matching the Makefile variable too
general, e.g. to match any "$(VARIABLE)", because some lines of our
Makefile do contain variables as directory prefixes, e.g.
"UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/test-lib.o", and we must
definitely keep those.
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
---
I rarely do CMake, so it's quite possible that this is not the most
straightforward or idiomatic approach.
contrib/buildsystems/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index 8f56203f34..241da0d43a 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -102,7 +102,7 @@ project(git
macro(parse_makefile_for_sources list_var makefile regex)
file(STRINGS ${makefile} ${list_var} REGEX "^${regex} \\+=(.*)")
string(REPLACE "${regex} +=" "" ${list_var} ${${list_var}})
- string(REPLACE "$(COMPAT_OBJS)" "" ${list_var} ${${list_var}}) #remove "$(COMPAT_OBJS)" This is only for libgit.
+ string(REGEX REPLACE "\\$\\([^)]*_OBJS\\)" "" ${list_var} ${${list_var}}) # remove any "$(*_OBJS)" variables
string(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces
string(REPLACE ".o" ".c;" ${list_var} ${${list_var}}) #change .o to .c, ; is for converting the string into a list
list(TRANSFORM ${list_var} STRIP) #remove trailing/leading whitespaces for each element in list
--
2.55.0.1193.g1b994e35de
next prev parent reply other threads:[~2026-09-09 19:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 19:50 [PATCH 0/4] make: precompile "git-compat-util.h" SZEDER Gábor
2026-09-09 19:50 ` [PATCH 1/4] Makefile: remove XDIFF_OBJS initialization SZEDER Gábor
2026-09-09 19:50 ` SZEDER Gábor [this message]
2026-09-09 19:50 ` [PATCH 3/4] Makefile: reintroduce REFTABLE_OBJS SZEDER Gábor
2026-09-09 21:07 ` Junio C Hamano
2026-09-09 19:50 ` [PATCH 4/4] Makefile: precompile "git-compat-util.h" SZEDER Gábor
2026-09-09 19:57 ` SZEDER Gábor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260909195006.2179119-3-szeder.dev@gmail.com \
--to=szeder.dev@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.