From 986cd1cd9e2c10bbcccd510be699a68fdf2ceaa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?SZEDER=20G=C3=A1bor?= Date: Tue, 15 Sep 2026 08:09:50 +0200 Subject: [PATCH] cmake: remove any "$(*_OBJS)" variables when parsing Makefile for sources MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano --- 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 e76bd19b65..42244b3c0a 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