Skip to content

Commit 7fe0727

Browse files
dschogitster
authored andcommitted
cmake: determine list of extra built-ins dynamically
In 0a21d0e (Makefile: mark git-maintenance as a builtin, 2020-12-01), we marked git-maintenance as a builtin in the Makefile, but forgot to do the same in `CMakeLists.txt`. Rather than always play catch-up and adjust `git_builtin_extra` manually, use the `BUILT_INS` definitions in the Makefile as authoritative source and generate `git_builtin_extra` dynamically. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 898f807 commit 7fe0727

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

contrib/buildsystems/CMakeLists.txt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ macro(parse_makefile_for_scripts list_var regex lang)
114114
endif()
115115
endmacro()
116116

117+
macro(parse_makefile_for_executables list_var regex)
118+
file(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX "^${regex} \\+= git-(.*)")
119+
string(REPLACE "${regex} +=" "" ${list_var} ${${list_var}})
120+
string(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces
121+
string(REPLACE "git-" "" ${list_var} ${${list_var}}) #strip `git-` prefix
122+
string(REPLACE "\$X" ";" ${list_var} ${${list_var}}) #strip $X, ; is for converting the string into a list
123+
list(TRANSFORM ${list_var} STRIP) #remove trailing/leading whitespaces for each element in list
124+
list(REMOVE_ITEM ${list_var} "") #remove empty list elements
125+
endmacro()
126+
117127
include(CheckTypeSize)
118128
include(CheckCSourceRuns)
119129
include(CheckCSourceCompiles)
@@ -673,10 +683,7 @@ if(CURL_FOUND)
673683
endif()
674684
endif()
675685

676-
set(git_builtin_extra
677-
cherry cherry-pick format-patch fsck-objects
678-
init merge-subtree restore show
679-
stage status switch whatchanged)
686+
parse_makefile_for_executables(git_builtin_extra "BUILT_INS")
680687

681688
#Creating hardlinks
682689
foreach(s ${git_SOURCES} ${git_builtin_extra})

0 commit comments

Comments
 (0)