]> git.ipfire.org Git - thirdparty/git.git/commitdiff
cmake: determine list of extra built-ins dynamically
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Fri, 4 Dec 2020 19:33:56 +0000 (19:33 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 4 Dec 2020 20:11:07 +0000 (12:11 -0800)
In 0a21d0e08902 (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 <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/buildsystems/CMakeLists.txt

index df539a44fa0a1b5c4516d1766dfe24e8ee30204e..c151dd7257f31c0641160404e93b71abee7e315e 100644 (file)
@@ -114,6 +114,16 @@ macro(parse_makefile_for_scripts list_var regex lang)
        endif()
 endmacro()
 
+macro(parse_makefile_for_executables list_var regex)
+       file(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX "^${regex} \\+= git-(.*)")
+       string(REPLACE "${regex} +=" "" ${list_var} ${${list_var}})
+       string(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces
+       string(REPLACE "git-" "" ${list_var} ${${list_var}}) #strip `git-` prefix
+       string(REPLACE "\$X" ";" ${list_var} ${${list_var}}) #strip $X, ; is for converting the string into a list
+       list(TRANSFORM ${list_var} STRIP) #remove trailing/leading whitespaces for each element in list
+       list(REMOVE_ITEM ${list_var} "") #remove empty list elements
+endmacro()
+
 include(CheckTypeSize)
 include(CheckCSourceRuns)
 include(CheckCSourceCompiles)
@@ -673,10 +683,7 @@ if(CURL_FOUND)
        endif()
 endif()
 
-set(git_builtin_extra
-       cherry cherry-pick format-patch fsck-objects
-       init merge-subtree restore show
-       stage status switch whatchanged)
+parse_makefile_for_executables(git_builtin_extra "BUILT_INS")
 
 #Creating hardlinks
 foreach(s ${git_SOURCES} ${git_builtin_extra})