Skip to contentSkip to conversation

CMake build system for git

PATCH Superseded Sibi Siddharthan via GitGitGadget 14 participants 179 messages Apr 24, 2020 – Jul 1, 2020 Page 1 of 2

lore
Share & tools
lore
#0 lore raw

cover CMake build system for git

This is an attempt to build Git using CMake. CMake is cross-platform build generator which works well on a variety of platforms(primarily Linux and Windows). Using CMake we can check whether certain headers exist, certain functions exist, the required libraries are present and configure the build accordingly. Using CMake we can also build and test Git out of source, resulting in a clean source tree.

Tested platforms

Ubuntu 18.04 GCC 7.4 Clang 8.0.1

Windows MinGW GCC 9.2 Clang 9 Visual Studio 2015,2017,2019

Sibi Siddharthan (8):
Introduce CMake support for configuring Git on Linux
cmake: generate the shell/perl/python scripts and templates,
translations
cmake: installation support for git
cmake: support for testing git with ctest
cmake: support for testing git when building out of the source tree
cmake: support for building git on windows with mingw
cmake: support for building git on windows with msvc and clang.
ci: modification of main.yml to use cmake for vs-build job

 .github/workflows/main.yml |  43 +-
 CMakeLists.txt             | 952 +++++++++++++++++++++++++++++++++++++
 2 files changed, 977 insertions(+), 18 deletions(-)
 create mode 100644 CMakeLists.txt

base-commit: 744177e7f7fd407c26e9e4aa3b19696859010c48
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-614%2FSibiSiddharthan%2Fgit-og-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-614/SibiSiddharthan/git-og-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/614

Signature · 1 line
gitgitgadget
#1 lore raw

PATCH 1/8 Introduce CMake support for configuring Git on Linux

From: Sibi Siddharthan <[email protected]>

At the moment, the recommended way to configure Git's builds is to simply run make. If that does not work, the recommended strategy is to look at the top of the Makefile to see whether any "Makefile knob" has to be turned on/off, e.g. make NO_OPENSSL=YesPlease.

Alternatively, Git also has an autoconf setup which allows configuring builds via ./configure [<option>...].

Both of these options are fine if the developer works on Unix or Linux. But on Windows, we have to jump through hoops to configure a build (read: we force the user to install a full Git for Windows SDK, which occupies around two gigabytes (!) on disk and downloads about three quarters of a gigabyte worth of Git objects).

To make this a little less awkward, the Git for Windows project offers the vs/master branch which has a full Visual Studio solution generated and committed. This branch can therefore be used to tinker with Git in Visual Studio _without_ having to download the full Git for Windows SDK. Unfortunatly, that branch is auto-generated from Git for Windows' master. If a developer wants to tinker, say, with pu, they are out of luck.

CMake was invented to make this sort of problem go away, by providing a more standardized, cross-platform way to configure builds.

With a working support CMake, developers on Windows need only install CMake, configure their build, load the generated Visual Studio solution and immediately start modifying the code and build their own version of Git. Likewise, developers on other platforms can use the convenient GUI tools provided by CMake to configure their build.

So let's start building CMake support for Git.

This is only the first step, and to make it easier to review, it only allows for configuring builds on the platform that is easiest to configure for: Linux.

The CMake script checks whether the headers are present(eg. libgen.h), whether the functions are present(eg. memmem), whether the funtions work properly (eg. snprintf) and generate the required compile definitions for the platform. The script also searches for the required libraries, if it fails to find the required libraries the respective executables won't be built.(eg. If libcurl is not found then git-remote-http won't be built). This will help building Git easier.

With a CMake script an out of source build of git is possible resulting in a clean source tree.

Note: earlier endeavors on the Git mailing list to introduce CMake ended up in dead water. The primary reason for that was that reviewers _expected_ CMake support to fall out of maintenance, unless the contributor would promise to keep an eye on keeping CMake support up to date. However, in the meantime, support for automated testing has been introduced in Git's source code, and a later patch will modify the (still experimental) GitHub workflow to continually verify that CMake support is still complete. That will make maintenance reasonably easy.

Note: this patch asks for the minimum version v3.14 of CMake (which is not all that old as of time of writing) because that is the first version to offer a platform-independent way to generate hardlinks as part of the build. This is needed to generate all those hardlinks for the built-in commands of Git.

Instructions to run CMake:

cmake relative-path-to-srcdir -DCMAKE_BUILD_TYPE=Release

Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding compiler flags
Debug : -g
Release: -O3
RelWithDebInfo : -O2 -g
MinSizeRel : -Os
empty(default) :

NOTE: -DCMAKE_BUILD_TYPE is optional

This process generates a Makefile.
Then run make to build Git.

NOTE: By default CMake uses Makefile as the build tool on Linux, to use another tool say ninja add this to the command line when configuring. -G Ninja

---
 CMakeLists.txt | 528 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 528 insertions(+)
 create mode 100644 CMakeLists.txt
CMakeLists.txt new file +528 -0
new file mode 100644
index 00000000000..73703bd321f
@@ -0,0 +1,528 @@
+#
+#	Copyright (c) 2020 Sibi Siddharthan
+#
+
+cmake_minimum_required(VERSION 3.14)
+
+#Parse GIT-VERSION-GEN to get the version
+file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX "DEF_VER=v(.*)")
+string(REPLACE "DEF_VER=v" "" git_version ${git_version})
+string(REPLACE ".GIT" ".0" git_version ${git_version})#for building from a snapshot
+
+project(git
+	VERSION ${git_version}
+	LANGUAGES C)
+
+
+include(CheckTypeSize)
+include(CheckCSourceRuns)
+include(CheckCSourceCompiles)
+include(CheckIncludeFile)
+include(CheckFunctionExists)
+include(CheckSymbolExists)
+include(CheckStructHasMember)
+
+find_package(ZLIB REQUIRED)
+find_package(CURL)
+find_package(EXPAT)
+find_package(Iconv)
+find_package(Intl)
+
+if(NOT Intl_FOUND)
+	add_compile_definitions(NO_GETTEXT)
+	if(NOT Iconv_FOUND)
+		add_compile_definitions(NO_ICONV)
+	endif()
+endif()
+
+include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
+if(CURL_FOUND)
+	include_directories(SYSTEM ${CURL_INCLUDE_DIRS})
+endif()
+if(EXPAT_FOUND)
+	include_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})
+endif()
+if(Iconv_FOUND)
+	include_directories(SYSTEM ${Iconv_INCLUDE_DIRS})
+endif()
+if(Intl_FOUND)
+	include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
+endif()
+
+find_program(SH_EXE sh)
+
+#default behaviour
+include_directories(${CMAKE_SOURCE_DIR})
+add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
+add_compile_definitions(SHA256_BLK INTERNAL_QSORT RUNTIME_PREFIX)
+add_compile_definitions(NO_OPENSSL SHA1_DC SHA1DC_NO_STANDARD_INCLUDES
+			SHA1DC_INIT_SAFE_HASH_DEFAULT=0
+			SHA1DC_CUSTOM_INCLUDE_SHA1_C="cache.h"
+			SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="git-compat-util.h" )
+list(APPEND compat_SOURCES sha1dc_git.c sha1dc/sha1.c sha1dc/ubc_check.c block-sha1/sha1.c sha256/block/sha256.c compat/qsort_s.c)
+
+
+add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
+			ETC_GITATTRIBUTES="etc/gitattributes"
+			ETC_GITCONFIG="etc/gitconfig"
+			GIT_EXEC_PATH="libexec/git-core"
+			GIT_LOCALE_PATH="share/locale"
+			GIT_MAN_PATH="share/man"
+			GIT_INFO_PATH="share/info"
+			GIT_HTML_PATH="share/doc/git-doc"
+			DEFAULT_HELP_FORMAT="html"
+			DEFAULT_GIT_TEMPLATE_DIR="share/git-core/templates"
+			GIT_VERSION="${PROJECT_VERSION}.GIT"
+			GIT_USER_AGENT="git/${PROJECT_VERSION}.GIT"
+			BINDIR="bin"
+			GIT_BUILT_FROM_COMMIT="")
+
+set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
+add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+
+add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
+list(APPEND compat_SOURCES unix-socket.c)
+
+#header checks
+check_include_file(libgen.h HAVE_LIBGEN_H)
+if(NOT HAVE_LIBGEN_H)
+	add_compile_definitions(NO_LIBGEN_H)
+	list(APPEND compat_SOURCES compat/basename.c)
+endif()
+
+check_include_file(sys/sysinfo.h HAVE_SYSINFO)
+if(HAVE_SYSINFO)
+	add_compile_definitions(HAVE_SYSINFO)
+endif()
+
+check_c_source_compiles("
+#include <alloca.h>
+int
+main ()
+{
+char *p = (char *) alloca (2 * sizeof (int));
+	if (p) return 0;
+	return 0;
+}"
+HAVE_ALLOCA_H)
+if(HAVE_ALLOCA_H)
+	add_compile_definitions(HAVE_ALLOCA_H)
+endif()
+
+check_include_file(strings.h HAVE_STRINGS_H)
+if(HAVE_STRINGS_H)
+	add_compile_definitions(HAVE_STRINGS_H)
+endif()
+
+check_include_file(sys/select.h HAVE_SYS_SELECT_H)
+if(NOT HAVE_SYS_SELECT_H)
+	add_compile_definitions(NO_SYS_SELECT_H)
+endif()
+
+check_include_file(sys/poll.h HAVE_SYS_POLL_H)
+if(NOT HAVE_SYS_POLL_H)
+	add_compile_definitions(NO_SYS_POLL_H)
+endif()
+
+check_include_file(poll.h HAVE_POLL_H)
+if(NOT HAVE_POLL_H)
+	add_compile_definitions(NO_POLL_H)
+endif()
+
+check_include_file(inttypes.h HAVE_INTTYPES_H)
+if(NOT HAVE_INTTYPES_H)
+	add_compile_definitions(NO_INTTYPES_H)
+endif()
+
+check_include_file(paths.h HAVE_PATHS_H)
+if(HAVE_PATHS_H)
+	add_compile_definitions(HAVE_PATHS_H)
+endif()
+
+#function checks
+set(function_checks
+	strcasestr memmem strlcpy strtoimax strtoumax strtoull
+	setenv  mkdtemp poll pread  memmem unsetenv hstrerror)
+
+foreach(f ${function_checks})
+	string(TOUPPER ${f} uf)
+	check_function_exists(${f} HAVE_${uf})
+	if(NOT HAVE_${uf})
+		add_compile_definitions(NO_${uf})
+	endif()
+endforeach()
+
+if(NOT HAVE_POLL_H OR NOT HAVE_SYS_POLL_H OR NOT HAVE_POLL)
+	include_directories(compat/poll)
+	add_compile_definitions(NO_POLL)
+	list(APPEND compat_SOURCES compat/poll/poll.c)
+endif()
+
+if(NOT HAVE_STRCASESTR)
+	list(APPEND compat_SOURCES compat/strcasestr.c)
+endif()
+
+if(NOT HAVE_STRLCPY)
+	list(APPEND compat_SOURCES compat/strlcpy.c)
+endif()
+
+if(NOT HAVE_STRTOUMAX)
+	list(APPEND compat_SOURCES compat/strtoumax.c compat/strtoimax.c)
+endif()
+
+if(NOT HAVE_SETENV)
+	list(APPEND compat_SOURCES compat/setenv.c)
+endif()
+
+if(NOT HAVE_MKDTEMP)
+	list(APPEND compat_SOURCES compat/mkdtemp.c)
+endif()
+
+if(NOT HAVE_PREAD)
+	list(APPEND compat_SOURCES compat/pread.c)
+endif()
+
+if(NOT HAVE_MEMMEM)
+	list(APPEND compat_SOURCES compat/memmem.c)
+endif()
+
+if(NOT WIN32)
+	if(NOT HAVE_UNSETENV)
+		list(APPEND compat_SOURCES compat/unsetenv.c)
+	endif()
+
+	if(NOT HAVE_HSTRERROR)
+		list(APPEND compat_SOURCES compat/hstrerror.c)
+	endif()
+endif()
+
+check_function_exists(getdelim HAVE_GETDELIM)
+if(HAVE_GETDELIM)
+	add_compile_definitions(HAVE_GETDELIM)
+endif()
+
+check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
+check_symbol_exists(CLOCK_MONOTONIC "time.h" HAVE_CLOCK_MONOTONIC)
+if(HAVE_CLOCK_GETTIME)
+	add_compile_definitions(HAVE_CLOCK_GETTIME)
+endif()
+if(HAVE_CLOCK_MONOTONIC)
+	add_compile_definitions(HAVE_CLOCK_MONOTONIC)
+endif()
+
+
+#compile checks
+check_c_source_runs("
+#include<stdio.h>
+#include<stdarg.h>
+#include<string.h>
+#include<stdlib.h>
+int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)
+{
+	int ret;
+	va_list ap;
+
+	va_start(ap, format);
+	ret = vsnprintf(str, maxsize, format, ap);
+	va_end(ap);
+	return ret;
+}
+
+int
+main ()
+{
+	char buf[6];
+	if (test_vsnprintf(buf, 3, \"%s\", \"12345\") != 5
+		|| strcmp(buf, \"12\")) return 1;
+	if (snprintf(buf, 3, \"%s\", \"12345\") != 5
+		|| strcmp(buf, \"12\")) return 1;
+
+	return 0;
+}"
+SNPRINTF_OK)
+if(NOT SNPRINTF_OK)
+	add_compile_definitions(SNPRINTF_RETURNS_BOGUS)
+	list(APPEND compat_SOURCES compat/snprintf.c)
+endif()
+
+check_c_source_runs("
+#include<stdio.h>
+int
+main ()
+{
+	FILE *f = fopen(\".\", \"r\");
+	return f != NULL;
+
+	return 0;
+}"
+FREAD_READS_DIRECTORIES_NO)
+if(NOT FREAD_READS_DIRECTORIES_NO)
+	add_compile_definitions(FREAD_READS_DIRECTORIES)
+	list(APPEND compat_SOURCES compat/fopen.c)
+endif()
+
+check_c_source_compiles("
+#include <regex.h>
+#ifndef REG_STARTEND
+#error oops we dont have it
+#endif
+int main(){return 0;}"
+HAVE_REGEX)
+if(NOT HAVE_REGEX)
+	include_directories(compat/regex )
+	list(APPEND compat_SOURCES compat/regex/regex.c )
+	add_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)
+endif()
+
+
+check_c_source_compiles("
+#include <stddef.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+int
+main ()
+{
+	int val, mib[2];
+	size_t len;
+
+	mib[0] = CTL_HW;
+	mib[1] = 1;
+	len = sizeof(val);
+	return sysctl(mib, 2, &val, &len, NULL, 0) ? 1 : 0;
+
+	return 0;
+}"
+HAVE_BSD_SYSCTL)
+if(HAVE_BSD_SYSCTL)
+	add_compile_definitions(HAVE_BSD_SYSCTL)
+endif()
+
+#programs
+set(PROGRAMS_BUILT
+	git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
+	git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)
+
+if(NOT CURL_FOUND)
+	list(APPEND excluded_progs git-http-fetch git-http-push)
+	add_compile_definitions(NO_CURL)
+	message(WARNING "git-http-push and git-http-fetch will not be built")
+else()
+	list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)
+	if(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)
+		add_compile_definitions(USE_CURL_FOR_IMAP_SEND)
+	endif()
+endif()
+
+if(NOT EXPAT_FOUND)
+	list(APPEND excluded_progs git-http-push)
+	add_compile_definitions(NO_EXPAT)
+else()
+	list(APPEND PROGRAMS_BUILT git-http-push)
+	if(EXPAT_VERSION_STRING VERSION_LESS_EQUAL 1.2)
+		add_compile_definitions(EXPAT_NEEDS_XMLPARSE_H)
+	endif()
+endif()
+
+list(REMOVE_DUPLICATES excluded_progs)
+list(REMOVE_DUPLICATES PROGRAMS_BUILT)
+
+
+foreach(p ${excluded_progs})
+	list(APPEND EXCLUSION_PROGS --exclude-program ${p} )
+endforeach()
+
+#for comparing null values
+list(APPEND EXCLUSION_PROGS empty)
+set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING "Programs not built" FORCE)
+
+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)
+	list(REMOVE_ITEM EXCLUSION_PROGS empty)
+	message("Generating command-list.h")
+	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt
+			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+			OUTPUT_FILE ${CMAKE_SOURCE_DIR}/command-list.h)
+endif()
+
+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/config-list.h)
+	message("Generating config-list.h")
+	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh
+			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+			OUTPUT_FILE ${CMAKE_SOURCE_DIR}/config-list.h)
+endif()
+
+
+#build
+set(libgit_SOURCES
+	abspath.c add-interactive.c add-patch.c advice.c alias.c
+	alloc.c apply.c archive.c archive-tar.c archive-zip.c argv-array.c
+	attr.c base85.c bisect.c blame.c blob.c bloom.c branch.c bulk-checkin.c
+	bundle.c cache-tree.c chdir-notify.c checkout.c color.c column.c
+	combine-diff.c commit.c commit-graph.c commit-reach.c compat/obstack.c
+	compat/terminal.c config.c connect.c connected.c convert.c copy.c credential.c
+	csum-file.c ctype.c date.c decorate.c delta-islands.c diffcore-break.c
+	diffcore-delta.c diffcore-order.c diffcore-pickaxe.c diffcore-rename.c
+	diff-delta.c diff-lib.c diff-no-index.c diff.c dir.c dir-iterator.c editor.c
+	entry.c environment.c ewah/bitmap.c ewah/ewah_bitmap.c ewah/ewah_io.c
+	ewah/ewah_rlw.c exec-cmd.c fetch-negotiator.c fetch-pack.c fmt-merge-msg.c fsck.c fsmonitor.c
+	gettext.c gpg-interface.c graph.c grep.c hashmap.c linear-assignment.c help.c hex.c
+	ident.c interdiff.c json-writer.c kwset.c levenshtein.c line-log.c line-range.c list-objects.c
+	list-objects-filter.c list-objects-filter-options.c ll-merge.c lockfile.c
+	log-tree.c ls-refs.c mailinfo.c mailmap.c match-trees.c mem-pool.c merge.c merge-blobs.c
+	merge-recursive.c mergesort.c midx.c name-hash.c negotiator/default.c
+	negotiator/skipping.c notes.c notes-cache.c notes-merge.c notes-utils.c object.c oidmap.c
+	oidset.c oid-array.c packfile.c pack-bitmap.c pack-bitmap-write.c pack-check.c pack-objects.c
+	pack-revindex.c pack-write.c pager.c parse-options.c parse-options-cb.c patch-delta.c
+	patch-ids.c path.c pathspec.c pkt-line.c preload-index.c pretty.c prio-queue.c progress.c
+	promisor-remote.c prompt.c protocol.c prune-packed.c quote.c range-diff.c reachable.c read-cache.c rebase.c
+	rebase-interactive.c reflog-walk.c refs.c refs/files-backend.c refs/iterator.c
+	refs/packed-backend.c refs/ref-cache.c refspec.c ref-filter.c remote.c replace-object.c
+	repo-settings.c repository.c rerere.c reset.c resolve-undo.c revision.c run-command.c
+	send-pack.c sequencer.c serve.c server-info.c setup.c sha1-lookup.c
+	sha1-file.c sha1-name.c shallow.c sideband.c sigchain.c split-index.c
+	stable-qsort.c strbuf.c streaming.c string-list.c submodule.c submodule-config.c
+	sub-process.c symlinks.c tag.c tempfile.c thread-utils.c tmp-objdir.c
+	trace.c trace2.c trace2/tr2_cfg.c trace2/tr2_cmd_name.c trace2/tr2_dst.c
+	trace2/tr2_sid.c trace2/tr2_sysenv.c trace2/tr2_tbuf.c trace2/tr2_tgt_event.c
+	trace2/tr2_tgt_normal.c trace2/tr2_tgt_perf.c trace2/tr2_tls.c trailer.c transport.c
+	transport-helper.c tree-diff.c tree.c tree-walk.c unpack-trees.c upload-pack.c url.c
+	urlmatch.c usage.c userdiff.c utf8.c varint.c version.c versioncmp.c walker.c wildmatch.c
+	worktree.c wrapper.c write-or-die.c ws.c wt-status.c xdiff-interface.c
+	zlib.c)
+
+add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})
+
+set(libxdiff_SOURCES
+	xdiff/xdiffi.c xdiff/xprepare.c xdiff/xutils.c xdiff/xemit.c
+	xdiff/xmerge.c xdiff/xpatience.c xdiff/xhistogram.c)
+add_library(xdiff STATIC ${libxdiff_SOURCES})
+
+set(libvcs-svn_SOURCES
+	vcs-svn/line_buffer.c vcs-svn/sliding_window.c vcs-svn/fast_export.c
+	vcs-svn/svndiff.c vcs-svn/svndump.c)
+add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
+
+#link all required libraries to common-main
+add_library(common-main OBJECT common-main.c)
+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
+if(Intl_FOUND)
+	target_link_libraries(common-main ${Intl_LIBRARIES})
+endif()
+if(Iconv_FOUND)
+	target_link_libraries(common-main ${Iconv_LIBRARIES})
+endif()
+
+
+set(git_SOURCES
+	builtin/add.c builtin/am.c builtin/annotate.c builtin/apply.c
+	builtin/archive.c builtin/bisect--helper.c builtin/blame.c
+	builtin/branch.c builtin/bundle.c builtin/cat-file.c builtin/check-attr.c
+	builtin/check-ignore.c builtin/check-mailmap.c builtin/check-ref-format.c
+	builtin/checkout-index.c builtin/checkout.c builtin/clean.c
+	builtin/clone.c builtin/column.c builtin/commit-tree.c
+	builtin/commit.c builtin/commit-graph.c builtin/config.c
+	builtin/count-objects.c builtin/credential.c builtin/describe.c
+	builtin/diff-files.c builtin/diff-index.c builtin/diff-tree.c
+	builtin/diff.c builtin/difftool.c builtin/env--helper.c
+	builtin/fast-export.c builtin/fetch-pack.c builtin/fetch.c builtin/fmt-merge-msg.c
+	builtin/for-each-ref.c builtin/fsck.c builtin/gc.c
+	builtin/get-tar-commit-id.c builtin/grep.c builtin/hash-object.c
+	builtin/help.c builtin/index-pack.c builtin/init-db.c
+	builtin/interpret-trailers.c builtin/log.c builtin/ls-files.c
+	builtin/ls-remote.c builtin/ls-tree.c builtin/mailinfo.c builtin/mailsplit.c
+	builtin/merge.c builtin/merge-base.c builtin/merge-file.c builtin/merge-index.c
+	builtin/merge-ours.c builtin/merge-recursive.c builtin/merge-tree.c
+	builtin/mktag.c builtin/mktree.c builtin/multi-pack-index.c builtin/mv.c
+	builtin/name-rev.c builtin/notes.c builtin/pack-objects.c builtin/pack-redundant.c
+	builtin/pack-refs.c builtin/patch-id.c builtin/prune-packed.c builtin/prune.c
+	builtin/pull.c builtin/push.c builtin/range-diff.c builtin/read-tree.c
+	builtin/rebase.c builtin/receive-pack.c builtin/reflog.c builtin/remote.c
+	builtin/remote-ext.c builtin/remote-fd.c builtin/repack.c builtin/replace.c
+	builtin/rerere.c builtin/reset.c builtin/rev-list.c builtin/rev-parse.c
+	builtin/revert.c builtin/rm.c builtin/send-pack.c builtin/shortlog.c
+	builtin/show-branch.c builtin/show-index.c builtin/show-ref.c
+	builtin/sparse-checkout.c builtin/stash.c builtin/stripspace.c
+	builtin/submodule--helper.c builtin/symbolic-ref.c builtin/tag.c
+	builtin/unpack-file.c builtin/unpack-objects.c builtin/update-index.c
+	builtin/update-ref.c builtin/update-server-info.c builtin/upload-archive.c
+	builtin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c
+	builtin/verify-tag.c builtin/worktree.c builtin/write-tree.c)
+
+add_executable(git git.c ${git_SOURCES})
+target_link_libraries(git common-main )
+
+add_executable(git-bugreport bugreport.c)
+target_link_libraries(git-bugreport common-main)
+
+add_executable(git-credential-store credential-store.c)
+target_link_libraries(git-credential-store common-main)
+
+add_executable(git-daemon daemon.c)
+target_link_libraries(git-daemon common-main)
+
+add_executable(git-fast-import fast-import.c)
+target_link_libraries(git-fast-import common-main)
+
+add_executable(git-http-backend http-backend.c)
+target_link_libraries(git-http-backend common-main)
+
+add_executable(git-sh-i18n--envsubst sh-i18n--envsubst.c)
+target_link_libraries(git-sh-i18n--envsubst common-main)
+
+add_executable(git-shell shell.c)
+target_link_libraries(git-shell common-main)
+
+if(CURL_FOUND)
+	add_library(http_obj OBJECT http.c)
+
+	add_executable(git-imap-send imap-send.c)
+	target_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})
+
+	add_executable(git-http-fetch http-walker.c http-fetch.c)
+	target_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})
+
+	add_executable(git-remote-http http-walker.c remote-curl.c)
+	target_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )
+
+	if(EXPAT_FOUND)
+		add_executable(git-http-push http-push.c)
+		target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
+	endif()
+endif()
+
+add_executable(git-remote-testsvn remote-testsvn.c)
+target_link_libraries(git-remote-testsvn common-main vcs-svn)
+
+add_executable(git-credential-cache credential-cache.c)
+target_link_libraries(git-credential-cache common-main)
+
+add_executable(git-credential-cache--daemon credential-cache--daemon.c)
+target_link_libraries(git-credential-cache--daemon common-main)
+
+
+set(git_builtin_extra
+	cherry cherry-pick format-patch fsck-objects
+	init merge-subtree restore show
+	stage status switch whatchanged)
+
+#Creating hardlinks
+foreach(s ${git_SOURCES} ${git_builtin_extra})
+	string(REPLACE "builtin/" "" s ${s})
+	string(REPLACE ".c" "" s ${s})
+	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git git-${s})\n")
+	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})
+endforeach()
+
+if(CURL_FOUND)
+	set(remote_exes
+		git-remote-https git-remote-ftp git-remote-ftps)
+	foreach(s ${remote_exes})
+		file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http ${s})\n")
+		list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})
+	endforeach()
+endif()
+
+add_custom_command(OUTPUT ${git_links} ${git_http_links}
+		COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
+		DEPENDS git git-remote-http)
+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
\ No newline at end of file
Signature · 1 line
gitgitgadget
#2 lore raw

Re: [PATCH 1/8] Introduce CMake support for configuring Git on Linux

On 2020-04-24 04:01:30+0000, Sibi Siddharthan via GitGitGadget <[email protected]> wrote:

Please excuse my hatred for CMake.

I guess it's my own fault for not learning how to write CMake properly, or is it too hard to write correct CMake?

Quoted 7 lines

To make this a little less awkward, the Git for Windows project offers the vs/master branch which has a full Visual Studio solution generated and committed. This branch can therefore be used to tinker with Git in Visual Studio _without_ having to download the full Git for Windows SDK. Unfortunatly, that branch is auto-generated from Git for Windows' master. If a developer wants to tinker, say, with pu, they are out of luck.

I thought:
make NDEBUG=1 DEVELOPER=1 vcxproj

was invented for this use case?

Quoted 2 lines

CMake was invented to make this sort of problem go away, by providing a more standardized, cross-platform way to configure builds.

There is something fun with that *cross* Is cmake able to cross-compile cmake by cmake now?

Quoted 5 lines

With a working support CMake, developers on Windows need only install CMake, configure their build, load the generated Visual Studio solution and immediately start modifying the code and build their own version of Git. Likewise, developers on other platforms can use the convenient GUI tools provided by CMake to configure their build.

OK, that's fine if it works for you.
Please don't drop support for autoconf and Makefile, though. (I haven't look into other patches)

Quoted 26 lines

So let's start building CMake support for Git.

This is only the first step, and to make it easier to review, it only allows for configuring builds on the platform that is easiest to configure for: Linux.

The CMake script checks whether the headers are present(eg. libgen.h), whether the functions are present(eg. memmem), whether the funtions work properly (eg. snprintf) and generate the required compile definitions for the platform. The script also searches for the required libraries, if it fails to find the required libraries the respective executables won't be built.(eg. If libcurl is not found then git-remote-http won't be built). This will help building Git easier.

With a CMake script an out of source build of git is possible resulting in a clean source tree.

Note: earlier endeavors on the Git mailing list to introduce CMake ended up in dead water. The primary reason for that was that reviewers _expected_ CMake support to fall out of maintenance, unless the contributor would promise to keep an eye on keeping CMake support up to date. However, in the meantime, support for automated testing has been introduced in Git's source code, and a later patch will modify the (still experimental) GitHub workflow to continually verify that CMake support is still complete. That will make maintenance reasonably easy.

Quoted 2 lines

Note: this patch asks for the minimum version v3.14 of CMake (which is not all that old as of time of writing) because that is the first

Debian Buster (current stable) ships v3.13.4, I think I don't need to mention old-stable of Debian (Stretch or Jessie).

Quoted 4 lines

version to offer a platform-independent way to generate hardlinks as part of the build. This is needed to generate all those hardlinks for the built-in commands of Git.

Quoted 8 lines

Instructions to run CMake:

cmake relative-path-to-srcdir -DCMAKE_BUILD_TYPE=Release

Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding compiler flags
Debug : -g
Release: -O3

IIRC, Linus and Junio used to said noone ever needs "-03"

Quoted 25 lines

RelWithDebInfo : -O2 -g
MinSizeRel : -Os
empty(default) :

NOTE: -DCMAKE_BUILD_TYPE is optional

This process generates a Makefile.
Then run make to build Git.

NOTE: By default CMake uses Makefile as the build tool on Linux, to use another tool say ninja add this to the command line when configuring. -G Ninja

---
 CMakeLists.txt | 528 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 528 insertions(+)
 create mode 100644 CMakeLists.txt
CMakeLists.txt new file +0 -0
new file mode 100644
index 00000000000..73703bd321f

CMakeLists.txt line 10

Quoted 10 lines
CMakeLists.txt new file +10 -0
@@ -0,0 +1,528 @@
+#
+#	Copyright (c) 2020 Sibi Siddharthan
+#
+
+cmake_minimum_required(VERSION 3.14)
+
+#Parse GIT-VERSION-GEN to get the version
+file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX "DEF_VER=v(.*)")
+string(REPLACE "DEF_VER=v" "" git_version ${git_version})
+string(REPLACE ".GIT" ".0" git_version ${git_version})#for building from a snapshot

Does it work with e.g. 2.26.1?

Quoted 6 lines
CMakeLists.txt new file +6 -0
+
+project(git
+	VERSION ${git_version}
+	LANGUAGES C)
+
+

CMakeLists.txt line 26

Quoted 10 lines
CMakeLists.txt new file +10 -0
+include(CheckTypeSize)
+include(CheckCSourceRuns)
+include(CheckCSourceCompiles)
+include(CheckIncludeFile)
+include(CheckFunctionExists)
+include(CheckSymbolExists)
+include(CheckStructHasMember)
+
+find_package(ZLIB REQUIRED)
+find_package(CURL)

Right now, we should --with-zlib=/path/to/zlib/root Does this find_package support it?

CMakeLists.txt line 32

Quoted 7 lines
CMakeLists.txt new file +6 -0
+find_package(EXPAT)
+find_package(Iconv)
+find_package(Intl)
+
 
+if(NOT Intl_FOUND)
+	add_compile_definitions(NO_GETTEXT)

find_package(Gettext)?

CMakeLists.txt line 36

Quoted 4 lines
CMakeLists.txt new file +4 -0
+	if(NOT Iconv_FOUND)
+		add_compile_definitions(NO_ICONV)
+	endif()
+endif()

ICONV_OMITS_BOM?

Quoted 6 lines
CMakeLists.txt new file +6 -0
+
+include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
+if(CURL_FOUND)
+	include_directories(SYSTEM ${CURL_INCLUDE_DIRS})
+endif()
+if(EXPAT_FOUND)

CMakeLists.txt line 52

Quoted 10 lines
CMakeLists.txt new file +10 -0
+	include_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})
+endif()
+if(Iconv_FOUND)
+	include_directories(SYSTEM ${Iconv_INCLUDE_DIRS})
+endif()
+if(Intl_FOUND)
+	include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
+endif()
+
+find_program(SH_EXE sh)

We want to find usable sh, not just sh, no?

It's matter on Solaris, HP-UX

Quoted 16 lines
CMakeLists.txt new file +16 -0
+
+#default behaviour
+include_directories(${CMAKE_SOURCE_DIR})
+add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
+add_compile_definitions(SHA256_BLK INTERNAL_QSORT RUNTIME_PREFIX)
+add_compile_definitions(NO_OPENSSL SHA1_DC SHA1DC_NO_STANDARD_INCLUDES
+			SHA1DC_INIT_SAFE_HASH_DEFAULT=0
+			SHA1DC_CUSTOM_INCLUDE_SHA1_C="cache.h"
+			SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="git-compat-util.h" )
+list(APPEND compat_SOURCES sha1dc_git.c sha1dc/sha1.c sha1dc/ubc_check.c block-sha1/sha1.c sha256/block/sha256.c compat/qsort_s.c)
+
+
+add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
+			ETC_GITATTRIBUTES="etc/gitattributes"
+			ETC_GITCONFIG="etc/gitconfig"
+			GIT_EXEC_PATH="libexec/git-core"

CMakeLists.txt line 78

Quoted 10 lines
CMakeLists.txt new file +10 -0
+			GIT_LOCALE_PATH="share/locale"
+			GIT_MAN_PATH="share/man"
+			GIT_INFO_PATH="share/info"
+			GIT_HTML_PATH="share/doc/git-doc"
+			DEFAULT_HELP_FORMAT="html"
+			DEFAULT_GIT_TEMPLATE_DIR="share/git-core/templates"
+			GIT_VERSION="${PROJECT_VERSION}.GIT"
+			GIT_USER_AGENT="git/${PROJECT_VERSION}.GIT"
+			BINDIR="bin"
+			GIT_BUILT_FROM_COMMIT="")

I wish I could verify this.
Have you check this part on a default build system for a Linux distro, FreeBSD? For things started with "etc/"

CMakeLists.txt line 83

Quoted 5 lines
CMakeLists.txt new file +5 -0
+
+set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
+add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+
+add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )

/proc/self/exe is Linux only, no?

Quoted 12 lines
CMakeLists.txt new file +12 -0
+list(APPEND compat_SOURCES unix-socket.c)
+
+#header checks
+check_include_file(libgen.h HAVE_LIBGEN_H)
+if(NOT HAVE_LIBGEN_H)
+	add_compile_definitions(NO_LIBGEN_H)
+	list(APPEND compat_SOURCES compat/basename.c)
+endif()
+
+check_include_file(sys/sysinfo.h HAVE_SYSINFO)
+if(HAVE_SYSINFO)
+	add_compile_definitions(HAVE_SYSINFO)

CMakeLists.txt line 105

Quoted 10 lines
CMakeLists.txt new file +10 -0
+endif()
+
+check_c_source_compiles("
+#include <alloca.h>
+int
+main ()
+{
+char *p = (char *) alloca (2 * sizeof (int));
+	if (p) return 0;
+	return 0;

All code path will return 0?

Quoted 12 lines
CMakeLists.txt new file +12 -0
+}"
+HAVE_ALLOCA_H)
+if(HAVE_ALLOCA_H)
+	add_compile_definitions(HAVE_ALLOCA_H)
+endif()
+
+check_include_file(strings.h HAVE_STRINGS_H)
+if(HAVE_STRINGS_H)
+	add_compile_definitions(HAVE_STRINGS_H)
+endif()
+
+check_include_file(sys/select.h HAVE_SYS_SELECT_H)

CMakeLists.txt line 127

Quoted 10 lines
CMakeLists.txt new file +10 -0
+if(NOT HAVE_SYS_SELECT_H)
+	add_compile_definitions(NO_SYS_SELECT_H)
+endif()
+
+check_include_file(sys/poll.h HAVE_SYS_POLL_H)
+if(NOT HAVE_SYS_POLL_H)
+	add_compile_definitions(NO_SYS_POLL_H)
+endif()
+
+check_include_file(poll.h HAVE_POLL_H)

POSIX defined poll.h instead of sys/poll.h

Quoted 392 lines
CMakeLists.txt new file +392 -0
+if(NOT HAVE_POLL_H)
+	add_compile_definitions(NO_POLL_H)
+endif()
+
+check_include_file(inttypes.h HAVE_INTTYPES_H)
+if(NOT HAVE_INTTYPES_H)
+	add_compile_definitions(NO_INTTYPES_H)
+endif()
+
+check_include_file(paths.h HAVE_PATHS_H)
+if(HAVE_PATHS_H)
+	add_compile_definitions(HAVE_PATHS_H)
+endif()
+
+#function checks
+set(function_checks
+	strcasestr memmem strlcpy strtoimax strtoumax strtoull
+	setenv  mkdtemp poll pread  memmem unsetenv hstrerror)
+
+foreach(f ${function_checks})
+	string(TOUPPER ${f} uf)
+	check_function_exists(${f} HAVE_${uf})
+	if(NOT HAVE_${uf})
+		add_compile_definitions(NO_${uf})
+	endif()
+endforeach()
+
+if(NOT HAVE_POLL_H OR NOT HAVE_SYS_POLL_H OR NOT HAVE_POLL)
+	include_directories(compat/poll)
+	add_compile_definitions(NO_POLL)
+	list(APPEND compat_SOURCES compat/poll/poll.c)
+endif()
+
+if(NOT HAVE_STRCASESTR)
+	list(APPEND compat_SOURCES compat/strcasestr.c)
+endif()
+
+if(NOT HAVE_STRLCPY)
+	list(APPEND compat_SOURCES compat/strlcpy.c)
+endif()
+
+if(NOT HAVE_STRTOUMAX)
+	list(APPEND compat_SOURCES compat/strtoumax.c compat/strtoimax.c)
+endif()
+
+if(NOT HAVE_SETENV)
+	list(APPEND compat_SOURCES compat/setenv.c)
+endif()
+
+if(NOT HAVE_MKDTEMP)
+	list(APPEND compat_SOURCES compat/mkdtemp.c)
+endif()
+
+if(NOT HAVE_PREAD)
+	list(APPEND compat_SOURCES compat/pread.c)
+endif()
+
+if(NOT HAVE_MEMMEM)
+	list(APPEND compat_SOURCES compat/memmem.c)
+endif()
+
+if(NOT WIN32)
+	if(NOT HAVE_UNSETENV)
+		list(APPEND compat_SOURCES compat/unsetenv.c)
+	endif()
+
+	if(NOT HAVE_HSTRERROR)
+		list(APPEND compat_SOURCES compat/hstrerror.c)
+	endif()
+endif()
+
+check_function_exists(getdelim HAVE_GETDELIM)
+if(HAVE_GETDELIM)
+	add_compile_definitions(HAVE_GETDELIM)
+endif()
+
+check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
+check_symbol_exists(CLOCK_MONOTONIC "time.h" HAVE_CLOCK_MONOTONIC)
+if(HAVE_CLOCK_GETTIME)
+	add_compile_definitions(HAVE_CLOCK_GETTIME)
+endif()
+if(HAVE_CLOCK_MONOTONIC)
+	add_compile_definitions(HAVE_CLOCK_MONOTONIC)
+endif()
+
+
+#compile checks
+check_c_source_runs("
+#include<stdio.h>
+#include<stdarg.h>
+#include<string.h>
+#include<stdlib.h>
+int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)
+{
+	int ret;
+	va_list ap;
+
+	va_start(ap, format);
+	ret = vsnprintf(str, maxsize, format, ap);
+	va_end(ap);
+	return ret;
+}
+
+int
+main ()
+{
+	char buf[6];
+	if (test_vsnprintf(buf, 3, \"%s\", \"12345\") != 5
+		|| strcmp(buf, \"12\")) return 1;
+	if (snprintf(buf, 3, \"%s\", \"12345\") != 5
+		|| strcmp(buf, \"12\")) return 1;
+
+	return 0;
+}"
+SNPRINTF_OK)
+if(NOT SNPRINTF_OK)
+	add_compile_definitions(SNPRINTF_RETURNS_BOGUS)
+	list(APPEND compat_SOURCES compat/snprintf.c)
+endif()
+
+check_c_source_runs("
+#include<stdio.h>
+int
+main ()
+{
+	FILE *f = fopen(\".\", \"r\");
+	return f != NULL;
+
+	return 0;
+}"
+FREAD_READS_DIRECTORIES_NO)
+if(NOT FREAD_READS_DIRECTORIES_NO)
+	add_compile_definitions(FREAD_READS_DIRECTORIES)
+	list(APPEND compat_SOURCES compat/fopen.c)
+endif()
+
+check_c_source_compiles("
+#include <regex.h>
+#ifndef REG_STARTEND
+#error oops we dont have it
+#endif
+int main(){return 0;}"
+HAVE_REGEX)
+if(NOT HAVE_REGEX)
+	include_directories(compat/regex )
+	list(APPEND compat_SOURCES compat/regex/regex.c )
+	add_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)
+endif()
+
+
+check_c_source_compiles("
+#include <stddef.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+int
+main ()
+{
+	int val, mib[2];
+	size_t len;
+
+	mib[0] = CTL_HW;
+	mib[1] = 1;
+	len = sizeof(val);
+	return sysctl(mib, 2, &val, &len, NULL, 0) ? 1 : 0;
+
+	return 0;
+}"
+HAVE_BSD_SYSCTL)
+if(HAVE_BSD_SYSCTL)
+	add_compile_definitions(HAVE_BSD_SYSCTL)
+endif()
+
+#programs
+set(PROGRAMS_BUILT
+	git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
+	git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)
+
+if(NOT CURL_FOUND)
+	list(APPEND excluded_progs git-http-fetch git-http-push)
+	add_compile_definitions(NO_CURL)
+	message(WARNING "git-http-push and git-http-fetch will not be built")
+else()
+	list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)
+	if(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)
+		add_compile_definitions(USE_CURL_FOR_IMAP_SEND)
+	endif()
+endif()
+
+if(NOT EXPAT_FOUND)
+	list(APPEND excluded_progs git-http-push)
+	add_compile_definitions(NO_EXPAT)
+else()
+	list(APPEND PROGRAMS_BUILT git-http-push)
+	if(EXPAT_VERSION_STRING VERSION_LESS_EQUAL 1.2)
+		add_compile_definitions(EXPAT_NEEDS_XMLPARSE_H)
+	endif()
+endif()
+
+list(REMOVE_DUPLICATES excluded_progs)
+list(REMOVE_DUPLICATES PROGRAMS_BUILT)
+
+
+foreach(p ${excluded_progs})
+	list(APPEND EXCLUSION_PROGS --exclude-program ${p} )
+endforeach()
+
+#for comparing null values
+list(APPEND EXCLUSION_PROGS empty)
+set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING "Programs not built" FORCE)
+
+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)
+	list(REMOVE_ITEM EXCLUSION_PROGS empty)
+	message("Generating command-list.h")
+	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt
+			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+			OUTPUT_FILE ${CMAKE_SOURCE_DIR}/command-list.h)
+endif()
+
+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/config-list.h)
+	message("Generating config-list.h")
+	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh
+			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+			OUTPUT_FILE ${CMAKE_SOURCE_DIR}/config-list.h)
+endif()
+
+
+#build
+set(libgit_SOURCES
+	abspath.c add-interactive.c add-patch.c advice.c alias.c
+	alloc.c apply.c archive.c archive-tar.c archive-zip.c argv-array.c
+	attr.c base85.c bisect.c blame.c blob.c bloom.c branch.c bulk-checkin.c
+	bundle.c cache-tree.c chdir-notify.c checkout.c color.c column.c
+	combine-diff.c commit.c commit-graph.c commit-reach.c compat/obstack.c
+	compat/terminal.c config.c connect.c connected.c convert.c copy.c credential.c
+	csum-file.c ctype.c date.c decorate.c delta-islands.c diffcore-break.c
+	diffcore-delta.c diffcore-order.c diffcore-pickaxe.c diffcore-rename.c
+	diff-delta.c diff-lib.c diff-no-index.c diff.c dir.c dir-iterator.c editor.c
+	entry.c environment.c ewah/bitmap.c ewah/ewah_bitmap.c ewah/ewah_io.c
+	ewah/ewah_rlw.c exec-cmd.c fetch-negotiator.c fetch-pack.c fmt-merge-msg.c fsck.c fsmonitor.c
+	gettext.c gpg-interface.c graph.c grep.c hashmap.c linear-assignment.c help.c hex.c
+	ident.c interdiff.c json-writer.c kwset.c levenshtein.c line-log.c line-range.c list-objects.c
+	list-objects-filter.c list-objects-filter-options.c ll-merge.c lockfile.c
+	log-tree.c ls-refs.c mailinfo.c mailmap.c match-trees.c mem-pool.c merge.c merge-blobs.c
+	merge-recursive.c mergesort.c midx.c name-hash.c negotiator/default.c
+	negotiator/skipping.c notes.c notes-cache.c notes-merge.c notes-utils.c object.c oidmap.c
+	oidset.c oid-array.c packfile.c pack-bitmap.c pack-bitmap-write.c pack-check.c pack-objects.c
+	pack-revindex.c pack-write.c pager.c parse-options.c parse-options-cb.c patch-delta.c
+	patch-ids.c path.c pathspec.c pkt-line.c preload-index.c pretty.c prio-queue.c progress.c
+	promisor-remote.c prompt.c protocol.c prune-packed.c quote.c range-diff.c reachable.c read-cache.c rebase.c
+	rebase-interactive.c reflog-walk.c refs.c refs/files-backend.c refs/iterator.c
+	refs/packed-backend.c refs/ref-cache.c refspec.c ref-filter.c remote.c replace-object.c
+	repo-settings.c repository.c rerere.c reset.c resolve-undo.c revision.c run-command.c
+	send-pack.c sequencer.c serve.c server-info.c setup.c sha1-lookup.c
+	sha1-file.c sha1-name.c shallow.c sideband.c sigchain.c split-index.c
+	stable-qsort.c strbuf.c streaming.c string-list.c submodule.c submodule-config.c
+	sub-process.c symlinks.c tag.c tempfile.c thread-utils.c tmp-objdir.c
+	trace.c trace2.c trace2/tr2_cfg.c trace2/tr2_cmd_name.c trace2/tr2_dst.c
+	trace2/tr2_sid.c trace2/tr2_sysenv.c trace2/tr2_tbuf.c trace2/tr2_tgt_event.c
+	trace2/tr2_tgt_normal.c trace2/tr2_tgt_perf.c trace2/tr2_tls.c trailer.c transport.c
+	transport-helper.c tree-diff.c tree.c tree-walk.c unpack-trees.c upload-pack.c url.c
+	urlmatch.c usage.c userdiff.c utf8.c varint.c version.c versioncmp.c walker.c wildmatch.c
+	worktree.c wrapper.c write-or-die.c ws.c wt-status.c xdiff-interface.c
+	zlib.c)
+
+add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})
+
+set(libxdiff_SOURCES
+	xdiff/xdiffi.c xdiff/xprepare.c xdiff/xutils.c xdiff/xemit.c
+	xdiff/xmerge.c xdiff/xpatience.c xdiff/xhistogram.c)
+add_library(xdiff STATIC ${libxdiff_SOURCES})
+
+set(libvcs-svn_SOURCES
+	vcs-svn/line_buffer.c vcs-svn/sliding_window.c vcs-svn/fast_export.c
+	vcs-svn/svndiff.c vcs-svn/svndump.c)
+add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
+
+#link all required libraries to common-main
+add_library(common-main OBJECT common-main.c)
+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
+if(Intl_FOUND)
+	target_link_libraries(common-main ${Intl_LIBRARIES})
+endif()
+if(Iconv_FOUND)
+	target_link_libraries(common-main ${Iconv_LIBRARIES})
+endif()
+
+
+set(git_SOURCES
+	builtin/add.c builtin/am.c builtin/annotate.c builtin/apply.c
+	builtin/archive.c builtin/bisect--helper.c builtin/blame.c
+	builtin/branch.c builtin/bundle.c builtin/cat-file.c builtin/check-attr.c
+	builtin/check-ignore.c builtin/check-mailmap.c builtin/check-ref-format.c
+	builtin/checkout-index.c builtin/checkout.c builtin/clean.c
+	builtin/clone.c builtin/column.c builtin/commit-tree.c
+	builtin/commit.c builtin/commit-graph.c builtin/config.c
+	builtin/count-objects.c builtin/credential.c builtin/describe.c
+	builtin/diff-files.c builtin/diff-index.c builtin/diff-tree.c
+	builtin/diff.c builtin/difftool.c builtin/env--helper.c
+	builtin/fast-export.c builtin/fetch-pack.c builtin/fetch.c builtin/fmt-merge-msg.c
+	builtin/for-each-ref.c builtin/fsck.c builtin/gc.c
+	builtin/get-tar-commit-id.c builtin/grep.c builtin/hash-object.c
+	builtin/help.c builtin/index-pack.c builtin/init-db.c
+	builtin/interpret-trailers.c builtin/log.c builtin/ls-files.c
+	builtin/ls-remote.c builtin/ls-tree.c builtin/mailinfo.c builtin/mailsplit.c
+	builtin/merge.c builtin/merge-base.c builtin/merge-file.c builtin/merge-index.c
+	builtin/merge-ours.c builtin/merge-recursive.c builtin/merge-tree.c
+	builtin/mktag.c builtin/mktree.c builtin/multi-pack-index.c builtin/mv.c
+	builtin/name-rev.c builtin/notes.c builtin/pack-objects.c builtin/pack-redundant.c
+	builtin/pack-refs.c builtin/patch-id.c builtin/prune-packed.c builtin/prune.c
+	builtin/pull.c builtin/push.c builtin/range-diff.c builtin/read-tree.c
+	builtin/rebase.c builtin/receive-pack.c builtin/reflog.c builtin/remote.c
+	builtin/remote-ext.c builtin/remote-fd.c builtin/repack.c builtin/replace.c
+	builtin/rerere.c builtin/reset.c builtin/rev-list.c builtin/rev-parse.c
+	builtin/revert.c builtin/rm.c builtin/send-pack.c builtin/shortlog.c
+	builtin/show-branch.c builtin/show-index.c builtin/show-ref.c
+	builtin/sparse-checkout.c builtin/stash.c builtin/stripspace.c
+	builtin/submodule--helper.c builtin/symbolic-ref.c builtin/tag.c
+	builtin/unpack-file.c builtin/unpack-objects.c builtin/update-index.c
+	builtin/update-ref.c builtin/update-server-info.c builtin/upload-archive.c
+	builtin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c
+	builtin/verify-tag.c builtin/worktree.c builtin/write-tree.c)
+
+add_executable(git git.c ${git_SOURCES})
+target_link_libraries(git common-main )
+
+add_executable(git-bugreport bugreport.c)
+target_link_libraries(git-bugreport common-main)
+
+add_executable(git-credential-store credential-store.c)
+target_link_libraries(git-credential-store common-main)
+
+add_executable(git-daemon daemon.c)
+target_link_libraries(git-daemon common-main)
+
+add_executable(git-fast-import fast-import.c)
+target_link_libraries(git-fast-import common-main)
+
+add_executable(git-http-backend http-backend.c)
+target_link_libraries(git-http-backend common-main)
+
+add_executable(git-sh-i18n--envsubst sh-i18n--envsubst.c)
+target_link_libraries(git-sh-i18n--envsubst common-main)
+
+add_executable(git-shell shell.c)
+target_link_libraries(git-shell common-main)
+
+if(CURL_FOUND)
+	add_library(http_obj OBJECT http.c)
+
+	add_executable(git-imap-send imap-send.c)
+	target_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})
+
+	add_executable(git-http-fetch http-walker.c http-fetch.c)
+	target_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})
+
+	add_executable(git-remote-http http-walker.c remote-curl.c)
+	target_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )
+
+	if(EXPAT_FOUND)
+		add_executable(git-http-push http-push.c)
+		target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
+	endif()
+endif()
+
+add_executable(git-remote-testsvn remote-testsvn.c)
+target_link_libraries(git-remote-testsvn common-main vcs-svn)
+
+add_executable(git-credential-cache credential-cache.c)
+target_link_libraries(git-credential-cache common-main)
+
+add_executable(git-credential-cache--daemon credential-cache--daemon.c)
+target_link_libraries(git-credential-cache--daemon common-main)
+
+
+set(git_builtin_extra
+	cherry cherry-pick format-patch fsck-objects
+	init merge-subtree restore show
+	stage status switch whatchanged)
+
+#Creating hardlinks
+foreach(s ${git_SOURCES} ${git_builtin_extra})
+	string(REPLACE "builtin/" "" s ${s})
+	string(REPLACE ".c" "" s ${s})
+	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git git-${s})\n")
+	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})
+endforeach()
+
+if(CURL_FOUND)
+	set(remote_exes
+		git-remote-https git-remote-ftp git-remote-ftps)
+	foreach(s ${remote_exes})

CMakeLists.txt line 528

Quoted 10 lines
CMakeLists.txt new file +9 -0
+		file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http ${s})\n")
+		list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})
+	endforeach()
+endif()
+
+add_custom_command(OUTPUT ${git_links} ${git_http_links}
+		COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
+		DEPENDS git git-remote-http)
+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
\ No newline at end of file

No new line at end of line always leave a bad taste in my mount!

Signature · 1 line
Danh
#3 lore raw

Re: [PATCH 1/8] Introduce CMake support for configuring Git on Linux

Hi Danh,
Thank You for your feedback.
Before I answer your comments, I would like to say that the CMake script only supports Linux and Windows.
I don't have BSD, Solaris or Apple systems to test the script on. The Makefile will still be used for those systems and won't be replaced. Also, I am sorry for not leaving a newline at the end.

Quoted 16 lines · Danh Doan

On 2020-04-24 04:01:30+0000, Sibi Siddharthan via GitGitGadget <[email protected]> wrote:

Please excuse my hatred for CMake.

I guess it's my own fault for not learning how to write CMake properly, or is it too hard to write correct CMake?

Quoted 7 lines

To make this a little less awkward, the Git for Windows project offers the vs/master branch which has a full Visual Studio solution generated and committed. This branch can therefore be used to tinker with Git in Visual Studio _without_ having to download the full Git for Windows SDK. Unfortunatly, that branch is auto-generated from Git for Windows' master. If a developer wants to tinker, say, with pu, they are out of luck.

Quoted 5 lines

I thought:
make NDEBUG=1 DEVELOPER=1 vcxproj

was invented for this use case?

Yes,
But with CMake a lot more can be done with Visual Studio. For example we can also target clang-cl now.

Quoted 12 lines
Quoted 2 lines

CMake was invented to make this sort of problem go away, by providing a more standardized, cross-platform way to configure builds.

There is something fun with that *cross* Is cmake able to cross-compile cmake by cmake now?

Quoted 5 lines

With a working support CMake, developers on Windows need only install CMake, configure their build, load the generated Visual Studio solution and immediately start modifying the code and build their own version of Git. Likewise, developers on other platforms can use the convenient GUI tools provided by CMake to configure their build.

Quoted 4 lines

OK, that's fine if it works for you.
Please don't drop support for autoconf and Makefile, though. (I haven't look into other patches)

The Makefile is not going away at all. The CMake script is intended to complement
the already existing Makefile by giving people flexibility.

Quoted 39 lines
Quoted 26 lines

So let's start building CMake support for Git.

This is only the first step, and to make it easier to review, it only allows for configuring builds on the platform that is easiest to configure for: Linux.

The CMake script checks whether the headers are present(eg. libgen.h), whether the functions are present(eg. memmem), whether the funtions work properly (eg. snprintf) and generate the required compile definitions for the platform. The script also searches for the required libraries, if it fails to find the required libraries the respective executables won't be built.(eg. If libcurl is not found then git-remote-http won't be built). This will help building Git easier.

With a CMake script an out of source build of git is possible resulting in a clean source tree.

Note: earlier endeavors on the Git mailing list to introduce CMake ended up in dead water. The primary reason for that was that reviewers _expected_ CMake support to fall out of maintenance, unless the contributor would promise to keep an eye on keeping CMake support up to date. However, in the meantime, support for automated testing has been introduced in Git's source code, and a later patch will modify the (still experimental) GitHub workflow to continually verify that CMake support is still complete. That will make maintenance reasonably easy.

Quoted 2 lines

Note: this patch asks for the minimum version v3.14 of CMake (which is not all that old as of time of writing) because that is the first

Debian Buster (current stable) ships v3.13.4, I think I don't need to mention old-stable of Debian (Stretch or Jessie).

Quoted 6 lines

version to offer a platform-independent way to generate hardlinks as part of the build. This is needed to generate all those hardlinks for the built-in commands of Git.

Instructions to run CMake:

Quoted 9 lines
Quoted 6 lines

cmake relative-path-to-srcdir -DCMAKE_BUILD_TYPE=Release

Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding compiler flags
Debug : -g
Release: -O3

IIRC, Linus and Junio used to said noone ever needs "-03"

Okay, there is still a way to for "-O2" on Release builds, if you prefer to do that.

Quoted 29 lines
Quoted 29 lines

RelWithDebInfo : -O2 -g
MinSizeRel : -Os
empty(default) :

NOTE: -DCMAKE_BUILD_TYPE is optional

This process generates a Makefile.
Then run make to build Git.

NOTE: By default CMake uses Makefile as the build tool on Linux, to use another tool say ninja add this to the command line when configuring. -G Ninja

---
 CMakeLists.txt | 528 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 528 insertions(+)
 create mode 100644 CMakeLists.txt
CMakeLists.txt new file +4 -0
new file mode 100644
index 00000000000..73703bd321f
@@ -0,0 +1,528 @@
+#
+#    Copyright (c) 2020 Sibi Siddharthan
+#
+
Quoted 9 lines

CMakeLists.txt line 10

Quoted 6 lines
CMakeLists.txt new file +6 -0
+cmake_minimum_required(VERSION 3.14)
+
+#Parse GIT-VERSION-GEN to get the version
+file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX "DEF_VER=v(.*)")
+string(REPLACE "DEF_VER=v" "" git_version ${git_version})
+string(REPLACE ".GIT" ".0" git_version ${git_version})#for building from a snapshot

Does it work with e.g. 2.26.1?

Yes it does, the snapshots have ".GIT" at the end the versions whereas the tags have "2.26.1".
This was a hack for setting the patch level to 0 for the snapshot builds.

Quoted 11 lines
Quoted 11 lines
CMakeLists.txt new file +11 -0
+
+project(git
+     VERSION ${git_version}
+     LANGUAGES C)
+
+
+include(CheckTypeSize)
+include(CheckCSourceRuns)
+include(CheckCSourceCompiles)
+include(CheckIncludeFile)
+include(CheckFunctionExists)
Quoted 9 lines

CMakeLists.txt line 26

Quoted 5 lines
CMakeLists.txt new file +5 -0
+include(CheckSymbolExists)
+include(CheckStructHasMember)
+
+find_package(ZLIB REQUIRED)
+find_package(CURL)

Right now, we should --with-zlib=/path/to/zlib/root Does this find_package support it?

Yes it does,
all you have to do is -DZLIB_ROOT=/path/to/zlib/root

Quoted 10 lines

CMakeLists.txt line 32

Quoted 7 lines
CMakeLists.txt new file +6 -0
+find_package(EXPAT)
+find_package(Iconv)
+find_package(Intl)
+
 
+if(NOT Intl_FOUND)
+     add_compile_definitions(NO_GETTEXT)

find_package(Gettext)?

find_package(Gettext) does not define libintl and libintl.h. If NO_GETTEXT is not defined, it means that libintl.h is present. So, we use find_package(Intl) for libintl

Quoted 7 lines

CMakeLists.txt line 36

Quoted 4 lines
CMakeLists.txt new file +4 -0
+     if(NOT Iconv_FOUND)
+             add_compile_definitions(NO_ICONV)
+     endif()
+endif()

ICONV_OMITS_BOM?

Forgot about this, will add it.

Quoted 19 lines
Quoted 6 lines
CMakeLists.txt new file +6 -0
+
+include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
+if(CURL_FOUND)
+     include_directories(SYSTEM ${CURL_INCLUDE_DIRS})
+endif()
+if(EXPAT_FOUND)

CMakeLists.txt line 52

Quoted 10 lines
CMakeLists.txt new file +10 -0
+     include_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})
+endif()
+if(Iconv_FOUND)
+     include_directories(SYSTEM ${Iconv_INCLUDE_DIRS})
+endif()
+if(Intl_FOUND)
+     include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
+endif()
+
+find_program(SH_EXE sh)

We want to find usable sh, not just sh, no?

Quoted 2 lines

It's matter on Solaris, HP-UX

How do I check for this, can you help?
Also, the script is not supported on Solaris and HP-UX.

Quoted 22 lines
Quoted 22 lines
CMakeLists.txt new file +22 -0
+
+#default behaviour
+include_directories(${CMAKE_SOURCE_DIR})
+add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
+add_compile_definitions(SHA256_BLK INTERNAL_QSORT RUNTIME_PREFIX)
+add_compile_definitions(NO_OPENSSL SHA1_DC SHA1DC_NO_STANDARD_INCLUDES
+                     SHA1DC_INIT_SAFE_HASH_DEFAULT=0
+                     SHA1DC_CUSTOM_INCLUDE_SHA1_C="cache.h"
+                     SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="git-compat-util.h" )
+list(APPEND compat_SOURCES sha1dc_git.c sha1dc/sha1.c sha1dc/ubc_check.c block-sha1/sha1.c sha256/block/sha256.c compat/qsort_s.c)
+
+
+add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
+                     ETC_GITATTRIBUTES="etc/gitattributes"
+                     ETC_GITCONFIG="etc/gitconfig"
+                     GIT_EXEC_PATH="libexec/git-core"
+                     GIT_LOCALE_PATH="share/locale"
+                     GIT_MAN_PATH="share/man"
+                     GIT_INFO_PATH="share/info"
+                     GIT_HTML_PATH="share/doc/git-doc"
+                     DEFAULT_HELP_FORMAT="html"
+                     DEFAULT_GIT_TEMPLATE_DIR="share/git-core/templates"
Quoted 9 lines

CMakeLists.txt line 78

Quoted 4 lines
CMakeLists.txt new file +4 -0
+                     GIT_VERSION="${PROJECT_VERSION}.GIT"
+                     GIT_USER_AGENT="git/${PROJECT_VERSION}.GIT"
+                     BINDIR="bin"
+                     GIT_BUILT_FROM_COMMIT="")

I wish I could verify this.
Have you check this part on a default build system for a Linux distro, FreeBSD? For things started with "etc/"

These are the values I got when I looked at the build logs from the Makefile (make -n) in Linux and Windows.
Don't know about FreeBSD

Quoted 8 lines

CMakeLists.txt line 83

Quoted 5 lines
CMakeLists.txt new file +5 -0
+
+set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
+add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+
+add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )

/proc/self/exe is Linux only, no?

Yes, it is. This first patch only supports Linux build.

Quoted 16 lines
Quoted 16 lines
CMakeLists.txt new file +16 -0
+list(APPEND compat_SOURCES unix-socket.c)
+
+#header checks
+check_include_file(libgen.h HAVE_LIBGEN_H)
+if(NOT HAVE_LIBGEN_H)
+     add_compile_definitions(NO_LIBGEN_H)
+     list(APPEND compat_SOURCES compat/basename.c)
+endif()
+
+check_include_file(sys/sysinfo.h HAVE_SYSINFO)
+if(HAVE_SYSINFO)
+     add_compile_definitions(HAVE_SYSINFO)
+endif()
+
+check_c_source_compiles("
+#include <alloca.h>
Quoted 9 lines

CMakeLists.txt line 105

Quoted 6 lines
CMakeLists.txt new file +6 -0
+int
+main ()
+{
+char *p = (char *) alloca (2 * sizeof (int));
+     if (p) return 0;
+     return 0;

All code path will return 0?

This check is for a working alloca.h.
Some systems define alloca in malloc.h (Windows)

Quoted 431 lines
Quoted 12 lines
CMakeLists.txt new file +12 -0
+}"
+HAVE_ALLOCA_H)
+if(HAVE_ALLOCA_H)
+     add_compile_definitions(HAVE_ALLOCA_H)
+endif()
+
+check_include_file(strings.h HAVE_STRINGS_H)
+if(HAVE_STRINGS_H)
+     add_compile_definitions(HAVE_STRINGS_H)
+endif()
+
+check_include_file(sys/select.h HAVE_SYS_SELECT_H)

CMakeLists.txt line 127

Quoted 10 lines
CMakeLists.txt new file +10 -0
+if(NOT HAVE_SYS_SELECT_H)
+     add_compile_definitions(NO_SYS_SELECT_H)
+endif()
+
+check_include_file(sys/poll.h HAVE_SYS_POLL_H)
+if(NOT HAVE_SYS_POLL_H)
+     add_compile_definitions(NO_SYS_POLL_H)
+endif()
+
+check_include_file(poll.h HAVE_POLL_H)

POSIX defined poll.h instead of sys/poll.h

Quoted 392 lines
CMakeLists.txt new file +392 -0
+if(NOT HAVE_POLL_H)
+     add_compile_definitions(NO_POLL_H)
+endif()
+
+check_include_file(inttypes.h HAVE_INTTYPES_H)
+if(NOT HAVE_INTTYPES_H)
+     add_compile_definitions(NO_INTTYPES_H)
+endif()
+
+check_include_file(paths.h HAVE_PATHS_H)
+if(HAVE_PATHS_H)
+     add_compile_definitions(HAVE_PATHS_H)
+endif()
+
+#function checks
+set(function_checks
+     strcasestr memmem strlcpy strtoimax strtoumax strtoull
+     setenv  mkdtemp poll pread  memmem unsetenv hstrerror)
+
+foreach(f ${function_checks})
+     string(TOUPPER ${f} uf)
+     check_function_exists(${f} HAVE_${uf})
+     if(NOT HAVE_${uf})
+             add_compile_definitions(NO_${uf})
+     endif()
+endforeach()
+
+if(NOT HAVE_POLL_H OR NOT HAVE_SYS_POLL_H OR NOT HAVE_POLL)
+     include_directories(compat/poll)
+     add_compile_definitions(NO_POLL)
+     list(APPEND compat_SOURCES compat/poll/poll.c)
+endif()
+
+if(NOT HAVE_STRCASESTR)
+     list(APPEND compat_SOURCES compat/strcasestr.c)
+endif()
+
+if(NOT HAVE_STRLCPY)
+     list(APPEND compat_SOURCES compat/strlcpy.c)
+endif()
+
+if(NOT HAVE_STRTOUMAX)
+     list(APPEND compat_SOURCES compat/strtoumax.c compat/strtoimax.c)
+endif()
+
+if(NOT HAVE_SETENV)
+     list(APPEND compat_SOURCES compat/setenv.c)
+endif()
+
+if(NOT HAVE_MKDTEMP)
+     list(APPEND compat_SOURCES compat/mkdtemp.c)
+endif()
+
+if(NOT HAVE_PREAD)
+     list(APPEND compat_SOURCES compat/pread.c)
+endif()
+
+if(NOT HAVE_MEMMEM)
+     list(APPEND compat_SOURCES compat/memmem.c)
+endif()
+
+if(NOT WIN32)
+     if(NOT HAVE_UNSETENV)
+             list(APPEND compat_SOURCES compat/unsetenv.c)
+     endif()
+
+     if(NOT HAVE_HSTRERROR)
+             list(APPEND compat_SOURCES compat/hstrerror.c)
+     endif()
+endif()
+
+check_function_exists(getdelim HAVE_GETDELIM)
+if(HAVE_GETDELIM)
+     add_compile_definitions(HAVE_GETDELIM)
+endif()
+
+check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
+check_symbol_exists(CLOCK_MONOTONIC "time.h" HAVE_CLOCK_MONOTONIC)
+if(HAVE_CLOCK_GETTIME)
+     add_compile_definitions(HAVE_CLOCK_GETTIME)
+endif()
+if(HAVE_CLOCK_MONOTONIC)
+     add_compile_definitions(HAVE_CLOCK_MONOTONIC)
+endif()
+
+
+#compile checks
+check_c_source_runs("
+#include<stdio.h>
+#include<stdarg.h>
+#include<string.h>
+#include<stdlib.h>
+int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)
+{
+     int ret;
+     va_list ap;
+
+     va_start(ap, format);
+     ret = vsnprintf(str, maxsize, format, ap);
+     va_end(ap);
+     return ret;
+}
+
+int
+main ()
+{
+     char buf[6];
+     if (test_vsnprintf(buf, 3, \"%s\", \"12345\") != 5
+             || strcmp(buf, \"12\")) return 1;
+     if (snprintf(buf, 3, \"%s\", \"12345\") != 5
+             || strcmp(buf, \"12\")) return 1;
+
+     return 0;
+}"
+SNPRINTF_OK)
+if(NOT SNPRINTF_OK)
+     add_compile_definitions(SNPRINTF_RETURNS_BOGUS)
+     list(APPEND compat_SOURCES compat/snprintf.c)
+endif()
+
+check_c_source_runs("
+#include<stdio.h>
+int
+main ()
+{
+     FILE *f = fopen(\".\", \"r\");
+     return f != NULL;
+
+     return 0;
+}"
+FREAD_READS_DIRECTORIES_NO)
+if(NOT FREAD_READS_DIRECTORIES_NO)
+     add_compile_definitions(FREAD_READS_DIRECTORIES)
+     list(APPEND compat_SOURCES compat/fopen.c)
+endif()
+
+check_c_source_compiles("
+#include <regex.h>
+#ifndef REG_STARTEND
+#error oops we dont have it
+#endif
+int main(){return 0;}"
+HAVE_REGEX)
+if(NOT HAVE_REGEX)
+     include_directories(compat/regex )
+     list(APPEND compat_SOURCES compat/regex/regex.c )
+     add_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)
+endif()
+
+
+check_c_source_compiles("
+#include <stddef.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+int
+main ()
+{
+     int val, mib[2];
+     size_t len;
+
+     mib[0] = CTL_HW;
+     mib[1] = 1;
+     len = sizeof(val);
+     return sysctl(mib, 2, &val, &len, NULL, 0) ? 1 : 0;
+
+     return 0;
+}"
+HAVE_BSD_SYSCTL)
+if(HAVE_BSD_SYSCTL)
+     add_compile_definitions(HAVE_BSD_SYSCTL)
+endif()
+
+#programs
+set(PROGRAMS_BUILT
+     git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
+     git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)
+
+if(NOT CURL_FOUND)
+     list(APPEND excluded_progs git-http-fetch git-http-push)
+     add_compile_definitions(NO_CURL)
+     message(WARNING "git-http-push and git-http-fetch will not be built")
+else()
+     list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)
+     if(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)
+             add_compile_definitions(USE_CURL_FOR_IMAP_SEND)
+     endif()
+endif()
+
+if(NOT EXPAT_FOUND)
+     list(APPEND excluded_progs git-http-push)
+     add_compile_definitions(NO_EXPAT)
+else()
+     list(APPEND PROGRAMS_BUILT git-http-push)
+     if(EXPAT_VERSION_STRING VERSION_LESS_EQUAL 1.2)
+             add_compile_definitions(EXPAT_NEEDS_XMLPARSE_H)
+     endif()
+endif()
+
+list(REMOVE_DUPLICATES excluded_progs)
+list(REMOVE_DUPLICATES PROGRAMS_BUILT)
+
+
+foreach(p ${excluded_progs})
+     list(APPEND EXCLUSION_PROGS --exclude-program ${p} )
+endforeach()
+
+#for comparing null values
+list(APPEND EXCLUSION_PROGS empty)
+set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING "Programs not built" FORCE)
+
+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)
+     list(REMOVE_ITEM EXCLUSION_PROGS empty)
+     message("Generating command-list.h")
+     execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt
+                     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+                     OUTPUT_FILE ${CMAKE_SOURCE_DIR}/command-list.h)
+endif()
+
+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/config-list.h)
+     message("Generating config-list.h")
+     execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh
+                     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+                     OUTPUT_FILE ${CMAKE_SOURCE_DIR}/config-list.h)
+endif()
+
+
+#build
+set(libgit_SOURCES
+     abspath.c add-interactive.c add-patch.c advice.c alias.c
+     alloc.c apply.c archive.c archive-tar.c archive-zip.c argv-array.c
+     attr.c base85.c bisect.c blame.c blob.c bloom.c branch.c bulk-checkin.c
+     bundle.c cache-tree.c chdir-notify.c checkout.c color.c column.c
+     combine-diff.c commit.c commit-graph.c commit-reach.c compat/obstack.c
+     compat/terminal.c config.c connect.c connected.c convert.c copy.c credential.c
+     csum-file.c ctype.c date.c decorate.c delta-islands.c diffcore-break.c
+     diffcore-delta.c diffcore-order.c diffcore-pickaxe.c diffcore-rename.c
+     diff-delta.c diff-lib.c diff-no-index.c diff.c dir.c dir-iterator.c editor.c
+     entry.c environment.c ewah/bitmap.c ewah/ewah_bitmap.c ewah/ewah_io.c
+     ewah/ewah_rlw.c exec-cmd.c fetch-negotiator.c fetch-pack.c fmt-merge-msg.c fsck.c fsmonitor.c
+     gettext.c gpg-interface.c graph.c grep.c hashmap.c linear-assignment.c help.c hex.c
+     ident.c interdiff.c json-writer.c kwset.c levenshtein.c line-log.c line-range.c list-objects.c
+     list-objects-filter.c list-objects-filter-options.c ll-merge.c lockfile.c
+     log-tree.c ls-refs.c mailinfo.c mailmap.c match-trees.c mem-pool.c merge.c merge-blobs.c
+     merge-recursive.c mergesort.c midx.c name-hash.c negotiator/default.c
+     negotiator/skipping.c notes.c notes-cache.c notes-merge.c notes-utils.c object.c oidmap.c
+     oidset.c oid-array.c packfile.c pack-bitmap.c pack-bitmap-write.c pack-check.c pack-objects.c
+     pack-revindex.c pack-write.c pager.c parse-options.c parse-options-cb.c patch-delta.c
+     patch-ids.c path.c pathspec.c pkt-line.c preload-index.c pretty.c prio-queue.c progress.c
+     promisor-remote.c prompt.c protocol.c prune-packed.c quote.c range-diff.c reachable.c read-cache.c rebase.c
+     rebase-interactive.c reflog-walk.c refs.c refs/files-backend.c refs/iterator.c
+     refs/packed-backend.c refs/ref-cache.c refspec.c ref-filter.c remote.c replace-object.c
+     repo-settings.c repository.c rerere.c reset.c resolve-undo.c revision.c run-command.c
+     send-pack.c sequencer.c serve.c server-info.c setup.c sha1-lookup.c
+     sha1-file.c sha1-name.c shallow.c sideband.c sigchain.c split-index.c
+     stable-qsort.c strbuf.c streaming.c string-list.c submodule.c submodule-config.c
+     sub-process.c symlinks.c tag.c tempfile.c thread-utils.c tmp-objdir.c
+     trace.c trace2.c trace2/tr2_cfg.c trace2/tr2_cmd_name.c trace2/tr2_dst.c
+     trace2/tr2_sid.c trace2/tr2_sysenv.c trace2/tr2_tbuf.c trace2/tr2_tgt_event.c
+     trace2/tr2_tgt_normal.c trace2/tr2_tgt_perf.c trace2/tr2_tls.c trailer.c transport.c
+     transport-helper.c tree-diff.c tree.c tree-walk.c unpack-trees.c upload-pack.c url.c
+     urlmatch.c usage.c userdiff.c utf8.c varint.c version.c versioncmp.c walker.c wildmatch.c
+     worktree.c wrapper.c write-or-die.c ws.c wt-status.c xdiff-interface.c
+     zlib.c)
+
+add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})
+
+set(libxdiff_SOURCES
+     xdiff/xdiffi.c xdiff/xprepare.c xdiff/xutils.c xdiff/xemit.c
+     xdiff/xmerge.c xdiff/xpatience.c xdiff/xhistogram.c)
+add_library(xdiff STATIC ${libxdiff_SOURCES})
+
+set(libvcs-svn_SOURCES
+     vcs-svn/line_buffer.c vcs-svn/sliding_window.c vcs-svn/fast_export.c
+     vcs-svn/svndiff.c vcs-svn/svndump.c)
+add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
+
+#link all required libraries to common-main
+add_library(common-main OBJECT common-main.c)
+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
+if(Intl_FOUND)
+     target_link_libraries(common-main ${Intl_LIBRARIES})
+endif()
+if(Iconv_FOUND)
+     target_link_libraries(common-main ${Iconv_LIBRARIES})
+endif()
+
+
+set(git_SOURCES
+     builtin/add.c builtin/am.c builtin/annotate.c builtin/apply.c
+     builtin/archive.c builtin/bisect--helper.c builtin/blame.c
+     builtin/branch.c builtin/bundle.c builtin/cat-file.c builtin/check-attr.c
+     builtin/check-ignore.c builtin/check-mailmap.c builtin/check-ref-format.c
+     builtin/checkout-index.c builtin/checkout.c builtin/clean.c
+     builtin/clone.c builtin/column.c builtin/commit-tree.c
+     builtin/commit.c builtin/commit-graph.c builtin/config.c
+     builtin/count-objects.c builtin/credential.c builtin/describe.c
+     builtin/diff-files.c builtin/diff-index.c builtin/diff-tree.c
+     builtin/diff.c builtin/difftool.c builtin/env--helper.c
+     builtin/fast-export.c builtin/fetch-pack.c builtin/fetch.c builtin/fmt-merge-msg.c
+     builtin/for-each-ref.c builtin/fsck.c builtin/gc.c
+     builtin/get-tar-commit-id.c builtin/grep.c builtin/hash-object.c
+     builtin/help.c builtin/index-pack.c builtin/init-db.c
+     builtin/interpret-trailers.c builtin/log.c builtin/ls-files.c
+     builtin/ls-remote.c builtin/ls-tree.c builtin/mailinfo.c builtin/mailsplit.c
+     builtin/merge.c builtin/merge-base.c builtin/merge-file.c builtin/merge-index.c
+     builtin/merge-ours.c builtin/merge-recursive.c builtin/merge-tree.c
+     builtin/mktag.c builtin/mktree.c builtin/multi-pack-index.c builtin/mv.c
+     builtin/name-rev.c builtin/notes.c builtin/pack-objects.c builtin/pack-redundant.c
+     builtin/pack-refs.c builtin/patch-id.c builtin/prune-packed.c builtin/prune.c
+     builtin/pull.c builtin/push.c builtin/range-diff.c builtin/read-tree.c
+     builtin/rebase.c builtin/receive-pack.c builtin/reflog.c builtin/remote.c
+     builtin/remote-ext.c builtin/remote-fd.c builtin/repack.c builtin/replace.c
+     builtin/rerere.c builtin/reset.c builtin/rev-list.c builtin/rev-parse.c
+     builtin/revert.c builtin/rm.c builtin/send-pack.c builtin/shortlog.c
+     builtin/show-branch.c builtin/show-index.c builtin/show-ref.c
+     builtin/sparse-checkout.c builtin/stash.c builtin/stripspace.c
+     builtin/submodule--helper.c builtin/symbolic-ref.c builtin/tag.c
+     builtin/unpack-file.c builtin/unpack-objects.c builtin/update-index.c
+     builtin/update-ref.c builtin/update-server-info.c builtin/upload-archive.c
+     builtin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c
+     builtin/verify-tag.c builtin/worktree.c builtin/write-tree.c)
+
+add_executable(git git.c ${git_SOURCES})
+target_link_libraries(git common-main )
+
+add_executable(git-bugreport bugreport.c)
+target_link_libraries(git-bugreport common-main)
+
+add_executable(git-credential-store credential-store.c)
+target_link_libraries(git-credential-store common-main)
+
+add_executable(git-daemon daemon.c)
+target_link_libraries(git-daemon common-main)
+
+add_executable(git-fast-import fast-import.c)
+target_link_libraries(git-fast-import common-main)
+
+add_executable(git-http-backend http-backend.c)
+target_link_libraries(git-http-backend common-main)
+
+add_executable(git-sh-i18n--envsubst sh-i18n--envsubst.c)
+target_link_libraries(git-sh-i18n--envsubst common-main)
+
+add_executable(git-shell shell.c)
+target_link_libraries(git-shell common-main)
+
+if(CURL_FOUND)
+     add_library(http_obj OBJECT http.c)
+
+     add_executable(git-imap-send imap-send.c)
+     target_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})
+
+     add_executable(git-http-fetch http-walker.c http-fetch.c)
+     target_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})
+
+     add_executable(git-remote-http http-walker.c remote-curl.c)
+     target_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )
+
+     if(EXPAT_FOUND)
+             add_executable(git-http-push http-push.c)
+             target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
+     endif()
+endif()
+
+add_executable(git-remote-testsvn remote-testsvn.c)
+target_link_libraries(git-remote-testsvn common-main vcs-svn)
+
+add_executable(git-credential-cache credential-cache.c)
+target_link_libraries(git-credential-cache common-main)
+
+add_executable(git-credential-cache--daemon credential-cache--daemon.c)
+target_link_libraries(git-credential-cache--daemon common-main)
+
+
+set(git_builtin_extra
+     cherry cherry-pick format-patch fsck-objects
+     init merge-subtree restore show
+     stage status switch whatchanged)
+
+#Creating hardlinks
+foreach(s ${git_SOURCES} ${git_builtin_extra})
+     string(REPLACE "builtin/" "" s ${s})
+     string(REPLACE ".c" "" s ${s})
+     file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git git-${s})\n")
+     list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})
+endforeach()
+
+if(CURL_FOUND)
+     set(remote_exes
+             git-remote-https git-remote-ftp git-remote-ftps)
+     foreach(s ${remote_exes})

CMakeLists.txt line 528

Quoted 10 lines
CMakeLists.txt new file +9 -0
+             file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http ${s})\n")
+             list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})
+     endforeach()
+endif()
+
+add_custom_command(OUTPUT ${git_links} ${git_http_links}
+             COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
+             DEPENDS git git-remote-http)
+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
\ No newline at end of file

No new line at end of line always leave a bad taste in my mount!

Quoted 2 lines

--
Danh

Thank You,
Sibi Siddharthan

#4 lore raw

Re: [PATCH 1/8] Introduce CMake support for configuring Git on Linux

Quoted 2 lines · Sibi Siddharthan

Yes it does,
all you have to do is -DZLIB_ROOT=/path/to/zlib/root

OK, I need to learn this syntax

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
CMakeLists.txt new file +6 -0
+find_package(EXPAT)
+find_package(Iconv)
+find_package(Intl)
+
 
+if(NOT Intl_FOUND)
+     add_compile_definitions(NO_GETTEXT)
Quoted 6 lines
Quoted 2 lines

find_package(Gettext)?

find_package(Gettext) does not define libintl and libintl.h. If NO_GETTEXT is not defined, it means that libintl.h is present. So, we use find_package(Intl) for libintl

People do weird things.

But, I bet that a lot of people have system that have libintl.h installed, but they don't install gettext tools. ;-)

Anyway, can I override NO_GETTEXT from command line?

Let's say, I want to bootstrap a new distro?
In the boostrap step, I don't want to build any i18n things, because the bootstrap package will be thrown away and rebuild again. I don't want to waste time on building such translation things.

Quoted 10 lines
Quoted 8 lines

CMakeLists.txt line 36

Quoted 5 lines
CMakeLists.txt new file +4 -0
+     if(NOT Iconv_FOUND)
+             add_compile_definitions(NO_ICONV)
+     endif()
+endif()

ICONV_OMITS_BOM?

Forgot about this, will add it.

Thanks, my platform relies on this definition!

Quoted 19 lines
Quoted 19 lines
Quoted 6 lines
CMakeLists.txt new file +6 -0
+
+include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
+if(CURL_FOUND)
+     include_directories(SYSTEM ${CURL_INCLUDE_DIRS})
+endif()
+if(EXPAT_FOUND)

CMakeLists.txt line 52

Quoted 10 lines
CMakeLists.txt new file +10 -0
+     include_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})
+endif()
+if(Iconv_FOUND)
+     include_directories(SYSTEM ${Iconv_INCLUDE_DIRS})
+endif()
+if(Intl_FOUND)
+     include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
+endif()
+
+find_program(SH_EXE sh)

We want to find usable sh, not just sh, no?

Quoted 4 lines
Quoted 2 lines

It's matter on Solaris, HP-UX

How do I check for this, can you help?

Sorry, Please ask someone else, check Makefile to see who fixed build for Solaris and HP-UX.

Quoted 1 line

Also, the script is not supported on Solaris and HP-UX.

If Solaris or HP-UX is out of equation,
I'll just write: SH_EXE=/bin/sh ;-)

Quoted 33 lines
Quoted 23 lines
Quoted 23 lines
CMakeLists.txt new file +22 -0
+
+#default behaviour
+include_directories(${CMAKE_SOURCE_DIR})
+add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
+add_compile_definitions(SHA256_BLK INTERNAL_QSORT RUNTIME_PREFIX)
+add_compile_definitions(NO_OPENSSL SHA1_DC SHA1DC_NO_STANDARD_INCLUDES
+                     SHA1DC_INIT_SAFE_HASH_DEFAULT=0
+                     SHA1DC_CUSTOM_INCLUDE_SHA1_C="cache.h"
+                     SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="git-compat-util.h" )
+list(APPEND compat_SOURCES sha1dc_git.c sha1dc/sha1.c sha1dc/ubc_check.c block-sha1/sha1.c sha256/block/sha256.c compat/qsort_s.c)
+
+
+add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
+                     ETC_GITATTRIBUTES="etc/gitattributes"
+                     ETC_GITCONFIG="etc/gitconfig"
+                     GIT_EXEC_PATH="libexec/git-core"
+                     GIT_LOCALE_PATH="share/locale"
+                     GIT_MAN_PATH="share/man"
+                     GIT_INFO_PATH="share/info"
+                     GIT_HTML_PATH="share/doc/git-doc"
+                     DEFAULT_HELP_FORMAT="html"
+                     DEFAULT_GIT_TEMPLATE_DIR="share/git-core/templates"
Quoted 9 lines

CMakeLists.txt line 78

Quoted 4 lines
CMakeLists.txt new file +4 -0
+                     GIT_VERSION="${PROJECT_VERSION}.GIT"
+                     GIT_USER_AGENT="git/${PROJECT_VERSION}.GIT"
+                     BINDIR="bin"
+                     GIT_BUILT_FROM_COMMIT="")

I wish I could verify this.
Have you check this part on a default build system for a Linux distro, FreeBSD? For things started with "etc/"

Quoted 3 lines

These are the values I got when I looked at the build logs from the Makefile (make -n) in Linux and Windows.
Don't know about FreeBSD

Linux will install configuration to /etc, Windows (by using msys), will also do that.

*BSD port installs git with /usr/local prefix, and install configuration to /usr/local/etc

Quoted 38 lines
Quoted 9 lines

CMakeLists.txt line 83

Quoted 6 lines
CMakeLists.txt new file +5 -0
+
+set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
+add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+
+add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )

/proc/self/exe is Linux only, no?

Yes, it is. This first patch only supports Linux build.

Quoted 16 lines
Quoted 16 lines
CMakeLists.txt new file +16 -0
+list(APPEND compat_SOURCES unix-socket.c)
+
+#header checks
+check_include_file(libgen.h HAVE_LIBGEN_H)
+if(NOT HAVE_LIBGEN_H)
+     add_compile_definitions(NO_LIBGEN_H)
+     list(APPEND compat_SOURCES compat/basename.c)
+endif()
+
+check_include_file(sys/sysinfo.h HAVE_SYSINFO)
+if(HAVE_SYSINFO)
+     add_compile_definitions(HAVE_SYSINFO)
+endif()
+
+check_c_source_compiles("
+#include <alloca.h>
Quoted 9 lines

CMakeLists.txt line 105

Quoted 6 lines
CMakeLists.txt new file +6 -0
+int
+main ()
+{
+char *p = (char *) alloca (2 * sizeof (int));
+     if (p) return 0;
+     return 0;

All code path will return 0?

Quoted 2 lines

This check is for a working alloca.h.
Some systems define alloca in malloc.h (Windows)

Does CMake have a macro for check function in which include files?

Quoted 13 lines
Quoted 13 lines

CMakeLists.txt line 520

Quoted 13 lines
CMakeLists.txt new file +12 -0
+}"
+HAVE_ALLOCA_H)
+if(HAVE_ALLOCA_H)
+     add_compile_definitions(HAVE_ALLOCA_H)
+endif()
+
+
+if(CURL_FOUND)
+     set(remote_exes
+             git-remote-https git-remote-ftp git-remote-ftps)
+     foreach(s ${remote_exes})
+             file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http ${s})\n")

Now, I looked at this again.
I didn't see the creatation of CreateLinks.cmake anywhere!

Quoted 12 lines
Quoted 12 lines

CMakeLists.txt line 528

Quoted 9 lines
CMakeLists.txt new file +8 -0
+             list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})
+     endforeach()
+endif()
+
+add_custom_command(OUTPUT ${git_links} ${git_http_links}
+             COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
+             DEPENDS git git-remote-http)
+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
\ No newline at end of file

No new line at end of line always leave a bad taste in my mount!

Signature · 1 line
Danh
#5 lore raw

Re: [PATCH 1/8] Introduce CMake support for configuring Git on Linux

Quoted 27 lines · Danh Doan
Quoted 2 lines · Sibi Siddharthan

Yes it does,
all you have to do is -DZLIB_ROOT=/path/to/zlib/root

OK, I need to learn this syntax

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
CMakeLists.txt new file +6 -0
+find_package(EXPAT)
+find_package(Iconv)
+find_package(Intl)
+
 
+if(NOT Intl_FOUND)
+     add_compile_definitions(NO_GETTEXT)
Quoted 6 lines
Quoted 2 lines

find_package(Gettext)?

find_package(Gettext) does not define libintl and libintl.h. If NO_GETTEXT is not defined, it means that libintl.h is present. So, we use find_package(Intl) for libintl

People do weird things.

But, I bet that a lot of people have system that have libintl.h installed, but they don't install gettext tools. ;-)

Quoted 7 lines

Anyway, can I override NO_GETTEXT from command line?

Let's say, I want to bootstrap a new distro?
In the boostrap step, I don't want to build any i18n things, because the bootstrap package will be thrown away and rebuild again. I don't want to waste time on building such translation things.

So, you are trying to build two times and configuring it only once. Am I right? If so I don't think you bootstrap with CMake. Will let you know if I figure something out.

Quoted 37 lines
Quoted 10 lines
Quoted 8 lines

CMakeLists.txt line 36

Quoted 5 lines
CMakeLists.txt new file +4 -0
+     if(NOT Iconv_FOUND)
+             add_compile_definitions(NO_ICONV)
+     endif()
+endif()

ICONV_OMITS_BOM?

Forgot about this, will add it.

Thanks, my platform relies on this definition!

Quoted 19 lines
Quoted 19 lines
Quoted 6 lines
CMakeLists.txt new file +6 -0
+
+include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
+if(CURL_FOUND)
+     include_directories(SYSTEM ${CURL_INCLUDE_DIRS})
+endif()
+if(EXPAT_FOUND)

CMakeLists.txt line 52

Quoted 10 lines
CMakeLists.txt new file +10 -0
+     include_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})
+endif()
+if(Iconv_FOUND)
+     include_directories(SYSTEM ${Iconv_INCLUDE_DIRS})
+endif()
+if(Intl_FOUND)
+     include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
+endif()
+
+find_program(SH_EXE sh)

We want to find usable sh, not just sh, no?

Quoted 4 lines
Quoted 2 lines

It's matter on Solaris, HP-UX

How do I check for this, can you help?

Quoted 9 lines

Sorry, Please ask someone else, check Makefile to see who fixed build for Solaris and HP-UX.

Quoted 1 line

Also, the script is not supported on Solaris and HP-UX.

If Solaris or HP-UX is out of equation,
I'll just write: SH_EXE=/bin/sh ;-)

This is exactly what the current definition does.

Quoted 37 lines
Quoted 33 lines
Quoted 23 lines
Quoted 23 lines
CMakeLists.txt new file +22 -0
+
+#default behaviour
+include_directories(${CMAKE_SOURCE_DIR})
+add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
+add_compile_definitions(SHA256_BLK INTERNAL_QSORT RUNTIME_PREFIX)
+add_compile_definitions(NO_OPENSSL SHA1_DC SHA1DC_NO_STANDARD_INCLUDES
+                     SHA1DC_INIT_SAFE_HASH_DEFAULT=0
+                     SHA1DC_CUSTOM_INCLUDE_SHA1_C="cache.h"
+                     SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="git-compat-util.h" )
+list(APPEND compat_SOURCES sha1dc_git.c sha1dc/sha1.c sha1dc/ubc_check.c block-sha1/sha1.c sha256/block/sha256.c compat/qsort_s.c)
+
+
+add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
+                     ETC_GITATTRIBUTES="etc/gitattributes"
+                     ETC_GITCONFIG="etc/gitconfig"
+                     GIT_EXEC_PATH="libexec/git-core"
+                     GIT_LOCALE_PATH="share/locale"
+                     GIT_MAN_PATH="share/man"
+                     GIT_INFO_PATH="share/info"
+                     GIT_HTML_PATH="share/doc/git-doc"
+                     DEFAULT_HELP_FORMAT="html"
+                     DEFAULT_GIT_TEMPLATE_DIR="share/git-core/templates"
Quoted 9 lines

CMakeLists.txt line 78

Quoted 4 lines
CMakeLists.txt new file +4 -0
+                     GIT_VERSION="${PROJECT_VERSION}.GIT"
+                     GIT_USER_AGENT="git/${PROJECT_VERSION}.GIT"
+                     BINDIR="bin"
+                     GIT_BUILT_FROM_COMMIT="")

I wish I could verify this.
Have you check this part on a default build system for a Linux distro, FreeBSD? For things started with "etc/"

Quoted 3 lines

These are the values I got when I looked at the build logs from the Makefile (make -n) in Linux and Windows.
Don't know about FreeBSD

Quoted 6 lines

Linux will install configuration to /etc, Windows (by using msys), will also do that.

*BSD port installs git with /usr/local prefix, and install configuration to /usr/local/etc

Aren't the above definitions relative paths?(With RUNTIME_PREFIX) Once you decide to install, you have INSTALL_PREFIX(similar to DESTDIR) with which you
can achieve the above.

Quoted 38 lines
Quoted 38 lines
Quoted 9 lines

CMakeLists.txt line 83

Quoted 6 lines
CMakeLists.txt new file +5 -0
+
+set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
+add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+
+add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )

/proc/self/exe is Linux only, no?

Yes, it is. This first patch only supports Linux build.

Quoted 25 lines
Quoted 12 lines
CMakeLists.txt new file +12 -0
+list(APPEND compat_SOURCES unix-socket.c)
+
+#header checks
+check_include_file(libgen.h HAVE_LIBGEN_H)
+if(NOT HAVE_LIBGEN_H)
+     add_compile_definitions(NO_LIBGEN_H)
+     list(APPEND compat_SOURCES compat/basename.c)
+endif()
+
+check_include_file(sys/sysinfo.h HAVE_SYSINFO)
+if(HAVE_SYSINFO)
+     add_compile_definitions(HAVE_SYSINFO)

CMakeLists.txt line 105

Quoted 10 lines
CMakeLists.txt new file +10 -0
+endif()
+
+check_c_source_compiles("
+#include <alloca.h>
+int
+main ()
+{
+char *p = (char *) alloca (2 * sizeof (int));
+     if (p) return 0;
+     return 0;

All code path will return 0?

Quoted 5 lines
Quoted 2 lines

This check is for a working alloca.h.
Some systems define alloca in malloc.h (Windows)

Does CMake have a macro for check function in which include files?

The check functions is something that was used to match the automake behaviour. If you want to check whether a function exists in a particulae header file use check_symbol_exists().

Quoted 30 lines
Quoted 13 lines
Quoted 13 lines

CMakeLists.txt line 520

Quoted 13 lines
CMakeLists.txt new file +12 -0
+}"
+HAVE_ALLOCA_H)
+if(HAVE_ALLOCA_H)
+     add_compile_definitions(HAVE_ALLOCA_H)
+endif()
+
+
+if(CURL_FOUND)
+     set(remote_exes
+             git-remote-https git-remote-ftp git-remote-ftps)
+     foreach(s ${remote_exes})
+             file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http ${s})\n")

Now, I looked at this again.
I didn't see the creatation of CreateLinks.cmake anywhere!

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
CMakeLists.txt new file +4 -0
+             list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})
+     endforeach()
+endif()
+
Quoted 8 lines
Quoted 8 lines

CMakeLists.txt line 528

Quoted 5 lines
CMakeLists.txt new file +4 -0
+add_custom_command(OUTPUT ${git_links} ${git_http_links}
+             COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
+             DEPENDS git git-remote-http)
+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
\ No newline at end of file

No new line at end of line always leave a bad taste in my mount!

Quoted 2 lines

--
Danh

Thank You,
Sibi Siddharthan

#6 lore raw

Re: [PATCH 1/8] Introduce CMake support for configuring Git on Linux

In reply to Danh Doan

Hi Danh,

Quoted 1 line · Danh Doan

Please excuse my hatred for CMake.

I share that distaste. However, is it really productive to bring that up here?

You know what I also hate? I also hate vulnerabilities, and find it _really_ taxing and tiring to work on them. Yet I frequently find myself focusing on security bug fixes. Why? Because it's important.

In this instance, while there's no love lost on CMake from my side, I do see tremendous benefits in having support for it in Git, in particular in supporting Windows-based developers instead of treating them like third-class citizens.

You had so many good and helpful comments and suggestions how to improve the CMake patches, maybe we can have more of those?

Thank you,
Dscho

#7 lore raw

Re: [PATCH 1/8] Introduce CMake support for configuring Git on Linux

In reply to Sibi Siddharthan via GitGitGadget

CMakeLists.txt line 5

Quoted 11 lines · Sibi Siddharthan via GitGitGadget
CMakeLists.txt new file +5 -0
new file mode 100644
index 00000000000..73703bd321f
@@ -0,0 +1,528 @@
+#
+#	Copyright (c) 2020 Sibi Siddharthan
+#
+
+cmake_minimum_required(VERSION 3.14)

I don't plan a full review of this series, but I wanted to point out that this version is newer than what's in Debian 10, so this isn't practically buildable on many systems.

If we wanted to add CMake support, even just for Linux and Windows, I'd want to see it functional on the latest versions of the major distros, at the very least. Ideally it would function using the system packages on all security-supported versions of the major distros, since our Makefile does right now.

Signature · 2 lines
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204
#8 lore raw

RE: [PATCH 1/8] Introduce CMake support for configuring Git on Linux

On April 25, 2020 1:08 PM, brian m. carlson Wrote:

Quoted 7 lines · Sibi Siddharthan via GitGitGadget
Quoted 6 lines
CMakeLists.txt new file +1 -0
index 00000000000..73703bd321f
@@ -0,0 +1,528 @@
+#
Quoted 8 lines

CMakeLists.txt line 5

Quoted 4 lines
CMakeLists.txt new file +4 -0
+#	Copyright (c) 2020 Sibi Siddharthan
+#
+
+cmake_minimum_required(VERSION 3.14)

I don't plan a full review of this series, but I wanted to point out that this version is newer than what's in Debian 10, so this isn't practically buildable on many systems.

I am unsure about this, but are non-git-foundation copyrights consistent GPL v2? Just asking for curiosity.

#9 lore raw

Re: [PATCH 1/8] Introduce CMake support for configuring Git on Linux

Quoted 15 lines · Randall S. Becker

On April 25, 2020 1:08 PM, brian m. carlson Wrote:

Quoted 6 lines · Sibi Siddharthan via GitGitGadget
Quoted 5 lines
CMakeLists.txt new file +0 -0
index 00000000000..73703bd321f
@@ -0,0 +1,528 @@
Quoted 8 lines

CMakeLists.txt line 5

Quoted 5 lines
CMakeLists.txt new file +5 -0
+#
+#	Copyright (c) 2020 Sibi Siddharthan
+#
+
+cmake_minimum_required(VERSION 3.14)

I don't plan a full review of this series, but I wanted to point out that this version is newer than what's in Debian 10, so this isn't practically buildable on many systems.

Quoted 2 lines

I am unsure about this, but are non-git-foundation copyrights consistent GPL v2? Just asking for curiosity.

grep'ing for copyright gave plenty of examples, so it looks OK. Someone had to author it.

Philip

#10 lore raw

Re: [PATCH 1/8] Introduce CMake support for configuring Git on Linux

In reply to brian m. carlson

Hi Brian,

Quoted 18 lines · brian m. carlson

CMakeLists.txt line 5

Quoted 11 lines · Sibi Siddharthan via GitGitGadget
CMakeLists.txt new file +5 -0
new file mode 100644
index 00000000000..73703bd321f
@@ -0,0 +1,528 @@
+#
+#    Copyright (c) 2020 Sibi Siddharthan
+#
+
+cmake_minimum_required(VERSION 3.14)

I don't plan a full review of this series, but I wanted to point out that this version is newer than what's in Debian 10, so this isn't practically buildable on many systems.

Quoted 5 lines

If we wanted to add CMake support, even just for Linux and Windows, I'd want to see it functional on the latest versions of the major distros, at the very least. Ideally it would function using the system packages on all security-supported versions of the major distros, since our Makefile does right now.

I know that version 3.14 is asking a lot, but without this version the script would
have a lot platform specific stuff related to how hard links are created. Windows -> mklink
Other systems -> ln

This is why this version was chosen.
I would also like to say that this CMake script is not a replacement for the Makefile.

Quoted 3 lines

--
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

Thank You,
Sibi Siddharthan

#11 lore raw

PATCH 2/8 cmake: generate the shell/perl/python scripts and templates, translations

In reply to Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch implements the placeholder substitution to generate, say, git-request-pull from git-request-pull.sh.

The shell/perl/python scripts and template are generated using CMake (very similar to what sed does).

The text translations are only build if msgfmt is found in your path.

NOTE: The scripts and templates are generated during configuration.

---
 CMakeLists.txt | 107 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 106 insertions(+), 1 deletion(-)
CMakeLists.txt +106 -1
index 73703bd321f..788b53be873 100644
@@ -51,6 +51,11 @@ endif()
 
 find_program(SH_EXE sh)
 
+find_program(MSGFMT_EXE msgfmt)
+if(NOT MSGFMT_EXE)
+	message(WARNING "Text Translations won't be build")
+endif()
+
 #default behaviour
 include_directories(${CMAKE_SOURCE_DIR})
 add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
@@ -525,4 +530,104 @@ endif()
 add_custom_command(OUTPUT ${git_links} ${git_http_links}
 		COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
 		DEPENDS git git-remote-http)
-add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
\ No newline at end of file
+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
+
+
+#creating required scripts
+set(SHELL_PATH /bin/sh)
+set(PERL_PATH /usr/bin/perl)
+set(LOCALEDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)
+set(GITWEBDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)
+set(INSTLIBDIR ${FALLBACK_RUNTIME_PREFIX}/share/perl5)
+
+#shell scripts
+set(git_shell_scripts
+	git-bisect git-difftool--helper git-filter-branch
+	git-merge-octopus git-merge-one-file git-merge-resolve
+	git-mergetool git-quiltimport
+	git-request-pull git-submodule git-web--browse
+	git-mergetool--lib git-parse-remote git-rebase--preserve-merges
+	git-sh-setup git-sh-i18n git-instaweb)
+
+foreach(script ${git_shell_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.sh content NEWLINE_CONSUME)
+	string(REPLACE "@SHELL_PATH@" "${SHELL_PATH}" content "${content}")
+	string(REPLACE "@@DIFF@@" "diff" content "${content}")
+	string(REPLACE "@LOCALEDIR@" "${LOCALEDIR}" content "${content}")
+	string(REPLACE "@GITWEBDIR@" "${GITWEBDIR}" content "${content}")
+	string(REPLACE "@@NO_CURL@@" "" content "${content}")
+	string(REPLACE "@@USE_GETTEXT_SCHEME@@" "" content "${content}")
+	string(REPLACE "# @@BROKEN_PATH_FIX@@" "" content "${content}")
+	string(REPLACE "@@PERL@@" "${PERL_PATH}" content "${content}")
+	string(REPLACE "@@SANE_TEXT_GREP@@" "-a" content "${content}")
+	string(REPLACE "@@PAGER_ENV@@" "LESS=FRX LV=-c" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
+endforeach()
+
+#perl scripts
+set(git_perl_scripts
+	git-add--interactive git-archimport git-cvsexportcommit
+	git-cvsimport git-cvsserver git-send-email git-svn)
+
+#create perl header
+file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )
+string(REPLACE "@@PATHSEP@@" ":" perl_header "${perl_header}")
+string(REPLACE "@@INSTLIBDIR@@" "${INSTLIBDIR}" perl_header "${perl_header}")
+
+foreach(script ${git_perl_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.perl content NEWLINE_CONSUME)
+	string(REPLACE "#!/usr/bin/perl" "#!/usr/bin/perl\n${perl_header}\n" content "${content}")
+	string(REPLACE "@@GIT_VERSION@@" "${PROJECT_VERSION}" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
+endforeach()
+
+#python script
+file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)
+string(REPLACE "#!/usr/bin/env python" "#!/usr/bin/python" content "${content}")
+file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})
+
+#perl modules
+file(GLOB_RECURSE perl_modules "${CMAKE_SOURCE_DIR}/perl/*.pm")
+
+foreach(pm ${perl_modules})
+	string(REPLACE "${CMAKE_SOURCE_DIR}/perl/" "" file_path ${pm})
+	file(STRINGS ${pm} content NEWLINE_CONSUME)
+	string(REPLACE "@@LOCALEDIR@@" "${LOCALEDIR}" content "${content}")
+	string(REPLACE "@@NO_PERL_CPAN_FALLBACKS@@" "" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})
+#test-lib.sh requires perl/build/lib to be the build directory of perl modules
+endforeach()
+
+
+#templates
+file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches
+set(hooks_templates
+	applypatch-msg.sample pre-applypatch.sample pre-push.sample
+	commit-msg.sample pre-commit.sample pre-rebase.sample
+	fsmonitor-watchman.sample pre-merge-commit.sample pre-receive.sample
+	post-update.sample prepare-commit-msg.sample update.sample)
+
+#templates have @.*@ replacement so use configure_file instead
+#hooks
+foreach(tm ${hooks_templates})
+	configure_file(${CMAKE_SOURCE_DIR}/templates/hooks--${tm} ${CMAKE_BINARY_DIR}/templates/blt/hooks/${tm} @ONLY)
+endforeach()
+
+#info
+configure_file(${CMAKE_SOURCE_DIR}/templates/info--exclude ${CMAKE_BINARY_DIR}/templates/blt/info/exclude @ONLY)
+
+#this
+configure_file(${CMAKE_SOURCE_DIR}/templates/this--description ${CMAKE_BINARY_DIR}/templates/blt/description @ONLY)
+
+
+#translations
+if(MSGFMT_EXE)
+	set(po_files bg  ca  de  el  es  fr  is  it  ko  pt_PT  ru  sv  tr  vi  zh_CN  zh_TW)
+	foreach(po ${po_files})
+		file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES)
+		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo
+				COMMAND ${MSGFMT_EXE} --check --statistics -o ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo ${CMAKE_SOURCE_DIR}/po/${po}.po)
+		list(APPEND po_gen ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo)
+	endforeach()
+	add_custom_target(po-gen ALL DEPENDS ${po_gen})
+endif()
Signature · 1 line
gitgitgadget
#12 lore raw

Re: [PATCH 2/8] cmake: generate the shell/perl/python scripts and templates, translations

Quoted 22 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch implements the placeholder substitution to generate, say, git-request-pull from git-request-pull.sh.

The shell/perl/python scripts and template are generated using CMake (very similar to what sed does).

The text translations are only build if msgfmt is found in your path.

NOTE: The scripts and templates are generated during configuration.

---
 CMakeLists.txt | 107 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 106 insertions(+), 1 deletion(-)
CMakeLists.txt +0 -0
index 73703bd321f..788b53be873 100644

CMakeLists.txt endif() · line 54

Quoted 4 lines
CMakeLists.txt +1 -0
@@ -51,6 +51,11 @@ endif()
 
 find_program(SH_EXE sh)
 
+find_program(MSGFMT_EXE msgfmt)

I suppose find_package(Gettext) can do most of this work?

CMakeLists.txt endif() · line 528

Quoted 13 lines
CMakeLists.txt +4 -1
+if(NOT MSGFMT_EXE)
+	message(WARNING "Text Translations won't be build")
+endif()
+
 #default behaviour
 include_directories(${CMAKE_SOURCE_DIR})
 add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
@@ -525,4 +530,104 @@ endif()
 add_custom_command(OUTPUT ${git_links} ${git_http_links}
 		COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
 		DEPENDS git git-remote-http)
-add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
\ No newline at end of file

No newline at end of file?

CMakeLists.txt endif() · line 538

Quoted 6 lines
CMakeLists.txt +6 -0
+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
+
+
+#creating required scripts
+set(SHELL_PATH /bin/sh)
+set(PERL_PATH /usr/bin/perl)

Really?
Have you tried on, let's say FreeBSD?

Quoted 17 lines
CMakeLists.txt +17 -0
+set(LOCALEDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)
+set(GITWEBDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)
+set(INSTLIBDIR ${FALLBACK_RUNTIME_PREFIX}/share/perl5)
+
+#shell scripts
+set(git_shell_scripts
+	git-bisect git-difftool--helper git-filter-branch
+	git-merge-octopus git-merge-one-file git-merge-resolve
+	git-mergetool git-quiltimport
+	git-request-pull git-submodule git-web--browse
+	git-mergetool--lib git-parse-remote git-rebase--preserve-merges
+	git-sh-setup git-sh-i18n git-instaweb)
+
+foreach(script ${git_shell_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.sh content NEWLINE_CONSUME)
+	string(REPLACE "@SHELL_PATH@" "${SHELL_PATH}" content "${content}")
+	string(REPLACE "@@DIFF@@" "diff" content "${content}")

CMakeLists.txt endif() · line 565

Quoted 10 lines
CMakeLists.txt +10 -0
+	string(REPLACE "@LOCALEDIR@" "${LOCALEDIR}" content "${content}")
+	string(REPLACE "@GITWEBDIR@" "${GITWEBDIR}" content "${content}")
+	string(REPLACE "@@NO_CURL@@" "" content "${content}")
+	string(REPLACE "@@USE_GETTEXT_SCHEME@@" "" content "${content}")
+	string(REPLACE "# @@BROKEN_PATH_FIX@@" "" content "${content}")
+	string(REPLACE "@@PERL@@" "${PERL_PATH}" content "${content}")
+	string(REPLACE "@@SANE_TEXT_GREP@@" "-a" content "${content}")
+	string(REPLACE "@@PAGER_ENV@@" "LESS=FRX LV=-c" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
+endforeach()

I assume this do most of sed magic?

Quoted 4 lines
CMakeLists.txt +4 -0
+
+#perl scripts
+set(git_perl_scripts
+	git-add--interactive git-archimport git-cvsexportcommit

CMakeLists.txt endif() · line 579

Quoted 10 lines
CMakeLists.txt +10 -0
+	git-cvsimport git-cvsserver git-send-email git-svn)
+
+#create perl header
+file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )
+string(REPLACE "@@PATHSEP@@" ":" perl_header "${perl_header}")
+string(REPLACE "@@INSTLIBDIR@@" "${INSTLIBDIR}" perl_header "${perl_header}")
+
+foreach(script ${git_perl_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.perl content NEWLINE_CONSUME)
+	string(REPLACE "#!/usr/bin/perl" "#!/usr/bin/perl\n${perl_header}\n" content "${content}")

Hoped that this is tried on BSD?

Quoted 4 lines
CMakeLists.txt +4 -0
+	string(REPLACE "@@GIT_VERSION@@" "${PROJECT_VERSION}" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
+endforeach()
+

CMakeLists.txt endif() · line 593

Quoted 10 lines
CMakeLists.txt +10 -0
+#python script
+file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)
+string(REPLACE "#!/usr/bin/env python" "#!/usr/bin/python" content "${content}")
+file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})
+
+#perl modules
+file(GLOB_RECURSE perl_modules "${CMAKE_SOURCE_DIR}/perl/*.pm")
+
+foreach(pm ${perl_modules})
+	string(REPLACE "${CMAKE_SOURCE_DIR}/perl/" "" file_path ${pm})

So, the real source code have reference to CMAKE_SOURCE_DIR? I don't think so? It's purely my guess from previous patch, this function will do
string(REPLACE from to file something_I_have_not_checked)

Quoted 5 lines
CMakeLists.txt +5 -0
+	file(STRINGS ${pm} content NEWLINE_CONSUME)
+	string(REPLACE "@@LOCALEDIR@@" "${LOCALEDIR}" content "${content}")
+	string(REPLACE "@@NO_PERL_CPAN_FALLBACKS@@" "" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})
+#test-lib.sh requires perl/build/lib to be the build directory of perl modules

CMakeLists.txt endif() · line 608

Quoted 10 lines
CMakeLists.txt +10 -0
+endforeach()
+
+
+#templates
+file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches
+set(hooks_templates
+	applypatch-msg.sample pre-applypatch.sample pre-push.sample
+	commit-msg.sample pre-commit.sample pre-rebase.sample
+	fsmonitor-watchman.sample pre-merge-commit.sample pre-receive.sample
+	post-update.sample prepare-commit-msg.sample update.sample)

Too much things merged into one line, I hate it.

CMakeLists.txt endif() · line 614

Quoted 6 lines
CMakeLists.txt +6 -0
+
+#templates have @.*@ replacement so use configure_file instead
+#hooks
+foreach(tm ${hooks_templates})
+	configure_file(${CMAKE_SOURCE_DIR}/templates/hooks--${tm} ${CMAKE_BINARY_DIR}/templates/blt/hooks/${tm} @ONLY)
+endforeach()

What does this really means?

CMakeLists.txt endif() · line 625

Quoted 11 lines
CMakeLists.txt +11 -0
+
+#info
+configure_file(${CMAKE_SOURCE_DIR}/templates/info--exclude ${CMAKE_BINARY_DIR}/templates/blt/info/exclude @ONLY)
+
+#this
+configure_file(${CMAKE_SOURCE_DIR}/templates/this--description ${CMAKE_BINARY_DIR}/templates/blt/description @ONLY)
+
+
+#translations
+if(MSGFMT_EXE)
+	set(po_files bg  ca  de  el  es  fr  is  it  ko  pt_PT  ru  sv  tr  vi  zh_CN  zh_TW)

hard coded, so this is a regression, compared to old Makefile?

CMakeLists.txt endif() · line 629

Quoted 4 lines
CMakeLists.txt +4 -0
+	foreach(po ${po_files})
+		file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES)
+		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo
+				COMMAND ${MSGFMT_EXE} --check --statistics -o ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo ${CMAKE_SOURCE_DIR}/po/${po}.po)

find_package(Gettext) defines MSGFMT_EXECUTABLE, I think. Have you check Solaris option?
Or is this tranlated from current Makefile?
I haven't checked current source code!

Quoted 7 lines
CMakeLists.txt +4 -0
+		list(APPEND po_gen ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo)
+	endforeach()
+	add_custom_target(po-gen ALL DEPENDS ${po_gen})
+endif()
Signature · 1 line
gitgitgadget
Signature · 1 line
Danh
#13 lore raw

Re: [PATCH 2/8] cmake: generate the shell/perl/python scripts and templates, translations

Quoted 25 lines · Danh Doan
Quoted 23 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch implements the placeholder substitution to generate, say, git-request-pull from git-request-pull.sh.

The shell/perl/python scripts and template are generated using CMake (very similar to what sed does).

The text translations are only build if msgfmt is found in your path.

NOTE: The scripts and templates are generated during configuration.

---
 CMakeLists.txt | 107 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 106 insertions(+), 1 deletion(-)
CMakeLists.txt +0 -0
index 73703bd321f..788b53be873 100644
@@ -51,6 +51,11 @@ endif()
 
Quoted 6 lines

CMakeLists.txt endif() · line 54

Quoted 3 lines
CMakeLists.txt +1 -0
 find_program(SH_EXE sh)
 
+find_program(MSGFMT_EXE msgfmt)

I suppose find_package(Gettext) can do most of this work?

Will change it using gettext.

Quoted 47 lines

CMakeLists.txt endif() · line 528

Quoted 13 lines
CMakeLists.txt +4 -1
+if(NOT MSGFMT_EXE)
+     message(WARNING "Text Translations won't be build")
+endif()
+
 #default behaviour
 include_directories(${CMAKE_SOURCE_DIR})
 add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
@@ -525,4 +530,104 @@ endif()
 add_custom_command(OUTPUT ${git_links} ${git_http_links}
              COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
              DEPENDS git git-remote-http)
-add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
\ No newline at end of file

No newline at end of file?

CMakeLists.txt endif() · line 538

Quoted 6 lines
CMakeLists.txt +6 -0
+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
+
+
+#creating required scripts
+set(SHELL_PATH /bin/sh)
+set(PERL_PATH /usr/bin/perl)

Really?
Have you tried on, let's say FreeBSD?

Quoted 21 lines
CMakeLists.txt +21 -0
+set(LOCALEDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)
+set(GITWEBDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)
+set(INSTLIBDIR ${FALLBACK_RUNTIME_PREFIX}/share/perl5)
+
+#shell scripts
+set(git_shell_scripts
+     git-bisect git-difftool--helper git-filter-branch
+     git-merge-octopus git-merge-one-file git-merge-resolve
+     git-mergetool git-quiltimport
+     git-request-pull git-submodule git-web--browse
+     git-mergetool--lib git-parse-remote git-rebase--preserve-merges
+     git-sh-setup git-sh-i18n git-instaweb)
+
+foreach(script ${git_shell_scripts})
+     file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.sh content NEWLINE_CONSUME)
+     string(REPLACE "@SHELL_PATH@" "${SHELL_PATH}" content "${content}")
+     string(REPLACE "@@DIFF@@" "diff" content "${content}")
+     string(REPLACE "@LOCALEDIR@" "${LOCALEDIR}" content "${content}")
+     string(REPLACE "@GITWEBDIR@" "${GITWEBDIR}" content "${content}")
+     string(REPLACE "@@NO_CURL@@" "" content "${content}")
+     string(REPLACE "@@USE_GETTEXT_SCHEME@@" "" content "${content}")
Quoted 9 lines

CMakeLists.txt endif() · line 565

Quoted 6 lines
CMakeLists.txt +6 -0
+     string(REPLACE "# @@BROKEN_PATH_FIX@@" "" content "${content}")
+     string(REPLACE "@@PERL@@" "${PERL_PATH}" content "${content}")
+     string(REPLACE "@@SANE_TEXT_GREP@@" "-a" content "${content}")
+     string(REPLACE "@@PAGER_ENV@@" "LESS=FRX LV=-c" content "${content}")
+     file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
+endforeach()

I assume this do most of sed magic?

Yes

Quoted 28 lines
Quoted 4 lines
CMakeLists.txt +4 -0
+
+#perl scripts
+set(git_perl_scripts
+     git-add--interactive git-archimport git-cvsexportcommit

CMakeLists.txt endif() · line 579

Quoted 10 lines
CMakeLists.txt +10 -0
+     git-cvsimport git-cvsserver git-send-email git-svn)
+
+#create perl header
+file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )
+string(REPLACE "@@PATHSEP@@" ":" perl_header "${perl_header}")
+string(REPLACE "@@INSTLIBDIR@@" "${INSTLIBDIR}" perl_header "${perl_header}")
+
+foreach(script ${git_perl_scripts})
+     file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.perl content NEWLINE_CONSUME)
+     string(REPLACE "#!/usr/bin/perl" "#!/usr/bin/perl\n${perl_header}\n" content "${content}")

Hoped that this is tried on BSD?

Quoted 11 lines
CMakeLists.txt +11 -0
+     string(REPLACE "@@GIT_VERSION@@" "${PROJECT_VERSION}" content "${content}")
+     file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
+endforeach()
+
+#python script
+file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)
+string(REPLACE "#!/usr/bin/env python" "#!/usr/bin/python" content "${content}")
+file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})
+
+#perl modules
+file(GLOB_RECURSE perl_modules "${CMAKE_SOURCE_DIR}/perl/*.pm")
Quoted 9 lines

CMakeLists.txt endif() · line 593

Quoted 3 lines
CMakeLists.txt +3 -0
+
+foreach(pm ${perl_modules})
+     string(REPLACE "${CMAKE_SOURCE_DIR}/perl/" "" file_path ${pm})

So, the real source code have reference to CMAKE_SOURCE_DIR? I don't think so? It's purely my guess from previous patch, this function will do
string(REPLACE from to file something_I_have_not_checked)

This if for getting the built perl modules in the right place "perl/build/lib" Once I glob the files, their paths are absolute, hence a replacement.

Quoted 9 lines
Quoted 9 lines
CMakeLists.txt +9 -0
+     file(STRINGS ${pm} content NEWLINE_CONSUME)
+     string(REPLACE "@@LOCALEDIR@@" "${LOCALEDIR}" content "${content}")
+     string(REPLACE "@@NO_PERL_CPAN_FALLBACKS@@" "" content "${content}")
+     file(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})
+#test-lib.sh requires perl/build/lib to be the build directory of perl modules
+endforeach()
+
+
+#templates
Quoted 9 lines

CMakeLists.txt endif() · line 608

Quoted 6 lines
CMakeLists.txt +6 -0
+file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches
+set(hooks_templates
+     applypatch-msg.sample pre-applypatch.sample pre-push.sample
+     commit-msg.sample pre-commit.sample pre-rebase.sample
+     fsmonitor-watchman.sample pre-merge-commit.sample pre-receive.sample
+     post-update.sample prepare-commit-msg.sample update.sample)

Too much things merged into one line, I hate it.

would you prefer something like this
set(hooks_templates

    applypatch-msg.sample
    pre-applypatch.sample
    ...)
Quoted 9 lines

CMakeLists.txt endif() · line 614

Quoted 6 lines
CMakeLists.txt +6 -0
+
+#templates have @.*@ replacement so use configure_file instead
+#hooks
+foreach(tm ${hooks_templates})
+     configure_file(${CMAKE_SOURCE_DIR}/templates/hooks--${tm} ${CMAKE_BINARY_DIR}/templates/blt/hooks/${tm} @ONLY)
+endforeach()

What does this really means?

The way above replacements(sed magic) use @@.*@@, whereas the templates use @.*@.
This pattern is what autoconf uses to configure Makefile.in, CMake also has a similar feature (configure_file)

Quoted 32 lines

CMakeLists.txt endif() · line 625

Quoted 11 lines
CMakeLists.txt +11 -0
+
+#info
+configure_file(${CMAKE_SOURCE_DIR}/templates/info--exclude ${CMAKE_BINARY_DIR}/templates/blt/info/exclude @ONLY)
+
+#this
+configure_file(${CMAKE_SOURCE_DIR}/templates/this--description ${CMAKE_BINARY_DIR}/templates/blt/description @ONLY)
+
+
+#translations
+if(MSGFMT_EXE)
+     set(po_files bg  ca  de  el  es  fr  is  it  ko  pt_PT  ru  sv  tr  vi  zh_CN  zh_TW)

hard coded, so this is a regression, compared to old Makefile?

CMakeLists.txt endif() · line 629

Quoted 4 lines
CMakeLists.txt +4 -0
+     foreach(po ${po_files})
+             file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES)
+             add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo
+                             COMMAND ${MSGFMT_EXE} --check --statistics -o ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo ${CMAKE_SOURCE_DIR}/po/${po}.po)

find_package(Gettext) defines MSGFMT_EXECUTABLE, I think. Have you check Solaris option?
Or is this tranlated from current Makefile?
I haven't checked current source code!

Quoted 7 lines
CMakeLists.txt +4 -1
+             list(APPEND po_gen ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo)
+     endforeach()
+     add_custom_target(po-gen ALL DEPENDS ${po_gen})
+endif()
--

gitgitgadget

Quoted 2 lines

--
Danh

Thank You,
Sibi Siddharthan

#14 lore raw

PATCH 3/8 cmake: installation support for git

In reply to Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch provides the facility to install the built binaries and scripts.

This is very similar to make install.
By default the destination directory(DESTDIR) is /usr/local/ on Linux To set a custom installation path do this:
cmake relative-path-to-srcdir
-DCMAKE_INSTALL_PREFIX=preferred-install-path

Then run make install

---
 CMakeLists.txt | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
CMakeLists.txt +49 -0
index 788b53be873..25de5b5bc35 100644
@@ -13,6 +13,8 @@ project(git
 	VERSION ${git_version}
 	LANGUAGES C)
 
+#TODO gitk git-gui gitweb
+#TODO Add pcre support
 
 include(CheckTypeSize)
 include(CheckCSourceRuns)
@@ -631,3 +633,50 @@ if(MSGFMT_EXE)
 	endforeach()
 	add_custom_target(po-gen ALL DEPENDS ${po_gen})
 endif()
+
+
+#to help with the install
+list(TRANSFORM git_shell_scripts PREPEND "${CMAKE_BINARY_DIR}/")
+list(TRANSFORM git_perl_scripts PREPEND "${CMAKE_BINARY_DIR}/")
+
+#install
+install(TARGETS git git-shell
+	RUNTIME DESTINATION bin)
+install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver  #${CMAKE_SOURCE_DIR}/gitk-git/gitk check
+	DESTINATION bin)
+
+list(REMOVE_ITEM PROGRAMS_BUILT git git-shell)
+install(TARGETS ${PROGRAMS_BUILT}
+	RUNTIME DESTINATION libexec/git-core)
+
+set(bin_links
+	git-receive-pack git-upload-archive git-upload-pack)
+
+foreach(b ${bin_links})
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})")
+endforeach()
+
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)")
+
+foreach(b ${git_links})
+	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
+	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+endforeach()
+
+foreach(b ${git_http_links})
+	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
+	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+endforeach()
+
+install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
+	DESTINATION libexec/git-core)
+
+install(DIRECTORY mergetools DESTINATION libexec/git-core)
+install(DIRECTORY ${CMAKE_BINARY_DIR}/perl/build/lib/ DESTINATION share/perl5
+	FILES_MATCHING PATTERN "*.pm")
+install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/templates)
+
+if(MSGFMT_EXE)
+	install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)
+endif()
Signature · 1 line
gitgitgadget
#15 lore raw

Re: [PATCH 3/8] cmake: installation support for git

Quoted 35 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch provides the facility to install the built binaries and scripts.

This is very similar to make install.
By default the destination directory(DESTDIR) is /usr/local/ on Linux To set a custom installation path do this:
cmake relative-path-to-srcdir
-DCMAKE_INSTALL_PREFIX=preferred-install-path

Then run make install

---
 CMakeLists.txt | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
CMakeLists.txt +2 -0
index 788b53be873..25de5b5bc35 100644
@@ -13,6 +13,8 @@ project(git
 	VERSION ${git_version}
 	LANGUAGES C)
 
+#TODO gitk git-gui gitweb
+#TODO Add pcre support
 
 include(CheckTypeSize)
 include(CheckCSourceRuns)
@@ -631,3 +633,50 @@ if(MSGFMT_EXE)
 	endforeach()
 	add_custom_target(po-gen ALL DEPENDS ${po_gen})
 endif()

CMakeLists.txt if(MSGFMT_EXE) · line 645

Quoted 10 lines
CMakeLists.txt +10 -0
+
+
+#to help with the install
+list(TRANSFORM git_shell_scripts PREPEND "${CMAKE_BINARY_DIR}/")
+list(TRANSFORM git_perl_scripts PREPEND "${CMAKE_BINARY_DIR}/")
+
+#install
+install(TARGETS git git-shell
+	RUNTIME DESTINATION bin)
+install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver  #${CMAKE_SOURCE_DIR}/gitk-git/gitk check

check? What does it mean?

CMakeLists.txt if(MSGFMT_EXE) · line 650

Quoted 5 lines
CMakeLists.txt +5 -0
+	DESTINATION bin)
+
+list(REMOVE_ITEM PROGRAMS_BUILT git git-shell)
+install(TARGETS ${PROGRAMS_BUILT}
+	RUNTIME DESTINATION libexec/git-core)

Ubuntu install exec file to /usr/lib/git-core?

Quoted 17 lines
CMakeLists.txt +17 -0
+
+set(bin_links
+	git-receive-pack git-upload-archive git-upload-pack)
+
+foreach(b ${bin_links})
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})")
+endforeach()
+
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)")
+
+foreach(b ${git_links})
+	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
+	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+endforeach()
+
+foreach(b ${git_http_links})

CMakeLists.txt if(MSGFMT_EXE) · line 677

Quoted 10 lines
CMakeLists.txt +10 -0
+	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
+	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+endforeach()
+
+install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
+	DESTINATION libexec/git-core)
+
+install(DIRECTORY mergetools DESTINATION libexec/git-core)
+install(DIRECTORY ${CMAKE_BINARY_DIR}/perl/build/lib/ DESTINATION share/perl5
+	FILES_MATCHING PATTERN "*.pm")

I think distro gonna complans about this pattern!

CMakeLists.txt if(MSGFMT_EXE) · line 682

Quoted 5 lines
CMakeLists.txt +5 -0
+install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/templates)
+
+if(MSGFMT_EXE)
+	install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)
+endif()

I thought we want to check for NO_GETTEXT?

Signature · 1 line
Danh
#16 lore raw

Re: [PATCH 3/8] cmake: installation support for git

Quoted 41 lines · Danh Doan
Quoted 39 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch provides the facility to install the built binaries and scripts.

This is very similar to make install.
By default the destination directory(DESTDIR) is /usr/local/ on Linux To set a custom installation path do this:
cmake relative-path-to-srcdir
-DCMAKE_INSTALL_PREFIX=preferred-install-path

Then run make install

---
 CMakeLists.txt | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
CMakeLists.txt +6 -0
index 788b53be873..25de5b5bc35 100644
@@ -13,6 +13,8 @@ project(git
      VERSION ${git_version}
      LANGUAGES C)
 
+#TODO gitk git-gui gitweb
+#TODO Add pcre support
 
 include(CheckTypeSize)
 include(CheckCSourceRuns)
@@ -631,3 +633,50 @@ if(MSGFMT_EXE)
      endforeach()
      add_custom_target(po-gen ALL DEPENDS ${po_gen})
 endif()
+
+
+#to help with the install
+list(TRANSFORM git_shell_scripts PREPEND "${CMAKE_BINARY_DIR}/")
Quoted 9 lines

CMakeLists.txt if(MSGFMT_EXE) · line 645

Quoted 6 lines
CMakeLists.txt +6 -0
+list(TRANSFORM git_perl_scripts PREPEND "${CMAKE_BINARY_DIR}/")
+
+#install
+install(TARGETS git git-shell
+     RUNTIME DESTINATION bin)
+install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver  #${CMAKE_SOURCE_DIR}/gitk-git/gitk check

check? What does it mean?

It is part of a TODO for gitk, will remove it. Sorry

Quoted 8 lines

CMakeLists.txt if(MSGFMT_EXE) · line 650

Quoted 5 lines
CMakeLists.txt +5 -0
+     DESTINATION bin)
+
+list(REMOVE_ITEM PROGRAMS_BUILT git git-shell)
+install(TARGETS ${PROGRAMS_BUILT}
+     RUNTIME DESTINATION libexec/git-core)

Ubuntu install exec file to /usr/lib/git-core?

Yes it does, but when I do make install the programs go to libexec/git-core

Quoted 21 lines
Quoted 21 lines
CMakeLists.txt +21 -0
+
+set(bin_links
+     git-receive-pack git-upload-archive git-upload-pack)
+
+foreach(b ${bin_links})
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})")
+endforeach()
+
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)")
+
+foreach(b ${git_links})
+     string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
+     install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+endforeach()
+
+foreach(b ${git_http_links})
+     string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
+     install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+endforeach()
+
Quoted 9 lines

CMakeLists.txt if(MSGFMT_EXE) · line 677

Quoted 6 lines
CMakeLists.txt +6 -0
+install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
+     DESTINATION libexec/git-core)
+
+install(DIRECTORY mergetools DESTINATION libexec/git-core)
+install(DIRECTORY ${CMAKE_BINARY_DIR}/perl/build/lib/ DESTINATION share/perl5
+     FILES_MATCHING PATTERN "*.pm")

I think distro gonna complans about this pattern!

What are you trying to say? Can you explain a bit more.

Quoted 10 lines

CMakeLists.txt if(MSGFMT_EXE) · line 682

Quoted 5 lines
CMakeLists.txt +5 -0
+install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/templates)
+
+if(MSGFMT_EXE)
+     install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)
+endif()

I thought we want to check for NO_GETTEXT?

--
Danh

Thank You,
Sibi Siddharthan

#17 lore raw

PATCH 4/8 cmake: support for testing git with ctest

In reply to Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch provides an alternate way to test git using ctest. CTest ships with CMake, so there is no additional dependency being introduced.

To perform the tests with ctest do this after building:
ctest -j[number of jobs]

NOTE: -j is optional, the default number of jobs is 1

Each of the jobs does this:
cd t/ && sh t[something].sh

The reason for using CTest is that it logs the output of the tests in a neat way, which can be helpful during diagnosis of failures.

After the tests have run ctest generates three log files located in build-directory/Testing/Temporary/

These log files are:

CTestCostData.txt:
This file contains the time taken to complete each test.

LastTestsFailed.log:
This log file contains the names of the tests that have failed in the run.

LastTest.log:
This log file contains the log of all the tests that have run. A snippet of the file is given below.

10/901 Testing: D:/my/git-master/t/t0009-prio-queue.sh 10/901 Test: D:/my/git-master/t/t0009-prio-queue.sh
Command: "sh.exe" "D:/my/git-master/t/t0009-prio-queue.sh"
Directory: D:/my/git-master/t "D:/my/git-master/t/t0009-prio-queue.sh"
Output:
----------------------------------------------------------
ok 1 - basic ordering
ok 2 - mixed put and get
ok 3 - notice empty queue
ok 4 - stack order
passed all 4 test(s)
1..4
<end of output>
Test time = 1.11 sec

NOTE: Testing only works when building in source for now.

---
 CMakeLists.txt | 142 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 142 insertions(+)
CMakeLists.txt +142 -0
index 25de5b5bc35..141ccefa559 100644
@@ -23,6 +23,7 @@ include(CheckIncludeFile)
 include(CheckFunctionExists)
 include(CheckSymbolExists)
 include(CheckStructHasMember)
+include(CTest)
 
 find_package(ZLIB REQUIRED)
 find_package(CURL)
@@ -680,3 +681,144 @@ install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/
 if(MSGFMT_EXE)
 	install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)
 endif()
+
+
+if(BUILD_TESTING)
+
+#tests-helpers
+add_executable(test-fake-ssh t/helper/test-fake-ssh.c)
+target_link_libraries(test-fake-ssh common-main)
+
+add_executable(test-line-buffer t/helper/test-line-buffer.c)
+target_link_libraries(test-line-buffer common-main vcs-svn)
+
+add_executable(test-svn-fe t/helper/test-svn-fe.c)
+target_link_libraries(test-svn-fe common-main vcs-svn)
+
+set(test_helper_sources
+	t/helper/test-tool.c t/helper/test-advise.c t/helper/test-bloom.c t/helper/test-chmtime.c
+	t/helper/test-config.c t/helper/test-ctype.c t/helper/test-date.c t/helper/test-delta.c
+	t/helper/test-dir-iterator.c t/helper/test-drop-caches.c t/helper/test-dump-cache-tree.c
+	t/helper/test-dump-fsmonitor.c t/helper/test-dump-split-index.c
+	t/helper/test-dump-untracked-cache.c t/helper/test-example-decorate.c
+	t/helper/test-genrandom.c t/helper/test-genzeros.c t/helper/test-hash.c
+	t/helper/test-hashmap.c t/helper/test-hash-speed.c t/helper/test-index-version.c
+	t/helper/test-json-writer.c t/helper/test-lazy-init-name-hash.c
+	t/helper/test-match-trees.c t/helper/test-mergesort.c t/helper/test-mktemp.c
+	t/helper/test-oidmap.c t/helper/test-online-cpus.c t/helper/test-parse-options.c
+	t/helper/test-parse-pathspec-file.c t/helper/test-path-utils.c t/helper/test-pkt-line.c
+	t/helper/test-prio-queue.c t/helper/test-progress.c t/helper/test-reach.c
+	t/helper/test-read-cache.c t/helper/test-read-graph.c t/helper/test-read-midx.c
+	t/helper/test-ref-store.c t/helper/test-regex.c t/helper/test-repository.c
+	t/helper/test-revision-walking.c t/helper/test-run-command.c t/helper/test-scrap-cache-tree.c
+	t/helper/test-serve-v2.c t/helper/test-sha1.c t/helper/test-oid-array.c t/helper/test-sha256.c
+	t/helper/test-sigchain.c t/helper/test-strcmp-offset.c t/helper/test-string-list.c
+	t/helper/test-submodule-config.c t/helper/test-submodule-nested-repo-config.c t/helper/test-subprocess.c
+	t/helper/test-trace2.c t/helper/test-urlmatch-normalization.c t/helper/test-xml-encode.c
+	t/helper/test-wildmatch.c t/helper/test-windows-named-pipe.c t/helper/test-write-cache.c)
+
+add_executable(test-tool ${test_helper_sources})
+target_link_libraries(test-tool common-main)
+
+set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
+			PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)
+
+#wrapper scripts
+set(wrapper_scripts
+	git git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)
+
+set(wrapper_test_scripts
+	test-fake-ssh test-line-buffer test-svn-fe test-tool)
+
+
+foreach(script ${wrapper_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
+	string(REPLACE "@@PROG@@" "${script}" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
+endforeach()
+
+foreach(script ${wrapper_test_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
+	string(REPLACE "@@PROG@@" "t/helper/${script}" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
+endforeach()
+
+file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
+string(REPLACE "@@PROG@@" "git-cvsserver" content "${content}")
+file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})
+
+#options for configuring test options
+option(PERL_TESTS "Perform tests that use perl" ON)
+option(PYTHON_TESTS "Perform tests that use python" ON)
+
+#GIT-BUILD-OPTIONS
+set(TEST_SHELL_PATH ${SHELL_PATH})
+set(DIFF diff)
+set(PYTHON_PATH /usr/bin/python)
+set(TAR tar)
+set(NO_CURL )
+set(NO_EXPAT )
+set(USE_LIBPCRE1 )
+set(USE_LIBPCRE2 )
+set(NO_LIBPCRE1_JIT )
+set(NO_PERL )
+set(NO_PTHREADS )
+set(NO_PYTHON )
+set(PAGER_ENV "LESS=FRX LV=-c")
+set(DC_SHA1 YesPlease)
+set(RUNTIME_PREFIX true)
+set(NO_GETTEXT )
+
+if(NOT CURL_FOUND)
+	set(NO_CURL 1)
+endif()
+
+if(NOT EXPAT_FOUND)
+	set(NO_EXPAT 1)
+endif()
+
+if(NOT Intl_FOUND)
+	set(NO_GETTEXT 1)
+endif()
+
+if(NOT PERL_TESTS)
+	set(NO_PERL 1)
+endif()
+
+if(NOT PYTHON_TESTS)
+	set(NO_PYTHON 1)
+endif()
+
+file(WRITE ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "SHELL_PATH='${SHELL_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TEST_SHELL_PATH='${TEST_SHELL_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PERL_PATH='${PERL_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DIFF='${DIFF}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PYTHON_PATH='${PYTHON_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TAR='${TAR}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_CURL='${NO_CURL}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_EXPAT='${NO_EXPAT}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "USE_LIBPCRE1='${USE_LIBPCRE1}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_LIBPCRE1_JIT='${NO_LIBPCRE1_JIT}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PERL='${NO_PERL}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PAGER_ENV='${PAGER_ENV}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DC_SHA1='${DC_SHA1}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X=''\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
+
+file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")
+
+#test
+foreach(tsh ${test_scipts})
+	add_test(NAME ${tsh}
+		COMMAND ${SH_EXE} ${tsh}
+		WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t)
+endforeach()
+
+endif()#BUILD_TESTING
\ No newline at end of file
Signature · 1 line
gitgitgadget
#18 lore raw

Re: [PATCH 4/8] cmake: support for testing git with ctest

Quoted 144 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch provides an alternate way to test git using ctest. CTest ships with CMake, so there is no additional dependency being introduced.

To perform the tests with ctest do this after building:
ctest -j[number of jobs]

NOTE: -j is optional, the default number of jobs is 1

Each of the jobs does this:
cd t/ && sh t[something].sh

The reason for using CTest is that it logs the output of the tests in a neat way, which can be helpful during diagnosis of failures.

After the tests have run ctest generates three log files located in build-directory/Testing/Temporary/

These log files are:

CTestCostData.txt:
This file contains the time taken to complete each test.

LastTestsFailed.log:
This log file contains the names of the tests that have failed in the run.

LastTest.log:
This log file contains the log of all the tests that have run. A snippet of the file is given below.

10/901 Testing: D:/my/git-master/t/t0009-prio-queue.sh 10/901 Test: D:/my/git-master/t/t0009-prio-queue.sh
Command: "sh.exe" "D:/my/git-master/t/t0009-prio-queue.sh"
Directory: D:/my/git-master/t "D:/my/git-master/t/t0009-prio-queue.sh"
Output:
----------------------------------------------------------
ok 1 - basic ordering
ok 2 - mixed put and get
ok 3 - notice empty queue
ok 4 - stack order
passed all 4 test(s)
1..4
<end of output>
Test time = 1.11 sec

NOTE: Testing only works when building in source for now.

---
 CMakeLists.txt | 142 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 142 insertions(+)
CMakeLists.txt +73 -0
index 25de5b5bc35..141ccefa559 100644
@@ -23,6 +23,7 @@ include(CheckIncludeFile)
 include(CheckFunctionExists)
 include(CheckSymbolExists)
 include(CheckStructHasMember)
+include(CTest)
 
 find_package(ZLIB REQUIRED)
 find_package(CURL)
@@ -680,3 +681,144 @@ install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/
 if(MSGFMT_EXE)
 	install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)
 endif()
+
+
+if(BUILD_TESTING)
+
+#tests-helpers
+add_executable(test-fake-ssh t/helper/test-fake-ssh.c)
+target_link_libraries(test-fake-ssh common-main)
+
+add_executable(test-line-buffer t/helper/test-line-buffer.c)
+target_link_libraries(test-line-buffer common-main vcs-svn)
+
+add_executable(test-svn-fe t/helper/test-svn-fe.c)
+target_link_libraries(test-svn-fe common-main vcs-svn)
+
+set(test_helper_sources
+	t/helper/test-tool.c t/helper/test-advise.c t/helper/test-bloom.c t/helper/test-chmtime.c
+	t/helper/test-config.c t/helper/test-ctype.c t/helper/test-date.c t/helper/test-delta.c
+	t/helper/test-dir-iterator.c t/helper/test-drop-caches.c t/helper/test-dump-cache-tree.c
+	t/helper/test-dump-fsmonitor.c t/helper/test-dump-split-index.c
+	t/helper/test-dump-untracked-cache.c t/helper/test-example-decorate.c
+	t/helper/test-genrandom.c t/helper/test-genzeros.c t/helper/test-hash.c
+	t/helper/test-hashmap.c t/helper/test-hash-speed.c t/helper/test-index-version.c
+	t/helper/test-json-writer.c t/helper/test-lazy-init-name-hash.c
+	t/helper/test-match-trees.c t/helper/test-mergesort.c t/helper/test-mktemp.c
+	t/helper/test-oidmap.c t/helper/test-online-cpus.c t/helper/test-parse-options.c
+	t/helper/test-parse-pathspec-file.c t/helper/test-path-utils.c t/helper/test-pkt-line.c
+	t/helper/test-prio-queue.c t/helper/test-progress.c t/helper/test-reach.c
+	t/helper/test-read-cache.c t/helper/test-read-graph.c t/helper/test-read-midx.c
+	t/helper/test-ref-store.c t/helper/test-regex.c t/helper/test-repository.c
+	t/helper/test-revision-walking.c t/helper/test-run-command.c t/helper/test-scrap-cache-tree.c
+	t/helper/test-serve-v2.c t/helper/test-sha1.c t/helper/test-oid-array.c t/helper/test-sha256.c
+	t/helper/test-sigchain.c t/helper/test-strcmp-offset.c t/helper/test-string-list.c
+	t/helper/test-submodule-config.c t/helper/test-submodule-nested-repo-config.c t/helper/test-subprocess.c
+	t/helper/test-trace2.c t/helper/test-urlmatch-normalization.c t/helper/test-xml-encode.c
+	t/helper/test-wildmatch.c t/helper/test-windows-named-pipe.c t/helper/test-write-cache.c)
+
+add_executable(test-tool ${test_helper_sources})
+target_link_libraries(test-tool common-main)
+
+set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
+			PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)
+
+#wrapper scripts
+set(wrapper_scripts
+	git git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)
+
+set(wrapper_test_scripts
+	test-fake-ssh test-line-buffer test-svn-fe test-tool)
+
+
+foreach(script ${wrapper_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
+	string(REPLACE "@@PROG@@" "${script}" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
+endforeach()
+
+foreach(script ${wrapper_test_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
+	string(REPLACE "@@PROG@@" "t/helper/${script}" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
+endforeach()
+
+file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
+string(REPLACE "@@PROG@@" "git-cvsserver" content "${content}")
+file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})
+
+#options for configuring test options
+option(PERL_TESTS "Perform tests that use perl" ON)
+option(PYTHON_TESTS "Perform tests that use python" ON)

CMakeLists.txt install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/ · line 765

Quoted 10 lines
CMakeLists.txt +10 -0
+
+#GIT-BUILD-OPTIONS
+set(TEST_SHELL_PATH ${SHELL_PATH})
+set(DIFF diff)
+set(PYTHON_PATH /usr/bin/python)
+set(TAR tar)
+set(NO_CURL )
+set(NO_EXPAT )
+set(USE_LIBPCRE1 )
+set(USE_LIBPCRE2 )

Hm, really?

Quoted 18 lines
CMakeLists.txt +18 -0
+set(NO_LIBPCRE1_JIT )
+set(NO_PERL )
+set(NO_PTHREADS )
+set(NO_PYTHON )
+set(PAGER_ENV "LESS=FRX LV=-c")
+set(DC_SHA1 YesPlease)
+set(RUNTIME_PREFIX true)
+set(NO_GETTEXT )
+
+if(NOT CURL_FOUND)
+	set(NO_CURL 1)
+endif()
+
+if(NOT EXPAT_FOUND)
+	set(NO_EXPAT 1)
+endif()
+
+if(NOT Intl_FOUND)

CMakeLists.txt install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/ · line 793

Quoted 10 lines
CMakeLists.txt +10 -0
+	set(NO_GETTEXT 1)
+endif()
+
+if(NOT PERL_TESTS)
+	set(NO_PERL 1)
+endif()
+
+if(NOT PYTHON_TESTS)
+	set(NO_PYTHON 1)
+endif()

I hope we have something like:

PYTHON_PATH=/path/to/my/yet/to/release/python/to/check/if/it/works/with/current/git

If it's ready, thanks.
If it isn't, no, I'm stressed enough by CMake.

Quoted 12 lines
CMakeLists.txt +12 -0
+
+file(WRITE ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "SHELL_PATH='${SHELL_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TEST_SHELL_PATH='${TEST_SHELL_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PERL_PATH='${PERL_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DIFF='${DIFF}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PYTHON_PATH='${PYTHON_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TAR='${TAR}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_CURL='${NO_CURL}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_EXPAT='${NO_EXPAT}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "USE_LIBPCRE1='${USE_LIBPCRE1}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_LIBPCRE1_JIT='${NO_LIBPCRE1_JIT}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PERL='${NO_PERL}'\n")

CMakeLists.txt install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/ · line 815

Quoted 10 lines
CMakeLists.txt +10 -0
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PAGER_ENV='${PAGER_ENV}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DC_SHA1='${DC_SHA1}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X=''\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
+
+file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")

CMake recommends to not use GLOB for this kind of things, themselves, no?

CMakeLists.txt install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/ · line 824

Quoted 10 lines
CMakeLists.txt +9 -0
+
+#test
+foreach(tsh ${test_scipts})
+	add_test(NAME ${tsh}
+		COMMAND ${SH_EXE} ${tsh}
+		WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t)
+endforeach()
+
+endif()#BUILD_TESTING
\ No newline at end of file

Please fix your editor!

Signature · 1 line
Danh
#19 lore raw

Re: [PATCH 4/8] cmake: support for testing git with ctest

Quoted 150 lines · Danh Doan
Quoted 148 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch provides an alternate way to test git using ctest. CTest ships with CMake, so there is no additional dependency being introduced.

To perform the tests with ctest do this after building:
ctest -j[number of jobs]

NOTE: -j is optional, the default number of jobs is 1

Each of the jobs does this:
cd t/ && sh t[something].sh

The reason for using CTest is that it logs the output of the tests in a neat way, which can be helpful during diagnosis of failures.

After the tests have run ctest generates three log files located in build-directory/Testing/Temporary/

These log files are:

CTestCostData.txt:
This file contains the time taken to complete each test.

LastTestsFailed.log:
This log file contains the names of the tests that have failed in the run.

LastTest.log:
This log file contains the log of all the tests that have run. A snippet of the file is given below.

10/901 Testing: D:/my/git-master/t/t0009-prio-queue.sh 10/901 Test: D:/my/git-master/t/t0009-prio-queue.sh
Command: "sh.exe" "D:/my/git-master/t/t0009-prio-queue.sh"
Directory: D:/my/git-master/t "D:/my/git-master/t/t0009-prio-queue.sh"
Output:
----------------------------------------------------------
ok 1 - basic ordering
ok 2 - mixed put and get
ok 3 - notice empty queue
ok 4 - stack order
passed all 4 test(s)
1..4
<end of output>
Test time = 1.11 sec

NOTE: Testing only works when building in source for now.

---
 CMakeLists.txt | 142 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 142 insertions(+)
CMakeLists.txt +77 -0
index 25de5b5bc35..141ccefa559 100644
@@ -23,6 +23,7 @@ include(CheckIncludeFile)
 include(CheckFunctionExists)
 include(CheckSymbolExists)
 include(CheckStructHasMember)
+include(CTest)
 
 find_package(ZLIB REQUIRED)
 find_package(CURL)
@@ -680,3 +681,144 @@ install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/
 if(MSGFMT_EXE)
      install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)
 endif()
+
+
+if(BUILD_TESTING)
+
+#tests-helpers
+add_executable(test-fake-ssh t/helper/test-fake-ssh.c)
+target_link_libraries(test-fake-ssh common-main)
+
+add_executable(test-line-buffer t/helper/test-line-buffer.c)
+target_link_libraries(test-line-buffer common-main vcs-svn)
+
+add_executable(test-svn-fe t/helper/test-svn-fe.c)
+target_link_libraries(test-svn-fe common-main vcs-svn)
+
+set(test_helper_sources
+     t/helper/test-tool.c t/helper/test-advise.c t/helper/test-bloom.c t/helper/test-chmtime.c
+     t/helper/test-config.c t/helper/test-ctype.c t/helper/test-date.c t/helper/test-delta.c
+     t/helper/test-dir-iterator.c t/helper/test-drop-caches.c t/helper/test-dump-cache-tree.c
+     t/helper/test-dump-fsmonitor.c t/helper/test-dump-split-index.c
+     t/helper/test-dump-untracked-cache.c t/helper/test-example-decorate.c
+     t/helper/test-genrandom.c t/helper/test-genzeros.c t/helper/test-hash.c
+     t/helper/test-hashmap.c t/helper/test-hash-speed.c t/helper/test-index-version.c
+     t/helper/test-json-writer.c t/helper/test-lazy-init-name-hash.c
+     t/helper/test-match-trees.c t/helper/test-mergesort.c t/helper/test-mktemp.c
+     t/helper/test-oidmap.c t/helper/test-online-cpus.c t/helper/test-parse-options.c
+     t/helper/test-parse-pathspec-file.c t/helper/test-path-utils.c t/helper/test-pkt-line.c
+     t/helper/test-prio-queue.c t/helper/test-progress.c t/helper/test-reach.c
+     t/helper/test-read-cache.c t/helper/test-read-graph.c t/helper/test-read-midx.c
+     t/helper/test-ref-store.c t/helper/test-regex.c t/helper/test-repository.c
+     t/helper/test-revision-walking.c t/helper/test-run-command.c t/helper/test-scrap-cache-tree.c
+     t/helper/test-serve-v2.c t/helper/test-sha1.c t/helper/test-oid-array.c t/helper/test-sha256.c
+     t/helper/test-sigchain.c t/helper/test-strcmp-offset.c t/helper/test-string-list.c
+     t/helper/test-submodule-config.c t/helper/test-submodule-nested-repo-config.c t/helper/test-subprocess.c
+     t/helper/test-trace2.c t/helper/test-urlmatch-normalization.c t/helper/test-xml-encode.c
+     t/helper/test-wildmatch.c t/helper/test-windows-named-pipe.c t/helper/test-write-cache.c)
+
+add_executable(test-tool ${test_helper_sources})
+target_link_libraries(test-tool common-main)
+
+set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
+                     PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)
+
+#wrapper scripts
+set(wrapper_scripts
+     git git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)
+
+set(wrapper_test_scripts
+     test-fake-ssh test-line-buffer test-svn-fe test-tool)
+
+
+foreach(script ${wrapper_scripts})
+     file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+     string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
+     string(REPLACE "@@PROG@@" "${script}" content "${content}")
+     file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
+endforeach()
+
+foreach(script ${wrapper_test_scripts})
+     file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+     string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
+     string(REPLACE "@@PROG@@" "t/helper/${script}" content "${content}")
+     file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
+endforeach()
+
+file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
+string(REPLACE "@@PROG@@" "git-cvsserver" content "${content}")
+file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})
+
+#options for configuring test options
+option(PERL_TESTS "Perform tests that use perl" ON)
+option(PYTHON_TESTS "Perform tests that use python" ON)
+
+#GIT-BUILD-OPTIONS
+set(TEST_SHELL_PATH ${SHELL_PATH})
+set(DIFF diff)
Quoted 10 lines

CMakeLists.txt install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/ · line 765

Quoted 6 lines
CMakeLists.txt +6 -0
+set(PYTHON_PATH /usr/bin/python)
+set(TAR tar)
+set(NO_CURL )
+set(NO_EXPAT )
+set(USE_LIBPCRE1 )
+set(USE_LIBPCRE2 )

Hm, really?

These are generated by default on the Makefile also.

Quoted 31 lines
Quoted 18 lines
CMakeLists.txt +18 -0
+set(NO_LIBPCRE1_JIT )
+set(NO_PERL )
+set(NO_PTHREADS )
+set(NO_PYTHON )
+set(PAGER_ENV "LESS=FRX LV=-c")
+set(DC_SHA1 YesPlease)
+set(RUNTIME_PREFIX true)
+set(NO_GETTEXT )
+
+if(NOT CURL_FOUND)
+     set(NO_CURL 1)
+endif()
+
+if(NOT EXPAT_FOUND)
+     set(NO_EXPAT 1)
+endif()
+
+if(NOT Intl_FOUND)

CMakeLists.txt install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/ · line 793

Quoted 10 lines
CMakeLists.txt +10 -0
+     set(NO_GETTEXT 1)
+endif()
+
+if(NOT PERL_TESTS)
+     set(NO_PERL 1)
+endif()
+
+if(NOT PYTHON_TESTS)
+     set(NO_PYTHON 1)
+endif()

I hope we have something like:

Quoted 5 lines

PYTHON_PATH=/path/to/my/yet/to/release/python/to/check/if/it/works/with/current/git

If it's ready, thanks.
If it isn't, no, I'm stressed enough by CMake.

Yes it can be done.

Quoted 38 lines
Quoted 12 lines
CMakeLists.txt +12 -0
+
+file(WRITE ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "SHELL_PATH='${SHELL_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TEST_SHELL_PATH='${TEST_SHELL_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PERL_PATH='${PERL_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DIFF='${DIFF}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PYTHON_PATH='${PYTHON_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TAR='${TAR}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_CURL='${NO_CURL}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_EXPAT='${NO_EXPAT}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "USE_LIBPCRE1='${USE_LIBPCRE1}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_LIBPCRE1_JIT='${NO_LIBPCRE1_JIT}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PERL='${NO_PERL}'\n")

CMakeLists.txt install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/ · line 815

Quoted 10 lines
CMakeLists.txt +10 -0
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PAGER_ENV='${PAGER_ENV}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DC_SHA1='${DC_SHA1}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X=''\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
+
+file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")

CMake recommends to not use GLOB for this kind of things, themselves, no?

CMakeLists.txt install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/ · line 824

Quoted 10 lines
CMakeLists.txt +9 -0
+
+#test
+foreach(tsh ${test_scipts})
+     add_test(NAME ${tsh}
+             COMMAND ${SH_EXE} ${tsh}
+             WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t)
+endforeach()
+
+endif()#BUILD_TESTING
\ No newline at end of file

Please fix your editor!

Quoted 2 lines

--
Danh

Thank You,
Sibi Siddharthan

#20 lore raw

PATCH 5/8 cmake: support for testing git when building out of the source tree

In reply to Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch allows git to be tested when performin out of source builds.

This involves changing GIT_BUILD_DIR in t/test-lib.sh to point to the build directory. Also some miscellaneous copies from the source directory to the build directory.
The copies are:
t/chainlint.sed needed by a bunch of test scripts
po/is.po needed by t0204-gettext-rencode-sanity mergetools/tkdiff needed by t7800-difftool contrib/completion/git-prompt.sh needed by t9903-bash-prompt contrib/completion/git-completion.bash needed by t9902-completion contrib/svn-fe/svnrdump_sim.py needed by t9020-remote-svn

NOTE: t/test-lib.sh is only modified when tests are run not during the build or configure.
The trash directory is still srcdir/t

---
 CMakeLists.txt | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
CMakeLists.txt +19 -0
index 141ccefa559..29a23eb11f7 100644
@@ -812,6 +812,25 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n"
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
 
+#Make the tests work when building out of the source tree
+if(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
+	file(RELATIVE_PATH BUILD_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/CMakeCache.txt)
+	string(REPLACE "/CMakeCache.txt" "" BUILD_DIR_RELATIVE ${BUILD_DIR_RELATIVE})
+	#Setting the build directory in test-lib.sh before running tests
+	file(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.cmake
+		"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh GIT_BUILD_DIR_REPL REGEX \"GIT_BUILD_DIR=(.*)\")\n"
+		"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh content NEWLINE_CONSUME)\n"
+		"string(REPLACE \"\${GIT_BUILD_DIR_REPL}\" \"GIT_BUILD_DIR=\\\"$TEST_DIRECTORY\\\"/../${BUILD_DIR_RELATIVE}\" content \"\${content}\")\n"
+		"file(WRITE ${CMAKE_SOURCE_DIR}/t/test-lib.sh \${content})")
+	#misc copies
+	file(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.sed DESTINATION ${CMAKE_BINARY_DIR}/t/)
+	file(COPY ${CMAKE_SOURCE_DIR}/po/is.po DESTINATION ${CMAKE_BINARY_DIR}/po/)
+	file(COPY ${CMAKE_SOURCE_DIR}/mergetools/tkdiff DESTINATION ${CMAKE_BINARY_DIR}/mergetools/)
+	file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-prompt.sh DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)
+	file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-completion.bash DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)
+	file(COPY ${CMAKE_SOURCE_DIR}/contrib/svn-fe/svnrdump_sim.py DESTINATION ${CMAKE_BINARY_DIR}/contrib/svn-fe/)
+endif()
+
 file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")
 
 #test
Signature · 1 line
gitgitgadget
#21 lore raw

Re: [PATCH 5/8] cmake: support for testing git when building out of the source tree

Quoted 29 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch allows git to be tested when performin out of source builds.

This involves changing GIT_BUILD_DIR in t/test-lib.sh to point to the build directory. Also some miscellaneous copies from the source directory to the build directory.
The copies are:
t/chainlint.sed needed by a bunch of test scripts
po/is.po needed by t0204-gettext-rencode-sanity mergetools/tkdiff needed by t7800-difftool contrib/completion/git-prompt.sh needed by t9903-bash-prompt contrib/completion/git-completion.bash needed by t9902-completion contrib/svn-fe/svnrdump_sim.py needed by t9020-remote-svn

NOTE: t/test-lib.sh is only modified when tests are run not during the build or configure.
The trash directory is still srcdir/t

---
 CMakeLists.txt | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
CMakeLists.txt +0 -0
index 141ccefa559..29a23eb11f7 100644

CMakeLists.txt file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n" · line 816

Quoted 5 lines
CMakeLists.txt +2 -0
@@ -812,6 +812,25 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n"
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
 
+#Make the tests work when building out of the source tree
+if(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})

IIRC, CMake recommends _NOT_ expand variable inside if() This very inconsistent recommendation of CMake (when should I use ${var} and when should I use var?) is one of reason I hate CMake

CMakeLists.txt file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n" · line 818

Quoted 2 lines
CMakeLists.txt +2 -0
+	file(RELATIVE_PATH BUILD_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/CMakeCache.txt)
+	string(REPLACE "/CMakeCache.txt" "" BUILD_DIR_RELATIVE ${BUILD_DIR_RELATIVE})

I don't know what is going on here!

CMakeLists.txt file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n" · line 826

Quoted 8 lines
CMakeLists.txt +8 -0
+	#Setting the build directory in test-lib.sh before running tests
+	file(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.cmake
+		"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh GIT_BUILD_DIR_REPL REGEX \"GIT_BUILD_DIR=(.*)\")\n"
+		"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh content NEWLINE_CONSUME)\n"
+		"string(REPLACE \"\${GIT_BUILD_DIR_REPL}\" \"GIT_BUILD_DIR=\\\"$TEST_DIRECTORY\\\"/../${BUILD_DIR_RELATIVE}\" content \"\${content}\")\n"
+		"file(WRITE ${CMAKE_SOURCE_DIR}/t/test-lib.sh \${content})")
+	#misc copies
+	file(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.sed DESTINATION ${CMAKE_BINARY_DIR}/t/)

So, some sed will be used in Windows without POSIX-like system, interesting!

CMakeLists.txt file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n" · line 834

Quoted 8 lines
CMakeLists.txt +7 -0
+	file(COPY ${CMAKE_SOURCE_DIR}/po/is.po DESTINATION ${CMAKE_BINARY_DIR}/po/)
+	file(COPY ${CMAKE_SOURCE_DIR}/mergetools/tkdiff DESTINATION ${CMAKE_BINARY_DIR}/mergetools/)
+	file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-prompt.sh DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)
+	file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-completion.bash DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)
+	file(COPY ${CMAKE_SOURCE_DIR}/contrib/svn-fe/svnrdump_sim.py DESTINATION ${CMAKE_BINARY_DIR}/contrib/svn-fe/)
+endif()
+
 file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")

Remember cmake won't be re-run if nothing was changed in CMakeList.txt If I only change some code, and I decided the change I make should be tested by a-new-and-independent-test-script.
I need to re-run cmake manually! I don't like it, at all.

Signature · 1 line
Danh
#22 lore raw

Re: [PATCH 5/8] cmake: support for testing git when building out of the source tree

Quoted 34 lines · Danh Doan
Quoted 32 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch allows git to be tested when performin out of source builds.

This involves changing GIT_BUILD_DIR in t/test-lib.sh to point to the build directory. Also some miscellaneous copies from the source directory to the build directory.
The copies are:
t/chainlint.sed needed by a bunch of test scripts
po/is.po needed by t0204-gettext-rencode-sanity mergetools/tkdiff needed by t7800-difftool contrib/completion/git-prompt.sh needed by t9903-bash-prompt contrib/completion/git-completion.bash needed by t9902-completion contrib/svn-fe/svnrdump_sim.py needed by t9020-remote-svn

NOTE: t/test-lib.sh is only modified when tests are run not during the build or configure.
The trash directory is still srcdir/t

---
 CMakeLists.txt | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
CMakeLists.txt +0 -0
index 141ccefa559..29a23eb11f7 100644
@@ -812,6 +812,25 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n"
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
 
Quoted 7 lines

CMakeLists.txt file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n" · line 816

Quoted 2 lines
CMakeLists.txt +2 -0
+#Make the tests work when building out of the source tree
+if(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})

IIRC, CMake recommends _NOT_ expand variable inside if() This very inconsistent recommendation of CMake (when should I use ${var} and when should I use var?) is one of reason I hate CMake

I know, I got taken aback at first, but then you get used to it.

Quoted 5 lines

CMakeLists.txt file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n" · line 818

Quoted 2 lines
CMakeLists.txt +2 -0
+     file(RELATIVE_PATH BUILD_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/CMakeCache.txt)
+     string(REPLACE "/CMakeCache.txt" "" BUILD_DIR_RELATIVE ${BUILD_DIR_RELATIVE})

I don't know what is going on here!

We are trying find the relative path to the build directory from the source directory
file(RELATIVE_PATH ...) requires a file in the to "whatever" directory. The one file that is always present in the build directory after a CMake configure is CMakeCache.txt, so we use that.
Then we remove "CMakeCache.txt" from the variable "BUILD_DIR_RELATIVE" to get the actual relative path.

Quoted 12 lines

CMakeLists.txt file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n" · line 826

Quoted 8 lines
CMakeLists.txt +8 -0
+     #Setting the build directory in test-lib.sh before running tests
+     file(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.cmake
+             "file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh GIT_BUILD_DIR_REPL REGEX \"GIT_BUILD_DIR=(.*)\")\n"
+             "file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh content NEWLINE_CONSUME)\n"
+             "string(REPLACE \"\${GIT_BUILD_DIR_REPL}\" \"GIT_BUILD_DIR=\\\"$TEST_DIRECTORY\\\"/../${BUILD_DIR_RELATIVE}\" content \"\${content}\")\n"
+             "file(WRITE ${CMAKE_SOURCE_DIR}/t/test-lib.sh \${content})")
+     #misc copies
+     file(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.sed DESTINATION ${CMAKE_BINARY_DIR}/t/)

So, some sed will be used in Windows without POSIX-like system, interesting!

Quoted 14 lines

CMakeLists.txt file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n" · line 834

Quoted 8 lines
CMakeLists.txt +7 -0
+     file(COPY ${CMAKE_SOURCE_DIR}/po/is.po DESTINATION ${CMAKE_BINARY_DIR}/po/)
+     file(COPY ${CMAKE_SOURCE_DIR}/mergetools/tkdiff DESTINATION ${CMAKE_BINARY_DIR}/mergetools/)
+     file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-prompt.sh DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)
+     file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-completion.bash DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)
+     file(COPY ${CMAKE_SOURCE_DIR}/contrib/svn-fe/svnrdump_sim.py DESTINATION ${CMAKE_BINARY_DIR}/contrib/svn-fe/)
+endif()
+
 file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")

Remember cmake won't be re-run if nothing was changed in CMakeList.txt If I only change some code, and I decided the change I make should be tested by a-new-and-independent-test-script.
I need to re-run cmake manually! I don't like it, at all.

No you don't have re-run CMake.

Quoted 3 lines

--
Danh

Thank You,
Sibi Siddharthan

#23 lore raw

Re: [PATCH 5/8] cmake: support for testing git when building out of the source tree

Quoted 9 lines · Sibi Siddharthan
Quoted 7 lines
Quoted 1 line

file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")

Remember cmake won't be re-run if nothing was changed in CMakeList.txt If I only change some code, and I decided the change I make should be tested by a-new-and-independent-test-script.
I need to re-run cmake manually! I don't like it, at all.

No you don't have re-run CMake.

Yes, you have to re-run CMake.
https://cmake.org/cmake/help/v3.14/command/file.html#glob

Quoted 10 lines

Note

We do not recommend using GLOB to collect a list of source files from your source tree. If no CMakeLists.txt file changes when a source is added or removed then the generated build system cannot know when to ask CMake to regenerate. The CONFIGURE_DEPENDS flag may not work reliably on all generators, or if a new generator is added in the future that cannot support it, projects using it will be stuck. Even if CONFIGURE_DEPENDS works reliably, there is still a cost to perform the check on every rebuild.

* Run CMake now.
* Don't touch anything
* Create new test-script, let's say t9904-just-for-cmake.sh

* Check if it's run or not, I bet the answer is not

Anyway, Junio said NO, I don't need to be a CMake hater here, anymore.

Signature · 1 line
Danh
#24 lore raw

Re: [PATCH 5/8] cmake: support for testing git when building out of the source tree

If you are adding a new test script you will have re-configure. Even in automake you are expected to do this, unless you have a glob pattern in Makefile.in somewhere.

Quoted 26 lines · Danh Doan
Quoted 9 lines · Sibi Siddharthan
Quoted 7 lines
Quoted 1 line

file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")

Remember cmake won't be re-run if nothing was changed in CMakeList.txt If I only change some code, and I decided the change I make should be tested by a-new-and-independent-test-script.
I need to re-run cmake manually! I don't like it, at all.

No you don't have re-run CMake.

Yes, you have to re-run CMake.
https://cmake.org/cmake/help/v3.14/command/file.html#glob

Quoted 10 lines

Note

We do not recommend using GLOB to collect a list of source files from your source tree. If no CMakeLists.txt file changes when a source is added or removed then the generated build system cannot know when to ask CMake to regenerate. The CONFIGURE_DEPENDS flag may not work reliably on all generators, or if a new generator is added in the future that cannot support it, projects using it will be stuck. Even if CONFIGURE_DEPENDS works reliably, there is still a cost to perform the check on every rebuild.

Quoted 6 lines

* Run CMake now.
* Don't touch anything
* Create new test-script, let's say t9904-just-for-cmake.sh

* Check if it's run or not, I bet the answer is not

The new test script is not added to list of test scripts. So yes, you will have to re-run CMake.
A reconfigure in CMake is going to take less than 2 seconds, not like automake which can take as long as the initial configure itself.

Quoted 4 lines

Anyway, Junio said NO, I don't need to be a CMake hater here, anymore.

--
Danh

Thank You,
Sibi Siddharthan

#25 lore raw

PATCH 6/8 cmake: support for building git on windows with mingw

In reply to Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch facilitates building git on Windows with CMake using MinGW

NOTE: The funtions unsetenv and hstrerror are not checked in Windows builds.
Reasons
NO_UNSETENV is not compatible with Windows builds.
lines 262-264 compat/mingw.h

compat/mingw.h(line 25) provides a definition of hstrerror which conflicts with the definition provided in git-compat-util.h(lines 733-736).

To use CMake on Windows with MinGW do this:
cmake relative-path-to-srcdir -G "MinGW Makefiles"

---
 CMakeLists.txt | 120 +++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 97 insertions(+), 23 deletions(-)
CMakeLists.txt +97 -23
index 29a23eb11f7..d9eb1060390 100644
@@ -13,9 +13,12 @@ project(git
 	VERSION ${git_version}
 	LANGUAGES C)
 
+
 #TODO gitk git-gui gitweb
+#TODO Enable NLS on windows natively
 #TODO Add pcre support
 
+
 include(CheckTypeSize)
 include(CheckCSourceRuns)
 include(CheckCSourceCompiles)
@@ -31,6 +34,7 @@ find_package(EXPAT)
 find_package(Iconv)
 find_package(Intl)
 
+
 if(NOT Intl_FOUND)
 	add_compile_definitions(NO_GETTEXT)
 	if(NOT Iconv_FOUND)
@@ -53,6 +57,16 @@ if(Intl_FOUND)
 endif()
 
 find_program(SH_EXE sh)
+if(NOT SH_EXE)
+	message(FATAL_ERROR "sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/")
+endif()
+
+if(WIN32)
+	find_program(WINDRES_EXE windres)
+	if(NOT WINDRES_EXE)
+		message(FATAL_ERROR "Install windres on Windows for resource files")
+	endif()
+endif()
 
 find_program(MSGFMT_EXE msgfmt)
 if(NOT MSGFMT_EXE)
@@ -85,11 +99,39 @@ add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
 			BINDIR="bin"
 			GIT_BUILT_FROM_COMMIT="")
 
-set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
-add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+if(WIN32)
+	set(FALLBACK_RUNTIME_PREFIX /mingw64)
+	add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+else()
+	set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
+	add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+endif()
 
-add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
-list(APPEND compat_SOURCES unix-socket.c)
+
+#Platform Specific
+if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+	include_directories(compat/win32)
+	add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
+				_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
+				NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0 NO_ST_BLOCKS_IN_STRUCT_STAT
+				USE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP
+				UNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)
+	list(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c
+		compat/win32/pthread.c compat/win32mmap.c compat/win32/syslog.c
+		compat/win32/trace2_win32_process_info.c compat/win32/dirent.c
+		compat/nedmalloc/nedmalloc.c compat/strdup.c)
+	set(NO_UNIX_SOCKETS 1)
+
+elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
+	add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
+	list(APPEND compat_SOURCES unix-socket.c)
+endif()
+
+if(WIN32)
+	set(EXE_EXTENSION .exe)
+else()
+	set(EXE_EXTENSION)
+endif()
 
 #header checks
 check_include_file(libgen.h HAVE_LIBGEN_H)
@@ -150,7 +192,12 @@ endif()
 #function checks
 set(function_checks
 	strcasestr memmem strlcpy strtoimax strtoumax strtoull
-	setenv  mkdtemp poll pread  memmem unsetenv hstrerror)
+	setenv  mkdtemp poll pread  memmem)
+
+#unsetenv,hstrerror are incompatible with windows build
+if(NOT WIN32)
+	list(APPEND function_checks unsetenv hstrerror)
+endif()
 
 foreach(f ${function_checks})
 	string(TOUPPER ${f} uf)
@@ -309,7 +356,13 @@ endif()
 #programs
 set(PROGRAMS_BUILT
 	git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
-	git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)
+	git-shell git-remote-testsvn)
+
+if(NO_UNIX_SOCKETS)
+	list(APPEND excluded_progs git-credential-cache git-credential-cache--daemon)
+else()
+	list(APPEND PROGRAMS_BUILT git-credential-cache git-credential-cache--daemon)
+endif()
 
 if(NOT CURL_FOUND)
 	list(APPEND excluded_progs git-http-fetch git-http-push)
@@ -410,15 +463,34 @@ set(libvcs-svn_SOURCES
 	vcs-svn/svndiff.c vcs-svn/svndump.c)
 add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
 
+#add git.rc for gcc
+if(WIN32)
+	add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
+			COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
+				-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
+				-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
+			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+			VERBATIM)
+	add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)
+endif()
+
 #link all required libraries to common-main
 add_library(common-main OBJECT common-main.c)
-target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
+
+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})
 if(Intl_FOUND)
 	target_link_libraries(common-main ${Intl_LIBRARIES})
 endif()
 if(Iconv_FOUND)
 	target_link_libraries(common-main ${Iconv_LIBRARIES})
 endif()
+if(WIN32)
+	target_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)
+	add_dependencies(common-main git-rc)
+	target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)
+elseif(UNIX)
+	target_link_libraries(common-main pthread rt)
+endif()
 
 
 set(git_SOURCES
@@ -501,11 +573,13 @@ endif()
 add_executable(git-remote-testsvn remote-testsvn.c)
 target_link_libraries(git-remote-testsvn common-main vcs-svn)
 
-add_executable(git-credential-cache credential-cache.c)
-target_link_libraries(git-credential-cache common-main)
+if(NOT NO_UNIX_SOCKETS)
+	add_executable(git-credential-cache credential-cache.c)
+	target_link_libraries(git-credential-cache common-main)
 
-add_executable(git-credential-cache--daemon credential-cache--daemon.c)
-target_link_libraries(git-credential-cache--daemon common-main)
+	add_executable(git-credential-cache--daemon credential-cache--daemon.c)
+	target_link_libraries(git-credential-cache--daemon common-main)
+endif()
 
 
 set(git_builtin_extra
@@ -517,16 +591,16 @@ set(git_builtin_extra
 foreach(s ${git_SOURCES} ${git_builtin_extra})
 	string(REPLACE "builtin/" "" s ${s})
 	string(REPLACE ".c" "" s ${s})
-	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git git-${s})\n")
-	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})
+	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git${EXE_EXTENSION} git-${s}${EXE_EXTENSION})\n")
+	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s}${EXE_EXTENSION})
 endforeach()
 
 if(CURL_FOUND)
 	set(remote_exes
 		git-remote-https git-remote-ftp git-remote-ftps)
 	foreach(s ${remote_exes})
-		file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http ${s})\n")
-		list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})
+		file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http${EXE_EXTENSION} ${s}${EXE_EXTENSION})\n")
+		list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s}${EXE_EXTENSION})
 	endforeach()
 endif()
 
@@ -654,20 +728,20 @@ set(bin_links
 	git-receive-pack git-upload-archive git-upload-pack)
 
 foreach(b ${bin_links})
-install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/bin/${b}${EXE_EXTENSION})")
 endforeach()
 
-install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)")
-install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git${EXE_EXTENSION})")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell${EXE_EXTENSION})")
 
 foreach(b ${git_links})
 	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
-	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})")
 endforeach()
 
 foreach(b ${git_http_links})
 	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
-	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})")
 endforeach()
 
 install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
@@ -734,14 +808,14 @@ set(wrapper_test_scripts
 foreach(script ${wrapper_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
 	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-	string(REPLACE "@@PROG@@" "${script}" content "${content}")
+	string(REPLACE "@@PROG@@" "${script}${EXE_EXTENSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
 foreach(script ${wrapper_test_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
 	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-	string(REPLACE "@@PROG@@" "t/helper/${script}" content "${content}")
+	string(REPLACE "@@PROG@@" "t/helper/${script}${EXE_EXTENSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
@@ -807,7 +881,7 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PAGER_ENV='${PAGER_ENV}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DC_SHA1='${DC_SHA1}'\n")
-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X=''\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X='${EXE_EXTENSION}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
Signature · 1 line
gitgitgadget
#26 lore raw

Re: [PATCH 6/8] cmake: support for building git on windows with mingw

Hi Sibi,

Quoted 48 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch facilitates building git on Windows with CMake using MinGW

NOTE: The funtions unsetenv and hstrerror are not checked in Windows builds.
Reasons
NO_UNSETENV is not compatible with Windows builds.
lines 262-264 compat/mingw.h

compat/mingw.h(line 25) provides a definition of hstrerror which conflicts with the definition provided in git-compat-util.h(lines 733-736).

To use CMake on Windows with MinGW do this:
cmake relative-path-to-srcdir -G "MinGW Makefiles"

---
 CMakeLists.txt | 120 +++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 97 insertions(+), 23 deletions(-)
CMakeLists.txt +4 -0
index 29a23eb11f7..d9eb1060390 100644
@@ -13,9 +13,12 @@ project(git
 	VERSION ${git_version}
 	LANGUAGES C)
 
+
 #TODO gitk git-gui gitweb
+#TODO Enable NLS on windows natively
 #TODO Add pcre support
 
+
 include(CheckTypeSize)
 include(CheckCSourceRuns)
 include(CheckCSourceCompiles)
@@ -31,6 +34,7 @@ find_package(EXPAT)
 find_package(Iconv)
 find_package(Intl)
 
+
 if(NOT Intl_FOUND)
 	add_compile_definitions(NO_GETTEXT)
 	if(NOT Iconv_FOUND)

CMakeLists.txt if(Intl_FOUND) · line 61

Quoted 5 lines
CMakeLists.txt +2 -0
@@ -53,6 +57,16 @@ if(Intl_FOUND)
 endif()
 
 find_program(SH_EXE sh)
+if(NOT SH_EXE)
+	message(FATAL_ERROR "sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/")

Either the error message or the web page it points to need to coordinate on the 'sh interpreter' reference to help the script kiddies follow the thread. At the moment there is no 'interp..' on the gitforwindows web page. Would someone attempting to use cmake need to use the Download or the Contribute buttons, or some other route to acquire the missing SH_EXE?

(this is also a context line in the next patch)

Quoted 211 lines
CMakeLists.txt +91 -23
+endif()
+
+if(WIN32)
+	find_program(WINDRES_EXE windres)
+	if(NOT WINDRES_EXE)
+		message(FATAL_ERROR "Install windres on Windows for resource files")
+	endif()
+endif()
 
 find_program(MSGFMT_EXE msgfmt)
 if(NOT MSGFMT_EXE)
@@ -85,11 +99,39 @@ add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
 			BINDIR="bin"
 			GIT_BUILT_FROM_COMMIT="")
 
-set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
-add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+if(WIN32)
+	set(FALLBACK_RUNTIME_PREFIX /mingw64)
+	add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+else()
+	set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
+	add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+endif()
 
-add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
-list(APPEND compat_SOURCES unix-socket.c)
+
+#Platform Specific
+if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+	include_directories(compat/win32)
+	add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
+				_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
+				NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0 NO_ST_BLOCKS_IN_STRUCT_STAT
+				USE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP
+				UNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)
+	list(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c
+		compat/win32/pthread.c compat/win32mmap.c compat/win32/syslog.c
+		compat/win32/trace2_win32_process_info.c compat/win32/dirent.c
+		compat/nedmalloc/nedmalloc.c compat/strdup.c)
+	set(NO_UNIX_SOCKETS 1)
+
+elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
+	add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
+	list(APPEND compat_SOURCES unix-socket.c)
+endif()
+
+if(WIN32)
+	set(EXE_EXTENSION .exe)
+else()
+	set(EXE_EXTENSION)
+endif()
 
 #header checks
 check_include_file(libgen.h HAVE_LIBGEN_H)
@@ -150,7 +192,12 @@ endif()
 #function checks
 set(function_checks
 	strcasestr memmem strlcpy strtoimax strtoumax strtoull
-	setenv  mkdtemp poll pread  memmem unsetenv hstrerror)
+	setenv  mkdtemp poll pread  memmem)
+
+#unsetenv,hstrerror are incompatible with windows build
+if(NOT WIN32)
+	list(APPEND function_checks unsetenv hstrerror)
+endif()
 
 foreach(f ${function_checks})
 	string(TOUPPER ${f} uf)
@@ -309,7 +356,13 @@ endif()
 #programs
 set(PROGRAMS_BUILT
 	git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
-	git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)
+	git-shell git-remote-testsvn)
+
+if(NO_UNIX_SOCKETS)
+	list(APPEND excluded_progs git-credential-cache git-credential-cache--daemon)
+else()
+	list(APPEND PROGRAMS_BUILT git-credential-cache git-credential-cache--daemon)
+endif()
 
 if(NOT CURL_FOUND)
 	list(APPEND excluded_progs git-http-fetch git-http-push)
@@ -410,15 +463,34 @@ set(libvcs-svn_SOURCES
 	vcs-svn/svndiff.c vcs-svn/svndump.c)
 add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
 
+#add git.rc for gcc
+if(WIN32)
+	add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
+			COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
+				-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
+				-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
+			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+			VERBATIM)
+	add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)
+endif()
+
 #link all required libraries to common-main
 add_library(common-main OBJECT common-main.c)
-target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
+
+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})
 if(Intl_FOUND)
 	target_link_libraries(common-main ${Intl_LIBRARIES})
 endif()
 if(Iconv_FOUND)
 	target_link_libraries(common-main ${Iconv_LIBRARIES})
 endif()
+if(WIN32)
+	target_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)
+	add_dependencies(common-main git-rc)
+	target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)
+elseif(UNIX)
+	target_link_libraries(common-main pthread rt)
+endif()
 
 
 set(git_SOURCES
@@ -501,11 +573,13 @@ endif()
 add_executable(git-remote-testsvn remote-testsvn.c)
 target_link_libraries(git-remote-testsvn common-main vcs-svn)
 
-add_executable(git-credential-cache credential-cache.c)
-target_link_libraries(git-credential-cache common-main)
+if(NOT NO_UNIX_SOCKETS)
+	add_executable(git-credential-cache credential-cache.c)
+	target_link_libraries(git-credential-cache common-main)
 
-add_executable(git-credential-cache--daemon credential-cache--daemon.c)
-target_link_libraries(git-credential-cache--daemon common-main)
+	add_executable(git-credential-cache--daemon credential-cache--daemon.c)
+	target_link_libraries(git-credential-cache--daemon common-main)
+endif()
 
 
 set(git_builtin_extra
@@ -517,16 +591,16 @@ set(git_builtin_extra
 foreach(s ${git_SOURCES} ${git_builtin_extra})
 	string(REPLACE "builtin/" "" s ${s})
 	string(REPLACE ".c" "" s ${s})
-	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git git-${s})\n")
-	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})
+	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git${EXE_EXTENSION} git-${s}${EXE_EXTENSION})\n")
+	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s}${EXE_EXTENSION})
 endforeach()
 
 if(CURL_FOUND)
 	set(remote_exes
 		git-remote-https git-remote-ftp git-remote-ftps)
 	foreach(s ${remote_exes})
-		file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http ${s})\n")
-		list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})
+		file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http${EXE_EXTENSION} ${s}${EXE_EXTENSION})\n")
+		list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s}${EXE_EXTENSION})
 	endforeach()
 endif()
 
@@ -654,20 +728,20 @@ set(bin_links
 	git-receive-pack git-upload-archive git-upload-pack)
 
 foreach(b ${bin_links})
-install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/bin/${b}${EXE_EXTENSION})")
 endforeach()
 
-install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)")
-install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git${EXE_EXTENSION})")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell${EXE_EXTENSION})")
 
 foreach(b ${git_links})
 	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
-	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})")
 endforeach()
 
 foreach(b ${git_http_links})
 	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
-	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})")
 endforeach()
 
 install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
@@ -734,14 +808,14 @@ set(wrapper_test_scripts
 foreach(script ${wrapper_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
 	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-	string(REPLACE "@@PROG@@" "${script}" content "${content}")
+	string(REPLACE "@@PROG@@" "${script}${EXE_EXTENSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
 foreach(script ${wrapper_test_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
 	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-	string(REPLACE "@@PROG@@" "t/helper/${script}" content "${content}")
+	string(REPLACE "@@PROG@@" "t/helper/${script}${EXE_EXTENSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
@@ -807,7 +881,7 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PAGER_ENV='${PAGER_ENV}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DC_SHA1='${DC_SHA1}'\n")
-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X=''\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X='${EXE_EXTENSION}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
#27 lore raw

Re: [PATCH 6/8] cmake: support for building git on windows with mingw

Hi Philip,

Quoted 54 lines · Philip Oakley

Hi Sibi,

Quoted 50 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch facilitates building git on Windows with CMake using MinGW

NOTE: The funtions unsetenv and hstrerror are not checked in Windows builds.
Reasons
NO_UNSETENV is not compatible with Windows builds.
lines 262-264 compat/mingw.h

compat/mingw.h(line 25) provides a definition of hstrerror which conflicts with the definition provided in git-compat-util.h(lines 733-736).

To use CMake on Windows with MinGW do this:
cmake relative-path-to-srcdir -G "MinGW Makefiles"

---
 CMakeLists.txt | 120 +++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 97 insertions(+), 23 deletions(-)
CMakeLists.txt +4 -0
index 29a23eb11f7..d9eb1060390 100644
@@ -13,9 +13,12 @@ project(git
      VERSION ${git_version}
      LANGUAGES C)
 
+
 #TODO gitk git-gui gitweb
+#TODO Enable NLS on windows natively
 #TODO Add pcre support
 
+
 include(CheckTypeSize)
 include(CheckCSourceRuns)
 include(CheckCSourceCompiles)
@@ -31,6 +34,7 @@ find_package(EXPAT)
 find_package(Iconv)
 find_package(Intl)
 
+
 if(NOT Intl_FOUND)
      add_compile_definitions(NO_GETTEXT)
      if(NOT Iconv_FOUND)
@@ -53,6 +57,16 @@ if(Intl_FOUND)
 endif()
 
Quoted 9 lines

CMakeLists.txt if(Intl_FOUND) · line 61

Quoted 3 lines
CMakeLists.txt +2 -0
 find_program(SH_EXE sh)
+if(NOT SH_EXE)
+     message(FATAL_ERROR "sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/")

Either the error message or the web page it points to need to coordinate on the 'sh interpreter' reference to help the script kiddies follow the thread. At the moment there is no 'interp..' on the gitforwindows web page. Would someone attempting to use cmake need to use the Download or the Contribute buttons, or some other route to acquire the missing SH_EXE?

On Windows, if you are using Git Bash, then you don't have a problem. This message was for people trying to Git on Windows without a bash shell.

I can rephrase the message saying
"On Windows go to https://gitforwindows.org/ and download the Git installer which ships with a sh interpreter(bash)."

Would you suggest something else?

Quoted 203 lines

(this is also a context line in the next patch)

Quoted 202 lines
CMakeLists.txt +90 -22
+endif()
+
+if(WIN32)
+     find_program(WINDRES_EXE windres)
+     if(NOT WINDRES_EXE)
+             message(FATAL_ERROR "Install windres on Windows for resource files")
+     endif()
+endif()
 
 find_program(MSGFMT_EXE msgfmt)
 if(NOT MSGFMT_EXE)
@@ -85,11 +99,39 @@ add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
                      BINDIR="bin"
                      GIT_BUILT_FROM_COMMIT="")
 
-set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
-add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+if(WIN32)
+     set(FALLBACK_RUNTIME_PREFIX /mingw64)
+     add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+else()
+     set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
+     add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+endif()
 
-add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
-list(APPEND compat_SOURCES unix-socket.c)
+
+#Platform Specific
+if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+     include_directories(compat/win32)
+     add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
+                             _CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
+                             NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0 NO_ST_BLOCKS_IN_STRUCT_STAT
+                             USE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP
+                             UNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)
+     list(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c
+             compat/win32/pthread.c compat/win32mmap.c compat/win32/syslog.c
+             compat/win32/trace2_win32_process_info.c compat/win32/dirent.c
+             compat/nedmalloc/nedmalloc.c compat/strdup.c)
+     set(NO_UNIX_SOCKETS 1)
+
+elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
+     add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
+     list(APPEND compat_SOURCES unix-socket.c)
+endif()
+
+if(WIN32)
+     set(EXE_EXTENSION .exe)
+else()
+     set(EXE_EXTENSION)
+endif()
 
 #header checks
 check_include_file(libgen.h HAVE_LIBGEN_H)
@@ -150,7 +192,12 @@ endif()
 #function checks
 set(function_checks
      strcasestr memmem strlcpy strtoimax strtoumax strtoull
-     setenv  mkdtemp poll pread  memmem unsetenv hstrerror)
+     setenv  mkdtemp poll pread  memmem)
+
+#unsetenv,hstrerror are incompatible with windows build
+if(NOT WIN32)
+     list(APPEND function_checks unsetenv hstrerror)
+endif()
 
 foreach(f ${function_checks})
      string(TOUPPER ${f} uf)
@@ -309,7 +356,13 @@ endif()
 #programs
 set(PROGRAMS_BUILT
      git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
-     git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)
+     git-shell git-remote-testsvn)
+
+if(NO_UNIX_SOCKETS)
+     list(APPEND excluded_progs git-credential-cache git-credential-cache--daemon)
+else()
+     list(APPEND PROGRAMS_BUILT git-credential-cache git-credential-cache--daemon)
+endif()
 
 if(NOT CURL_FOUND)
      list(APPEND excluded_progs git-http-fetch git-http-push)
@@ -410,15 +463,34 @@ set(libvcs-svn_SOURCES
      vcs-svn/svndiff.c vcs-svn/svndump.c)
 add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
 
+#add git.rc for gcc
+if(WIN32)
+     add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
+                     COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
+                             -DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
+                             -i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
+                     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+                     VERBATIM)
+     add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)
+endif()
+
 #link all required libraries to common-main
 add_library(common-main OBJECT common-main.c)
-target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
+
+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})
 if(Intl_FOUND)
      target_link_libraries(common-main ${Intl_LIBRARIES})
 endif()
 if(Iconv_FOUND)
      target_link_libraries(common-main ${Iconv_LIBRARIES})
 endif()
+if(WIN32)
+     target_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)
+     add_dependencies(common-main git-rc)
+     target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)
+elseif(UNIX)
+     target_link_libraries(common-main pthread rt)
+endif()
 
 
 set(git_SOURCES
@@ -501,11 +573,13 @@ endif()
 add_executable(git-remote-testsvn remote-testsvn.c)
 target_link_libraries(git-remote-testsvn common-main vcs-svn)
 
-add_executable(git-credential-cache credential-cache.c)
-target_link_libraries(git-credential-cache common-main)
+if(NOT NO_UNIX_SOCKETS)
+     add_executable(git-credential-cache credential-cache.c)
+     target_link_libraries(git-credential-cache common-main)
 
-add_executable(git-credential-cache--daemon credential-cache--daemon.c)
-target_link_libraries(git-credential-cache--daemon common-main)
+     add_executable(git-credential-cache--daemon credential-cache--daemon.c)
+     target_link_libraries(git-credential-cache--daemon common-main)
+endif()
 
 
 set(git_builtin_extra
@@ -517,16 +591,16 @@ set(git_builtin_extra
 foreach(s ${git_SOURCES} ${git_builtin_extra})
      string(REPLACE "builtin/" "" s ${s})
      string(REPLACE ".c" "" s ${s})
-     file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git git-${s})\n")
-     list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})
+     file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git${EXE_EXTENSION} git-${s}${EXE_EXTENSION})\n")
+     list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s}${EXE_EXTENSION})
 endforeach()
 
 if(CURL_FOUND)
      set(remote_exes
              git-remote-https git-remote-ftp git-remote-ftps)
      foreach(s ${remote_exes})
-             file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http ${s})\n")
-             list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})
+             file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http${EXE_EXTENSION} ${s}${EXE_EXTENSION})\n")
+             list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s}${EXE_EXTENSION})
      endforeach()
 endif()
 
@@ -654,20 +728,20 @@ set(bin_links
      git-receive-pack git-upload-archive git-upload-pack)
 
 foreach(b ${bin_links})
-install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/bin/${b}${EXE_EXTENSION})")
 endforeach()
 
-install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)")
-install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git${EXE_EXTENSION})")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell${EXE_EXTENSION})")
 
 foreach(b ${git_links})
      string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
-     install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+     install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})")
 endforeach()
 
 foreach(b ${git_http_links})
      string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
-     install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+     install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})")
 endforeach()
 
 install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
@@ -734,14 +808,14 @@ set(wrapper_test_scripts
 foreach(script ${wrapper_scripts})
      file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
      string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-     string(REPLACE "@@PROG@@" "${script}" content "${content}")
+     string(REPLACE "@@PROG@@" "${script}${EXE_EXTENSION}" content "${content}")
      file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
 foreach(script ${wrapper_test_scripts})
      file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
      string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-     string(REPLACE "@@PROG@@" "t/helper/${script}" content "${content}")
+     string(REPLACE "@@PROG@@" "t/helper/${script}${EXE_EXTENSION}" content "${content}")
      file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
Quoted 10 lines

CMakeLists.txt file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\ · line 887

Quoted 9 lines
CMakeLists.txt +1 -1
@@ -807,7 +881,7 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PAGER_ENV='${PAGER_ENV}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DC_SHA1='${DC_SHA1}'\n")
-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X=''\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X='${EXE_EXTENSION}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")

Thank You,
Sibi Siddharthan

#28 lore raw

Re: [PATCH 6/8] cmake: support for building git on windows with mingw

Hi Sibi,

Quoted 40 lines · Sibi Siddharthan

Hi Philip,

Quoted 25 lines · Philip Oakley

Hi Sibi,

Quoted 22 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch facilitates building git on Windows with CMake using MinGW

NOTE: The funtions unsetenv and hstrerror are not checked in Windows builds.
Reasons
NO_UNSETENV is not compatible with Windows builds.
lines 262-264 compat/mingw.h

compat/mingw.h(line 25) provides a definition of hstrerror which conflicts with the definition provided in git-compat-util.h(lines 733-736).

To use CMake on Windows with MinGW do this:
cmake relative-path-to-srcdir -G "MinGW Makefiles"

---
 CMakeLists.txt | 120 +++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 97 insertions(+), 23 deletions(-)
Quoted 12 lines

CMakeLists.txt if(Intl_FOUND) · line 61

Quoted 6 lines
CMakeLists.txt +2 -0
index 29a23eb11f7..d9eb1060390 100644
[snip..]
 find_program(SH_EXE sh)
+if(NOT SH_EXE)
+     message(FATAL_ERROR "sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/")

Either the error message or the web page it points to need to coordinate on the 'sh interpreter' reference to help the script kiddies follow the thread. At the moment there is no 'interp..' on the gitforwindows web page. Would someone attempting to use cmake need to use the Download or the Contribute buttons, or some other route to acquire the missing SH_EXE?

Quoted 8 lines

On Windows, if you are using Git Bash, then you don't have a problem. This message was for people trying to Git on Windows without a bash shell.

I can rephrase the message saying
"On Windows go to https://gitforwindows.org/ and download the Git installer which ships with a sh interpreter(bash)."

Would you suggest something else?

Filling the message out a little, I'm thinking of:

"sh: shell interpreter was not found in your path, please install one. On Windows, you can get it as part of 'Git for Windows' install at
https://gitforwindows.org/"

The second 'install' could be dropped, but may be needed to fully qualify the instructions for some readers.

The key feature I was checking was the clarity of the 'install' action, as opposed to the way sh is integrated within Git for Windows (which is a whole new topic of conversation for some users!)

Quoted 3 lines
Quoted 3 lines

(this is also a context line in the next patch)

[snip..]

--
Philip

#29 lore raw

Re: [PATCH 6/8] cmake: support for building git on windows with mingw

Hi Philip,

Quoted 59 lines · Philip Oakley

Hi Sibi,

Quoted 40 lines · Sibi Siddharthan

Hi Philip,

Quoted 25 lines · Philip Oakley

Hi Sibi,

Quoted 22 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch facilitates building git on Windows with CMake using MinGW

NOTE: The funtions unsetenv and hstrerror are not checked in Windows builds.
Reasons
NO_UNSETENV is not compatible with Windows builds.
lines 262-264 compat/mingw.h

compat/mingw.h(line 25) provides a definition of hstrerror which conflicts with the definition provided in git-compat-util.h(lines 733-736).

To use CMake on Windows with MinGW do this:
cmake relative-path-to-srcdir -G "MinGW Makefiles"

---
 CMakeLists.txt | 120 +++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 97 insertions(+), 23 deletions(-)
Quoted 12 lines

CMakeLists.txt if(Intl_FOUND) · line 61

Quoted 6 lines
CMakeLists.txt +2 -0
index 29a23eb11f7..d9eb1060390 100644
[snip..]
 find_program(SH_EXE sh)
+if(NOT SH_EXE)
+     message(FATAL_ERROR "sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/")

Either the error message or the web page it points to need to coordinate on the 'sh interpreter' reference to help the script kiddies follow the thread. At the moment there is no 'interp..' on the gitforwindows web page. Would someone attempting to use cmake need to use the Download or the Contribute buttons, or some other route to acquire the missing SH_EXE?

Quoted 8 lines

On Windows, if you are using Git Bash, then you don't have a problem. This message was for people trying to Git on Windows without a bash shell.

I can rephrase the message saying
"On Windows go to https://gitforwindows.org/ and download the Git installer which ships with a sh interpreter(bash)."

Would you suggest something else?

Filling the message out a little, I'm thinking of:

"sh: shell interpreter was not found in your path, please install one. On Windows, you can get it as part of 'Git for Windows' install at
https://gitforwindows.org/"

Quoted 6 lines

The second 'install' could be dropped, but may be needed to fully qualify the instructions for some readers.

The key feature I was checking was the clarity of the 'install' action, as opposed to the way sh is integrated within Git for Windows (which is a whole new topic of conversation for some users!)

Sure, We can incorporate this message.

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

(this is also a context line in the next patch)

[snip..]

--
Philip

Thank You,
Sibi Siddharthan

#30 lore raw

PATCH 7/8 cmake: support for building git on windows with msvc and clang.

In reply to Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch adds support for Visual Studio and Clang builds

The minimum required version of CMake is upgraded to 3.15 because this version offers proper support for Clang builds on Windows.

Libintl is not searched for when building with Visual Studio or Clang because there is no binary compatible version available yet.

NOTE: In the link options invalidcontinue.obj has to be included. The reason for this is because by default, Windows calls abort()'s instead of setting errno=EINVAL when invalid arguments are passed to standard functions.
This commit explains it in detail:
4b623d80f73528a632576990ca51e34c333d5dd6

On Windows the default generator is Visual Studio,so for Visual Studio builds do this:

cmake relative-path-to-srcdir

NOTE: Visual Studio generator is a multi config generator, which means that Debug and Release builds can be done on the same build directory.

For Clang builds do this:

On bash
CC=Clang cmake relative-path-to-srcdir -G Ninja
-DCMAKE_BUILD_TYPE=[Debug or Release]

On cmd
set CC=Clang
cmake relative-path-to-srcdir -G Ninja
-DCMAKE_BUILD_TYPE=[Debug or Release]

---
 CMakeLists.txt | 57 ++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 46 insertions(+), 11 deletions(-)
CMakeLists.txt +46 -11
index d9eb1060390..5ad3a2557f7 100644
@@ -2,7 +2,7 @@
 #	Copyright (c) 2020 Sibi Siddharthan
 #
 
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.15)
 
 #Parse GIT-VERSION-GEN to get the version
 file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX "DEF_VER=v(.*)")
@@ -32,8 +32,11 @@ find_package(ZLIB REQUIRED)
 find_package(CURL)
 find_package(EXPAT)
 find_package(Iconv)
-find_package(Intl)
 
+#Don't use libintl on Windows Visual Studio and Clang builds
+if(NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")))
+	find_package(Intl)
+endif()
 
 if(NOT Intl_FOUND)
 	add_compile_definitions(NO_GETTEXT)
@@ -61,7 +64,7 @@ if(NOT SH_EXE)
 	message(FATAL_ERROR "sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/")
 endif()
 
-if(WIN32)
+if(WIN32 AND NOT MSVC)#not required for visual studio builds
 	find_program(WINDRES_EXE windres)
 	if(NOT WINDRES_EXE)
 		message(FATAL_ERROR "Install windres on Windows for resource files")
@@ -73,6 +76,13 @@ if(NOT MSGFMT_EXE)
 	message(WARNING "Text Translations won't be build")
 endif()
 
+#Force all visual studio outputs to CMAKE_BINARY_DIR
+if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
+	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
+	add_compile_options(/MP)
+endif()
+
 #default behaviour
 include_directories(${CMAKE_SOURCE_DIR})
 add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
@@ -110,6 +120,10 @@ endif()
 
 #Platform Specific
 if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+	if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+		include_directories(compat/vcbuild/include)
+		add_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)
+	endif()
 	include_directories(compat/win32)
 	add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
 				_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
@@ -463,14 +477,22 @@ set(libvcs-svn_SOURCES
 	vcs-svn/svndiff.c vcs-svn/svndump.c)
 add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
 
-#add git.rc for gcc
 if(WIN32)
-	add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
-			COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
-				-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
-				-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
-			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
-			VERBATIM)
+	if(NOT MSVC)#use windres when compiling with gcc and clang
+		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
+				COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
+					-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
+					-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
+				WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+				VERBATIM)
+	else()#MSVC use rc
+		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
+				COMMAND ${CMAKE_RC_COMPILER} /d MAJOR=${PROJECT_VERSION_MAJOR} /d MINOR=${PROJECT_VERSION_MINOR}
+					/d MICRO=${PROJECT_VERSION_PATCH} /d PATCHLEVEL=0 /d GIT_VERSION="${PROJECT_VERSION}.GIT"
+					/fo ${CMAKE_BINARY_DIR}/git.res ${CMAKE_SOURCE_DIR}/git.rc
+				WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+				VERBATIM)
+	endif()
 	add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)
 endif()
 
@@ -487,7 +509,13 @@ endif()
 if(WIN32)
 	target_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)
 	add_dependencies(common-main git-rc)
-	target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)
+	if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
+		target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)
+	elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
+		target_link_options(common-main PUBLIC -municode -Wl,-nxcompat -Wl,-dynamicbase -Wl,-entry:wmainCRTStartup -Wl,invalidcontinue.obj)
+	elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+		target_link_options(common-main PUBLIC /IGNORE:4217 /IGNORE:4049 /NOLOGO /ENTRY:wmainCRTStartup /SUBSYSTEM:CONSOLE invalidcontinue.obj)
+	endif()
 elseif(UNIX)
 	target_link_libraries(common-main pthread rt)
 endif()
@@ -797,6 +825,13 @@ target_link_libraries(test-tool common-main)
 set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
 			PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)
 
+if(MSVC)
+	set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
+				PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/t/helper)
+	set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
+				PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/helper)
+endif()
+
 #wrapper scripts
 set(wrapper_scripts
 	git git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)
Signature · 1 line
gitgitgadget
#31 lore raw

Re: [PATCH 7/8] cmake: support for building git on windows with msvc and clang.

Quoted 46 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch adds support for Visual Studio and Clang builds

The minimum required version of CMake is upgraded to 3.15 because this version offers proper support for Clang builds on Windows.

Libintl is not searched for when building with Visual Studio or Clang because there is no binary compatible version available yet.

NOTE: In the link options invalidcontinue.obj has to be included. The reason for this is because by default, Windows calls abort()'s instead of setting errno=EINVAL when invalid arguments are passed to standard functions.
This commit explains it in detail:
4b623d80f73528a632576990ca51e34c333d5dd6

On Windows the default generator is Visual Studio,so for Visual Studio builds do this:

cmake relative-path-to-srcdir

NOTE: Visual Studio generator is a multi config generator, which means that Debug and Release builds can be done on the same build directory.

For Clang builds do this:

On bash
CC=Clang cmake relative-path-to-srcdir -G Ninja
-DCMAKE_BUILD_TYPE=[Debug or Release]

On cmd
set CC=Clang
cmake relative-path-to-srcdir -G Ninja
-DCMAKE_BUILD_TYPE=[Debug or Release]

---
 CMakeLists.txt | 57 ++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 46 insertions(+), 11 deletions(-)
CMakeLists.txt +0 -0
index d9eb1060390..5ad3a2557f7 100644

CMakeLists.txt line 5

Quoted 5 lines
CMakeLists.txt +1 -1
@@ -2,7 +2,7 @@
 #	Copyright (c) 2020 Sibi Siddharthan
 #
 
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.15)

3.14 is a step too far, and, now, we want CMake 3.15?

Quoted 40 lines
CMakeLists.txt +12 -2
 #Parse GIT-VERSION-GEN to get the version
 file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX "DEF_VER=v(.*)")
@@ -32,8 +32,11 @@ find_package(ZLIB REQUIRED)
 find_package(CURL)
 find_package(EXPAT)
 find_package(Iconv)
-find_package(Intl)
 
+#Don't use libintl on Windows Visual Studio and Clang builds
+if(NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")))
+	find_package(Intl)
+endif()
 
 if(NOT Intl_FOUND)
 	add_compile_definitions(NO_GETTEXT)
@@ -61,7 +64,7 @@ if(NOT SH_EXE)
 	message(FATAL_ERROR "sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/")
 endif()
 
-if(WIN32)
+if(WIN32 AND NOT MSVC)#not required for visual studio builds
 	find_program(WINDRES_EXE windres)
 	if(NOT WINDRES_EXE)
 		message(FATAL_ERROR "Install windres on Windows for resource files")
@@ -73,6 +76,13 @@ if(NOT MSGFMT_EXE)
 	message(WARNING "Text Translations won't be build")
 endif()
 
+#Force all visual studio outputs to CMAKE_BINARY_DIR
+if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
+	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
+	add_compile_options(/MP)
+endif()
+
 #default behaviour
 include_directories(${CMAKE_SOURCE_DIR})
 add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")

CMakeLists.txt endif() · line 125

Quoted 6 lines
CMakeLists.txt +3 -0
@@ -110,6 +120,10 @@ endif()
 
 #Platform Specific
 if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+	if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+		include_directories(compat/vcbuild/include)
+		add_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)

This is fair, I hate those warning, too.

Is _CRT_NONSTDC_NO_DEPRECATE implied when _CRT_SECURE_NO_WARNINGS defined? Or otherwise around?

Signature · 1 line
Danh
#32 lore raw

Re: [PATCH 7/8] cmake: support for building git on windows with msvc and clang.

Quoted 105 lines · Danh Doan
Quoted 46 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch adds support for Visual Studio and Clang builds

The minimum required version of CMake is upgraded to 3.15 because this version offers proper support for Clang builds on Windows.

Libintl is not searched for when building with Visual Studio or Clang because there is no binary compatible version available yet.

NOTE: In the link options invalidcontinue.obj has to be included. The reason for this is because by default, Windows calls abort()'s instead of setting errno=EINVAL when invalid arguments are passed to standard functions.
This commit explains it in detail:
4b623d80f73528a632576990ca51e34c333d5dd6

On Windows the default generator is Visual Studio,so for Visual Studio builds do this:

cmake relative-path-to-srcdir

NOTE: Visual Studio generator is a multi config generator, which means that Debug and Release builds can be done on the same build directory.

For Clang builds do this:

On bash
CC=Clang cmake relative-path-to-srcdir -G Ninja
-DCMAKE_BUILD_TYPE=[Debug or Release]

On cmd
set CC=Clang
cmake relative-path-to-srcdir -G Ninja
-DCMAKE_BUILD_TYPE=[Debug or Release]

---
 CMakeLists.txt | 57 ++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 46 insertions(+), 11 deletions(-)
CMakeLists.txt +0 -0
index d9eb1060390..5ad3a2557f7 100644

CMakeLists.txt line 5

Quoted 5 lines
CMakeLists.txt +1 -1
@@ -2,7 +2,7 @@
 #    Copyright (c) 2020 Sibi Siddharthan
 #
 
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.15)

3.14 is a step too far, and, now, we want CMake 3.15?

Quoted 40 lines
CMakeLists.txt +12 -2
 #Parse GIT-VERSION-GEN to get the version
 file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX "DEF_VER=v(.*)")
@@ -32,8 +32,11 @@ find_package(ZLIB REQUIRED)
 find_package(CURL)
 find_package(EXPAT)
 find_package(Iconv)
-find_package(Intl)
 
+#Don't use libintl on Windows Visual Studio and Clang builds
+if(NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")))
+     find_package(Intl)
+endif()
 
 if(NOT Intl_FOUND)
      add_compile_definitions(NO_GETTEXT)
@@ -61,7 +64,7 @@ if(NOT SH_EXE)
      message(FATAL_ERROR "sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/")
 endif()
 
-if(WIN32)
+if(WIN32 AND NOT MSVC)#not required for visual studio builds
      find_program(WINDRES_EXE windres)
      if(NOT WINDRES_EXE)
              message(FATAL_ERROR "Install windres on Windows for resource files")
@@ -73,6 +76,13 @@ if(NOT MSGFMT_EXE)
      message(WARNING "Text Translations won't be build")
 endif()
 
+#Force all visual studio outputs to CMAKE_BINARY_DIR
+if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+     set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
+     set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
+     add_compile_options(/MP)
+endif()
+
 #default behaviour
 include_directories(${CMAKE_SOURCE_DIR})
 add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")

CMakeLists.txt endif() · line 125

Quoted 6 lines
CMakeLists.txt +3 -0
@@ -110,6 +120,10 @@ endif()
 
 #Platform Specific
 if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+     if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+             include_directories(compat/vcbuild/include)
+             add_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)

This is fair, I hate those warning, too.

Quoted 4 lines

Is _CRT_NONSTDC_NO_DEPRECATE implied when _CRT_SECURE_NO_WARNINGS defined? Or otherwise around?

They both are independent

Quoted 2 lines

--
Danh

Thank You,
Sibi Siddharthan

#33 lore raw

PATCH 8/8 ci: modification of main.yml to use cmake for vs-build job

In reply to Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch modifies .github/workflows/main.yml to use CMake for Visual Studio builds.

Modified the vs-test step to match windows-test step. This speeds up the vs-test. Calling git-cmd from powershell and then calling git-bash to perform the tests slows things down(factor of about 6). So git-bash is directly called from powershell to perform the tests using prove.

NOTE: Since GitHub keeps the same directory for each job (with respect to path) absolute paths are used in the bin-wrapper scripts.

GitHub has switched to CMake 3.17.1 which changed the behaviour of FindCURL module. An extra definition (-DCURL_NO_CURL_CMAKE=ON) has been added to revert to the old behaviour.

---
 .github/workflows/main.yml | 43 ++++++++++++++++++++++----------------
 1 file changed, 25 insertions(+), 18 deletions(-)
.github/workflows/main.yml +25 -18
index fd4df939b50..94f9a385225 100644
@@ -80,13 +80,6 @@ jobs:
     - name: download git-sdk-64-minimal
       shell: bash
       run: a=git-sdk-64-minimal && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
-    - name: generate Visual Studio solution
-      shell: powershell
-      run: |
-        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
-          make NDEBUG=1 DEVELOPER=1 vcxproj
-        "@
-        if (!$?) { exit(1) }
     - name: download vcpkg artifacts
       shell: powershell
       run: |
@@ -98,6 +91,13 @@ jobs:
         Remove-Item compat.zip
     - name: add msbuild to PATH
       uses: microsoft/[email protected]
+    - name: generate Visual Studio solution
+      shell: powershell
+      run: |
+        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
+          cmake . -DCMAKE_PREFIX_PATH=./compat/vcbuild/vcpkg/installed/x64-windows -DMSGFMT_EXE=./git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
+        "@
+        if (!$?) { exit(1) }
     - name: MSBuild
       run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142
     - name: bundle artifact tar
@@ -125,9 +125,9 @@ jobs:
         nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
     steps:
     - uses: actions/checkout@v1
-    - name: download git-64-portable
+    - name: download git-sdk-64-minimal
       shell: bash
-      run: a=git-64-portable && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
+      run: a=git-sdk-64-minimal && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
     - name: download build artifacts
       uses: actions/download-artifact@v1
       with:
@@ -136,23 +136,30 @@ jobs:
     - name: extract build artifacts
       shell: bash
       run: tar xf artifacts.tar.gz
-    - name: test (parallel)
+    - name: test
       shell: powershell
       env:
         MSYSTEM: MINGW64
         NO_SVN_TESTS: 1
         GIT_TEST_SKIP_REBASE_P: 1
       run: |
-        & git-64-portable\git-cmd.exe --command=usr\bin\bash.exe -lc @"
-          # Let Git ignore the SDK and the test-cache
-          printf '%s\n' /git-64-portable/ /test-cache/ >>.git/info/exclude
+        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
+          # Let Git ignore the SDK
+          printf '%s\n' /git-sdk-64-minimal/ >>.git/info/exclude
 
-          cd t &&
-          PATH=\"`$PWD/helper:`$PATH\" &&
-          test-tool.exe run-command testsuite --jobs=10 -V -x --write-junit-xml \
-                  `$(test-tool.exe path-utils slice-tests \
-                          ${{matrix.nr}} 10 t[0-9]*.sh)
+          ci/run-test-slice.sh ${{matrix.nr}} 10
         "@
+    - name: ci/print-test-failures.sh
+      if: failure()
+      shell: powershell
+      run: |
+        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc ci/print-test-failures.sh
+    - name: Upload failed tests' directories
+      if: failure() && env.FAILED_TEST_ARTIFACTS != ''
+      uses: actions/upload-artifact@v1
+      with:
+        name: failed-tests-windows
+        path: ${{env.FAILED_TEST_ARTIFACTS}}
   regular:
     strategy:
       matrix:
Signature · 1 line
gitgitgadget
#34 lore raw

Re: [PATCH 8/8] ci: modification of main.yml to use cmake for vs-build job

Quoted 42 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch modifies .github/workflows/main.yml to use CMake for Visual Studio builds.

Modified the vs-test step to match windows-test step. This speeds up the vs-test. Calling git-cmd from powershell and then calling git-bash to perform the tests slows things down(factor of about 6). So git-bash is directly called from powershell to perform the tests using prove.

NOTE: Since GitHub keeps the same directory for each job (with respect to path) absolute paths are used in the bin-wrapper scripts.

GitHub has switched to CMake 3.17.1 which changed the behaviour of FindCURL module. An extra definition (-DCURL_NO_CURL_CMAKE=ON) has been added to revert to the old behaviour.

---
 .github/workflows/main.yml | 43 ++++++++++++++++++++++----------------
 1 file changed, 25 insertions(+), 18 deletions(-)
.github/workflows/main.yml +0 -7
index fd4df939b50..94f9a385225 100644
@@ -80,13 +80,6 @@ jobs:
     - name: download git-sdk-64-minimal
       shell: bash
       run: a=git-sdk-64-minimal && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
-    - name: generate Visual Studio solution
-      shell: powershell
-      run: |
-        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
-          make NDEBUG=1 DEVELOPER=1 vcxproj
-        "@
-        if (!$?) { exit(1) }
     - name: download vcpkg artifacts
       shell: powershell
       run: |

.github/workflows/main.yml jobs: · line 100

Quoted 10 lines
.github/workflows/main.yml +7 -0
@@ -98,6 +91,13 @@ jobs:
         Remove-Item compat.zip
     - name: add msbuild to PATH
       uses: microsoft/[email protected]
+    - name: generate Visual Studio solution
+      shell: powershell
+      run: |
+        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
+          cmake . -DCMAKE_PREFIX_PATH=./compat/vcbuild/vcpkg/installed/x64-windows -DMSGFMT_EXE=./git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
+        "@
+        if (!$?) { exit(1) }

If you intended to modified some steps to provide a better script for that step, I believe you should change in that step.

If the order of those steps need to be changed, please clarify your reasoning!

Quoted 16 lines
.github/workflows/main.yml +2 -2
     - name: MSBuild
       run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142
     - name: bundle artifact tar
@@ -125,9 +125,9 @@ jobs:
         nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
     steps:
     - uses: actions/checkout@v1
-    - name: download git-64-portable
+    - name: download git-sdk-64-minimal
       shell: bash
-      run: a=git-64-portable && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
+      run: a=git-sdk-64-minimal && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
     - name: download build artifacts
       uses: actions/download-artifact@v1
       with:

.github/workflows/main.yml jobs: · line 139

Quoted 5 lines
.github/workflows/main.yml +1 -1
@@ -136,23 +136,30 @@ jobs:
     - name: extract build artifacts
       shell: bash
       run: tar xf artifacts.tar.gz
-    - name: test (parallel)
+    - name: test

So the test couldn't be run in parallel anymore?
It's a regression!
And we don't need the matrix anymore!!!!!

I wonder if Dscho's effort is wasted, he tried very hard to make those tests run in parallel.
He even tried to re-order the matrix in GfW project to let longest test run first!

Quoted 15 lines
.github/workflows/main.yml +3 -5
       shell: powershell
       env:
         MSYSTEM: MINGW64
         NO_SVN_TESTS: 1
         GIT_TEST_SKIP_REBASE_P: 1
       run: |
-        & git-64-portable\git-cmd.exe --command=usr\bin\bash.exe -lc @"
-          # Let Git ignore the SDK and the test-cache
-          printf '%s\n' /git-64-portable/ /test-cache/ >>.git/info/exclude
+        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
+          # Let Git ignore the SDK
+          printf '%s\n' /git-sdk-64-minimal/ >>.git/info/exclude
 
-          cd t &&
-          PATH=\"`$PWD/helper:`$PATH\" &&

.github/workflows/main.yml jobs: · line 156

Quoted 10 lines
.github/workflows/main.yml +6 -3
-          test-tool.exe run-command testsuite --jobs=10 -V -x --write-junit-xml \
-                  `$(test-tool.exe path-utils slice-tests \
-                          ${{matrix.nr}} 10 t[0-9]*.sh)
+          ci/run-test-slice.sh ${{matrix.nr}} 10
         "@
+    - name: ci/print-test-failures.sh
+      if: failure()
+      shell: powershell
+      run: |
+        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc ci/print-test-failures.sh

What is changed?

Signature · 1 line
Danh
#35 lore raw

Re: [PATCH 8/8] ci: modification of main.yml to use cmake for vs-build job

Quoted 58 lines · Danh Doan
Quoted 42 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch modifies .github/workflows/main.yml to use CMake for Visual Studio builds.

Modified the vs-test step to match windows-test step. This speeds up the vs-test. Calling git-cmd from powershell and then calling git-bash to perform the tests slows things down(factor of about 6). So git-bash is directly called from powershell to perform the tests using prove.

NOTE: Since GitHub keeps the same directory for each job (with respect to path) absolute paths are used in the bin-wrapper scripts.

GitHub has switched to CMake 3.17.1 which changed the behaviour of FindCURL module. An extra definition (-DCURL_NO_CURL_CMAKE=ON) has been added to revert to the old behaviour.

---
 .github/workflows/main.yml | 43 ++++++++++++++++++++++----------------
 1 file changed, 25 insertions(+), 18 deletions(-)
.github/workflows/main.yml +0 -7
index fd4df939b50..94f9a385225 100644
@@ -80,13 +80,6 @@ jobs:
     - name: download git-sdk-64-minimal
       shell: bash
       run: a=git-sdk-64-minimal && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
-    - name: generate Visual Studio solution
-      shell: powershell
-      run: |
-        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
-          make NDEBUG=1 DEVELOPER=1 vcxproj
-        "@
-        if (!$?) { exit(1) }
     - name: download vcpkg artifacts
       shell: powershell
       run: |

.github/workflows/main.yml jobs: · line 100

Quoted 10 lines
.github/workflows/main.yml +7 -0
@@ -98,6 +91,13 @@ jobs:
         Remove-Item compat.zip
     - name: add msbuild to PATH
       uses: microsoft/[email protected]
+    - name: generate Visual Studio solution
+      shell: powershell
+      run: |
+        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
+          cmake . -DCMAKE_PREFIX_PATH=./compat/vcbuild/vcpkg/installed/x64-windows -DMSGFMT_EXE=./git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
+        "@
+        if (!$?) { exit(1) }

If you intended to modified some steps to provide a better script for that step, I believe you should change in that step.

Quoted 3 lines

If the order of those steps need to be changed, please clarify your reasoning!

Previously, the Visual Studio solution was generated, then the vcpkg artifacts were downloaded.
With CMake, as it searched for the libraries during configure the vcpkg artifacts are now downloaded before the configure step.

Quoted 26 lines
Quoted 16 lines
.github/workflows/main.yml +2 -2
     - name: MSBuild
       run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142
     - name: bundle artifact tar
@@ -125,9 +125,9 @@ jobs:
         nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
     steps:
     - uses: actions/checkout@v1
-    - name: download git-64-portable
+    - name: download git-sdk-64-minimal
       shell: bash
-      run: a=git-64-portable && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
+      run: a=git-sdk-64-minimal && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
     - name: download build artifacts
       uses: actions/download-artifact@v1
       with:

.github/workflows/main.yml jobs: · line 139

Quoted 5 lines
.github/workflows/main.yml +1 -1
@@ -136,23 +136,30 @@ jobs:
     - name: extract build artifacts
       shell: bash
       run: tar xf artifacts.tar.gz
-    - name: test (parallel)
+    - name: test

So the test couldn't be run in parallel anymore?
It's a regression!
And we don't need the matrix anymore!!!!!

Quoted 6 lines

I wonder if Dscho's effort is wasted, he tried very hard to make those tests run in parallel.
He even tried to re-order the matrix in GfW project to let longest test run first!

Okay, When I removed "(parallel)" does not mean that the tests are not run in parallel.
Now they are run in the same way how windows-test(step) is run. The tests(vs-test) actually completes before than the windows-test in the CI

Quoted 26 lines
Quoted 15 lines
.github/workflows/main.yml +3 -5
       shell: powershell
       env:
         MSYSTEM: MINGW64
         NO_SVN_TESTS: 1
         GIT_TEST_SKIP_REBASE_P: 1
       run: |
-        & git-64-portable\git-cmd.exe --command=usr\bin\bash.exe -lc @"
-          # Let Git ignore the SDK and the test-cache
-          printf '%s\n' /git-64-portable/ /test-cache/ >>.git/info/exclude
+        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
+          # Let Git ignore the SDK
+          printf '%s\n' /git-sdk-64-minimal/ >>.git/info/exclude
 
-          cd t &&
-          PATH=\"`$PWD/helper:`$PATH\" &&

.github/workflows/main.yml jobs: · line 156

Quoted 10 lines
.github/workflows/main.yml +6 -3
-          test-tool.exe run-command testsuite --jobs=10 -V -x --write-junit-xml \
-                  `$(test-tool.exe path-utils slice-tests \
-                          ${{matrix.nr}} 10 t[0-9]*.sh)
+          ci/run-test-slice.sh ${{matrix.nr}} 10
         "@
+    - name: ci/print-test-failures.sh
+      if: failure()
+      shell: powershell
+      run: |
+        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc ci/print-test-failures.sh
Quoted 4 lines

What is changed?

--
Danh

Thank You,
Sibi Siddharthan

#36 lore raw

Re: [PATCH 8/8] ci: modification of main.yml to use cmake for vs-build job

In reply to Danh Doan

Hi Danh,

Quoted 18 lines · Danh Doan

.github/workflows/main.yml jobs: · line 100

Quoted 13 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

.github/workflows/main.yml +7 -0
@@ -98,6 +91,13 @@ jobs:
         Remove-Item compat.zip
     - name: add msbuild to PATH
       uses: microsoft/[email protected]
+    - name: generate Visual Studio solution
+      shell: powershell
+      run: |
+        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
+          cmake . -DCMAKE_PREFIX_PATH=./compat/vcbuild/vcpkg/installed/x64-windows -DMSGFMT_EXE=./git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
+        "@
+        if (!$?) { exit(1) }

If you intended to modified some steps to provide a better script for that step, I believe you should change in that step.

Quoted 2 lines

If the order of those steps need to be changed, please clarify your reasoning!

It is the order that needs to be changed, indeed: The CMake step requires the vcpkg artifacts (i.e. pre-built dependencies like curl), whereas the previous make vcxproj did not require them.

And yes, that's good material for the commit message!

Quoted 26 lines
Quoted 16 lines
.github/workflows/main.yml +2 -2
     - name: MSBuild
       run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142
     - name: bundle artifact tar
@@ -125,9 +125,9 @@ jobs:
         nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
     steps:
     - uses: actions/checkout@v1
-    - name: download git-64-portable
+    - name: download git-sdk-64-minimal
       shell: bash
-      run: a=git-64-portable && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
+      run: a=git-sdk-64-minimal && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
     - name: download build artifacts
       uses: actions/download-artifact@v1
       with:

.github/workflows/main.yml jobs: · line 139

Quoted 5 lines
.github/workflows/main.yml +1 -1
@@ -136,23 +136,30 @@ jobs:
     - name: extract build artifacts
       shell: bash
       run: tar xf artifacts.tar.gz
-    - name: test (parallel)
+    - name: test

So the test couldn't be run in parallel anymore?
It's a regression!
And we don't need the matrix anymore!!!!!

Quoted 2 lines

I wonder if Dscho's effort is wasted, he tried very hard to make those tests run in parallel.

No need to worry, it's still parallel.

The reason why it looks incorrect is that Sibi used the windows-test job as an example rather than the vs-test one. For that reason, it is the full git-sdk-64-minimal rather than the portable Git in which the tests are run.

I would prefer to re-revert this again, to use the (parallel) and the git-64-portable again.

Quoted 2 lines

He even tried to re-order the matrix in GfW project to let longest test run first!

I did! And it was quite a bit of manual work because the times are not really obvious from the logs, you have to script something to get at them. In the end, it was not worth the effort, as the overall runtime was only minimally faster, and I did not like how the order could become stale and less helpful over time.

Quoted 26 lines
Quoted 15 lines
.github/workflows/main.yml +3 -5
       shell: powershell
       env:
         MSYSTEM: MINGW64
         NO_SVN_TESTS: 1
         GIT_TEST_SKIP_REBASE_P: 1
       run: |
-        & git-64-portable\git-cmd.exe --command=usr\bin\bash.exe -lc @"
-          # Let Git ignore the SDK and the test-cache
-          printf '%s\n' /git-64-portable/ /test-cache/ >>.git/info/exclude
+        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
+          # Let Git ignore the SDK
+          printf '%s\n' /git-sdk-64-minimal/ >>.git/info/exclude
 
-          cd t &&
-          PATH=\"`$PWD/helper:`$PATH\" &&

.github/workflows/main.yml jobs: · line 156

Quoted 10 lines
.github/workflows/main.yml +6 -3
-          test-tool.exe run-command testsuite --jobs=10 -V -x --write-junit-xml \
-                  `$(test-tool.exe path-utils slice-tests \
-                          ${{matrix.nr}} 10 t[0-9]*.sh)
+          ci/run-test-slice.sh ${{matrix.nr}} 10
         "@
+    - name: ci/print-test-failures.sh
+      if: failure()
+      shell: powershell
+      run: |
+        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc ci/print-test-failures.sh
Quoted 1 line

What is changed?

This also is a consequence of copy/editing the windows-test job instead of the vs-test one: The portable Git does not bring enough stuff to run prove, therefore we have to "roll our own runner" here.

Unless we use the substantially larger git-sdk-64-minimal. But the idea here _was_ to test in as similar a fashion to developers on Windows: they would not want to download the full Git for Windows SDK, but run the test in the Bash of a regular Git for Windows instead.

Indeed, you could say that in a way, this entire patch series is about trying to make it unnecessary for developers on Windows to download more than 500MB just to start tinkering with the Git source code.

Or maybe the patch series is about more than just that, but that alone would be reason enough to want it. And I think we do want it.

Ciao,
Dscho

#37 lore raw
In reply to Sibi Siddharthan via GitGitGadget
Quoted 1 line · Sibi Siddharthan via GitGitGadget

This is an attempt to build Git using CMake.

What is your longer-term plan on this one? Would the ultimate goal be

(1) to maintain both CMake and Makefile and keep them in sync?

(2) force all the Git developers (not users or binary packagers) start using cmake and abandon Makefile, and let CMake generate Makefile?

(3) something else?

Given that bootstrapping CMake typically takes a working "make", by definition, if you drop Makefile from our shipped source tree, the audience you can support on minority platforms would be smaller than what we have. It is not negotiable that we keep Makefile as a valid way to build Git, and the Makefile must be tweakable for those on a minority platforms when things do not go the way they want to (the tweakability is most needed on minority/exotic platforms).

W ith either (1) or (2) above, I have a feeling that engineering burden to divert resources to add cmake support (with sustainable plan to keep "fixable/tweakable" Makefile that is in sync) alone would already be high enough. It is unclear the reason why we want to pay all that cost---to gain what? Other than to make those who like CMake feel happier, that is.

I do not want to sound overly negative in my first response, but you might thank whoever says "no" early before you invest too much time on this topic, so I'll send the above before even reading these 8 patches.

Thanks for your interest in the project.

#38 lore raw
Quoted 31 lines · Junio C Hamano
Quoted 1 line · Sibi Siddharthan via GitGitGadget

This is an attempt to build Git using CMake.

What is your longer-term plan on this one? Would the ultimate goal be

(1) to maintain both CMake and Makefile and keep them in sync?

(2) force all the Git developers (not users or binary packagers) start using cmake and abandon Makefile, and let CMake generate Makefile?

(3) something else?

Given that bootstrapping CMake typically takes a working "make", by definition, if you drop Makefile from our shipped source tree, the audience you can support on minority platforms would be smaller than what we have. It is not negotiable that we keep Makefile as a valid way to build Git, and the Makefile must be tweakable for those on a minority platforms when things do not go the way they want to (the tweakability is most needed on minority/exotic platforms).

W ith either (1) or (2) above, I have a feeling that engineering burden to divert resources to add cmake support (with sustainable plan to keep "fixable/tweakable" Makefile that is in sync) alone would already be high enough. It is unclear the reason why we want to pay all that cost---to gain what? Other than to make those who like CMake feel happier, that is.

Quoted 7 lines

I do not want to sound overly negative in my first response, but you might thank whoever says "no" early before you invest too much time on this topic, so I'll send the above before even reading these 8 patches.

Thanks for your interest in the project.

Hi Junio,

The goal would be to maintain a CMake build for Git keeping it in sync with the Makefile.
The Makefile is not going to be replaced at all. The CMake script for now only supports Linux and Windows.
It does not support BSD, Solaris and others, whereas the Makefile does support them.

The reason for introducing CMake is primarily for compiling git on Windows and to do out of source builds.
I think the CMake script makes it easier to build Git as it does the necessary function and header checks and generates the required compile definitions.

I would like to say that the proposed CMake build system is meant to complement the currently used Makefile, not to replace it at all.

Thank You,
Sibi Siddharthan

PS: Sorry for the multiple emails:)

#39 lore raw
Quoted 6 lines · Sibi Siddharthan

The goal would be to maintain a CMake build for Git keeping it in sync with the Makefile.
The Makefile is not going to be replaced at all. The CMake script for now only supports Linux and Windows.
It does not support BSD, Solaris and others, whereas the Makefile does support them.

So you are doing (1). I already said that I feel that engineering burden to divert resources for CMake support would be unacceptably high.

Whenever any of our developers need to add source files, Makefile configuration knobs that people can add to config.mak, etc., you are forcing them to figure out where in the CMakefile to add them or devise ways to allow builders who do not use config.mak (because they use CMake) to do similar tweaks.

Any patch that is acceptable to the current project would become unacceptable because they lack updates to CMake part, but I suspect we do not have enough people who are so much devoted to give a good review if updates to CMake part are added. And it is unclear why it would be beneficial to slow our existing developers down by forcing them to become familiar with CMake.

So..., I am not just "still not convinced", but I am even more convinced that we do not want this series, after thinking about it longer.

Thanks.

#40 lore raw
Quoted 14 lines · Junio C Hamano
Quoted 6 lines · Sibi Siddharthan

The goal would be to maintain a CMake build for Git keeping it in sync with the Makefile.
The Makefile is not going to be replaced at all. The CMake script for now only supports Linux and Windows.
It does not support BSD, Solaris and others, whereas the Makefile does support them.

So you are doing (1). I already said that I feel that engineering burden to divert resources for CMake support would be unacceptably high.

Quoted 6 lines

Whenever any of our developers need to add source files, Makefile configuration knobs that people can add to config.mak, etc., you are forcing them to figure out where in the CMakefile to add them or devise ways to allow builders who do not use config.mak (because they use CMake) to do similar tweaks.

Adding source files to the CMakefile is going to just as long as adding it to the Makefile,
anyone can figure this out and this is not going to take much time at all.

As for the configuration knobs I agree that adding the same to CMake is going to a bit longer.
But anyone who is hacking Git is going to do it with the Makefile or (if accepted)CMake script, but not both while hacking.
So they will continue to make progress with the system they feel comfortable in. They will only run into an issue when they try for a PR. Currently the CMake script is only used for generating the visual studio solution. We can add a (continue-on-error) to vs-build job to make this process less of a hindrance.
If people take the time to hack Git, figuring out how to do the configuration knobs in the CMake script is not going to that much take time
compared to the time they spend making Git better.

Quoted 7 lines

Any patch that is acceptable to the current project would become unacceptable because they lack updates to CMake part, but I suspect we do not have enough people who are so much devoted to give a good review if updates to CMake part are added. And it is unclear why it would be beneficial to slow our existing developers down by forcing them to become familiar with CMake.

Quoted 6 lines

So..., I am not just "still not convinced", but I am even more convinced that we do not want this series, after thinking about it longer.

Thanks.

Thank You,
Sibi Siddharthan

#41 lore raw

Hi Sibi,

Quoted 19 lines · Sibi Siddharthan
Quoted 12 lines · Junio C Hamano
Quoted 6 lines · Sibi Siddharthan

The goal would be to maintain a CMake build for Git keeping it in sync with the Makefile.
The Makefile is not going to be replaced at all. The CMake script for now only supports Linux and Windows.
It does not support BSD, Solaris and others, whereas the Makefile does support them.

So you are doing (1). I already said that I feel that engineering burden to divert resources for CMake support would be unacceptably high.

Quoted 6 lines

Whenever any of our developers need to add source files, Makefile configuration knobs that people can add to config.mak, etc., you are forcing them to figure out where in the CMakefile to add them or devise ways to allow builders who do not use config.mak (because they use CMake) to do similar tweaks.

Quoted 3 lines

Adding source files to the CMakefile is going to just as long as adding it to the Makefile,
anyone can figure this out and this is not going to take much time at all.

While figuring these things out isn't /hard/ it can be tedious and time consuming for those who are not familiar with the particular tool set (as evidenced, in my mind, by the poor dev support for Git for Windows because of the need to understand two operating systems and their awkward interactions) - those that are familiar and understand the/their whole tool set are usually the x10 folks.

Quoted 29 lines

As for the configuration knobs I agree that adding the same to CMake is going to a bit longer.
But anyone who is hacking Git is going to do it with the Makefile or (if accepted)CMake script, but not both while hacking.
So they will continue to make progress with the system they feel comfortable in. They will only run into an issue when they try for a PR. Currently the CMake script is only used for generating the visual studio solution. We can add a (continue-on-error) to vs-build job to make this process less of a hindrance.
If people take the time to hack Git, figuring out how to do the configuration knobs in the CMake script is not going to that much take time
compared to the time they spend making Git better.

Quoted 13 lines

Any patch that is acceptable to the current project would become unacceptable because they lack updates to CMake part, but I suspect we do not have enough people who are so much devoted to give a good review if updates to CMake part are added. And it is unclear why it would be beneficial to slow our existing developers down by forcing them to become familiar with CMake.

So..., I am not just "still not convinced", but I am even more convinced that we do not want this series, after thinking about it longer.

Thanks.

Is there a middle way, given that IIUC there is most benefit on the Windows side, that on the git.git side the Makefile could contain a suitable comment directing those interested in CMake to the relevant part of Git-for-Windows. Is there a part that could hold, and track, the matching changes to the primary Makefile?

Are there tools that track and compare CMake and Make variants, or at least indicate any divergences to help separately maintaining the CMake series?

Quoted 2 lines

Thank You,
Sibi Siddharthan

--
Philip

#42 lore raw

Hi Philip,

Quoted 24 lines · Philip Oakley
Quoted 19 lines · Sibi Siddharthan
Quoted 12 lines · Junio C Hamano
Quoted 5 lines · Sibi Siddharthan

The goal would be to maintain a CMake build for Git keeping it in sync with the Makefile. The Makefile is not going to be replaced at all. The CMake script for now only supports Linux and Windows. It does not support BSD, Solaris and others, whereas the Makefile does support them.

So you are doing (1). I already said that I feel that engineering burden to divert resources for CMake support would be unacceptably high.

Quoted 5 lines

Whenever any of our developers need to add source files, Makefile configuration knobs that people can add to config.mak, etc., you are forcing them to figure out where in the CMakefile to add them or devise ways to allow builders who do not use config.mak (because they use CMake) to do similar tweaks.

Quoted 3 lines

Adding source files to the CMakefile is going to just as long as adding it to the Makefile, anyone can figure this out and this is not going to take much time at all.

Quoted 6 lines

While figuring these things out isn't /hard/ it can be tedious and time consuming for those who are not familiar with the particular tool set (as evidenced, in my mind, by the poor dev support for Git for Windows because of the need to understand two operating systems and their awkward interactions) - those that are familiar and understand the/their whole tool set are usually the x10 folks.

Is it fair to compare the complexities of the differences between what Git expects and what Windows provides to the difference to add files to Makefile _and_ CMakeLists.txt?

When I add a file to the Makefile, what I do (and imagine that _everybody_ is doing in that circumstance) is to find an already-existing file that is similar to the one I want to add. For example, if adding builtin/oakley--helper.c, I will try to imitate builtin/submodule--helper.c.

And when you do that, you don't really need to understand Makefiles or CMake. You find the list(s) and add your file there, paying attention to whether it is maintained alphabetically or append-only.

That is a _far_ cry from the hoops through which you have to jump to understand, say, the important background details in order to start working on compat/mingw.c.

At least from my point of view, there is very little analogy between the subject under discussion and what you brought up.

Having said that...

Quoted 26 lines
Quoted 26 lines

As for the configuration knobs I agree that adding the same to CMake is going to a bit longer.
But anyone who is hacking Git is going to do it with the Makefile or (if accepted)CMake script, but not both while hacking.
So they will continue to make progress with the system they feel comfortable in. They will only run into an issue when they try for a PR. Currently the CMake script is only used for generating the visual studio solution. We can add a (continue-on-error) to vs-build job to make this process less of a hindrance.
If people take the time to hack Git, figuring out how to do the configuration knobs in the CMake script is not going to that much take time
compared to the time they spend making Git better.

Quoted 11 lines

Any patch that is acceptable to the current project would become unacceptable because they lack updates to CMake part, but I suspect we do not have enough people who are so much devoted to give a good review if updates to CMake part are added. And it is unclear why it would be beneficial to slow our existing developers down by forcing them to become familiar with CMake.

So..., I am not just "still not convinced", but I am even more convinced that we do not want this series, after thinking about it longer.

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

Thanks.

Is there a middle way, given that IIUC there is most benefit on the Windows side, that on the git.git side the Makefile could contain a suitable comment directing those interested in CMake to the relevant part of Git-for-Windows. Is there a part that could hold, and track, the matching changes to the primary Makefile?

We already use GIT-VERSION-GEN as the authoritative source for the Git version, by parsing the line that contains.

It would look very similar, at least in my mind, to generate the list of source/script files by parsing the Makefile.

Sibi, what do you think?

Ciao,
Dscho

#43 lore raw

Hi Philip and Dscho

Quoted 35 lines · Johannes Schindelin

Hi Philip,

Quoted 30 lines · Philip Oakley
Quoted 19 lines · Sibi Siddharthan
Quoted 12 lines · Junio C Hamano
Quoted 5 lines · Sibi Siddharthan

The goal would be to maintain a CMake build for Git keeping it in sync with the Makefile. The Makefile is not going to be replaced at all. The CMake script for now only supports Linux and Windows. It does not support BSD, Solaris and others, whereas the Makefile does support them.

So you are doing (1). I already said that I feel that engineering burden to divert resources for CMake support would be unacceptably high.

Quoted 5 lines

Whenever any of our developers need to add source files, Makefile configuration knobs that people can add to config.mak, etc., you are forcing them to figure out where in the CMakefile to add them or devise ways to allow builders who do not use config.mak (because they use CMake) to do similar tweaks.

Quoted 3 lines

Adding source files to the CMakefile is going to just as long as adding it to the Makefile, anyone can figure this out and this is not going to take much time at all.

While figuring these things out isn't /hard/ it can be tedious and time consuming for those who are not familiar with the particular tool set (as evidenced, in my mind, by the poor dev support for Git for Windows because of the need to understand two operating systems and their awkward interactions) - those that are familiar and understand the/their whole tool set are usually the x10 folks.

One way of reducing the tediousness is to guide the developers in the Contribuiting document
as to where to add the new source files for both the Makefile and CMake script.

Quoted 59 lines

Is it fair to compare the complexities of the differences between what Git expects and what Windows provides to the difference to add files to Makefile _and_ CMakeLists.txt?

When I add a file to the Makefile, what I do (and imagine that _everybody_ is doing in that circumstance) is to find an already-existing file that is similar to the one I want to add. For example, if adding builtin/oakley--helper.c, I will try to imitate builtin/submodule--helper.c.

And when you do that, you don't really need to understand Makefiles or CMake. You find the list(s) and add your file there, paying attention to whether it is maintained alphabetically or append-only.

That is a _far_ cry from the hoops through which you have to jump to understand, say, the important background details in order to start working on compat/mingw.c.

At least from my point of view, there is very little analogy between the subject under discussion and what you brought up.

Having said that...

Quoted 26 lines
Quoted 26 lines

As for the configuration knobs I agree that adding the same to CMake is going to a bit longer.
But anyone who is hacking Git is going to do it with the Makefile or (if accepted)CMake script, but not both while hacking.
So they will continue to make progress with the system they feel comfortable in. They will only run into an issue when they try for a PR. Currently the CMake script is only used for generating the visual studio solution. We can add a (continue-on-error) to vs-build job to make this process less of a hindrance.
If people take the time to hack Git, figuring out how to do the configuration knobs in the CMake script is not going to that much take time
compared to the time they spend making Git better.

Quoted 11 lines

Any patch that is acceptable to the current project would become unacceptable because they lack updates to CMake part, but I suspect we do not have enough people who are so much devoted to give a good review if updates to CMake part are added. And it is unclear why it would be beneficial to slow our existing developers down by forcing them to become familiar with CMake.

So..., I am not just "still not convinced", but I am even more convinced that we do not want this series, after thinking about it longer.

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

Thanks.

Is there a middle way, given that IIUC there is most benefit on the Windows side, that on the git.git side the Makefile could contain a suitable comment directing those interested in CMake to the relevant part of Git-for-Windows. Is there a part that could hold, and track, the matching changes to the primary Makefile?

Quoted 8 lines

We already use GIT-VERSION-GEN as the authoritative source for the Git version, by parsing the line that contains.

It would look very similar, at least in my mind, to generate the list of source/script files by parsing the Makefile.

Sibi, what do you think?

One way of doing it is to track if the Makefile is changed in a commit, run a hook
to see if it contains any new OBJs and match it with the CMake script. But this is too much work, in my opinion.

For the scripts, things are a bit complicated, suppose people use sed and grep to
do their logic in the Makefile, we add "sed" and "grep" dependencies to the build process
This is not a bad thing, but the same logic can be implemented in CMake without "grep" and "sed".
Also, the Makefile script generation logics are path relative, which should be modified in CMake
to have arbitrary build and source directories.

The better option is to guide developers how to add their build changes to CMake also. (This is not hard at all)

Quoted 2 lines

Ciao,
Dscho

Thank You,
Sibi Siddharthan

#44 lore raw

Hi Sibi,

Quoted 7 lines · Sibi Siddharthan
Quoted 4 lines · Johannes Schindelin

We already use GIT-VERSION-GEN as the authoritative source for the Git version, by parsing the line that contains.

Quoted 8 lines
Quoted 4 lines

It would look very similar, at least in my mind, to generate the list of source/script files by parsing the Makefile.

Sibi, what do you think?

One way of doing it is to track if the Makefile is changed in a commit, run a hook to see if it contains any new OBJs and match it with the CMake script. But this is too much work, in my opinion.

Oh, sorry, I should have clarified: We already parse the DEF_VER=v2.26.GIT line in GIT-VERSION-GEN to determine the Git version.

We should be able to do the very exact same thing to parse the SCRIPT_SH lines like

	SCRIPT_SH += git-bisect.sh

in the Makefile to accumulate the list of shell scripts, and likewise the list of object files could be accumulated by parsing the LIB_OBJS lines like

	LIB_OBJS += abspath.o

(We would of course need to substitute the .o with .c, but that should be easy.)

That way, nobody will ever need to touch the CMakeLists.txt file when they add a new source file to libgit.a.

I was not trying to auto-detect what sed invocation changed. Those changes _will_ need manual forward-porting to CMakeLists.txt. Thankfully, those events are really rare.

Makes sense?

Ciao,
Dscho

#45 lore raw

Hi Dscho

Quoted 34 lines · Johannes Schindelin

Hi Sibi,

Quoted 7 lines · Sibi Siddharthan
Quoted 4 lines · Johannes Schindelin

We already use GIT-VERSION-GEN as the authoritative source for the Git version, by parsing the line that contains.

Quoted 8 lines
Quoted 4 lines

It would look very similar, at least in my mind, to generate the list of source/script files by parsing the Makefile.

Sibi, what do you think?

One way of doing it is to track if the Makefile is changed in a commit, run a hook to see if it contains any new OBJs and match it with the CMake script. But this is too much work, in my opinion.

Oh, sorry, I should have clarified: We already parse the DEF_VER=v2.26.GIT line in GIT-VERSION-GEN to determine the Git version.

We should be able to do the very exact same thing to parse the SCRIPT_SH lines like

        SCRIPT_SH += git-bisect.sh

in the Makefile to accumulate the list of shell scripts, and likewise the list of object files could be accumulated by parsing the LIB_OBJS lines like

Quoted 8 lines
        LIB_OBJS += abspath.o

(We would of course need to substitute the .o with .c, but that should be easy.)

That way, nobody will ever need to touch the CMakeLists.txt file when they add a new source file to libgit.a.

I understand what you are trying to say, this is not impossible to do but doing so will make the CMake script dependent on the Makefile for the sources. I am not fan of this approach.

We should write a separate script (say python) to match each of the sources in the Makefile and the CMake file automatically whenever the changes detected. This excludes the platform specific/compatibility stuff in config.mak.uname.

Quoted 8 lines

I was not trying to auto-detect what sed invocation changed. Those changes _will_ need manual forward-porting to CMakeLists.txt. Thankfully, those events are really rare.

Makes sense?

Ciao,
Dscho

Thank You,
Sibi Siddharthan

#46 lore raw

Hi Sibi,

Quoted 43 lines · Sibi Siddharthan
Quoted 32 lines · Johannes Schindelin
Quoted 7 lines · Sibi Siddharthan
Quoted 4 lines · Johannes Schindelin

We already use GIT-VERSION-GEN as the authoritative source for the Git version, by parsing the line that contains.

Quoted 8 lines
Quoted 4 lines

It would look very similar, at least in my mind, to generate the list of source/script files by parsing the Makefile.

Sibi, what do you think?

One way of doing it is to track if the Makefile is changed in a commit, run a hook to see if it contains any new OBJs and match it with the CMake script. But this is too much work, in my opinion.

Oh, sorry, I should have clarified: We already parse the DEF_VER=v2.26.GIT line in GIT-VERSION-GEN to determine the Git version.

We should be able to do the very exact same thing to parse the SCRIPT_SH lines like

        SCRIPT_SH += git-bisect.sh

in the Makefile to accumulate the list of shell scripts, and likewise the list of object files could be accumulated by parsing the LIB_OBJS lines like

Quoted 8 lines
        LIB_OBJS += abspath.o

(We would of course need to substitute the .o with .c, but that should be easy.)

That way, nobody will ever need to touch the CMakeLists.txt file when they add a new source file to libgit.a.

Quoted 7 lines

I understand what you are trying to say, this is not impossible to do but doing so will make the CMake script dependent on the Makefile for the sources. I am not fan of this approach.

We should write a separate script (say python) to match each of the sources in the Makefile and the CMake file automatically whenever the changes detected. This excludes the platform specific/compatibility stuff in config.mak.uname.

Hmm. That is an approach that _I_ don't like. Why duplicate the information when you don't have to?

I don't see any issue with keeping CMakeLists.txt dependent on Makefile. We could of course extract the lists into a separate file that is sourced both from the Makefile and from CMakeLists.txt, but that would actually not reflect that the Makefile _is_ authoritative. CMakeLists.txt will never be the authoritative source.

Ciao,
Dscho

Quoted 14 lines
Quoted 9 lines

I was not trying to auto-detect what sed invocation changed. Those changes _will_ need manual forward-porting to CMakeLists.txt. Thankfully, those events are really rare.

Makes sense?

Ciao,
Dscho

Thank You,
Sibi Siddharthan

#47 lore raw

Hi Dscho,

I guess this is a pain point having to manage two separate build systems. I will modify CMake script to get its sources from the Makefile.

Thank You,
Sibi Siddharthan

Quoted 82 lines · Johannes Schindelin

Hi Sibi,

Quoted 43 lines · Sibi Siddharthan
Quoted 32 lines · Johannes Schindelin
Quoted 7 lines · Sibi Siddharthan
Quoted 4 lines · Johannes Schindelin

We already use GIT-VERSION-GEN as the authoritative source for the Git version, by parsing the line that contains.

Quoted 8 lines
Quoted 4 lines

It would look very similar, at least in my mind, to generate the list of source/script files by parsing the Makefile.

Sibi, what do you think?

One way of doing it is to track if the Makefile is changed in a commit, run a hook to see if it contains any new OBJs and match it with the CMake script. But this is too much work, in my opinion.

Oh, sorry, I should have clarified: We already parse the DEF_VER=v2.26.GIT line in GIT-VERSION-GEN to determine the Git version.

We should be able to do the very exact same thing to parse the SCRIPT_SH lines like

        SCRIPT_SH += git-bisect.sh

in the Makefile to accumulate the list of shell scripts, and likewise the list of object files could be accumulated by parsing the LIB_OBJS lines like

Quoted 8 lines
        LIB_OBJS += abspath.o

(We would of course need to substitute the .o with .c, but that should be easy.)

That way, nobody will ever need to touch the CMakeLists.txt file when they add a new source file to libgit.a.

Quoted 7 lines

I understand what you are trying to say, this is not impossible to do but doing so will make the CMake script dependent on the Makefile for the sources. I am not fan of this approach.

We should write a separate script (say python) to match each of the sources in the Makefile and the CMake file automatically whenever the changes detected. This excludes the platform specific/compatibility stuff in config.mak.uname.

Hmm. That is an approach that _I_ don't like. Why duplicate the information when you don't have to?

I don't see any issue with keeping CMakeLists.txt dependent on Makefile. We could of course extract the lists into a separate file that is sourced both from the Makefile and from CMakeLists.txt, but that would actually not reflect that the Makefile _is_ authoritative. CMakeLists.txt will never be the authoritative source.

Ciao,
Dscho

Quoted 14 lines
Quoted 9 lines

I was not trying to auto-detect what sed invocation changed. Those changes _will_ need manual forward-porting to CMakeLists.txt. Thankfully, those events are really rare.

Makes sense?

Ciao,
Dscho

Thank You,
Sibi Siddharthan

#48 lore raw
Quoted 21 lines · Sibi Siddharthan

Hi Dscho,

I guess this is a pain point having to manage two separate build systems. I will modify CMake script to get its sources from the Makefile.

Quoted 16 lines
Quoted 7 lines

I understand what you are trying to say, this is not impossible to do but doing so will make the CMake script dependent on the Makefile for the sources. I am not fan of this approach.

We should write a separate script (say python) to match each of the sources in the Makefile and the CMake file automatically whenever the changes detected. This excludes the platform specific/compatibility stuff in config.mak.uname.

Hmm. That is an approach that _I_ don't like. Why duplicate the information when you don't have to?

I don't see any issue with keeping CMakeLists.txt dependent on Makefile. We could of course extract the lists into a separate file that is sourced both from the Makefile and from CMakeLists.txt, but that would actually not reflect that the Makefile _is_ authoritative. CMakeLists.txt will never be the authoritative source.

(This email is hard to be replied, because Sibi do top-posting. And, I want to quote both on this).

I'm still not a fan of CMake despite that I need to write it at previous $DAYJOBS.

I would like to keep Makefile as authoritative source of information, and to convince other developers, we need to keep Makefile as authoritative source of information. Let's say this way, I dislike it, but if it works for you, that's fine, just don't add more burden for existing people.

Remember that with CMake support, we will never able to use CMake generated build in-tree because we have an existing Makefile in-tree (not a problem since it's expected to be built out-of-tree if CMake is used), but please don't complain if it people accidentally break it. ./configure doesn't work correctly with --without-<pkg> and people seems to not interest in my series to respect it, for example.

When writing this, I intended to write something to support out-of-tree build with current Makefile. Hopefully, it won't be rocket science.

Last but not least, (this point was discussed with Sibi off-list) about our test infrastructure, when we add a new test, we can simply run:

make test

Makefile will pick it up, and run all tests just fine.

CMake's glob only works at CMake configuration time.
If there's a new test after CMake was run, and nothing changed in CMakeList.txt. The list generated by CMake will still be the same, ctest wouldn't know that there's a new test.
People need to manually run cmake again to pick it up (or as Sibi told me off-list, that developer is question can run by hand

	path/to/git/source/t/t-9999-true.sh

That's not a problem for the person write that test,
but it'll be problem for other people, who will fetch the new source to their own repo, and naively run msbuild and ctest.

It's analogue to this habit in git (me in my previous $DAYJOBS)

yes | git add -p

Anyway, get back to the solution (should this series be accepted), I think it'll work if we can split:

	SOURCE_FILES += cmake.c

into a source-list.mak

Then, cmake will do some magic with configure_file or something similar, IIRC, it's a reduced functionallity of sed.

Signature · 1 line
Danh
#49 lore raw
Quoted 36 lines · Danh Doan
Quoted 21 lines · Sibi Siddharthan

Hi Dscho,

I guess this is a pain point having to manage two separate build systems. I will modify CMake script to get its sources from the Makefile.

Quoted 16 lines
Quoted 7 lines

I understand what you are trying to say, this is not impossible to do but doing so will make the CMake script dependent on the Makefile for the sources. I am not fan of this approach.

We should write a separate script (say python) to match each of the sources in the Makefile and the CMake file automatically whenever the changes detected. This excludes the platform specific/compatibility stuff in config.mak.uname.

Hmm. That is an approach that _I_ don't like. Why duplicate the information when you don't have to?

I don't see any issue with keeping CMakeLists.txt dependent on Makefile. We could of course extract the lists into a separate file that is sourced both from the Makefile and from CMakeLists.txt, but that would actually not reflect that the Makefile _is_ authoritative. CMakeLists.txt will never be the authoritative source.

(This email is hard to be replied, because Sibi do top-posting. And, I want to quote both on this).

I'm still not a fan of CMake despite that I need to write it at previous $DAYJOBS.

I would like to keep Makefile as authoritative source of information, and to convince other developers, we need to keep Makefile as authoritative source of information. Let's say this way, I dislike it, but if it works for you, that's fine, just don't add more burden for existing people.

Quoted 7 lines

Remember that with CMake support, we will never able to use CMake generated build in-tree because we have an existing Makefile in-tree (not a problem since it's expected to be built out-of-tree if CMake is used), but please don't complain if it people accidentally break it. ./configure doesn't work correctly with --without-<pkg> and people seems to not interest in my series to respect it, for example.

To prevent the CMake script from overwriting the current Makefile, I can add a check at the beginning to stop the configure if the build is done in source.

Quoted 32 lines

When writing this, I intended to write something to support out-of-tree build with current Makefile. Hopefully, it won't be rocket science.

Last but not least, (this point was discussed with Sibi off-list) about our test infrastructure, when we add a new test, we can simply run:

make test

Makefile will pick it up, and run all tests just fine.

CMake's glob only works at CMake configuration time.
If there's a new test after CMake was run, and nothing changed in CMakeList.txt. The list generated by CMake will still be the same, ctest wouldn't know that there's a new test.
People need to manually run cmake again to pick it up (or as Sibi told me off-list, that developer is question can run by hand

        path/to/git/source/t/t-9999-true.sh

That's not a problem for the person write that test,
but it'll be problem for other people, who will fetch the new source to their own repo, and naively run msbuild and ctest.

It's analogue to this habit in git (me in my previous $DAYJOBS)

yes | git add -p

Anyway, get back to the solution (should this series be accepted), I think it'll work if we can split:

Quoted 7 lines
        SOURCE_FILES += cmake.c

into a source-list.mak

Then, cmake will do some magic with configure_file or something similar, IIRC, it's a reduced functionallity of sed.

Me and Dscho discussed that we will use the Makefile for getting the source list.
So we will basically parse the Makefile for the requires sourced to be used( in CMake itself).
So devs can just maintain the Makefile alone.
This approach works for
SCRIPT_SH
SCRIPT_LIB
SCRIPT_PERL
SCRIPT_PYTHON
TEST_BUILTINS_OBJS
LIB_OBJS
BUILTIN_OBJS
XDIFF_OBJS
VCSSVN_OBJS

PROGRAM_OBJS do not work, as a few of them link with curl and expat. As git-bugreport was added recently to the next branch. This should not be major issue I guess.

Quoted 2 lines

--
Danh

Thank You,
Sibi Siddharthan

#50 lore raw
In reply to Junio C Hamano

Hi Junio,

Quoted 11 lines · Junio C Hamano
Quoted 5 lines · Sibi Siddharthan

The goal would be to maintain a CMake build for Git keeping it in sync with the Makefile. The Makefile is not going to be replaced at all. The CMake script for now only supports Linux and Windows. It does not support BSD, Solaris and others, whereas the Makefile does support them.

So you are doing (1). I already said that I feel that engineering burden to divert resources for CMake support would be unacceptably high.

Would your position change if Sibi was interested in maintaining this, and helping with keeping CMake support in shape?

If you have a look at https://github.com/git-for-windows/git/pull/2580 and at https://github.com/gitgitgadget/git/pull/614, you will probably get the same impression as I: in contrast to earlier contributors who just talked about adding CMake support, Sibi went ahead and did it, and then polished the heck out of the patches, was very responsive and active.

I have a pretty good feeling about this.

Quoted 5 lines

Whenever any of our developers need to add source files, Makefile configuration knobs that people can add to config.mak, etc., you are forcing them to figure out where in the CMakefile to add them or devise ways to allow builders who do not use config.mak (because they use CMake) to do similar tweaks.

To be honest, I don't think that that happens all that often, and quite honestly, I think anybody who has had a look at the Makefile and at CMakeLists.txt will have a pretty good idea where new files should go.

Quoted 6 lines

Any patch that is acceptable to the current project would become unacceptable because they lack updates to CMake part, but I suspect we do not have enough people who are so much devoted to give a good review if updates to CMake part are added. And it is unclear why it would be beneficial to slow our existing developers down by forcing them to become familiar with CMake.

When it comes to new Makefile knobs, I do agree that it would place an unacceptable burden on contributors if we expected them to add the same knob to CMakeLists.txt. But we already don't do that for our autoconf support, so why would we expect it for CMake?

When it comes to adding new, and/or removing, files, I fail to see the problem. It is dead easy to keep the Makefile and CMakeLists.txt in sync when it comes to lists of files.

Another thing that strikes me as much more favorable this time as compared to earlier attempts at adding CMake support is that we now have pretty good automated builds that will definitely help with keeping CMake support up to date.

So now that I have covered the "it's not all that bad to maintain this" angle, let's cover the much more important part: "why would we even bother with this?". And that's pretty easy to answer for me: first-class Visual Studio support.

It is totally unacceptable to expect a contributor to download three quarters of a gigabyte and then let the Git for Windows SDK occupy around two full gigabytes on disk, just to get going. This is an upfront cost we currently expect from any developer on Windows, whether someone familiar with Visual Studio or more familiar with the command-line and GCC or not.

And guess what? Whenever I try to encourage a developer who uses Git and who is pretty good with C to "just check out the Git for Windows SDK, run make vcxproj, then load the generated Visual Studio solution and then start developing", the odds are really, really, really high that that's the last of it.

This is frustrating. And not only for me: Why should a contributor fight so hard just to get started, when all they want to do is to tinker with the code in order to see whether there is a chance that they can easily make it do what they want?

For some time now, I have an automated build which auto-generates the vs/master branch from Git for Windows' master branch, which has all of this preconfigured. But it is too hard to find, and it is definitely too hard to go from there to contributing the patches back to the Git project, so I think that maybe one contributor used that venue in the last years. One. Just one. That's very little return for the effort spent on getting Visual Studio support back to functional ever after it was broken with Visual Studio 2010's release. And it demonstrates a level of being uninviting that I am simply uncomfortable with.

There's more.

If you are a developer who feels at home in IDEs, running make in the command-line, and finding out about options in the Makefile and how to specify them on the command-line, is just very awkward. CMake recognizes this, and offers GUIs to configure the builds. So that's nice.

But there's more.

It would appear that in recent years, ARM64-based Windows laptops have made great progress. They are affordable, they are fast, and they have long battery life. If I could use and develop Git for Windows on one of these beauties, I would.

But I can't, because the obstacles to building Git on ARM64 Windows are just too high. The mingw-w64 version of GCC "does not really support" that. We have literally no ARM64 support whatsoever from MSYS2's side, i.e. no Bash, no Perl, no OpenSSH.

And then Sibi comes along and offers CMake support for Git.

CMake can target Visual Studio and clang. Both have pretty good support for ARM64 Windows.

So while this is not a complete solution for the ARM64 Windows problem, it is at least the most exciting opportunity in that regard that I have seen in _years_.

Given all these benefits, I would like to believe that the cost is rather minimal in comparison.

And that's coming from me, who is not a fan of CMake at all.

Quoted 3 lines

So..., I am not just "still not convinced", but I am even more convinced that we do not want this series, after thinking about it longer.

Of course, I do hope that I have convinced you above that it might not look all that bleak.

But even if I haven't, I would like to propose to run with Sibi's patches and merge them first to pu, and then to next, and let that cook for a while (I will merge them into Git for Windows early so that there is also some support stream from that side).

I know you think that the maintenance cost is too high, but I think it might be more than just manageable. And I don't think that the risk is too high to give the patches a try, at least inside next, for a couple of weeks or even months.

If it turns out that they _do_ add too much of a maintenance burden, big
deal: we just drop the patches, and that's that. No hard feelings, we gave it a try, a scientific test, if you want, and we now have evidence to back up your initial suspicion.

If it turns out that they _do_ add value _and_ are easy to maintain, then that's good, right? And then, at your leisurely leisure, you can merge them down to master and eventually into an official release.

What do you think? Doesn't that sound like a good plan?

Ciao,
Dscho

#51 lore raw
Quoted 6 lines · Johannes Schindelin
Quoted 6 lines
Quoted 5 lines

The goal would be to maintain a CMake build for Git keeping it in sync with the Makefile. The Makefile is not going to be replaced at all. The CMake script for now only supports Linux and Windows. It does not support BSD, Solaris and others, whereas the Makefile does support them.

Quoted 6 lines
Quoted 3 lines

So you are doing (1). I already said that I feel that engineering burden to divert resources for CMake support would be unacceptably high.

Would your position change if Sibi was interested in maintaining this, and helping with keeping CMake support in shape?

I have mixed feelings.

Imagine we say that the Makefile is the official build mechanism and that cmake support is a second-class citizen. I.e., somebody is willing to be the maintainer of that feature and port over changes for people who want to use cmake. That removes the issue of developers spending time dealing with a new make tool that they don't care about (and might not even have, or might not be available for their platform).

That's basically what we do with autoconf. But I haven't been all that pleased with the results. The autoconf code is frequently out-of-date or just plain wrong (e.g., the recent inet_ntop issues) and a frequent response to questions on the list is "have you tried just building without autoconf". I'm not sure if we are doing users a disservice to pretend that we have maintained autoconf support.

On the other hand, if it is helping people avoid turning Makefile knobs manually, we'd never hear complaints if it Just Works for some folks. So maybe autoconf is a necessary evil (evil from the perspective of developers, not users) that does pull its own weight.

Getting back to cmake: I can plausibly believe it's in the same boat. I don't have any interest in Visual Studio, but I can believe that it's an important convenience for some people / platforms, and that cmake is the best way to get there.

So if you are proposing to declare this as an experiment which will be maintained independently, and we can see how often it becomes a problem and how many people it helps, that makes more sense to me.

Skimming the patches, I do wish I didn't see so much repetition with the existing Makefile. I know that some of the logic will just have to be ported manually, but surely we could be pulling things like the list of libgit_SOURCES from the Makefile as the single source of truth?

Quoted 11 lines
Quoted 6 lines

Any patch that is acceptable to the current project would become unacceptable because they lack updates to CMake part, but I suspect we do not have enough people who are so much devoted to give a good review if updates to CMake part are added. And it is unclear why it would be beneficial to slow our existing developers down by forcing them to become familiar with CMake.

When it comes to new Makefile knobs, I do agree that it would place an unacceptable burden on contributors if we expected them to add the same knob to CMakeLists.txt. But we already don't do that for our autoconf support, so why would we expect it for CMake?

My concern here would be that the various knobs and behaviors are going to fall out of date, and nobody will notice. Because there aren't many cmake users, and because some of the logic is subtle (e.g., if it picked the wrong sha1-implementation default, who would notice?). But again, if we're willing to say "cmake support is an experiment" and let the maintenance burden fall to people who are interested, then we can at least have some data on how it works in practice.

Quoted 3 lines

When it comes to adding new, and/or removing, files, I fail to see the problem. It is dead easy to keep the Makefile and CMakeLists.txt in sync when it comes to lists of files.

It's _conceptually_ dead easy, but now there's a new tool and a new step people have to know about. Automated builds let you know when there's a problem, but somebody still has to fix it. I'd hope that basic stuff like file lists could be written so that there's no need to fix at all:
they'd just pull from the same source as the Makefile.

Quoted 15 lines

But even if I haven't, I would like to propose to run with Sibi's patches and merge them first to pu, and then to next, and let that cook for a while (I will merge them into Git for Windows early so that there is also some support stream from that side).

I know you think that the maintenance cost is too high, but I think it might be more than just manageable. And I don't think that the risk is too high to give the patches a try, at least inside next, for a couple of weeks or even months.

If it turns out that they _do_ add too much of a maintenance burden, big
deal: we just drop the patches, and that's that. No hard feelings, we gave it a try, a scientific test, if you want, and we now have evidence to back up your initial suspicion.

Quoted 5 lines

If it turns out that they _do_ add value _and_ are easy to maintain, then that's good, right? And then, at your leisurely leisure, you can merge them down to master and eventually into an official release.

What do you think? Doesn't that sound like a good plan?

I think what I'm suggesting is not all that different from this, except that I'd suspect "next" would not get enough exposure. So in my mind merging to master is not so much "hooray, we now have visual studio support" but rather the first step in getting data. But we'd have to be very clear about how the project regards the cmake support: it's there for now, you're encouraged to play with it, but don't be upset if it needs some coaxing to behave like the normal Makefile or if it goes away in the future.

-Peff

#52 lore raw
Quoted 4 lines · Jeff King

Skimming the patches, I do wish I didn't see so much repetition with the existing Makefile. I know that some of the logic will just have to be ported manually, but surely we could be pulling things like the list of libgit_SOURCES from the Makefile as the single source of truth?

Thinking I surely couldn't be the only one to think of this, I dug further into some of the sub-threads. And indeed, it seems like you are on the same page here.

IMHO it is worth making the cmake file depend as much as possible on what's in the Makefile.

-Peff

#53 lore raw
Quoted 7 lines · Jeff King
Quoted 4 lines · Jeff King

Skimming the patches, I do wish I didn't see so much repetition with the existing Makefile. I know that some of the logic will just have to be ported manually, but surely we could be pulling things like the list of libgit_SOURCES from the Makefile as the single source of truth?

Quoted 6 lines

Thinking I surely couldn't be the only one to think of this, I dug further into some of the sub-threads. And indeed, it seems like you are on the same page here.

IMHO it is worth making the cmake file depend as much as possible on what's in the Makefile.

Please correct me if I were wrong (I recall this from my memory without checking anything).

The worst thing about CMake is we can't override (Make's) variable in Makefile generated by CMake.

I've made some comment in Sibi's patch about some make's variable, because Sibi naively translates them from current Makefile. Namely, the location of some system configuration files, $(libexecdir) and build conditional macro.

With current Makefile, we can just:

make VAR=VALUE target

or:
echo "VAR=VALUE" >> config.mak
make target

With cmake, we need to define all of them as CMake options (this will brings along a big burden), whenever we need to change any options, we need to (assume that cmake generates Makefile):

cmake -DVAR=VALUE path/to/src/dir
make target

How many make variables that we need to define in CMakeList.txt, I don't know.

Signature · 1 line
Danh
#54 lore raw
Quoted 12 lines · Danh Doan
Quoted 11 lines · Jeff King
Quoted 4 lines · Jeff King

Skimming the patches, I do wish I didn't see so much repetition with the existing Makefile. I know that some of the logic will just have to be ported manually, but surely we could be pulling things like the list of libgit_SOURCES from the Makefile as the single source of truth?

Thinking I surely couldn't be the only one to think of this, I dug further into some of the sub-threads. And indeed, it seems like you are on the same page here.

Quoted 8 lines
Quoted 2 lines

IMHO it is worth making the cmake file depend as much as possible on what's in the Makefile.

Please correct me if I were wrong (I recall this from my memory without checking anything).

The worst thing about CMake is we can't override (Make's) variable in Makefile generated by CMake.

I really don't know enough about cmake to say one way or the other. I can well believe there are parts of the Makefile that will need to be manually translated, and that it may not ever hit full parity.

But as long as it just a tool for people using Visual Studio, and if they are happier being able to use that tool, even with a few deficiencies, then it may still be worth doing.

-Peff

#55 lore raw

Adding the CMake script to contrib/buildsystem is a good option. Is there any changes (apart from the CMakeLists.txt critique and) that I have to do on my part?

Thank You,
Sibi Siddharthan

Quoted 33 lines · Jeff King
Quoted 12 lines · Danh Doan
Quoted 11 lines · Jeff King
Quoted 4 lines · Jeff King

Skimming the patches, I do wish I didn't see so much repetition with the existing Makefile. I know that some of the logic will just have to be ported manually, but surely we could be pulling things like the list of libgit_SOURCES from the Makefile as the single source of truth?

Thinking I surely couldn't be the only one to think of this, I dug further into some of the sub-threads. And indeed, it seems like you are on the same page here.

Quoted 8 lines
Quoted 2 lines

IMHO it is worth making the cmake file depend as much as possible on what's in the Makefile.

Please correct me if I were wrong (I recall this from my memory without checking anything).

The worst thing about CMake is we can't override (Make's) variable in Makefile generated by CMake.

I really don't know enough about cmake to say one way or the other. I can well believe there are parts of the Makefile that will need to be manually translated, and that it may not ever hit full parity.

But as long as it just a tool for people using Visual Studio, and if they are happier being able to use that tool, even with a few deficiencies, then it may still be worth doing.

-Peff

#56 lore raw

Hi Sibi,

[please avoid top-posting on this list, but do reply inline instead, that is much preferred.]

Quoted 1 line · Sibi Siddharthan

Adding the CMake script to contrib/buildsystem is a good option.

I'd actually prefer it to live in a different subdirectory: what is in contrib/buildsystem/ uses the technique of running make in a dry-run mode, parsing the output, and then generating project files. But that is not what CMakeLists.txt is about.

How about contrib/cmake/?

Quoted 2 lines

Is there any changes (apart from the CMakeLists.txt critique and) that I have to do on my part?

No, I think that's it!

Thanks,
Dscho

Quoted 39 lines

Thank You,
Sibi Siddharthan

Quoted 33 lines · Jeff King
Quoted 12 lines · Danh Doan
Quoted 11 lines · Jeff King
Quoted 4 lines · Jeff King

Skimming the patches, I do wish I didn't see so much repetition with the existing Makefile. I know that some of the logic will just have to be ported manually, but surely we could be pulling things like the list of libgit_SOURCES from the Makefile as the single source of truth?

Thinking I surely couldn't be the only one to think of this, I dug further into some of the sub-threads. And indeed, it seems like you are on the same page here.

Quoted 8 lines
Quoted 2 lines

IMHO it is worth making the cmake file depend as much as possible on what's in the Makefile.

Please correct me if I were wrong (I recall this from my memory without checking anything).

The worst thing about CMake is we can't override (Make's) variable in Makefile generated by CMake.

I really don't know enough about cmake to say one way or the other. I can well believe there are parts of the Makefile that will need to be manually translated, and that it may not ever hit full parity.

But as long as it just a tool for people using Visual Studio, and if they are happier being able to use that tool, even with a few deficiencies, then it may still be worth doing.

-Peff

#57 lore raw
Quoted 8 lines · Johannes Schindelin

Hi Sibi,

[please avoid top-posting on this list, but do reply inline instead, that is much preferred.]

On Wed, 29 Apr 2020, Sibi Siddharthan wrote:

Quoted 9 lines
Quoted 1 line

Adding the CMake script to contrib/buildsystem is a good option.

I'd actually prefer it to live in a different subdirectory: what is in contrib/buildsystem/ uses the technique of running make in a dry-run mode, parsing the output, and then generating project files. But that is not what CMakeLists.txt is about.

How about contrib/cmake/?

The CMakeLists.txt will be non-functional if it in any other directory except the root source directory. To help users we can,
add some instructions in INSTALL on how to use the script.
OR
create a dummy CMakeLists.txt in the root directory which just says
message("Copy and Replace the CMakeLists from whatever-folder to here") along with some instructions if necessary. This is what LLVM does for autoconf.

Thank You,
Sibi Siddharthan

Quoted 47 lines
Quoted 2 lines

Is there any changes (apart from the CMakeLists.txt critique and) that I have to do on my part?

No, I think that's it!

Thanks,
Dscho

Quoted 39 lines

Thank You,
Sibi Siddharthan

Quoted 33 lines · Jeff King
Quoted 12 lines · Danh Doan
Quoted 11 lines · Jeff King
Quoted 4 lines · Jeff King

Skimming the patches, I do wish I didn't see so much repetition with the existing Makefile. I know that some of the logic will just have to be ported manually, but surely we could be pulling things like the list of libgit_SOURCES from the Makefile as the single source of truth?

Thinking I surely couldn't be the only one to think of this, I dug further into some of the sub-threads. And indeed, it seems like you are on the same page here.

Quoted 8 lines
Quoted 2 lines

IMHO it is worth making the cmake file depend as much as possible on what's in the Makefile.

Please correct me if I were wrong (I recall this from my memory without checking anything).

The worst thing about CMake is we can't override (Make's) variable in Makefile generated by CMake.

I really don't know enough about cmake to say one way or the other. I can well believe there are parts of the Makefile that will need to be manually translated, and that it may not ever hit full parity.

But as long as it just a tool for people using Visual Studio, and if they are happier being able to use that tool, even with a few deficiencies, then it may still be worth doing.

-Peff

#58 lore raw

On May 2, 2020 10:32 AM, Sibi Siddharthan Wrote:

Quoted 57 lines
Quoted 11 lines · Johannes Schindelin
Quoted 1 line · Sibi Siddharthan

Adding the CMake script to contrib/buildsystem is a good option.

I'd actually prefer it to live in a different subdirectory: what is in contrib/buildsystem/ uses the technique of running make in a dry-run mode, parsing the output, and then generating project files. But that is not what CMakeLists.txt is about.

How about contrib/cmake/?

The CMakeLists.txt will be non-functional if it in any other directory except the root source directory. To help users we can, add some instructions in INSTALL on how to use the script.
OR
create a dummy CMakeLists.txt in the root directory which just says message("Copy and Replace the CMakeLists from whatever-folder to here") along with some instructions if necessary. This is what LLVM does for autoconf.

Quoted 23 lines
Quoted 2 lines

Is there any changes (apart from the CMakeLists.txt critique and) that I have to do on my part?

No, I think that's it!

Thanks,
Dscho

Quoted 15 lines

Thank You,
Sibi Siddharthan

Quoted 10 lines · Jeff King
Quoted 7 lines · Danh Doan
Quoted 6 lines · Jeff King
Quoted 4 lines · Jeff King

Skimming the patches, I do wish I didn't see so much repetition with the existing Makefile. I know that some of the logic will just have to be ported manually, but surely we could be pulling things like the list of libgit_SOURCES from the

Makefile as the single source of truth?

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 7 lines

Thinking I surely couldn't be the only one to think of this, I dug further into some of the sub-threads. And indeed, it seems like you are on the same page here.

IMHO it is worth making the cmake file depend as much as possible on what's in the Makefile.

Please correct me if I were wrong (I recall this from my memory without checking anything).

Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

The worst thing about CMake is we can't override (Make's) variable in Makefile generated by CMake.

I really don't know enough about cmake to say one way or the other. I can well believe there are parts of the Makefile that will need to be manually translated, and that it may not ever hit full

parity.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

But as long as it just a tool for people using Visual Studio, and if they are happier being able to use that tool, even with a few deficiencies, then it may still be worth doing.

-Peff

Just a head's up that neither the HPE NonStop OSS nor IBM z/OS USS platforms currently have any support for CMake nor do I expect any support in the foreseeable future. We are seeing very strong adoption rates on both platforms (sorry, cannot share statistics at this time).

Regards,
Randall

-- Brief whoami:
NonStop developer since approximately 211288444200000000 UNIX developer since approximately 421664400
-- In my real life, I talk too much.

#59 lore raw
In reply to Sibi Siddharthan
Quoted 11 lines · Sibi Siddharthan
Quoted 2 lines

How about contrib/cmake/?

The CMakeLists.txt will be non-functional if it in any other directory except the root source directory. To help users we can,
add some instructions in INSTALL on how to use the script.
OR
create a dummy CMakeLists.txt in the root directory which just says
message("Copy and Replace the CMakeLists from whatever-folder to here") along with some instructions if necessary. This is what LLVM does for autoconf.

Isn't there a corresponding feature to make's "-f" option to specify which file to read instructions from?

As you say, an extra instruction in INSTALL file to tell users to copy from contrib/cmake may workable, though it is unsatisfactory. But the other one will not simply work. If we need to have a new file with string "CMake" in its name at the top-level *anyway*, we should have the real thing to reduce one step from those who want to use it. Those who do not want to see "CMake" at the toplevel are already harmed either way, if is a dummy or if it is the real thing.

Thanks.

#60 lore raw
Quoted 15 lines · Junio C Hamano
Quoted 11 lines · Sibi Siddharthan
Quoted 2 lines

How about contrib/cmake/?

The CMakeLists.txt will be non-functional if it in any other directory except the root source directory. To help users we can,
add some instructions in INSTALL on how to use the script.
OR
create a dummy CMakeLists.txt in the root directory which just says
message("Copy and Replace the CMakeLists from whatever-folder to here") along with some instructions if necessary. This is what LLVM does for autoconf.

Quoted 2 lines

Isn't there a corresponding feature to make's "-f" option to specify which file to read instructions from?

Sadly, CMake expects CMakeLists.txt only, nothing else.

Quoted 8 lines

As you say, an extra instruction in INSTALL file to tell users to copy from contrib/cmake may workable, though it is unsatisfactory. But the other one will not simply work. If we need to have a new file with string "CMake" in its name at the top-level *anyway*, we should have the real thing to reduce one step from those who want to use it. Those who do not want to see "CMake" at the toplevel are already harmed either way, if is a dummy or if it is the real thing.

In your opinion, what would be the best way to communicate with users, there is an optional CMake build system for git?

Thank You,
Sibi Siddharthan

Quoted 2 lines

Thanks.

#61 lore raw
Quoted 10 lines · Sibi Siddharthan
Quoted 7 lines

As you say, an extra instruction in INSTALL file to tell users to copy from contrib/cmake may workable, though it is unsatisfactory. But the other one will not simply work. If we need to have a new file with string "CMake" in its name at the top-level *anyway*, we should have the real thing to reduce one step from those who want to use it. Those who do not want to see "CMake" at the toplevel are already harmed either way, if is a dummy or if it is the real thing.

In your opinion, what would be the best way to communicate with users, there is an optional CMake build system for git?

You do not want to hear my opinion, as my priorities would be different from yours ;-)

Given that we all agreed that the only reason we contemplate use of CMake in our project is strictly to help Windows build, i.e. due to the same reason why we have contrib/buildsystems/, it is not one of my goals to communicate with general users about optional CMake support in the first place. It has lower priority than keeping the project tree and the project history less cluttered.

So my first preference would be an instruction somewhere in install or readme that tells those who want to build for windows to copy from (or perhaps update cmake to offer the "-f" option and tell it to read from) contrib/cmake/CMakeLists.txt to the toplevel before doing anything [*1*].

If there are many people who want to help the cmake effort, however, shipping a real CMakeLists.txt at the top-level of the tree, with all the instructions at the beginning of *that* file, would be an easier way for them to discover and polish. It would also be my preference but only under the "if there are many people" condition.

Thanks.

[Footnote]

*1* It probably is too error prone to tell people who do the real
work to "copy", as they are prone to modify the copy and forget updating the source. So the instruction may tell them to create a symlink at the toplevel that points to the real file in the contrib/cmake/ directory, or if the filesystem does not support symbolic links (which is very likely given the target audience of this are all on Windows), tell them copy a small skeleton file that is also shipped in contrib/cmake/ directory to the top-level. That skeleton file would "include" the real thing that lives in contrib/cmake/ directory (I am assuming that CMakeLists.txt can include other CMakeLists.txt file here).

#62 lore raw

03.05.2020, 20:21, "Junio C Hamano" <[email protected]>:

Quoted 23 lines
Quoted 10 lines · Sibi Siddharthan
Quoted 7 lines

 As you say, an extra instruction in INSTALL file to tell users to copy from contrib/cmake may workable, though it is unsatisfactory. But the other one will not simply work. If we need to have a new file with string "CMake" in its name at the top-level *anyway*, we should have the real thing to reduce one step from those who want to use it. Those who do not want to see "CMake" at the toplevel are already harmed either way, if is a dummy or if it is the real thing.

 In your opinion, what would be the best way to communicate with users, there is an optional CMake build system for git?

You do not want to hear my opinion, as my priorities would be different from yours ;-)

Given that we all agreed that the only reason we contemplate use of CMake in our project is strictly to help Windows build, i.e. due to the same reason why we have contrib/buildsystems/, it is not one of my goals to communicate with general users about optional CMake support in the first place. It has lower priority than keeping the project tree and the project history less cluttered.

Quoted 5 lines

So my first preference would be an instruction somewhere in install or readme that tells those who want to build for windows to copy from (or perhaps update cmake to offer the "-f" option and tell it to read from) contrib/cmake/CMakeLists.txt to the toplevel before doing anything [*1*].

FWIW, CMakeLists.txt doesn't have to be in the root of source tree in order to work. It can perfectly work from contrib/cmake after necessary changes in relative paths.

Quoted 22 lines

If there are many people who want to help the cmake effort, however, shipping a real CMakeLists.txt at the top-level of the tree, with all the instructions at the beginning of *that* file, would be an easier way for them to discover and polish. It would also be my preference but only under the "if there are many people" condition.

Thanks.

[Footnote]

*1* It probably is too error prone to tell people who do the real work to "copy", as they are prone to modify the copy and forget updating the source. So the instruction may tell them to create a symlink at the toplevel that points to the real file in the contrib/cmake/ directory, or if the filesystem does not support symbolic links (which is very likely given the target audience of this are all on Windows), tell them copy a small skeleton file that is also shipped in contrib/cmake/ directory to the top-level. That skeleton file would "include" the real thing that lives in contrib/cmake/ directory (I am assuming that CMakeLists.txt can include other CMakeLists.txt file here).

Signature · 2 lines
Regards,
Konstantin
#63 lore raw
Quoted 3 lines · Konstantin Tokarev

FWIW, CMakeLists.txt doesn't have to be in the root of source tree in order to work. It can perfectly work from contrib/cmake after necessary changes in relative paths.

That's great to know---perhaps you can work with Sibi to help whipping the CMakeLists.txt into shape, placing it in contrib/cmake/ directory?

When that is in place, my answer to Sibi's question, i.e. "what is the best way to tell users they can use CMake for their Windows build?" would be "the same way as we advertise contrib/buildsystems and/or compat/vcbuild to them", I think.

Thanks.

#64 lore raw
In reply to Konstantin Tokarev

Hi Konst,

Quoted 32 lines · Konstantin Tokarev

03.05.2020, 20:21, "Junio C Hamano" <[email protected]>:

Quoted 23 lines
Quoted 10 lines · Sibi Siddharthan
Quoted 7 lines

 As you say, an extra instruction in INSTALL file to tell users to copy from contrib/cmake may workable, though it is unsatisfactory. But the other one will not simply work. If we need to have a new file with string "CMake" in its name at the top-level *anyway*, we should have the real thing to reduce one step from those who want to use it. Those who do not want to see "CMake" at the toplevel are already harmed either way, if is a dummy or if it is the real thing.

 In your opinion, what would be the best way to communicate with users, there is an optional CMake build system for git?

You do not want to hear my opinion, as my priorities would be different from yours ;-)

Given that we all agreed that the only reason we contemplate use of CMake in our project is strictly to help Windows build, i.e. due to the same reason why we have contrib/buildsystems/, it is not one of my goals to communicate with general users about optional CMake support in the first place. It has lower priority than keeping the project tree and the project history less cluttered.

Quoted 5 lines

So my first preference would be an instruction somewhere in install or readme that tells those who want to build for windows to copy from (or perhaps update cmake to offer the "-f" option and tell it to read from) contrib/cmake/CMakeLists.txt to the toplevel before doing anything [*1*].

Quoted 3 lines

FWIW, CMakeLists.txt doesn't have to be in the root of source tree in order to work. It can perfectly work from contrib/cmake after necessary changes in relative paths.

Would you have an example handy, or a link to an article describing this?

Ciao,
Johannes

#65 lore raw

05.05.2020, 00:32, "Johannes Schindelin" <[email protected]>:

Quoted 34 lines

Hi Konst,

Quoted 30 lines · Konstantin Tokarev

 03.05.2020, 20:21, "Junio C Hamano" <[email protected]>:
 > Sibi Siddharthan <[email protected]> writes:
 >
 >>>  As you say, an extra instruction in INSTALL file to tell users to >>>  copy from contrib/cmake may workable, though it is unsatisfactory. >>>  But the other one will not simply work. If we need to have a new >>>  file with string "CMake" in its name at the top-level *anyway*, we >>>  should have the real thing to reduce one step from those who want to >>>  use it. Those who do not want to see "CMake" at the toplevel are >>>  already harmed either way, if is a dummy or if it is the real thing. >>
 >>  In your opinion, what would be the best way to communicate with users, there is >>  an optional CMake build system for git?
 >
 > You do not want to hear my opinion, as my priorities would be
 > different from yours ;-)
 >
 > Given that we all agreed that the only reason we contemplate use of > CMake in our project is strictly to help Windows build, i.e. due to > the same reason why we have contrib/buildsystems/, it is not one of > my goals to communicate with general users about optional CMake
 > support in the first place. It has lower priority than keeping the > project tree and the project history less cluttered.
 >
 > So my first preference would be an instruction somewhere in install > or readme that tells those who want to build for windows to copy
 > from (or perhaps update cmake to offer the "-f" option and tell it > to read from) contrib/cmake/CMakeLists.txt to the toplevel before
 > doing anything [*1*].

Quoted 5 lines
Quoted 3 lines

 FWIW, CMakeLists.txt doesn't have to be in the root of source tree in order to work. It can perfectly work from contrib/cmake after necessary changes in relative paths.

Would you have an example handy, or a link to an article describing this?

It's so trivial that I'm not sure what such an article would have to describe.

https://github.com/annulen/cmake-example

Signature · 2 lines
Regards,
Konstantin
#66 lore raw
Quoted 42 lines · Konstantin Tokarev

05.05.2020, 00:32, "Johannes Schindelin" <[email protected]>:

Quoted 38 lines

Hi Konst,

Quoted 33 lines · Konstantin Tokarev

03.05.2020, 20:21, "Junio C Hamano" <[email protected]>:

Quoted 23 lines
Quoted 10 lines · Sibi Siddharthan
Quoted 7 lines

As you say, an extra instruction in INSTALL file to tell users to

 copy from contrib/cmake may workable, though it is unsatisfactory.

But the other one will not simply work. If we need to have a new file with string "CMake" in its name at the top-level *anyway*, we should have the real thing to reduce one step from those who want to use it. Those who do not want to see "CMake" at the toplevel are already harmed either way, if is a dummy or if it is the real thing.

In your opinion, what would be the best way to communicate with users, there is an optional CMake build system for git?

You do not want to hear my opinion, as my priorities would be different from yours ;-)

Given that we all agreed that the only reason we contemplate use of CMake in our project is strictly to help Windows build, i.e. due to the same reason why we have contrib/buildsystems/, it is not one of my goals to communicate with general users about optional CMake support in the first place. It has lower priority than keeping the project tree and the project history less cluttered.

Quoted 5 lines

So my first preference would be an instruction somewhere in install or readme that tells those who want to build for windows to copy from (or perhaps update cmake to offer the "-f" option and tell it to read from) contrib/cmake/CMakeLists.txt to the toplevel before doing anything [*1*].

FWIW, CMakeLists.txt doesn't have to be in the root of source tree in order to work. It can perfectly work from contrib/cmake after necessary changes in relative paths.

Quoted 6 lines
Quoted 1 line

Would you have an example handy, or a link to an article describing this?

It's so trivial that I'm not sure what such an article would have to describe.

https://github.com/annulen/cmake-example

Yes, this is trivial, but doing so is bad practice in general and difficult to maintain.
Won't it be better just to copy the CMakeLists.txt to the root directory for configuring.

Thank You,
Sibi Siddharthan

Quoted 4 lines

--
Regards,
Konstantin

#67 lore raw
Quoted 2 lines · Sibi Siddharthan

Yes, this is trivial, but doing so is bad practice in general and difficult to maintain.

Can you substantiate "bad" and "difficult" in the above sentence?

They are so subjective words and sounds more of your "opinion" than generally accepted "fact".

Quoted 2 lines

Won't it be better just to copy the CMakeLists.txt to the root directory for configuring.

I do not know it is better or not compared to using directly from a subdirectory. But it is easy to see that it is a bad practice to keep the source of truth in contrib/cmake/CMakeLists.txt and use it by copying it to the top of the working tree.

The reason would be obvious once you imagine what happens when those who are helping to improve CMake support find that they need to make changes. It is too easy to edit the one they copied to the top of the working tree until they manage to get it working, and then forget to copy it back to contrib/cmake/ before committing the change [*1*].

Compared to that, the way Konstantin showed, which is just to be at the top of the working tree and run the cmake command with a single argument, which is the path to the CMakeList.txt file, looked quite simple and straight-forward to an untrained eye that hsan't seen a real use of CMake. But there must be reasons, coming from lessons learned by using CMake with a CMakeList.txt file in a subdirectory and suffering the consequences of doing so, that makes you say it is a bad practice and difficult to maintain. It needs to be spelled out to help those who do not know CMake understand.

Thanks.

[Footnote]

*1* Creating a symlink CMakeLists.txt at the top of the working tree that points into contrib/cmake/CMakeLists.txt (and it needs to be done only once) would avoid such a problem, but if your filesystem does not let you use a symlink, copying a skeletal CMakeLists.txt that nobody is expected to modify to the top of the working tree might be an acceptable workaround. The sole purpose of that skeletal CMakeLists.txt at the top of the working tree would be to include the "real" thing in contrib/cmake/ directory (I am assuming that CMake is capable of including a CMakeLists.txt file that exists elsewhere in another CMakeLists.txt file).

With either of these arrangements, it is much less likely for the user to accidentally edit a "wrong" copy and forgets to update the real thing---the real thing stored in contrib/cmake will be the only one that would be edited.

#68 lore raw

Hi there,

I have made the following changes as suggested:
1) The CMake script works from contrib/cmake now.
2) The CMake script parses the Makefile for
SCRIPT_SH
SCRIPT_PERL
TEST_BUILTINS_OBJS
LIB_OBJS
BUILTIN_OBJS
XDIFF_OBJS
VCSSVN_OBJS
3) Philip suggested to change the error message if sh/bash was not found on windows.
4) CMake now tests for ICONV_OMITS_BOM, NO_ST_BLOCKS_IN_STRUCT_STAT.

Regarding the commits, since 1,2,4 are additions to the script, is it acceptable for those changes to be staged in the next commits? Regarding the workflow file(main.yml), I modified the vs-build and test steps, should I drop the commit or should I keep the changes(a modification is further needed if CMake is going to be used for vs-build)

Thank You,
Sibi Siddharthan

#69 lore raw
Quoted 14 lines · Sibi Siddharthan

I have made the following changes as suggested:
1) The CMake script works from contrib/cmake now.
2) The CMake script parses the Makefile for
SCRIPT_SH
SCRIPT_PERL
TEST_BUILTINS_OBJS
LIB_OBJS
BUILTIN_OBJS
XDIFF_OBJS
VCSSVN_OBJS
3) Philip suggested to change the error message if sh/bash was not found on windows.
4) CMake now tests for ICONV_OMITS_BOM, NO_ST_BLOCKS_IN_STRUCT_STAT.

Quoted 2 lines

Regarding the commits, since 1,2,4 are additions to the script, is it acceptable for those changes to be staged in the next commits?

I am not sure what you exactly mean by "to be staged in the next commits". But as a new topic (from the point of view of the general public), please avoid adding a known-broken one in patch 1 and then following up with a series of "oops, that was wrong and here is to fix the breakage" patches.

On the other hand, if the final contents added by the resulting topic is easier to explain and review if built incrementally in logical steps, please do so. In other words, a series of follow up "now we have basics there, teach the machinery to do this, too" patches is perfectly fine, as opposed to "oops, that was wrong and here is to fix".

Quoted 4 lines

Regarding the workflow file(main.yml), I modified the vs-build and test steps, should I drop the commit or should I keep the changes(a modification is further needed if CMake is going to be used for vs-build)

It sounds like an integral part of the end result we would want to get out of this series, so if that is the case, I do not see a reason to exclude it.

Thanks.

#70 lore raw
Quoted 26 lines · Junio C Hamano
Quoted 14 lines · Sibi Siddharthan

I have made the following changes as suggested:
1) The CMake script works from contrib/cmake now.
2) The CMake script parses the Makefile for
SCRIPT_SH
SCRIPT_PERL
TEST_BUILTINS_OBJS
LIB_OBJS
BUILTIN_OBJS
XDIFF_OBJS
VCSSVN_OBJS
3) Philip suggested to change the error message if sh/bash was not found on windows.
4) CMake now tests for ICONV_OMITS_BOM, NO_ST_BLOCKS_IN_STRUCT_STAT.

Quoted 2 lines

Regarding the commits, since 1,2,4 are additions to the script, is it acceptable for those changes to be staged in the next commits?

I am not sure what you exactly mean by "to be staged in the next commits". But as a new topic (from the point of view of the general public), please avoid adding a known-broken one in patch 1 and then following up with a series of "oops, that was wrong and here is to fix the breakage" patches.

Quoted 7 lines

On the other hand, if the final contents added by the resulting topic is easier to explain and review if built incrementally in logical steps, please do so. In other words, a series of follow up "now we have basics there, teach the machinery to do this, too" patches is perfectly fine, as opposed to "oops, that was wrong and here is to fix".

2 and 4 are additions to the capability of the script, which means they have to be added
as separate commits (between 7/8 and 8/8).

3 is clearly an edit (fixup 6/8)

I am confused for 1 though.
I think it would be better to add it as a new commit (between 7/8 and 8/8). Is this acceptable?

Thank You,
Sibi Siddharthan

Quoted 10 lines
Quoted 4 lines

Regarding the workflow file(main.yml), I modified the vs-build and test steps, should I drop the commit or should I keep the changes(a modification is further needed if CMake is going to be used for vs-build)

It sounds like an integral part of the end result we would want to get out of this series, so if that is the case, I do not see a reason to exclude it.

Thanks.

#71 lore raw
Quoted 9 lines · Sibi Siddharthan
Quoted 5 lines · Junio C Hamano
Quoted 2 lines · Sibi Siddharthan

I have made the following changes as suggested:
1) The CMake script works from contrib/cmake now.

I am confused for 1 though.
I think it would be better to add it as a new commit (between 7/8 and 8/8). Is this acceptable?

Please make CMake works from contrib/cmake from the first patch in the series.

Signature · 1 line
Danh
#72 lore raw
In reply to Sibi Siddharthan

Hi Sibi,

Quoted 16 lines · Sibi Siddharthan

Hi there,

I have made the following changes as suggested:
1) The CMake script works from contrib/cmake now.
2) The CMake script parses the Makefile for
SCRIPT_SH
SCRIPT_PERL
TEST_BUILTINS_OBJS
LIB_OBJS
BUILTIN_OBJS
XDIFF_OBJS
VCSSVN_OBJS
3) Philip suggested to change the error message if sh/bash was not found on windows.
4) CMake now tests for ICONV_OMITS_BOM, NO_ST_BLOCKS_IN_STRUCT_STAT.

Quoted 6 lines

Regarding the commits, since 1,2,4 are additions to the script, is it acceptable for those changes to be staged in the next commits? Regarding the workflow file(main.yml), I modified the vs-build and test steps, should I drop the commit or should I keep the changes(a modification is further needed if CMake is going to be used for vs-build)

Yes, I think it will be crucial to use CMake for vs-build, to keep the CMake support functional.

Ciao,
Dscho

#73 lore raw
In reply to Konstantin Tokarev

Hi Konst,

Quoted 39 lines · Konstantin Tokarev

05.05.2020, 00:32, "Johannes Schindelin" <[email protected]>:

Quoted 38 lines

Hi Konst,

Quoted 33 lines · Konstantin Tokarev

 03.05.2020, 20:21, "Junio C Hamano" <[email protected]>:
 > Sibi Siddharthan <[email protected]> writes:
 >
 >>>  As you say, an extra instruction in INSTALL file to tell users to >>>  copy from contrib/cmake may workable, though it is unsatisfactory. >>>  But the other one will not simply work. If we need to have a new >>>  file with string "CMake" in its name at the top-level *anyway*, we >>>  should have the real thing to reduce one step from those who want to >>>  use it. Those who do not want to see "CMake" at the toplevel are >>>  already harmed either way, if is a dummy or if it is the real thing. >>
 >>  In your opinion, what would be the best way to communicate with users, there is >>  an optional CMake build system for git?
 >
 > You do not want to hear my opinion, as my priorities would be
 > different from yours ;-)
 >
 > Given that we all agreed that the only reason we contemplate use of > CMake in our project is strictly to help Windows build, i.e. due to > the same reason why we have contrib/buildsystems/, it is not one of > my goals to communicate with general users about optional CMake
 > support in the first place. It has lower priority than keeping the > project tree and the project history less cluttered.
 >
 > So my first preference would be an instruction somewhere in install > or readme that tells those who want to build for windows to copy
 > from (or perhaps update cmake to offer the "-f" option and tell it > to read from) contrib/cmake/CMakeLists.txt to the toplevel before
 > doing anything [*1*].

 FWIW, CMakeLists.txt doesn't have to be in the root of source tree in order to work. It can perfectly work from contrib/cmake after necessary changes in relative paths.

Quoted 5 lines
Quoted 1 line

Would you have an example handy, or a link to an article describing this?

It's so trivial that I'm not sure what such an article would have to describe.

https://github.com/annulen/cmake-example

It is trivial all right, but I had hoped for a more elegant solution along the lines of set_top_level_directory(../..) or some such. I mistook your mail for having an elegant version of this, and I was curious.

Ciao,
Johannes

Quoted 5 lines

--
Regards,
Konstantin

#74 lore raw
In reply to Sibi Siddharthan

Hi Sibi,

Quoted 10 lines · Sibi Siddharthan
Quoted 10 lines
Quoted 5 lines

Please correct me if I were wrong (I recall this from my memory without checking anything).

The worst thing about CMake is we can't override (Make's) variable in Makefile generated by CMake.

I really don't know enough about cmake to say one way or the other. I can well believe there are parts of the Makefile that will need to be manually translated, and that it may not ever hit full parity.

Quoted 6 lines
Quoted 3 lines

But as long as it just a tool for people using Visual Studio, and if they are happier being able to use that tool, even with a few deficiencies, then it may still be worth doing.

Adding the CMake script to contrib/buildsystem is a good option. Is there any changes (apart from the CMakeLists.txt critique and) that I have to do on my part?

(Sorry for this late reply, it's holiday over here).

It's long time since last time I worked with CMake, but I have some suggestion, maybe it was written in my previous comment, maybe not.

- If we could find anything in CMake that equivalent with sysconfdir in autotools, please use it for configuration files instead of relative to CMAKE_INSTALL_PREFIX
- I'll change (this and alikes)
find_program(SH_PATH, "sh")
with:
option(SHELL_PATH "path to POSIX compliance shell" "/bin/sh")
in order to support Solaris people, should they want to try CMake
- I'll wrap the incompatible option of gettext under uname check
- and remove ${} around variable in if

Signature · 1 line
Danh
#75 lore raw
Quoted 21 lines · Danh Doan

Hi Sibi,

Quoted 10 lines · Sibi Siddharthan
Quoted 10 lines
Quoted 5 lines

Please correct me if I were wrong (I recall this from my memory without checking anything).

The worst thing about CMake is we can't override (Make's) variable in Makefile generated by CMake.

I really don't know enough about cmake to say one way or the other. I can well believe there are parts of the Makefile that will need to be manually translated, and that it may not ever hit full parity.

Quoted 6 lines
Quoted 3 lines

But as long as it just a tool for people using Visual Studio, and if they are happier being able to use that tool, even with a few deficiencies, then it may still be worth doing.

Adding the CMake script to contrib/buildsystem is a good option. Is there any changes (apart from the CMakeLists.txt critique and) that I have to do on my part?

Quoted 8 lines

(Sorry for this late reply, it's holiday over here).

It's long time since last time I worked with CMake, but I have some suggestion, maybe it was written in my previous comment, maybe not.

- If we could find anything in CMake that equivalent with sysconfdir in autotools, please use it for configuration files instead of relative to CMAKE_INSTALL_PREFIX

The module GNUInstallDirs does what you ask.

Quoted 8 lines

- I'll change (this and alikes)

        find_program(SH_PATH, "sh")

with:
option(SHELL_PATH "path to POSIX compliance shell" "/bin/sh")
in order to support Solaris people, should they want to try CMake
- I'll wrap the incompatible option of gettext under uname check
- and remove ${} around variable in if

The thing with options in cmake is the values it takes are boolean only. To do what you want I think you have to do something along the lines of this. if(NOT DEFINED SHELL_PATH)
set(SHELL_PATH <default value> CACHE STRING "path to POSIX compliance shell") endif()

Then if you want to change this value, edit this value in CMakeCache.txt.

Thank You,
Sibi Siddharthan

Quoted 2 lines

--
Danh

#76 lore raw
Quoted 8 lines · Sibi Siddharthan

On Sat, May 2, 2020 at 6:51 PM Danh Doan <[email protected]> wrote:
The thing with options in cmake is the values it takes are boolean only. To do what you want I think you have to do something along the lines of this. if(NOT DEFINED SHELL_PATH)
set(SHELL_PATH <default value> CACHE STRING "path to POSIX compliance shell") endif()

Then if you want to change this value, edit this value in CMakeCache.txt.

Ah, this is what I mean, I think it's better to use this (without if_not_define)

set(SHELL_PATH "/bin/sh" CACHE PATH "path to POSIX compliance shell")

Then, we can use this:

	cmake -DSHELL_PATH=/path/to/good/sh ...
Signature · 1 line
Danh
#77 lore raw
Quoted 11 lines · Danh Doan
Quoted 8 lines · Sibi Siddharthan

On Sat, May 2, 2020 at 6:51 PM Danh Doan <[email protected]> wrote:
The thing with options in cmake is the values it takes are boolean only. To do what you want I think you have to do something along the lines of this. if(NOT DEFINED SHELL_PATH)
set(SHELL_PATH <default value> CACHE STRING "path to POSIX compliance shell") endif()

Then if you want to change this value, edit this value in CMakeCache.txt.

Quoted 9 lines

Ah, this is what I mean, I think it's better to use this (without if_not_define)

set(SHELL_PATH "/bin/sh" CACHE PATH "path to POSIX compliance shell")

Then, we can use this:

        cmake -DSHELL_PATH=/path/to/good/sh ...

If you CACHE the variable, you have to do this
cmake -USHELL_PATH -DSHELL_PATH=/path/to/good/sh

I know it is bad.
Otherwise you can modify the cache entry directly in CMakeCache.txt.

Thank You,
Sibi Siddharthan

Quoted 2 lines

--
Danh

#78 lore raw
In reply to Jeff King
Quoted 8 lines · Jeff King

I think what I'm suggesting is not all that different from this, except that I'd suspect "next" would not get enough exposure. So in my mind merging to master is not so much "hooray, we now have visual studio support" but rather the first step in getting data. But we'd have to be very clear about how the project regards the cmake support: it's there for now, you're encouraged to play with it, but don't be upset if it needs some coaxing to behave like the normal Makefile or if it goes away in the future.

I think you said almost everything I would have said.

If we were to adopt it as an experiment, hoping to gain exposure, nothing above 'master' (or tagged releases) won't work. And once a thing is in 'master', users will ignore the "this is merely an experiment" warning and expect it to be fully functional and usable.

Given the observation in the thread that it would take a fairly recent version to benefit platform-agnostic usability features, I did not get an impression that it is ready to be anywhere near that, not even ready for 'next'. It is *not* like "Sibi's patches were bad but they can become ready with further polishing". The impression I got was that the large part of why it is not ready is because it needs time for larger set of distros to adopt more recent versions of cmake.

And I somehow think that rewriting Sibi's patches to lose the parts that takes advantage of more recent cmake (abstracting "mklink" vs "ln" out was mentioned as an example---there may be a lot more) is going in a wrong direction. The world will eventually catch up, and Git does not need cmake immediately. Using the more recent features while waiting for the right time would be a more sensible approach than aiming for an outdated version.

So, perhaps we'll try again in 3 years, perhaps, to consider if it makes sense to add the cmake support to _my_ tree.

But in the meantime, those who are interested in building Git with cmake do not have to wait, doing nothing, I would imagine. I wonder if they can work on a separate project (let's call it git-on-cmake) whose sole purpose is to develop and polish CMakeLists.txt, waiting for an advanced enough version of cmake becomes commonplace. Then, anybody who are interested and has recent cmake can subtree-merge git-on-cmake project into their own clone of our project somewhere, and help developing git-on-cmake further.

Then we'll meet again in 3 years and see if the world got new enough ;-)

#79 lore raw
Quoted 18 lines · On Mon, 27 Apr 2020 14:17:32 -0700 Junio C Hamano <[email protected]> wrote:
Quoted 8 lines · Jeff King

I think what I'm suggesting is not all that different from this, except that I'd suspect "next" would not get enough exposure. So in my mind merging to master is not so much "hooray, we now have visual studio support" but rather the first step in getting data. But we'd have to be very clear about how the project regards the cmake support: it's there for now, you're encouraged to play with it, but don't be upset if it needs some coaxing to behave like the normal Makefile or if it goes away in the future.

I think you said almost everything I would have said.

If we were to adopt it as an experiment, hoping to gain exposure, nothing above 'master' (or tagged releases) won't work. And once a thing is in 'master', users will ignore the "this is merely an experiment" warning and expect it to be fully functional and usable.

Quoted 9 lines

Given the observation in the thread that it would take a fairly recent version to benefit platform-agnostic usability features, I did not get an impression that it is ready to be anywhere near that, not even ready for 'next'. It is *not* like "Sibi's patches were bad but they can become ready with further polishing". The impression I got was that the large part of why it is not ready is because it needs time for larger set of distros to adopt more recent versions of cmake.

Why do you need distros to adopt more recent versions of cmake?

The cmake support is mainly for VS and you can install current version of cmake with VS, there is no distro there. It can also work on distros with recent cmake but that's not really the goal so it's not a problem if many distros don't work.

Thanks

Michal

#80 lore raw
In reply to Junio C Hamano
Quoted 4 lines · Junio C Hamano

If we were to adopt it as an experiment, hoping to gain exposure, nothing above 'master' (or tagged releases) won't work. And once a thing is in 'master', users will ignore the "this is merely an experiment" warning and expect it to be fully functional and usable.

Yeah, that is a problem. I wonder if the state would be more obvious if it lived in contrib/. We already have contrib/buildsystems, which seems like an earlier attempt at this exact problem?

Quoted 8 lines

But in the meantime, those who are interested in building Git with cmake do not have to wait, doing nothing, I would imagine. I wonder if they can work on a separate project (let's call it git-on-cmake) whose sole purpose is to develop and polish CMakeLists.txt, waiting for an advanced enough version of cmake becomes commonplace. Then, anybody who are interested and has recent cmake can subtree-merge git-on-cmake project into their own clone of our project somewhere, and help developing git-on-cmake further.

I think there's actually a good reason to have it in your tree: people use your tree as the basis to build (and submit!) changes.

I noticed the same thing with trying to play with CI changes. As a contributor, yes I _can_ make my CI changes, and then base my branches on that. But it gets rather awkward juggling branches that contain some changes that should go upstream, and some which should not. And quite a bit more difficult if people want to use tools like GitGitGadget to just target a PR against git.git and send it to the mailing list.

If it lived in contrib/ that might strike a good balance between making it available for people to experiment with, but not having people confuse it for the official build system.

-Peff

#81 lore raw
Quoted 31 lines · Jeff King
Quoted 4 lines · Junio C Hamano

If we were to adopt it as an experiment, hoping to gain exposure, nothing above 'master' (or tagged releases) won't work. And once a thing is in 'master', users will ignore the "this is merely an experiment" warning and expect it to be fully functional and usable.

Yeah, that is a problem. I wonder if the state would be more obvious if it lived in contrib/. We already have contrib/buildsystems, which seems like an earlier attempt at this exact problem?

Quoted 8 lines

But in the meantime, those who are interested in building Git with cmake do not have to wait, doing nothing, I would imagine. I wonder if they can work on a separate project (let's call it git-on-cmake) whose sole purpose is to develop and polish CMakeLists.txt, waiting for an advanced enough version of cmake becomes commonplace. Then, anybody who are interested and has recent cmake can subtree-merge git-on-cmake project into their own clone of our project somewhere, and help developing git-on-cmake further.

I think there's actually a good reason to have it in your tree: people use your tree as the basis to build (and submit!) changes.

I noticed the same thing with trying to play with CI changes. As a contributor, yes I _can_ make my CI changes, and then base my branches on that. But it gets rather awkward juggling branches that contain some changes that should go upstream, and some which should not. And quite a bit more difficult if people want to use tools like GitGitGadget to just target a PR against git.git and send it to the mailing list.

Quoted 3 lines

If it lived in contrib/ that might strike a good balance between making it available for people to experiment with, but not having people confuse it for the official build system.

Maybe we could move configure.ac and config.mak.in into contrib as well?

#82 lore raw
Quoted 3 lines · Elijah Newren
Quoted 3 lines

If it lived in contrib/ that might strike a good balance between making it available for people to experiment with, but not having people confuse it for the official build system.

If we declare cmake support is only for VS and throw it into somewhere like contrib/buildsystems, that may be good enough.

Quoted 1 line

Maybe we could move configure.ac and config.mak.in into contrib as well?

Perhaps.

#83 lore raw
In reply to Elijah Newren
Quoted 5 lines · Elijah Newren
Quoted 3 lines

If it lived in contrib/ that might strike a good balance between making it available for people to experiment with, but not having people confuse it for the official build system.

Maybe we could move configure.ac and config.mak.in into contrib as well?

Maybe. I have a feeling that most folks who use autoconf do it from the tarballs, which have the generated ./configure anyway.

-Peff

#84 lore raw

v2 cover CMake build system for git

In reply to Sibi Siddharthan via GitGitGadget

This is an attempt to build Git using CMake. CMake is cross-platform build generator which works well on a variety of platforms(primarily Linux and Windows). Using CMake we can check whether certain headers exist, certain functions exist, the required libraries are present and configure the build accordingly. Using CMake we can also build and test Git out of source, resulting in a clean source tree.

Tested platforms

Ubuntu 18.04 GCC 7.4 Clang 8.0.1

Windows MinGW GCC 9.2 Clang 9 Visual Studio 2015,2017,2019

Changes:

1) The CMake script has been relocated to contrib/buildsystems 2) The CMake script parses the Makefile for the sources. 3) Philip suggested to change the error message if sh/bash was not found on windows. 4) CMake now tests for ICONV_OMITS_BOM, NO_ST_BLOCKS_IN_STRUCT_STAT

Sibi Siddharthan (11):
Introduce CMake support for configuring Git on Linux
cmake: generate the shell/perl/python scripts and templates,
translations
cmake: installation support for git
cmake: support for testing git with ctest
cmake: support for testing git when building out of the source tree
cmake: support for building git on windows with mingw
cmake: support for building git on windows with msvc and clang.
cmake: added checks for struct stat and libiconv
cmake: relocated script file contrib/buildsystems
cmake: parse the makefile for the sources.
ci: modification of main.yml to use cmake for vs-build job

 .github/workflows/main.yml          |  46 +-
 contrib/buildsystems/CMakeLists.txt | 945 ++++++++++++++++++++++++++++
 2 files changed, 971 insertions(+), 20 deletions(-)
 create mode 100644 contrib/buildsystems/CMakeLists.txt

base-commit: 744177e7f7fd407c26e9e4aa3b19696859010c48
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-614%2FSibiSiddharthan%2Fgit-og-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-614/SibiSiddharthan/git-og-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/614

Range-diff vs v1:

  1:  70ab1f03dd5 =  1:  70ab1f03dd5 Introduce CMake support for configuring Git on Linux
  2:  ca242cf5bda =  2:  ca242cf5bda cmake: generate the shell/perl/python scripts and templates, translations
  3:  10390063a39 !  3:  b2974432d77 cmake: installation support for git

@@ Commit message

Then run make install

+ Changes:
+ Removed a comment regarding the installation of gitk.
+

## CMakeLists.txt ##
@@ CMakeLists.txt: if(MSGFMT_EXE)
+#install
+install(TARGETS git git-shell
+ RUNTIME DESTINATION bin)
-+install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver #${CMAKE_SOURCE_DIR}/gitk-git/gitk check ++install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver
+ DESTINATION bin)
+
+list(REMOVE_ITEM PROGRAMS_BUILT git git-shell)
4: 35a3554df3e ! 4: 2bd8870fb96 cmake: support for testing git with ctest
@@ Commit message

NOTE: Testing only works when building in source for now.

+ Changes:
+ Renamed the variable test_helper_sources to test-tool_SOURCES
+ to be consistent with the naming of source variables.
+

## CMakeLists.txt ##
@@ CMakeLists.txt: install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION
+add_executable(test-svn-fe t/helper/test-svn-fe.c) +target_link_libraries(test-svn-fe common-main vcs-svn)
+
-+set(test_helper_sources
++set(test-tool_SOURCES
+ t/helper/test-tool.c t/helper/test-advise.c t/helper/test-bloom.c t/helper/test-chmtime.c
+ t/helper/test-config.c t/helper/test-ctype.c t/helper/test-date.c t/helper/test-delta.c
+ t/helper/test-dir-iterator.c t/helper/test-drop-caches.c t/helper/test-dump-cache-tree.c
@@ CMakeLists.txt: install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION
+ t/helper/test-trace2.c t/helper/test-urlmatch-normalization.c t/helper/test-xml-encode.c
+ t/helper/test-wildmatch.c t/helper/test-windows-named-pipe.c t/helper/test-write-cache.c)
+
-+add_executable(test-tool ${test_helper_sources}) ++add_executable(test-tool ${test-tool_SOURCES})
+target_link_libraries(test-tool common-main)
+
+set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool

  5:  166b78f7175 =  5:  096f6311ad5 cmake: support for testing git when building out of the source tree
  6:  d6c630028bf !  6:  00cae10bbb7 cmake: support for building git on windows with mingw

@@ Commit message
To use CMake on Windows with MinGW do this:
cmake relative-path-to-srcdir -G "MinGW Makefiles"

+ Changes:
+ Changed the error message when sh.exe is not found on Windows as
+ suggested by Philip Oakley <[email protected]>
+

## CMakeLists.txt ##
@@ CMakeLists.txt: if(Intl_FOUND)

find_program(SH_EXE sh)
+if(NOT SH_EXE)
-+ message(FATAL_ERROR "sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/")
++ message(FATAL_ERROR "sh: shell interpreter was not found in your path, please install one."
++ "On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/")
+endif()
+
+if(WIN32)
7: 0577d7bf0a8 ! 7: af6c606881d cmake: support for building git on windows with msvc and clang.
@@ CMakeLists.txt: find_package(ZLIB REQUIRED)
if(NOT Intl_FOUND)
add_compile_definitions(NO_GETTEXT)
@@ CMakeLists.txt: if(NOT SH_EXE)
- message(FATAL_ERROR "sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/")
+ "On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/")
endif()

-if(WIN32)

  -:  ----------- >  8:  f496cd7d8aa cmake: added checks for struct stat and libiconv
  -:  ----------- >  9:  9c674372fb5 cmake: relocated script file contrib/buildsystems
  -:  ----------- > 10:  b0a321a714a cmake: parse the makefile for the sources.
  8:  f0294be3f11 ! 11:  fa1b8032906 ci: modification of main.yml to use cmake for vs-build job

@@ Commit message
FindCURL module. An extra definition (-DCURL_NO_CURL_CMAKE=ON) has been added to revert to the old behaviour.

+ Edit(Explanation for the reordering of build steps):
+ In the configuration phase CMake looks for the required libraries for
+ building git (eg zlib,libiconv). So we extract the libraries before we
+ configure.
+
+ Changes:
+ The CMake script has been relocated to contib/buildsystems, so point
+ to the CMakeLists.txt in the invocation commands.
+
+ The generation command now uses the absolute paths for the generation
+ step.
+
+ To check for ICONV_OMITS_BOM libiconv.dll needs to be in the working
+ directory of script or path. So we copy the dlls before we configure.
+

## .github/workflows/main.yml ##
@@ .github/workflows/main.yml: jobs:
Remove-Item compat.zip
- name: add msbuild to PATH
uses: microsoft/[email protected]
-+ - name: generate Visual Studio solution
++ - name: copy dlls to root
+ shell: powershell
+ run: |
-+ & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
-+ cmake . -DCMAKE_PREFIX_PATH=./compat/vcbuild/vcpkg/installed/x64-windows -DMSGFMT_EXE=./git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
-+ "@
++ & compat\vcbuild\vcpkg_copy_dlls.bat release
+ if (!$?) { exit(1) }
++ - name: generate Visual Studio solution
++ shell: bash
++ run: cmake pwd/contrib/buildsystems/ -DCMAKE_PREFIX_PATH=pwd/compat/vcbuild/vcpkg/installed/x64-windows -DMSGFMT_EXE=pwd/git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
- name: MSBuild
run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142
- name: bundle artifact tar
+@@ .github/workflows/main.yml: jobs:
+ MSVC: 1
+ VCPKG_ROOT: ${{github.workspace}}\compat\vcbuild\vcpkg
+ run: |
+- & compat\vcbuild\vcpkg_copy_dlls.bat release
+- if (!$?) { exit(1) }
+ & git-sdk-64-minimal\usr\bin\bash.exe -lc @"
+ mkdir -p artifacts &&
+ eval \"`$(make -n artifacts-tar INCLUDE_DLLS_IN_ARTIFACTS=YesPlease ARTIFACTS_DIRECTORY=artifacts 2>&1 | grep ^tar)\"
@@ .github/workflows/main.yml: jobs:
nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
steps:

Signature · 1 line
gitgitgadget
#85 lore raw

PATCH v2 1/11 Introduce CMake support for configuring Git on Linux

From: Sibi Siddharthan <[email protected]>

At the moment, the recommended way to configure Git's builds is to simply run make. If that does not work, the recommended strategy is to look at the top of the Makefile to see whether any "Makefile knob" has to be turned on/off, e.g. make NO_OPENSSL=YesPlease.

Alternatively, Git also has an autoconf setup which allows configuring builds via ./configure [<option>...].

Both of these options are fine if the developer works on Unix or Linux. But on Windows, we have to jump through hoops to configure a build (read: we force the user to install a full Git for Windows SDK, which occupies around two gigabytes (!) on disk and downloads about three quarters of a gigabyte worth of Git objects).

To make this a little less awkward, the Git for Windows project offers the vs/master branch which has a full Visual Studio solution generated and committed. This branch can therefore be used to tinker with Git in Visual Studio _without_ having to download the full Git for Windows SDK. Unfortunatly, that branch is auto-generated from Git for Windows' master. If a developer wants to tinker, say, with pu, they are out of luck.

CMake was invented to make this sort of problem go away, by providing a more standardized, cross-platform way to configure builds.

With a working support CMake, developers on Windows need only install CMake, configure their build, load the generated Visual Studio solution and immediately start modifying the code and build their own version of Git. Likewise, developers on other platforms can use the convenient GUI tools provided by CMake to configure their build.

So let's start building CMake support for Git.

This is only the first step, and to make it easier to review, it only allows for configuring builds on the platform that is easiest to configure for: Linux.

The CMake script checks whether the headers are present(eg. libgen.h), whether the functions are present(eg. memmem), whether the funtions work properly (eg. snprintf) and generate the required compile definitions for the platform. The script also searches for the required libraries, if it fails to find the required libraries the respective executables won't be built.(eg. If libcurl is not found then git-remote-http won't be built). This will help building Git easier.

With a CMake script an out of source build of git is possible resulting in a clean source tree.

Note: earlier endeavors on the Git mailing list to introduce CMake ended up in dead water. The primary reason for that was that reviewers _expected_ CMake support to fall out of maintenance, unless the contributor would promise to keep an eye on keeping CMake support up to date. However, in the meantime, support for automated testing has been introduced in Git's source code, and a later patch will modify the (still experimental) GitHub workflow to continually verify that CMake support is still complete. That will make maintenance reasonably easy.

Note: this patch asks for the minimum version v3.14 of CMake (which is not all that old as of time of writing) because that is the first version to offer a platform-independent way to generate hardlinks as part of the build. This is needed to generate all those hardlinks for the built-in commands of Git.

Instructions to run CMake:

cmake relative-path-to-srcdir -DCMAKE_BUILD_TYPE=Release

Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding compiler flags
Debug : -g
Release: -O3
RelWithDebInfo : -O2 -g
MinSizeRel : -Os
empty(default) :

NOTE: -DCMAKE_BUILD_TYPE is optional

This process generates a Makefile.
Then run make to build Git.

NOTE: By default CMake uses Makefile as the build tool on Linux, to use another tool say ninja add this to the command line when configuring. -G Ninja

---
 CMakeLists.txt | 528 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 528 insertions(+)
 create mode 100644 CMakeLists.txt
CMakeLists.txt new file +528 -0
new file mode 100644
index 00000000000..73703bd321f
@@ -0,0 +1,528 @@
+#
+#	Copyright (c) 2020 Sibi Siddharthan
+#
+
+cmake_minimum_required(VERSION 3.14)
+
+#Parse GIT-VERSION-GEN to get the version
+file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX "DEF_VER=v(.*)")
+string(REPLACE "DEF_VER=v" "" git_version ${git_version})
+string(REPLACE ".GIT" ".0" git_version ${git_version})#for building from a snapshot
+
+project(git
+	VERSION ${git_version}
+	LANGUAGES C)
+
+
+include(CheckTypeSize)
+include(CheckCSourceRuns)
+include(CheckCSourceCompiles)
+include(CheckIncludeFile)
+include(CheckFunctionExists)
+include(CheckSymbolExists)
+include(CheckStructHasMember)
+
+find_package(ZLIB REQUIRED)
+find_package(CURL)
+find_package(EXPAT)
+find_package(Iconv)
+find_package(Intl)
+
+if(NOT Intl_FOUND)
+	add_compile_definitions(NO_GETTEXT)
+	if(NOT Iconv_FOUND)
+		add_compile_definitions(NO_ICONV)
+	endif()
+endif()
+
+include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
+if(CURL_FOUND)
+	include_directories(SYSTEM ${CURL_INCLUDE_DIRS})
+endif()
+if(EXPAT_FOUND)
+	include_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})
+endif()
+if(Iconv_FOUND)
+	include_directories(SYSTEM ${Iconv_INCLUDE_DIRS})
+endif()
+if(Intl_FOUND)
+	include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
+endif()
+
+find_program(SH_EXE sh)
+
+#default behaviour
+include_directories(${CMAKE_SOURCE_DIR})
+add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
+add_compile_definitions(SHA256_BLK INTERNAL_QSORT RUNTIME_PREFIX)
+add_compile_definitions(NO_OPENSSL SHA1_DC SHA1DC_NO_STANDARD_INCLUDES
+			SHA1DC_INIT_SAFE_HASH_DEFAULT=0
+			SHA1DC_CUSTOM_INCLUDE_SHA1_C="cache.h"
+			SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="git-compat-util.h" )
+list(APPEND compat_SOURCES sha1dc_git.c sha1dc/sha1.c sha1dc/ubc_check.c block-sha1/sha1.c sha256/block/sha256.c compat/qsort_s.c)
+
+
+add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
+			ETC_GITATTRIBUTES="etc/gitattributes"
+			ETC_GITCONFIG="etc/gitconfig"
+			GIT_EXEC_PATH="libexec/git-core"
+			GIT_LOCALE_PATH="share/locale"
+			GIT_MAN_PATH="share/man"
+			GIT_INFO_PATH="share/info"
+			GIT_HTML_PATH="share/doc/git-doc"
+			DEFAULT_HELP_FORMAT="html"
+			DEFAULT_GIT_TEMPLATE_DIR="share/git-core/templates"
+			GIT_VERSION="${PROJECT_VERSION}.GIT"
+			GIT_USER_AGENT="git/${PROJECT_VERSION}.GIT"
+			BINDIR="bin"
+			GIT_BUILT_FROM_COMMIT="")
+
+set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
+add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+
+add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
+list(APPEND compat_SOURCES unix-socket.c)
+
+#header checks
+check_include_file(libgen.h HAVE_LIBGEN_H)
+if(NOT HAVE_LIBGEN_H)
+	add_compile_definitions(NO_LIBGEN_H)
+	list(APPEND compat_SOURCES compat/basename.c)
+endif()
+
+check_include_file(sys/sysinfo.h HAVE_SYSINFO)
+if(HAVE_SYSINFO)
+	add_compile_definitions(HAVE_SYSINFO)
+endif()
+
+check_c_source_compiles("
+#include <alloca.h>
+int
+main ()
+{
+char *p = (char *) alloca (2 * sizeof (int));
+	if (p) return 0;
+	return 0;
+}"
+HAVE_ALLOCA_H)
+if(HAVE_ALLOCA_H)
+	add_compile_definitions(HAVE_ALLOCA_H)
+endif()
+
+check_include_file(strings.h HAVE_STRINGS_H)
+if(HAVE_STRINGS_H)
+	add_compile_definitions(HAVE_STRINGS_H)
+endif()
+
+check_include_file(sys/select.h HAVE_SYS_SELECT_H)
+if(NOT HAVE_SYS_SELECT_H)
+	add_compile_definitions(NO_SYS_SELECT_H)
+endif()
+
+check_include_file(sys/poll.h HAVE_SYS_POLL_H)
+if(NOT HAVE_SYS_POLL_H)
+	add_compile_definitions(NO_SYS_POLL_H)
+endif()
+
+check_include_file(poll.h HAVE_POLL_H)
+if(NOT HAVE_POLL_H)
+	add_compile_definitions(NO_POLL_H)
+endif()
+
+check_include_file(inttypes.h HAVE_INTTYPES_H)
+if(NOT HAVE_INTTYPES_H)
+	add_compile_definitions(NO_INTTYPES_H)
+endif()
+
+check_include_file(paths.h HAVE_PATHS_H)
+if(HAVE_PATHS_H)
+	add_compile_definitions(HAVE_PATHS_H)
+endif()
+
+#function checks
+set(function_checks
+	strcasestr memmem strlcpy strtoimax strtoumax strtoull
+	setenv  mkdtemp poll pread  memmem unsetenv hstrerror)
+
+foreach(f ${function_checks})
+	string(TOUPPER ${f} uf)
+	check_function_exists(${f} HAVE_${uf})
+	if(NOT HAVE_${uf})
+		add_compile_definitions(NO_${uf})
+	endif()
+endforeach()
+
+if(NOT HAVE_POLL_H OR NOT HAVE_SYS_POLL_H OR NOT HAVE_POLL)
+	include_directories(compat/poll)
+	add_compile_definitions(NO_POLL)
+	list(APPEND compat_SOURCES compat/poll/poll.c)
+endif()
+
+if(NOT HAVE_STRCASESTR)
+	list(APPEND compat_SOURCES compat/strcasestr.c)
+endif()
+
+if(NOT HAVE_STRLCPY)
+	list(APPEND compat_SOURCES compat/strlcpy.c)
+endif()
+
+if(NOT HAVE_STRTOUMAX)
+	list(APPEND compat_SOURCES compat/strtoumax.c compat/strtoimax.c)
+endif()
+
+if(NOT HAVE_SETENV)
+	list(APPEND compat_SOURCES compat/setenv.c)
+endif()
+
+if(NOT HAVE_MKDTEMP)
+	list(APPEND compat_SOURCES compat/mkdtemp.c)
+endif()
+
+if(NOT HAVE_PREAD)
+	list(APPEND compat_SOURCES compat/pread.c)
+endif()
+
+if(NOT HAVE_MEMMEM)
+	list(APPEND compat_SOURCES compat/memmem.c)
+endif()
+
+if(NOT WIN32)
+	if(NOT HAVE_UNSETENV)
+		list(APPEND compat_SOURCES compat/unsetenv.c)
+	endif()
+
+	if(NOT HAVE_HSTRERROR)
+		list(APPEND compat_SOURCES compat/hstrerror.c)
+	endif()
+endif()
+
+check_function_exists(getdelim HAVE_GETDELIM)
+if(HAVE_GETDELIM)
+	add_compile_definitions(HAVE_GETDELIM)
+endif()
+
+check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
+check_symbol_exists(CLOCK_MONOTONIC "time.h" HAVE_CLOCK_MONOTONIC)
+if(HAVE_CLOCK_GETTIME)
+	add_compile_definitions(HAVE_CLOCK_GETTIME)
+endif()
+if(HAVE_CLOCK_MONOTONIC)
+	add_compile_definitions(HAVE_CLOCK_MONOTONIC)
+endif()
+
+
+#compile checks
+check_c_source_runs("
+#include<stdio.h>
+#include<stdarg.h>
+#include<string.h>
+#include<stdlib.h>
+int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)
+{
+	int ret;
+	va_list ap;
+
+	va_start(ap, format);
+	ret = vsnprintf(str, maxsize, format, ap);
+	va_end(ap);
+	return ret;
+}
+
+int
+main ()
+{
+	char buf[6];
+	if (test_vsnprintf(buf, 3, \"%s\", \"12345\") != 5
+		|| strcmp(buf, \"12\")) return 1;
+	if (snprintf(buf, 3, \"%s\", \"12345\") != 5
+		|| strcmp(buf, \"12\")) return 1;
+
+	return 0;
+}"
+SNPRINTF_OK)
+if(NOT SNPRINTF_OK)
+	add_compile_definitions(SNPRINTF_RETURNS_BOGUS)
+	list(APPEND compat_SOURCES compat/snprintf.c)
+endif()
+
+check_c_source_runs("
+#include<stdio.h>
+int
+main ()
+{
+	FILE *f = fopen(\".\", \"r\");
+	return f != NULL;
+
+	return 0;
+}"
+FREAD_READS_DIRECTORIES_NO)
+if(NOT FREAD_READS_DIRECTORIES_NO)
+	add_compile_definitions(FREAD_READS_DIRECTORIES)
+	list(APPEND compat_SOURCES compat/fopen.c)
+endif()
+
+check_c_source_compiles("
+#include <regex.h>
+#ifndef REG_STARTEND
+#error oops we dont have it
+#endif
+int main(){return 0;}"
+HAVE_REGEX)
+if(NOT HAVE_REGEX)
+	include_directories(compat/regex )
+	list(APPEND compat_SOURCES compat/regex/regex.c )
+	add_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)
+endif()
+
+
+check_c_source_compiles("
+#include <stddef.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+int
+main ()
+{
+	int val, mib[2];
+	size_t len;
+
+	mib[0] = CTL_HW;
+	mib[1] = 1;
+	len = sizeof(val);
+	return sysctl(mib, 2, &val, &len, NULL, 0) ? 1 : 0;
+
+	return 0;
+}"
+HAVE_BSD_SYSCTL)
+if(HAVE_BSD_SYSCTL)
+	add_compile_definitions(HAVE_BSD_SYSCTL)
+endif()
+
+#programs
+set(PROGRAMS_BUILT
+	git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
+	git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)
+
+if(NOT CURL_FOUND)
+	list(APPEND excluded_progs git-http-fetch git-http-push)
+	add_compile_definitions(NO_CURL)
+	message(WARNING "git-http-push and git-http-fetch will not be built")
+else()
+	list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)
+	if(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)
+		add_compile_definitions(USE_CURL_FOR_IMAP_SEND)
+	endif()
+endif()
+
+if(NOT EXPAT_FOUND)
+	list(APPEND excluded_progs git-http-push)
+	add_compile_definitions(NO_EXPAT)
+else()
+	list(APPEND PROGRAMS_BUILT git-http-push)
+	if(EXPAT_VERSION_STRING VERSION_LESS_EQUAL 1.2)
+		add_compile_definitions(EXPAT_NEEDS_XMLPARSE_H)
+	endif()
+endif()
+
+list(REMOVE_DUPLICATES excluded_progs)
+list(REMOVE_DUPLICATES PROGRAMS_BUILT)
+
+
+foreach(p ${excluded_progs})
+	list(APPEND EXCLUSION_PROGS --exclude-program ${p} )
+endforeach()
+
+#for comparing null values
+list(APPEND EXCLUSION_PROGS empty)
+set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING "Programs not built" FORCE)
+
+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)
+	list(REMOVE_ITEM EXCLUSION_PROGS empty)
+	message("Generating command-list.h")
+	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt
+			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+			OUTPUT_FILE ${CMAKE_SOURCE_DIR}/command-list.h)
+endif()
+
+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/config-list.h)
+	message("Generating config-list.h")
+	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh
+			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+			OUTPUT_FILE ${CMAKE_SOURCE_DIR}/config-list.h)
+endif()
+
+
+#build
+set(libgit_SOURCES
+	abspath.c add-interactive.c add-patch.c advice.c alias.c
+	alloc.c apply.c archive.c archive-tar.c archive-zip.c argv-array.c
+	attr.c base85.c bisect.c blame.c blob.c bloom.c branch.c bulk-checkin.c
+	bundle.c cache-tree.c chdir-notify.c checkout.c color.c column.c
+	combine-diff.c commit.c commit-graph.c commit-reach.c compat/obstack.c
+	compat/terminal.c config.c connect.c connected.c convert.c copy.c credential.c
+	csum-file.c ctype.c date.c decorate.c delta-islands.c diffcore-break.c
+	diffcore-delta.c diffcore-order.c diffcore-pickaxe.c diffcore-rename.c
+	diff-delta.c diff-lib.c diff-no-index.c diff.c dir.c dir-iterator.c editor.c
+	entry.c environment.c ewah/bitmap.c ewah/ewah_bitmap.c ewah/ewah_io.c
+	ewah/ewah_rlw.c exec-cmd.c fetch-negotiator.c fetch-pack.c fmt-merge-msg.c fsck.c fsmonitor.c
+	gettext.c gpg-interface.c graph.c grep.c hashmap.c linear-assignment.c help.c hex.c
+	ident.c interdiff.c json-writer.c kwset.c levenshtein.c line-log.c line-range.c list-objects.c
+	list-objects-filter.c list-objects-filter-options.c ll-merge.c lockfile.c
+	log-tree.c ls-refs.c mailinfo.c mailmap.c match-trees.c mem-pool.c merge.c merge-blobs.c
+	merge-recursive.c mergesort.c midx.c name-hash.c negotiator/default.c
+	negotiator/skipping.c notes.c notes-cache.c notes-merge.c notes-utils.c object.c oidmap.c
+	oidset.c oid-array.c packfile.c pack-bitmap.c pack-bitmap-write.c pack-check.c pack-objects.c
+	pack-revindex.c pack-write.c pager.c parse-options.c parse-options-cb.c patch-delta.c
+	patch-ids.c path.c pathspec.c pkt-line.c preload-index.c pretty.c prio-queue.c progress.c
+	promisor-remote.c prompt.c protocol.c prune-packed.c quote.c range-diff.c reachable.c read-cache.c rebase.c
+	rebase-interactive.c reflog-walk.c refs.c refs/files-backend.c refs/iterator.c
+	refs/packed-backend.c refs/ref-cache.c refspec.c ref-filter.c remote.c replace-object.c
+	repo-settings.c repository.c rerere.c reset.c resolve-undo.c revision.c run-command.c
+	send-pack.c sequencer.c serve.c server-info.c setup.c sha1-lookup.c
+	sha1-file.c sha1-name.c shallow.c sideband.c sigchain.c split-index.c
+	stable-qsort.c strbuf.c streaming.c string-list.c submodule.c submodule-config.c
+	sub-process.c symlinks.c tag.c tempfile.c thread-utils.c tmp-objdir.c
+	trace.c trace2.c trace2/tr2_cfg.c trace2/tr2_cmd_name.c trace2/tr2_dst.c
+	trace2/tr2_sid.c trace2/tr2_sysenv.c trace2/tr2_tbuf.c trace2/tr2_tgt_event.c
+	trace2/tr2_tgt_normal.c trace2/tr2_tgt_perf.c trace2/tr2_tls.c trailer.c transport.c
+	transport-helper.c tree-diff.c tree.c tree-walk.c unpack-trees.c upload-pack.c url.c
+	urlmatch.c usage.c userdiff.c utf8.c varint.c version.c versioncmp.c walker.c wildmatch.c
+	worktree.c wrapper.c write-or-die.c ws.c wt-status.c xdiff-interface.c
+	zlib.c)
+
+add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})
+
+set(libxdiff_SOURCES
+	xdiff/xdiffi.c xdiff/xprepare.c xdiff/xutils.c xdiff/xemit.c
+	xdiff/xmerge.c xdiff/xpatience.c xdiff/xhistogram.c)
+add_library(xdiff STATIC ${libxdiff_SOURCES})
+
+set(libvcs-svn_SOURCES
+	vcs-svn/line_buffer.c vcs-svn/sliding_window.c vcs-svn/fast_export.c
+	vcs-svn/svndiff.c vcs-svn/svndump.c)
+add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
+
+#link all required libraries to common-main
+add_library(common-main OBJECT common-main.c)
+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
+if(Intl_FOUND)
+	target_link_libraries(common-main ${Intl_LIBRARIES})
+endif()
+if(Iconv_FOUND)
+	target_link_libraries(common-main ${Iconv_LIBRARIES})
+endif()
+
+
+set(git_SOURCES
+	builtin/add.c builtin/am.c builtin/annotate.c builtin/apply.c
+	builtin/archive.c builtin/bisect--helper.c builtin/blame.c
+	builtin/branch.c builtin/bundle.c builtin/cat-file.c builtin/check-attr.c
+	builtin/check-ignore.c builtin/check-mailmap.c builtin/check-ref-format.c
+	builtin/checkout-index.c builtin/checkout.c builtin/clean.c
+	builtin/clone.c builtin/column.c builtin/commit-tree.c
+	builtin/commit.c builtin/commit-graph.c builtin/config.c
+	builtin/count-objects.c builtin/credential.c builtin/describe.c
+	builtin/diff-files.c builtin/diff-index.c builtin/diff-tree.c
+	builtin/diff.c builtin/difftool.c builtin/env--helper.c
+	builtin/fast-export.c builtin/fetch-pack.c builtin/fetch.c builtin/fmt-merge-msg.c
+	builtin/for-each-ref.c builtin/fsck.c builtin/gc.c
+	builtin/get-tar-commit-id.c builtin/grep.c builtin/hash-object.c
+	builtin/help.c builtin/index-pack.c builtin/init-db.c
+	builtin/interpret-trailers.c builtin/log.c builtin/ls-files.c
+	builtin/ls-remote.c builtin/ls-tree.c builtin/mailinfo.c builtin/mailsplit.c
+	builtin/merge.c builtin/merge-base.c builtin/merge-file.c builtin/merge-index.c
+	builtin/merge-ours.c builtin/merge-recursive.c builtin/merge-tree.c
+	builtin/mktag.c builtin/mktree.c builtin/multi-pack-index.c builtin/mv.c
+	builtin/name-rev.c builtin/notes.c builtin/pack-objects.c builtin/pack-redundant.c
+	builtin/pack-refs.c builtin/patch-id.c builtin/prune-packed.c builtin/prune.c
+	builtin/pull.c builtin/push.c builtin/range-diff.c builtin/read-tree.c
+	builtin/rebase.c builtin/receive-pack.c builtin/reflog.c builtin/remote.c
+	builtin/remote-ext.c builtin/remote-fd.c builtin/repack.c builtin/replace.c
+	builtin/rerere.c builtin/reset.c builtin/rev-list.c builtin/rev-parse.c
+	builtin/revert.c builtin/rm.c builtin/send-pack.c builtin/shortlog.c
+	builtin/show-branch.c builtin/show-index.c builtin/show-ref.c
+	builtin/sparse-checkout.c builtin/stash.c builtin/stripspace.c
+	builtin/submodule--helper.c builtin/symbolic-ref.c builtin/tag.c
+	builtin/unpack-file.c builtin/unpack-objects.c builtin/update-index.c
+	builtin/update-ref.c builtin/update-server-info.c builtin/upload-archive.c
+	builtin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c
+	builtin/verify-tag.c builtin/worktree.c builtin/write-tree.c)
+
+add_executable(git git.c ${git_SOURCES})
+target_link_libraries(git common-main )
+
+add_executable(git-bugreport bugreport.c)
+target_link_libraries(git-bugreport common-main)
+
+add_executable(git-credential-store credential-store.c)
+target_link_libraries(git-credential-store common-main)
+
+add_executable(git-daemon daemon.c)
+target_link_libraries(git-daemon common-main)
+
+add_executable(git-fast-import fast-import.c)
+target_link_libraries(git-fast-import common-main)
+
+add_executable(git-http-backend http-backend.c)
+target_link_libraries(git-http-backend common-main)
+
+add_executable(git-sh-i18n--envsubst sh-i18n--envsubst.c)
+target_link_libraries(git-sh-i18n--envsubst common-main)
+
+add_executable(git-shell shell.c)
+target_link_libraries(git-shell common-main)
+
+if(CURL_FOUND)
+	add_library(http_obj OBJECT http.c)
+
+	add_executable(git-imap-send imap-send.c)
+	target_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})
+
+	add_executable(git-http-fetch http-walker.c http-fetch.c)
+	target_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})
+
+	add_executable(git-remote-http http-walker.c remote-curl.c)
+	target_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )
+
+	if(EXPAT_FOUND)
+		add_executable(git-http-push http-push.c)
+		target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
+	endif()
+endif()
+
+add_executable(git-remote-testsvn remote-testsvn.c)
+target_link_libraries(git-remote-testsvn common-main vcs-svn)
+
+add_executable(git-credential-cache credential-cache.c)
+target_link_libraries(git-credential-cache common-main)
+
+add_executable(git-credential-cache--daemon credential-cache--daemon.c)
+target_link_libraries(git-credential-cache--daemon common-main)
+
+
+set(git_builtin_extra
+	cherry cherry-pick format-patch fsck-objects
+	init merge-subtree restore show
+	stage status switch whatchanged)
+
+#Creating hardlinks
+foreach(s ${git_SOURCES} ${git_builtin_extra})
+	string(REPLACE "builtin/" "" s ${s})
+	string(REPLACE ".c" "" s ${s})
+	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git git-${s})\n")
+	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})
+endforeach()
+
+if(CURL_FOUND)
+	set(remote_exes
+		git-remote-https git-remote-ftp git-remote-ftps)
+	foreach(s ${remote_exes})
+		file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http ${s})\n")
+		list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})
+	endforeach()
+endif()
+
+add_custom_command(OUTPUT ${git_links} ${git_http_links}
+		COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
+		DEPENDS git git-remote-http)
+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
\ No newline at end of file
Signature · 1 line
gitgitgadget
#86 lore raw

Re: [PATCH v2 01/11] Introduce CMake support for configuring Git on Linux

Quoted 7 lines · Sibi Siddharthan via GitGitGadget

To make this a little less awkward, the Git for Windows project offers the vs/master branch which has a full Visual Studio solution generated and committed. This branch can therefore be used to tinker with Git in Visual Studio _without_ having to download the full Git for Windows SDK. Unfortunatly, that branch is auto-generated from Git for Windows' master. If a developer wants to tinker, say, with pu, they are out of luck.

'pu' or 'next' are not to be built upon, so this is not a good line of reasoning to complain that generating only for 'master' is bad.

Quoted 2 lines

CMake was invented to make this sort of problem go away, by providing a more standardized, cross-platform way to configure builds.

I think everything above this point (including Makefile, autoconf etc.) can be replaced with a single sentence

The build infrastructure for Git is written around being able to run make, which is not supported natively on Windows.

without anything else. That will flow naturally to

Add a build script that uses CMake to help developers on Windows to build git.

and then you can continue the current state, like this paragraph.

Quoted 16 lines

This is only the first step, and to make it easier to review, it only allows for configuring builds on the platform that is easiest to configure for: Linux.

The CMake script checks whether the headers are present(eg. libgen.h), whether the functions are present(eg. memmem), whether the funtions work properly (eg. snprintf) and generate the required compile definitions for the platform. The script also searches for the required libraries, if it fails to find the required libraries the respective executables won't be built.(eg. If libcurl is not found then git-remote-http won't be built). This will help building Git easier.

With a CMake script an out of source build of git is possible resulting in a clean source tree.

Quoted 8 lines

Note: earlier endeavors on the Git mailing list to introduce CMake ended up in dead water. The primary reason for that was that reviewers _expected_ CMake support to fall out of maintenance, unless the contributor would promise to keep an eye on keeping CMake support up to date. However, in the meantime, support for automated testing has been introduced in Git's source code, and a later patch will modify the (still experimental) GitHub workflow to continually verify that CMake support is still complete. That will make maintenance reasonably easy.

I am not sure this belongs to the log message.

Quoted 5 lines

Note: this patch asks for the minimum version v3.14 of CMake (which is not all that old as of time of writing) because that is the first version to offer a platform-independent way to generate hardlinks as part of the build. This is needed to generate all those hardlinks for the built-in commands of Git.

This does, but I do not think hardlinks are not required for our build. On Unix filesystems, it is not just possible but convenient to use, and that is the only reason why we use hardlinks.

If hardlinks are possible but inconvenient to use on Windows, you shouldn't force your target audience to use it.

Quoted 12 lines

Instructions to run CMake:

cmake relative-path-to-srcdir -DCMAKE_BUILD_TYPE=Release

Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding compiler flags
Debug : -g
Release: -O3
RelWithDebInfo : -O2 -g
MinSizeRel : -Os
empty(default) :

Quoted 8 lines

NOTE: -DCMAKE_BUILD_TYPE is optional

This process generates a Makefile.
Then run make to build Git.

NOTE: By default CMake uses Makefile as the build tool on Linux, to use another tool say ninja add this to the command line when configuring. -G Ninja

I find it curious that from the instruction, the most important platform, the primary reason why we are reviewing this patch, is missing. Don't Windows folks need to be told how to run CMake to build?

In any case, all of the above "Instructions" should go at the top part of CMakeLists.txt in a comment, and not in the log message. "git log" output is not an easy way for your target audience to learn how to use what the commit adds. Think what they need to do when they discover there is CMakeLists.txt in our tree in three months. Don't force them to run "git blame" to find this commit that added the support.

Quoted 12 lines
---
 CMakeLists.txt | 528 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 528 insertions(+)
 create mode 100644 CMakeLists.txt
CMakeLists.txt new file +0 -0
new file mode 100644
index 00000000000..73703bd321f

CMakeLists.txt line 10

Quoted 10 lines
CMakeLists.txt new file +10 -0
@@ -0,0 +1,528 @@
+#
+#	Copyright (c) 2020 Sibi Siddharthan
+#
+
+cmake_minimum_required(VERSION 3.14)
+
+#Parse GIT-VERSION-GEN to get the version
+file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX "DEF_VER=v(.*)")
+string(REPLACE "DEF_VER=v" "" git_version ${git_version})
+string(REPLACE ".GIT" ".0" git_version ${git_version})#for building from a snapshot

Hmph, I'd really prefer to see the logic in GIT-VERSION-GEN not bypassed like this. People know they can create a text file 'version' and record the version name they desire in it and expect GIT-VERSION-GEN to pick it up, for example.

Later in this file, you seem to depend on the shell to do things like generating config-list.h file, so I'd rather see the same technique used here a well.

CMakeLists.txt line 391

Quoted 4 lines
CMakeLists.txt new file +4 -0
+set(libgit_SOURCES
+	abspath.c add-interactive.c add-patch.c advice.c alias.c
+...
+	zlib.c)

Hmph.

Quoted 24 lines
CMakeLists.txt new file +24 -0
+set(git_SOURCES
+	builtin/add.c builtin/am.c builtin/annotate.c builtin/apply.c
+	builtin/archive.c builtin/bisect--helper.c builtin/blame.c
+	builtin/branch.c builtin/bundle.c builtin/cat-file.c builtin/check-attr.c
+	builtin/check-ignore.c builtin/check-mailmap.c builtin/check-ref-format.c
+	builtin/checkout-index.c builtin/checkout.c builtin/clean.c
+	builtin/clone.c builtin/column.c builtin/commit-tree.c
+	builtin/commit.c builtin/commit-graph.c builtin/config.c
+	builtin/count-objects.c builtin/credential.c builtin/describe.c
+	builtin/diff-files.c builtin/diff-index.c builtin/diff-tree.c
+	builtin/diff.c builtin/difftool.c builtin/env--helper.c
+	builtin/fast-export.c builtin/fetch-pack.c builtin/fetch.c builtin/fmt-merge-msg.c
+	builtin/for-each-ref.c builtin/fsck.c builtin/gc.c
+	builtin/get-tar-commit-id.c builtin/grep.c builtin/hash-object.c
+	builtin/help.c builtin/index-pack.c builtin/init-db.c
+	builtin/interpret-trailers.c builtin/log.c builtin/ls-files.c
+	builtin/ls-remote.c builtin/ls-tree.c builtin/mailinfo.c builtin/mailsplit.c
+	builtin/merge.c builtin/merge-base.c builtin/merge-file.c builtin/merge-index.c
+	builtin/merge-ours.c builtin/merge-recursive.c builtin/merge-tree.c
+	builtin/mktag.c builtin/mktree.c builtin/multi-pack-index.c builtin/mv.c
+	builtin/name-rev.c builtin/notes.c builtin/pack-objects.c builtin/pack-redundant.c
+	builtin/pack-refs.c builtin/patch-id.c builtin/prune-packed.c builtin/prune.c
+	builtin/pull.c builtin/push.c builtin/range-diff.c builtin/read-tree.c
+	builtin/rebase.c builtin/receive-pack.c builtin/reflog.c builtin/remote.c

CMakeLists.txt line 449

Quoted 10 lines
CMakeLists.txt new file +10 -0
+	builtin/remote-ext.c builtin/remote-fd.c builtin/repack.c builtin/replace.c
+	builtin/rerere.c builtin/reset.c builtin/rev-list.c builtin/rev-parse.c
+	builtin/revert.c builtin/rm.c builtin/send-pack.c builtin/shortlog.c
+	builtin/show-branch.c builtin/show-index.c builtin/show-ref.c
+	builtin/sparse-checkout.c builtin/stash.c builtin/stripspace.c
+	builtin/submodule--helper.c builtin/symbolic-ref.c builtin/tag.c
+	builtin/unpack-file.c builtin/unpack-objects.c builtin/update-index.c
+	builtin/update-ref.c builtin/update-server-info.c builtin/upload-archive.c
+	builtin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c
+	builtin/verify-tag.c builtin/worktree.c builtin/write-tree.c)

Can't we do a bit better here?

Perhaps grab this out of our Makefile? The same command applies to huge lists of sources we have seen.

Or do the equivalent of $(wildcard builtin/*.c) if CMake has such a feature?

Quoted 2 lines

...
\ No newline at end of file

Double check and make sure you have a text file without an incomplete line at the end.

Thanks.

#87 lore raw

Re: [PATCH v2 01/11] Introduce CMake support for configuring Git on Linux

Quoted 56 lines · Junio C Hamano
Quoted 7 lines · Sibi Siddharthan via GitGitGadget

To make this a little less awkward, the Git for Windows project offers the vs/master branch which has a full Visual Studio solution generated and committed. This branch can therefore be used to tinker with Git in Visual Studio _without_ having to download the full Git for Windows SDK. Unfortunatly, that branch is auto-generated from Git for Windows' master. If a developer wants to tinker, say, with pu, they are out of luck.

'pu' or 'next' are not to be built upon, so this is not a good line of reasoning to complain that generating only for 'master' is bad.

Quoted 2 lines

CMake was invented to make this sort of problem go away, by providing a more standardized, cross-platform way to configure builds.

I think everything above this point (including Makefile, autoconf etc.) can be replaced with a single sentence

The build infrastructure for Git is written around being able to run make, which is not supported natively on Windows.

without anything else. That will flow naturally to

Add a build script that uses CMake to help developers on Windows to build git.

and then you can continue the current state, like this paragraph.

Quoted 16 lines

This is only the first step, and to make it easier to review, it only allows for configuring builds on the platform that is easiest to configure for: Linux.

The CMake script checks whether the headers are present(eg. libgen.h), whether the functions are present(eg. memmem), whether the funtions work properly (eg. snprintf) and generate the required compile definitions for the platform. The script also searches for the required libraries, if it fails to find the required libraries the respective executables won't be built.(eg. If libcurl is not found then git-remote-http won't be built). This will help building Git easier.

With a CMake script an out of source build of git is possible resulting in a clean source tree.

Quoted 8 lines

Note: earlier endeavors on the Git mailing list to introduce CMake ended up in dead water. The primary reason for that was that reviewers _expected_ CMake support to fall out of maintenance, unless the contributor would promise to keep an eye on keeping CMake support up to date. However, in the meantime, support for automated testing has been introduced in Git's source code, and a later patch will modify the (still experimental) GitHub workflow to continually verify that CMake support is still complete. That will make maintenance reasonably easy.

Quoted 2 lines

I am not sure this belongs to the log message.

Will remove it.

Quoted 6 lines
Quoted 5 lines

Note: this patch asks for the minimum version v3.14 of CMake (which is not all that old as of time of writing) because that is the first version to offer a platform-independent way to generate hardlinks as part of the build. This is needed to generate all those hardlinks for the built-in commands of Git.

Quoted 6 lines

This does, but I do not think hardlinks are not required for our build. On Unix filesystems, it is not just possible but convenient to use, and that is the only reason why we use hardlinks.

If hardlinks are possible but inconvenient to use on Windows, you shouldn't force your target audience to use it.

Another alternative is to use verbatim copies, but this increases the size of the generated build artifacts considerably. Hardlinks are not inconvenient on Windows, CMake 3.14 gives a cross platform way of generating them.

Quoted 18 lines
Quoted 18 lines

Instructions to run CMake:

cmake relative-path-to-srcdir -DCMAKE_BUILD_TYPE=Release

Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding compiler flags
Debug : -g
Release: -O3
RelWithDebInfo : -O2 -g
MinSizeRel : -Os
empty(default) :

NOTE: -DCMAKE_BUILD_TYPE is optional

This process generates a Makefile.
Then run make to build Git.

Quoted 8 lines
Quoted 3 lines

NOTE: By default CMake uses Makefile as the build tool on Linux, to use another tool say ninja add this to the command line when configuring. -G Ninja

I find it curious that from the instruction, the most important platform, the primary reason why we are reviewing this patch, is missing. Don't Windows folks need to be told how to run CMake to build?

The instructions are the same for any platform. Just like ./configure.

Quoted 8 lines

In any case, all of the above "Instructions" should go at the top part of CMakeLists.txt in a comment, and not in the log message. "git log" output is not an easy way for your target audience to learn how to use what the commit adds. Think what they need to do when they discover there is CMakeLists.txt in our tree in three months. Don't force them to run "git blame" to find this commit that added the support.

Okay, will add some instructions on top of the script.

Quoted 75 lines
Quoted 13 lines
---
 CMakeLists.txt | 528 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 528 insertions(+)
 create mode 100644 CMakeLists.txt
CMakeLists.txt new file +0 -0
new file mode 100644
index 00000000000..73703bd321f

CMakeLists.txt line 10

Quoted 10 lines
CMakeLists.txt new file +10 -0
@@ -0,0 +1,528 @@
+#
+#    Copyright (c) 2020 Sibi Siddharthan
+#
+
+cmake_minimum_required(VERSION 3.14)
+
+#Parse GIT-VERSION-GEN to get the version
+file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX "DEF_VER=v(.*)")
+string(REPLACE "DEF_VER=v" "" git_version ${git_version})
+string(REPLACE ".GIT" ".0" git_version ${git_version})#for building from a snapshot

Hmph, I'd really prefer to see the logic in GIT-VERSION-GEN not bypassed like this. People know they can create a text file 'version' and record the version name they desire in it and expect GIT-VERSION-GEN to pick it up, for example.

Later in this file, you seem to depend on the shell to do things like generating config-list.h file, so I'd rather see the same technique used here a well.

CMakeLists.txt line 391

Quoted 4 lines
CMakeLists.txt new file +4 -0
+set(libgit_SOURCES
+     abspath.c add-interactive.c add-patch.c advice.c alias.c
+...
+     zlib.c)

Hmph.

Quoted 24 lines
CMakeLists.txt new file +24 -0
+set(git_SOURCES
+     builtin/add.c builtin/am.c builtin/annotate.c builtin/apply.c
+     builtin/archive.c builtin/bisect--helper.c builtin/blame.c
+     builtin/branch.c builtin/bundle.c builtin/cat-file.c builtin/check-attr.c
+     builtin/check-ignore.c builtin/check-mailmap.c builtin/check-ref-format.c
+     builtin/checkout-index.c builtin/checkout.c builtin/clean.c
+     builtin/clone.c builtin/column.c builtin/commit-tree.c
+     builtin/commit.c builtin/commit-graph.c builtin/config.c
+     builtin/count-objects.c builtin/credential.c builtin/describe.c
+     builtin/diff-files.c builtin/diff-index.c builtin/diff-tree.c
+     builtin/diff.c builtin/difftool.c builtin/env--helper.c
+     builtin/fast-export.c builtin/fetch-pack.c builtin/fetch.c builtin/fmt-merge-msg.c
+     builtin/for-each-ref.c builtin/fsck.c builtin/gc.c
+     builtin/get-tar-commit-id.c builtin/grep.c builtin/hash-object.c
+     builtin/help.c builtin/index-pack.c builtin/init-db.c
+     builtin/interpret-trailers.c builtin/log.c builtin/ls-files.c
+     builtin/ls-remote.c builtin/ls-tree.c builtin/mailinfo.c builtin/mailsplit.c
+     builtin/merge.c builtin/merge-base.c builtin/merge-file.c builtin/merge-index.c
+     builtin/merge-ours.c builtin/merge-recursive.c builtin/merge-tree.c
+     builtin/mktag.c builtin/mktree.c builtin/multi-pack-index.c builtin/mv.c
+     builtin/name-rev.c builtin/notes.c builtin/pack-objects.c builtin/pack-redundant.c
+     builtin/pack-refs.c builtin/patch-id.c builtin/prune-packed.c builtin/prune.c
+     builtin/pull.c builtin/push.c builtin/range-diff.c builtin/read-tree.c
+     builtin/rebase.c builtin/receive-pack.c builtin/reflog.c builtin/remote.c

CMakeLists.txt line 449

Quoted 10 lines
CMakeLists.txt new file +10 -0
+     builtin/remote-ext.c builtin/remote-fd.c builtin/repack.c builtin/replace.c
+     builtin/rerere.c builtin/reset.c builtin/rev-list.c builtin/rev-parse.c
+     builtin/revert.c builtin/rm.c builtin/send-pack.c builtin/shortlog.c
+     builtin/show-branch.c builtin/show-index.c builtin/show-ref.c
+     builtin/sparse-checkout.c builtin/stash.c builtin/stripspace.c
+     builtin/submodule--helper.c builtin/symbolic-ref.c builtin/tag.c
+     builtin/unpack-file.c builtin/unpack-objects.c builtin/update-index.c
+     builtin/update-ref.c builtin/update-server-info.c builtin/upload-archive.c
+     builtin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c
+     builtin/verify-tag.c builtin/worktree.c builtin/write-tree.c)
Quoted 8 lines

Can't we do a bit better here?

Perhaps grab this out of our Makefile? The same command applies to huge lists of sources we have seen.

Or do the equivalent of $(wildcard builtin/*.c) if CMake has such a feature?

We do have that.

Quoted 7 lines
Quoted 2 lines

...
\ No newline at end of file

Double check and make sure you have a text file without an incomplete line at the end.

Thanks.

Thank You,
Sibi Siddharthan

#88 lore raw

PATCH v2 2/11 cmake: generate the shell/perl/python scripts and templates, translations

In reply to Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch implements the placeholder substitution to generate, say, git-request-pull from git-request-pull.sh.

The shell/perl/python scripts and template are generated using CMake (very similar to what sed does).

The text translations are only build if msgfmt is found in your path.

NOTE: The scripts and templates are generated during configuration.

---
 CMakeLists.txt | 107 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 106 insertions(+), 1 deletion(-)
CMakeLists.txt +106 -1
index 73703bd321f..788b53be873 100644
@@ -51,6 +51,11 @@ endif()
 
 find_program(SH_EXE sh)
 
+find_program(MSGFMT_EXE msgfmt)
+if(NOT MSGFMT_EXE)
+	message(WARNING "Text Translations won't be build")
+endif()
+
 #default behaviour
 include_directories(${CMAKE_SOURCE_DIR})
 add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
@@ -525,4 +530,104 @@ endif()
 add_custom_command(OUTPUT ${git_links} ${git_http_links}
 		COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
 		DEPENDS git git-remote-http)
-add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
\ No newline at end of file
+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
+
+
+#creating required scripts
+set(SHELL_PATH /bin/sh)
+set(PERL_PATH /usr/bin/perl)
+set(LOCALEDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)
+set(GITWEBDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)
+set(INSTLIBDIR ${FALLBACK_RUNTIME_PREFIX}/share/perl5)
+
+#shell scripts
+set(git_shell_scripts
+	git-bisect git-difftool--helper git-filter-branch
+	git-merge-octopus git-merge-one-file git-merge-resolve
+	git-mergetool git-quiltimport
+	git-request-pull git-submodule git-web--browse
+	git-mergetool--lib git-parse-remote git-rebase--preserve-merges
+	git-sh-setup git-sh-i18n git-instaweb)
+
+foreach(script ${git_shell_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.sh content NEWLINE_CONSUME)
+	string(REPLACE "@SHELL_PATH@" "${SHELL_PATH}" content "${content}")
+	string(REPLACE "@@DIFF@@" "diff" content "${content}")
+	string(REPLACE "@LOCALEDIR@" "${LOCALEDIR}" content "${content}")
+	string(REPLACE "@GITWEBDIR@" "${GITWEBDIR}" content "${content}")
+	string(REPLACE "@@NO_CURL@@" "" content "${content}")
+	string(REPLACE "@@USE_GETTEXT_SCHEME@@" "" content "${content}")
+	string(REPLACE "# @@BROKEN_PATH_FIX@@" "" content "${content}")
+	string(REPLACE "@@PERL@@" "${PERL_PATH}" content "${content}")
+	string(REPLACE "@@SANE_TEXT_GREP@@" "-a" content "${content}")
+	string(REPLACE "@@PAGER_ENV@@" "LESS=FRX LV=-c" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
+endforeach()
+
+#perl scripts
+set(git_perl_scripts
+	git-add--interactive git-archimport git-cvsexportcommit
+	git-cvsimport git-cvsserver git-send-email git-svn)
+
+#create perl header
+file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )
+string(REPLACE "@@PATHSEP@@" ":" perl_header "${perl_header}")
+string(REPLACE "@@INSTLIBDIR@@" "${INSTLIBDIR}" perl_header "${perl_header}")
+
+foreach(script ${git_perl_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.perl content NEWLINE_CONSUME)
+	string(REPLACE "#!/usr/bin/perl" "#!/usr/bin/perl\n${perl_header}\n" content "${content}")
+	string(REPLACE "@@GIT_VERSION@@" "${PROJECT_VERSION}" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
+endforeach()
+
+#python script
+file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)
+string(REPLACE "#!/usr/bin/env python" "#!/usr/bin/python" content "${content}")
+file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})
+
+#perl modules
+file(GLOB_RECURSE perl_modules "${CMAKE_SOURCE_DIR}/perl/*.pm")
+
+foreach(pm ${perl_modules})
+	string(REPLACE "${CMAKE_SOURCE_DIR}/perl/" "" file_path ${pm})
+	file(STRINGS ${pm} content NEWLINE_CONSUME)
+	string(REPLACE "@@LOCALEDIR@@" "${LOCALEDIR}" content "${content}")
+	string(REPLACE "@@NO_PERL_CPAN_FALLBACKS@@" "" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})
+#test-lib.sh requires perl/build/lib to be the build directory of perl modules
+endforeach()
+
+
+#templates
+file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches
+set(hooks_templates
+	applypatch-msg.sample pre-applypatch.sample pre-push.sample
+	commit-msg.sample pre-commit.sample pre-rebase.sample
+	fsmonitor-watchman.sample pre-merge-commit.sample pre-receive.sample
+	post-update.sample prepare-commit-msg.sample update.sample)
+
+#templates have @.*@ replacement so use configure_file instead
+#hooks
+foreach(tm ${hooks_templates})
+	configure_file(${CMAKE_SOURCE_DIR}/templates/hooks--${tm} ${CMAKE_BINARY_DIR}/templates/blt/hooks/${tm} @ONLY)
+endforeach()
+
+#info
+configure_file(${CMAKE_SOURCE_DIR}/templates/info--exclude ${CMAKE_BINARY_DIR}/templates/blt/info/exclude @ONLY)
+
+#this
+configure_file(${CMAKE_SOURCE_DIR}/templates/this--description ${CMAKE_BINARY_DIR}/templates/blt/description @ONLY)
+
+
+#translations
+if(MSGFMT_EXE)
+	set(po_files bg  ca  de  el  es  fr  is  it  ko  pt_PT  ru  sv  tr  vi  zh_CN  zh_TW)
+	foreach(po ${po_files})
+		file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES)
+		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo
+				COMMAND ${MSGFMT_EXE} --check --statistics -o ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo ${CMAKE_SOURCE_DIR}/po/${po}.po)
+		list(APPEND po_gen ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo)
+	endforeach()
+	add_custom_target(po-gen ALL DEPENDS ${po_gen})
+endif()
Signature · 1 line
gitgitgadget
#89 lore raw

Re: [PATCH v2 02/11] cmake: generate the shell/perl/python scripts and templates, translations

Quoted 7 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch implements the placeholder substitution to generate, say, git-request-pull from git-request-pull.sh.

The shell/perl/python scripts and template are generated using CMake (very similar to what sed does).

We do not say "This patch does X" or "I do Y in this patch". perhaps.

Implement the placeholder substitution to generate scripted Porcelain commands, e.g. git-request-pull out of git-request-pull.sh

Generate scripts and templates using CMake, instead of using sed like the build procedure in the Makefile does.

#90 lore raw

Re: [PATCH v2 02/11] cmake: generate the shell/perl/python scripts and templates, translations

Quoted 14 lines · Junio C Hamano
Quoted 7 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch implements the placeholder substitution to generate, say, git-request-pull from git-request-pull.sh.

The shell/perl/python scripts and template are generated using CMake (very similar to what sed does).

We do not say "This patch does X" or "I do Y in this patch". perhaps.

Quoted 7 lines

Implement the placeholder substitution to generate scripted Porcelain commands, e.g. git-request-pull out of git-request-pull.sh

Generate scripts and templates using CMake, instead of using sed like the build procedure in the Makefile does.

Will reword.

Thank You,
Sibi Siddharthan

#91 lore raw

PATCH v2 3/11 cmake: installation support for git

In reply to Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch provides the facility to install the built binaries and scripts.

This is very similar to make install.
By default the destination directory(DESTDIR) is /usr/local/ on Linux To set a custom installation path do this:
cmake relative-path-to-srcdir
-DCMAKE_INSTALL_PREFIX=preferred-install-path

Then run make install

Changes:
Removed a comment regarding the installation of gitk.

---
 CMakeLists.txt | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
CMakeLists.txt +49 -0
index 788b53be873..1e9f2fe8ff6 100644
@@ -13,6 +13,8 @@ project(git
 	VERSION ${git_version}
 	LANGUAGES C)
 
+#TODO gitk git-gui gitweb
+#TODO Add pcre support
 
 include(CheckTypeSize)
 include(CheckCSourceRuns)
@@ -631,3 +633,50 @@ if(MSGFMT_EXE)
 	endforeach()
 	add_custom_target(po-gen ALL DEPENDS ${po_gen})
 endif()
+
+
+#to help with the install
+list(TRANSFORM git_shell_scripts PREPEND "${CMAKE_BINARY_DIR}/")
+list(TRANSFORM git_perl_scripts PREPEND "${CMAKE_BINARY_DIR}/")
+
+#install
+install(TARGETS git git-shell
+	RUNTIME DESTINATION bin)
+install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver
+	DESTINATION bin)
+
+list(REMOVE_ITEM PROGRAMS_BUILT git git-shell)
+install(TARGETS ${PROGRAMS_BUILT}
+	RUNTIME DESTINATION libexec/git-core)
+
+set(bin_links
+	git-receive-pack git-upload-archive git-upload-pack)
+
+foreach(b ${bin_links})
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})")
+endforeach()
+
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)")
+
+foreach(b ${git_links})
+	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
+	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+endforeach()
+
+foreach(b ${git_http_links})
+	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
+	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+endforeach()
+
+install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
+	DESTINATION libexec/git-core)
+
+install(DIRECTORY mergetools DESTINATION libexec/git-core)
+install(DIRECTORY ${CMAKE_BINARY_DIR}/perl/build/lib/ DESTINATION share/perl5
+	FILES_MATCHING PATTERN "*.pm")
+install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/templates)
+
+if(MSGFMT_EXE)
+	install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)
+endif()
Signature · 1 line
gitgitgadget
#92 lore raw

PATCH v2 4/11 cmake: support for testing git with ctest

In reply to Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch provides an alternate way to test git using ctest. CTest ships with CMake, so there is no additional dependency being introduced.

To perform the tests with ctest do this after building:
ctest -j[number of jobs]

NOTE: -j is optional, the default number of jobs is 1

Each of the jobs does this:
cd t/ && sh t[something].sh

The reason for using CTest is that it logs the output of the tests in a neat way, which can be helpful during diagnosis of failures.

After the tests have run ctest generates three log files located in build-directory/Testing/Temporary/

These log files are:

CTestCostData.txt:
This file contains the time taken to complete each test.

LastTestsFailed.log:
This log file contains the names of the tests that have failed in the run.

LastTest.log:
This log file contains the log of all the tests that have run. A snippet of the file is given below.

10/901 Testing: D:/my/git-master/t/t0009-prio-queue.sh 10/901 Test: D:/my/git-master/t/t0009-prio-queue.sh
Command: "sh.exe" "D:/my/git-master/t/t0009-prio-queue.sh"
Directory: D:/my/git-master/t "D:/my/git-master/t/t0009-prio-queue.sh"
Output:
----------------------------------------------------------
ok 1 - basic ordering
ok 2 - mixed put and get
ok 3 - notice empty queue
ok 4 - stack order
passed all 4 test(s)
1..4
<end of output>
Test time = 1.11 sec

NOTE: Testing only works when building in source for now.

Changes:
Renamed the variable test_helper_sources to test-tool_SOURCES to be consistent with the naming of source variables.

---
 CMakeLists.txt | 142 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 142 insertions(+)
CMakeLists.txt +142 -0
index 1e9f2fe8ff6..05fbb05c6ad 100644
@@ -23,6 +23,7 @@ include(CheckIncludeFile)
 include(CheckFunctionExists)
 include(CheckSymbolExists)
 include(CheckStructHasMember)
+include(CTest)
 
 find_package(ZLIB REQUIRED)
 find_package(CURL)
@@ -680,3 +681,144 @@ install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/
 if(MSGFMT_EXE)
 	install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)
 endif()
+
+
+if(BUILD_TESTING)
+
+#tests-helpers
+add_executable(test-fake-ssh t/helper/test-fake-ssh.c)
+target_link_libraries(test-fake-ssh common-main)
+
+add_executable(test-line-buffer t/helper/test-line-buffer.c)
+target_link_libraries(test-line-buffer common-main vcs-svn)
+
+add_executable(test-svn-fe t/helper/test-svn-fe.c)
+target_link_libraries(test-svn-fe common-main vcs-svn)
+
+set(test-tool_SOURCES
+	t/helper/test-tool.c t/helper/test-advise.c t/helper/test-bloom.c t/helper/test-chmtime.c
+	t/helper/test-config.c t/helper/test-ctype.c t/helper/test-date.c t/helper/test-delta.c
+	t/helper/test-dir-iterator.c t/helper/test-drop-caches.c t/helper/test-dump-cache-tree.c
+	t/helper/test-dump-fsmonitor.c t/helper/test-dump-split-index.c
+	t/helper/test-dump-untracked-cache.c t/helper/test-example-decorate.c
+	t/helper/test-genrandom.c t/helper/test-genzeros.c t/helper/test-hash.c
+	t/helper/test-hashmap.c t/helper/test-hash-speed.c t/helper/test-index-version.c
+	t/helper/test-json-writer.c t/helper/test-lazy-init-name-hash.c
+	t/helper/test-match-trees.c t/helper/test-mergesort.c t/helper/test-mktemp.c
+	t/helper/test-oidmap.c t/helper/test-online-cpus.c t/helper/test-parse-options.c
+	t/helper/test-parse-pathspec-file.c t/helper/test-path-utils.c t/helper/test-pkt-line.c
+	t/helper/test-prio-queue.c t/helper/test-progress.c t/helper/test-reach.c
+	t/helper/test-read-cache.c t/helper/test-read-graph.c t/helper/test-read-midx.c
+	t/helper/test-ref-store.c t/helper/test-regex.c t/helper/test-repository.c
+	t/helper/test-revision-walking.c t/helper/test-run-command.c t/helper/test-scrap-cache-tree.c
+	t/helper/test-serve-v2.c t/helper/test-sha1.c t/helper/test-oid-array.c t/helper/test-sha256.c
+	t/helper/test-sigchain.c t/helper/test-strcmp-offset.c t/helper/test-string-list.c
+	t/helper/test-submodule-config.c t/helper/test-submodule-nested-repo-config.c t/helper/test-subprocess.c
+	t/helper/test-trace2.c t/helper/test-urlmatch-normalization.c t/helper/test-xml-encode.c
+	t/helper/test-wildmatch.c t/helper/test-windows-named-pipe.c t/helper/test-write-cache.c)
+
+add_executable(test-tool ${test-tool_SOURCES})
+target_link_libraries(test-tool common-main)
+
+set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
+			PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)
+
+#wrapper scripts
+set(wrapper_scripts
+	git git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)
+
+set(wrapper_test_scripts
+	test-fake-ssh test-line-buffer test-svn-fe test-tool)
+
+
+foreach(script ${wrapper_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
+	string(REPLACE "@@PROG@@" "${script}" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
+endforeach()
+
+foreach(script ${wrapper_test_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
+	string(REPLACE "@@PROG@@" "t/helper/${script}" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
+endforeach()
+
+file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
+string(REPLACE "@@PROG@@" "git-cvsserver" content "${content}")
+file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})
+
+#options for configuring test options
+option(PERL_TESTS "Perform tests that use perl" ON)
+option(PYTHON_TESTS "Perform tests that use python" ON)
+
+#GIT-BUILD-OPTIONS
+set(TEST_SHELL_PATH ${SHELL_PATH})
+set(DIFF diff)
+set(PYTHON_PATH /usr/bin/python)
+set(TAR tar)
+set(NO_CURL )
+set(NO_EXPAT )
+set(USE_LIBPCRE1 )
+set(USE_LIBPCRE2 )
+set(NO_LIBPCRE1_JIT )
+set(NO_PERL )
+set(NO_PTHREADS )
+set(NO_PYTHON )
+set(PAGER_ENV "LESS=FRX LV=-c")
+set(DC_SHA1 YesPlease)
+set(RUNTIME_PREFIX true)
+set(NO_GETTEXT )
+
+if(NOT CURL_FOUND)
+	set(NO_CURL 1)
+endif()
+
+if(NOT EXPAT_FOUND)
+	set(NO_EXPAT 1)
+endif()
+
+if(NOT Intl_FOUND)
+	set(NO_GETTEXT 1)
+endif()
+
+if(NOT PERL_TESTS)
+	set(NO_PERL 1)
+endif()
+
+if(NOT PYTHON_TESTS)
+	set(NO_PYTHON 1)
+endif()
+
+file(WRITE ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "SHELL_PATH='${SHELL_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TEST_SHELL_PATH='${TEST_SHELL_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PERL_PATH='${PERL_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DIFF='${DIFF}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PYTHON_PATH='${PYTHON_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TAR='${TAR}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_CURL='${NO_CURL}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_EXPAT='${NO_EXPAT}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "USE_LIBPCRE1='${USE_LIBPCRE1}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_LIBPCRE1_JIT='${NO_LIBPCRE1_JIT}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PERL='${NO_PERL}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PAGER_ENV='${PAGER_ENV}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DC_SHA1='${DC_SHA1}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X=''\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
+
+file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")
+
+#test
+foreach(tsh ${test_scipts})
+	add_test(NAME ${tsh}
+		COMMAND ${SH_EXE} ${tsh}
+		WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t)
+endforeach()
+
+endif()#BUILD_TESTING
\ No newline at end of file
Signature · 1 line
gitgitgadget
#93 lore raw

PATCH v2 5/11 cmake: support for testing git when building out of the source tree

In reply to Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch allows git to be tested when performin out of source builds.

This involves changing GIT_BUILD_DIR in t/test-lib.sh to point to the build directory. Also some miscellaneous copies from the source directory to the build directory.
The copies are:
t/chainlint.sed needed by a bunch of test scripts
po/is.po needed by t0204-gettext-rencode-sanity mergetools/tkdiff needed by t7800-difftool contrib/completion/git-prompt.sh needed by t9903-bash-prompt contrib/completion/git-completion.bash needed by t9902-completion contrib/svn-fe/svnrdump_sim.py needed by t9020-remote-svn

NOTE: t/test-lib.sh is only modified when tests are run not during the build or configure.
The trash directory is still srcdir/t

---
 CMakeLists.txt | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
CMakeLists.txt +19 -0
index 05fbb05c6ad..47d3f3c2866 100644
@@ -812,6 +812,25 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n"
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
 
+#Make the tests work when building out of the source tree
+if(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
+	file(RELATIVE_PATH BUILD_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/CMakeCache.txt)
+	string(REPLACE "/CMakeCache.txt" "" BUILD_DIR_RELATIVE ${BUILD_DIR_RELATIVE})
+	#Setting the build directory in test-lib.sh before running tests
+	file(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.cmake
+		"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh GIT_BUILD_DIR_REPL REGEX \"GIT_BUILD_DIR=(.*)\")\n"
+		"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh content NEWLINE_CONSUME)\n"
+		"string(REPLACE \"\${GIT_BUILD_DIR_REPL}\" \"GIT_BUILD_DIR=\\\"$TEST_DIRECTORY\\\"/../${BUILD_DIR_RELATIVE}\" content \"\${content}\")\n"
+		"file(WRITE ${CMAKE_SOURCE_DIR}/t/test-lib.sh \${content})")
+	#misc copies
+	file(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.sed DESTINATION ${CMAKE_BINARY_DIR}/t/)
+	file(COPY ${CMAKE_SOURCE_DIR}/po/is.po DESTINATION ${CMAKE_BINARY_DIR}/po/)
+	file(COPY ${CMAKE_SOURCE_DIR}/mergetools/tkdiff DESTINATION ${CMAKE_BINARY_DIR}/mergetools/)
+	file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-prompt.sh DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)
+	file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-completion.bash DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)
+	file(COPY ${CMAKE_SOURCE_DIR}/contrib/svn-fe/svnrdump_sim.py DESTINATION ${CMAKE_BINARY_DIR}/contrib/svn-fe/)
+endif()
+
 file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")
 
 #test
Signature · 1 line
gitgitgadget
#94 lore raw

PATCH v2 6/11 cmake: support for building git on windows with mingw

In reply to Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch facilitates building git on Windows with CMake using MinGW

NOTE: The funtions unsetenv and hstrerror are not checked in Windows builds.
Reasons
NO_UNSETENV is not compatible with Windows builds.
lines 262-264 compat/mingw.h

compat/mingw.h(line 25) provides a definition of hstrerror which conflicts with the definition provided in git-compat-util.h(lines 733-736).

To use CMake on Windows with MinGW do this:
cmake relative-path-to-srcdir -G "MinGW Makefiles"

Changes:
Changed the error message when sh.exe is not found on Windows as suggested by Philip Oakley <[email protected]>

---
 CMakeLists.txt | 121 +++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 98 insertions(+), 23 deletions(-)
CMakeLists.txt +98 -23
index 47d3f3c2866..9625e41886f 100644
@@ -13,9 +13,12 @@ project(git
 	VERSION ${git_version}
 	LANGUAGES C)
 
+
 #TODO gitk git-gui gitweb
+#TODO Enable NLS on windows natively
 #TODO Add pcre support
 
+
 include(CheckTypeSize)
 include(CheckCSourceRuns)
 include(CheckCSourceCompiles)
@@ -31,6 +34,7 @@ find_package(EXPAT)
 find_package(Iconv)
 find_package(Intl)
 
+
 if(NOT Intl_FOUND)
 	add_compile_definitions(NO_GETTEXT)
 	if(NOT Iconv_FOUND)
@@ -53,6 +57,17 @@ if(Intl_FOUND)
 endif()
 
 find_program(SH_EXE sh)
+if(NOT SH_EXE)
+	message(FATAL_ERROR "sh: shell interpreter was not found in your path, please install one."
+			"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/")
+endif()
+
+if(WIN32)
+	find_program(WINDRES_EXE windres)
+	if(NOT WINDRES_EXE)
+		message(FATAL_ERROR "Install windres on Windows for resource files")
+	endif()
+endif()
 
 find_program(MSGFMT_EXE msgfmt)
 if(NOT MSGFMT_EXE)
@@ -85,11 +100,39 @@ add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
 			BINDIR="bin"
 			GIT_BUILT_FROM_COMMIT="")
 
-set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
-add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+if(WIN32)
+	set(FALLBACK_RUNTIME_PREFIX /mingw64)
+	add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+else()
+	set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
+	add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+endif()
 
-add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
-list(APPEND compat_SOURCES unix-socket.c)
+
+#Platform Specific
+if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+	include_directories(compat/win32)
+	add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
+				_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
+				NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0 NO_ST_BLOCKS_IN_STRUCT_STAT
+				USE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP
+				UNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)
+	list(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c
+		compat/win32/pthread.c compat/win32mmap.c compat/win32/syslog.c
+		compat/win32/trace2_win32_process_info.c compat/win32/dirent.c
+		compat/nedmalloc/nedmalloc.c compat/strdup.c)
+	set(NO_UNIX_SOCKETS 1)
+
+elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
+	add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
+	list(APPEND compat_SOURCES unix-socket.c)
+endif()
+
+if(WIN32)
+	set(EXE_EXTENSION .exe)
+else()
+	set(EXE_EXTENSION)
+endif()
 
 #header checks
 check_include_file(libgen.h HAVE_LIBGEN_H)
@@ -150,7 +193,12 @@ endif()
 #function checks
 set(function_checks
 	strcasestr memmem strlcpy strtoimax strtoumax strtoull
-	setenv  mkdtemp poll pread  memmem unsetenv hstrerror)
+	setenv  mkdtemp poll pread  memmem)
+
+#unsetenv,hstrerror are incompatible with windows build
+if(NOT WIN32)
+	list(APPEND function_checks unsetenv hstrerror)
+endif()
 
 foreach(f ${function_checks})
 	string(TOUPPER ${f} uf)
@@ -309,7 +357,13 @@ endif()
 #programs
 set(PROGRAMS_BUILT
 	git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
-	git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)
+	git-shell git-remote-testsvn)
+
+if(NO_UNIX_SOCKETS)
+	list(APPEND excluded_progs git-credential-cache git-credential-cache--daemon)
+else()
+	list(APPEND PROGRAMS_BUILT git-credential-cache git-credential-cache--daemon)
+endif()
 
 if(NOT CURL_FOUND)
 	list(APPEND excluded_progs git-http-fetch git-http-push)
@@ -410,15 +464,34 @@ set(libvcs-svn_SOURCES
 	vcs-svn/svndiff.c vcs-svn/svndump.c)
 add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
 
+#add git.rc for gcc
+if(WIN32)
+	add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
+			COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
+				-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
+				-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
+			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+			VERBATIM)
+	add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)
+endif()
+
 #link all required libraries to common-main
 add_library(common-main OBJECT common-main.c)
-target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
+
+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})
 if(Intl_FOUND)
 	target_link_libraries(common-main ${Intl_LIBRARIES})
 endif()
 if(Iconv_FOUND)
 	target_link_libraries(common-main ${Iconv_LIBRARIES})
 endif()
+if(WIN32)
+	target_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)
+	add_dependencies(common-main git-rc)
+	target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)
+elseif(UNIX)
+	target_link_libraries(common-main pthread rt)
+endif()
 
 
 set(git_SOURCES
@@ -501,11 +574,13 @@ endif()
 add_executable(git-remote-testsvn remote-testsvn.c)
 target_link_libraries(git-remote-testsvn common-main vcs-svn)
 
-add_executable(git-credential-cache credential-cache.c)
-target_link_libraries(git-credential-cache common-main)
+if(NOT NO_UNIX_SOCKETS)
+	add_executable(git-credential-cache credential-cache.c)
+	target_link_libraries(git-credential-cache common-main)
 
-add_executable(git-credential-cache--daemon credential-cache--daemon.c)
-target_link_libraries(git-credential-cache--daemon common-main)
+	add_executable(git-credential-cache--daemon credential-cache--daemon.c)
+	target_link_libraries(git-credential-cache--daemon common-main)
+endif()
 
 
 set(git_builtin_extra
@@ -517,16 +592,16 @@ set(git_builtin_extra
 foreach(s ${git_SOURCES} ${git_builtin_extra})
 	string(REPLACE "builtin/" "" s ${s})
 	string(REPLACE ".c" "" s ${s})
-	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git git-${s})\n")
-	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})
+	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git${EXE_EXTENSION} git-${s}${EXE_EXTENSION})\n")
+	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s}${EXE_EXTENSION})
 endforeach()
 
 if(CURL_FOUND)
 	set(remote_exes
 		git-remote-https git-remote-ftp git-remote-ftps)
 	foreach(s ${remote_exes})
-		file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http ${s})\n")
-		list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})
+		file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http${EXE_EXTENSION} ${s}${EXE_EXTENSION})\n")
+		list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s}${EXE_EXTENSION})
 	endforeach()
 endif()
 
@@ -654,20 +729,20 @@ set(bin_links
 	git-receive-pack git-upload-archive git-upload-pack)
 
 foreach(b ${bin_links})
-install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/bin/${b}${EXE_EXTENSION})")
 endforeach()
 
-install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)")
-install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git${EXE_EXTENSION})")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell${EXE_EXTENSION})")
 
 foreach(b ${git_links})
 	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
-	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})")
 endforeach()
 
 foreach(b ${git_http_links})
 	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
-	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})")
 endforeach()
 
 install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
@@ -734,14 +809,14 @@ set(wrapper_test_scripts
 foreach(script ${wrapper_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
 	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-	string(REPLACE "@@PROG@@" "${script}" content "${content}")
+	string(REPLACE "@@PROG@@" "${script}${EXE_EXTENSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
 foreach(script ${wrapper_test_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
 	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-	string(REPLACE "@@PROG@@" "t/helper/${script}" content "${content}")
+	string(REPLACE "@@PROG@@" "t/helper/${script}${EXE_EXTENSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
@@ -807,7 +882,7 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PAGER_ENV='${PAGER_ENV}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DC_SHA1='${DC_SHA1}'\n")
-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X=''\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X='${EXE_EXTENSION}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
Signature · 1 line
gitgitgadget
#95 lore raw

Re: [PATCH v2 06/11] cmake: support for building git on windows with mingw

Hi Sibi,

CMakeLists.txt project(git · line 16

Quoted 10 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

CMakeLists.txt +1 -0
index 47d3f3c2866..9625e41886f 100644
@@ -13,9 +13,12 @@ project(git
 	VERSION ${git_version}
 	LANGUAGES C)
 
+

This newline maybe left from debugging. (and other new newline below).

CMakeLists.txt add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c" · line 113

Quoted 2 lines
CMakeLists.txt +2 -0
+#Platform Specific
+if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")

Please drop ${} around CMAKE_SYSTEM_NAME, here (and other if) Or user may accidental messed up. ------------8<----------------

$ cat CMakeLists.txt
project(test)
message("This is ${CMAKE_SYSTEM_NAME}")
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
	message("Yes, STREQUAL Windows")
endif()
$ cmake . -DLinux=Windows
This is Linux
Yes, STREQUAL Windows
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp
---------------->8--------------
Signature · 1 line
Danh
#96 lore raw

Re: [PATCH v2 06/11] cmake: support for building git on windows with mingw

Quoted 23 lines · Đoàn Trần Công Danh

Hi Sibi,

CMakeLists.txt project(git · line 16

Quoted 10 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

CMakeLists.txt +1 -0
index 47d3f3c2866..9625e41886f 100644
@@ -13,9 +13,12 @@ project(git
      VERSION ${git_version}
      LANGUAGES C)
 
+

This newline maybe left from debugging. (and other new newline below).

CMakeLists.txt add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c" · line 113

Quoted 2 lines
CMakeLists.txt +2 -0
+#Platform Specific
+if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")

Please drop ${} around CMAKE_SYSTEM_NAME, here (and other if) Or user may accidental messed up. ------------8<----------------

Quoted 14 lines
$ cat CMakeLists.txt
project(test)
message("This is ${CMAKE_SYSTEM_NAME}")
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
        message("Yes, STREQUAL Windows")
endif()
$ cmake . -DLinux=Windows
This is Linux
Yes, STREQUAL Windows
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp
---------------->8--------------

Thanks for pointing it out, will fix it ASAP.

Thank You,
Sibi Siddharthan

Quoted 3 lines

--
Danh

#97 lore raw

PATCH v2 7/11 cmake: support for building git on windows with msvc and clang.

In reply to Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch adds support for Visual Studio and Clang builds

The minimum required version of CMake is upgraded to 3.15 because this version offers proper support for Clang builds on Windows.

Libintl is not searched for when building with Visual Studio or Clang because there is no binary compatible version available yet.

NOTE: In the link options invalidcontinue.obj has to be included. The reason for this is because by default, Windows calls abort()'s instead of setting errno=EINVAL when invalid arguments are passed to standard functions.
This commit explains it in detail:
4b623d80f73528a632576990ca51e34c333d5dd6

On Windows the default generator is Visual Studio,so for Visual Studio builds do this:

cmake relative-path-to-srcdir

NOTE: Visual Studio generator is a multi config generator, which means that Debug and Release builds can be done on the same build directory.

For Clang builds do this:

On bash
CC=Clang cmake relative-path-to-srcdir -G Ninja
-DCMAKE_BUILD_TYPE=[Debug or Release]

On cmd
set CC=Clang
cmake relative-path-to-srcdir -G Ninja
-DCMAKE_BUILD_TYPE=[Debug or Release]

---
 CMakeLists.txt | 57 ++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 46 insertions(+), 11 deletions(-)
CMakeLists.txt +46 -11
index 9625e41886f..4353080b708 100644
@@ -2,7 +2,7 @@
 #	Copyright (c) 2020 Sibi Siddharthan
 #
 
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.15)
 
 #Parse GIT-VERSION-GEN to get the version
 file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX "DEF_VER=v(.*)")
@@ -32,8 +32,11 @@ find_package(ZLIB REQUIRED)
 find_package(CURL)
 find_package(EXPAT)
 find_package(Iconv)
-find_package(Intl)
 
+#Don't use libintl on Windows Visual Studio and Clang builds
+if(NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")))
+	find_package(Intl)
+endif()
 
 if(NOT Intl_FOUND)
 	add_compile_definitions(NO_GETTEXT)
@@ -62,7 +65,7 @@ if(NOT SH_EXE)
 			"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/")
 endif()
 
-if(WIN32)
+if(WIN32 AND NOT MSVC)#not required for visual studio builds
 	find_program(WINDRES_EXE windres)
 	if(NOT WINDRES_EXE)
 		message(FATAL_ERROR "Install windres on Windows for resource files")
@@ -74,6 +77,13 @@ if(NOT MSGFMT_EXE)
 	message(WARNING "Text Translations won't be build")
 endif()
 
+#Force all visual studio outputs to CMAKE_BINARY_DIR
+if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
+	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
+	add_compile_options(/MP)
+endif()
+
 #default behaviour
 include_directories(${CMAKE_SOURCE_DIR})
 add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
@@ -111,6 +121,10 @@ endif()
 
 #Platform Specific
 if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+	if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+		include_directories(compat/vcbuild/include)
+		add_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)
+	endif()
 	include_directories(compat/win32)
 	add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
 				_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
@@ -464,14 +478,22 @@ set(libvcs-svn_SOURCES
 	vcs-svn/svndiff.c vcs-svn/svndump.c)
 add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
 
-#add git.rc for gcc
 if(WIN32)
-	add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
-			COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
-				-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
-				-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
-			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
-			VERBATIM)
+	if(NOT MSVC)#use windres when compiling with gcc and clang
+		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
+				COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
+					-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
+					-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
+				WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+				VERBATIM)
+	else()#MSVC use rc
+		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
+				COMMAND ${CMAKE_RC_COMPILER} /d MAJOR=${PROJECT_VERSION_MAJOR} /d MINOR=${PROJECT_VERSION_MINOR}
+					/d MICRO=${PROJECT_VERSION_PATCH} /d PATCHLEVEL=0 /d GIT_VERSION="${PROJECT_VERSION}.GIT"
+					/fo ${CMAKE_BINARY_DIR}/git.res ${CMAKE_SOURCE_DIR}/git.rc
+				WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+				VERBATIM)
+	endif()
 	add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)
 endif()
 
@@ -488,7 +510,13 @@ endif()
 if(WIN32)
 	target_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)
 	add_dependencies(common-main git-rc)
-	target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)
+	if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
+		target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)
+	elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
+		target_link_options(common-main PUBLIC -municode -Wl,-nxcompat -Wl,-dynamicbase -Wl,-entry:wmainCRTStartup -Wl,invalidcontinue.obj)
+	elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+		target_link_options(common-main PUBLIC /IGNORE:4217 /IGNORE:4049 /NOLOGO /ENTRY:wmainCRTStartup /SUBSYSTEM:CONSOLE invalidcontinue.obj)
+	endif()
 elseif(UNIX)
 	target_link_libraries(common-main pthread rt)
 endif()
@@ -798,6 +826,13 @@ target_link_libraries(test-tool common-main)
 set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
 			PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)
 
+if(MSVC)
+	set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
+				PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/t/helper)
+	set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
+				PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/helper)
+endif()
+
 #wrapper scripts
 set(wrapper_scripts
 	git git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)
Signature · 1 line
gitgitgadget
#98 lore raw

PATCH v2 8/11 cmake: added checks for struct stat and libiconv

In reply to Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

The CMake script now checks whether st_blocks is a member of struct stat and set the compile definition NO_ST_BLOCKS_IN_STRUCT_STAT accordingly.

The check for whether ICONV_OMITS_BOM is also added as requested by Danh.

---
 CMakeLists.txt | 59 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 57 insertions(+), 2 deletions(-)
CMakeLists.txt +57 -2
index 4353080b708..975791c8b89 100644
@@ -22,6 +22,7 @@ project(git
 include(CheckTypeSize)
 include(CheckCSourceRuns)
 include(CheckCSourceCompiles)
+include(CheckCSourceRuns)
 include(CheckIncludeFile)
 include(CheckFunctionExists)
 include(CheckSymbolExists)
@@ -128,7 +129,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
 	include_directories(compat/win32)
 	add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
 				_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
-				NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0 NO_ST_BLOCKS_IN_STRUCT_STAT
+				NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0
 				USE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP
 				UNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)
 	list(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c
@@ -280,6 +281,11 @@ if(HAVE_CLOCK_MONOTONIC)
 	add_compile_definitions(HAVE_CLOCK_MONOTONIC)
 endif()
 
+#check for st_blocks in struct stat
+check_struct_has_member("struct stat" st_blocks "sys/stat.h" STRUCT_STAT_HAS_ST_BLOCKS)
+if(NOT STRUCT_STAT_HAS_ST_BLOCKS)
+	add_compile_definitions(NO_ST_BLOCKS_IN_STRUCT_STAT)
+endif()
 
 #compile checks
 check_c_source_runs("
@@ -344,7 +350,6 @@ if(NOT HAVE_REGEX)
 	add_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)
 endif()
 
-
 check_c_source_compiles("
 #include <stddef.h>
 #include <sys/types.h>
@@ -368,6 +373,56 @@ if(HAVE_BSD_SYSCTL)
 	add_compile_definitions(HAVE_BSD_SYSCTL)
 endif()
 
+set(CMAKE_REQUIRED_LIBRARIES ${Iconv_LIBRARIES})
+set(CMAKE_REQUIRED_INCLUDES ${Iconv_INCLUDE_DIRS})
+
+check_c_source_compiles("
+#include <iconv.h>
+
+extern size_t iconv(iconv_t cd,
+		char **inbuf, size_t *inbytesleft,
+		char **outbuf, size_t *outbytesleft);
+
+int main(){return 0;}"
+HAVE_NEW_ICONV)
+if(HAVE_NEW_ICONV)
+	set(HAVE_OLD_ICONV 0)
+else()
+	set(HAVE_OLD_ICONV 1)
+endif()
+
+check_c_source_runs("
+#include <iconv.h>
+#if ${HAVE_OLD_ICONV}
+typedef const char *iconv_ibp;
+#else
+typedef char *iconv_ibp;
+#endif
+
+int main()
+{
+	int v;
+	iconv_t conv;
+	char in[] = \"a\"; iconv_ibp pin = in;
+	char out[20] = \"\"; char *pout = out;
+	size_t isz = sizeof in;
+	size_t osz = sizeof out;
+
+	conv = iconv_open(\"UTF-16\", \"UTF-8\");
+	iconv(conv, &pin, &isz, &pout, &osz);
+	iconv_close(conv);
+	v = (unsigned char)(out[0]) + (unsigned char)(out[1]);
+	return v != 0xfe + 0xff;
+}"
+ICONV_DOESNOT_OMIT_BOM)
+if(NOT ICONV_DOESNOT_OMIT_BOM)
+	add_compile_definitions(ICONV_OMITS_BOM)
+endif()
+
+unset(CMAKE_REQUIRED_LIBRARIES)
+unset(CMAKE_REQUIRED_INCLUDES)
+
+
 #programs
 set(PROGRAMS_BUILT
 	git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
Signature · 1 line
gitgitgadget
#99 lore raw

Re: [PATCH v2 08/11] cmake: added checks for struct stat and libiconv

Quoted 2 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>
Subject: Re: [PATCH v2 08/11] cmake: added checks for struct stat and libiconv

s/added/add/; give a command to the codebase to "be like so", or a command to whoever is typing changes to the editor to "make this happen".

Quoted 2 lines

The CMake script now checks whether st_blocks is a member of struct stat and set the compile definition NO_ST_BLOCKS_IN_STRUCT_STAT accordingly.

Teach the CMake script to check ...

Quoted 5 lines
CMakeLists.txt +0 -0
index 4353080b708..975791c8b89 100644

CMakeLists.txt project(git

Quoted 10 lines
CMakeLists.txt +6 -0
@@ -22,6 +22,7 @@ project(git
 include(CheckTypeSize)
 include(CheckCSourceRuns)
 include(CheckCSourceCompiles)
+include(CheckCSourceRuns)
...
+#check for st_blocks in struct stat
+check_struct_has_member("struct stat" st_blocks "sys/stat.h" STRUCT_STAT_HAS_ST_BLOCKS)
+if(NOT STRUCT_STAT_HAS_ST_BLOCKS)
+	add_compile_definitions(NO_ST_BLOCKS_IN_STRUCT_STAT)
+endif()

All of these compatibility stuff makes sense, but how do we decide where to draw the line between the checks we saw added in [01/11] and the checks added here? It feels pretty arbitrary to me and if that is the case, perhaps we want to move all the "add checks" to a commit separate from [01/11] (whose primary purpose is to add the basic rules without these build tweaks in the file at the final place)?

#100 lore raw

Re: [PATCH v2 08/11] cmake: added checks for struct stat and libiconv

Quoted 31 lines · Junio C Hamano
Quoted 2 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>
Subject: Re: [PATCH v2 08/11] cmake: added checks for struct stat and libiconv

s/added/add/; give a command to the codebase to "be like so", or a command to whoever is typing changes to the editor to "make this happen".

Quoted 2 lines

The CMake script now checks whether st_blocks is a member of struct stat and set the compile definition NO_ST_BLOCKS_IN_STRUCT_STAT accordingly.

Teach the CMake script to check ...

Quoted 5 lines
CMakeLists.txt +0 -0
index 4353080b708..975791c8b89 100644

CMakeLists.txt project(git

Quoted 10 lines
CMakeLists.txt +6 -0
@@ -22,6 +22,7 @@ project(git
 include(CheckTypeSize)
 include(CheckCSourceRuns)
 include(CheckCSourceCompiles)
+include(CheckCSourceRuns)
...
+#check for st_blocks in struct stat
+check_struct_has_member("struct stat" st_blocks "sys/stat.h" STRUCT_STAT_HAS_ST_BLOCKS)
+if(NOT STRUCT_STAT_HAS_ST_BLOCKS)
+     add_compile_definitions(NO_ST_BLOCKS_IN_STRUCT_STAT)
+endif()
Quoted 8 lines

All of these compatibility stuff makes sense, but how do we decide where to draw the line between the checks we saw added in [01/11] and the checks added here? It feels pretty arbitrary to me and if that is the case, perhaps we want to move all the "add checks" to a commit separate from [01/11] (whose primary purpose is to add the basic rules without these build tweaks in the file at the final place)?

The checks are added on a "demand" based the target platform.
In the future, if apple support is needed, we need to add ST_TIMESPEC checks.

Thank You,
Sibi Siddharthan

#101 lore raw

Re: [PATCH v2 08/11] cmake: added checks for struct stat and libiconv

Quoted 11 lines · Sibi Siddharthan
Quoted 8 lines

All of these compatibility stuff makes sense, but how do we decide where to draw the line between the checks we saw added in [01/11] and the checks added here? It feels pretty arbitrary to me and if that is the case, perhaps we want to move all the "add checks" to a commit separate from [01/11] (whose primary purpose is to add the basic rules without these build tweaks in the file at the final place)?

The checks are added on a "demand" based the target platform.
In the future, if apple support is needed, we need to add ST_TIMESPEC checks.

Well, let's ask a related question then.

Given that the primary reason why the project may be interested in adding cmake-based build system is because of its support for Windows build, how much smaller would this 11-patch series can become if we discard support for any platforms other than Windows? Let's say we add support for other platforms only after the series proves capable to build on/for Windows by going through the usual "queued in 'pu', merged to 'next' and then down to 'master'" route and appears in a tagged release. Would it reduce the time we need to spend before seeing a cmake-based build for Windows by doing so?

#102 lore raw

Re: [PATCH v2 08/11] cmake: added checks for struct stat and libiconv

In reply to Sibi Siddharthan via GitGitGadget
Quoted 6 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

The CMake script now checks whether st_blocks is a member of struct stat and set the compile definition NO_ST_BLOCKS_IN_STRUCT_STAT accordingly.

The check for whether ICONV_OMITS_BOM is also added as requested by Danh.

Please don't write my name in the commit message like this. This maybe rephased to:

While we're as it, add the check for ICONV_OMITS_BOM.

Quoted 81 lines
---
 CMakeLists.txt | 59 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 57 insertions(+), 2 deletions(-)
CMakeLists.txt +38 -2
index 4353080b708..975791c8b89 100644
@@ -22,6 +22,7 @@ project(git
 include(CheckTypeSize)
 include(CheckCSourceRuns)
 include(CheckCSourceCompiles)
+include(CheckCSourceRuns)
 include(CheckIncludeFile)
 include(CheckFunctionExists)
 include(CheckSymbolExists)
@@ -128,7 +129,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
 	include_directories(compat/win32)
 	add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
 				_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
-				NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0 NO_ST_BLOCKS_IN_STRUCT_STAT
+				NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0
 				USE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP
 				UNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)
 	list(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c
@@ -280,6 +281,11 @@ if(HAVE_CLOCK_MONOTONIC)
 	add_compile_definitions(HAVE_CLOCK_MONOTONIC)
 endif()
 
+#check for st_blocks in struct stat
+check_struct_has_member("struct stat" st_blocks "sys/stat.h" STRUCT_STAT_HAS_ST_BLOCKS)
+if(NOT STRUCT_STAT_HAS_ST_BLOCKS)
+	add_compile_definitions(NO_ST_BLOCKS_IN_STRUCT_STAT)
+endif()
 
 #compile checks
 check_c_source_runs("
@@ -344,7 +350,6 @@ if(NOT HAVE_REGEX)
 	add_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)
 endif()
 
-
 check_c_source_compiles("
 #include <stddef.h>
 #include <sys/types.h>
@@ -368,6 +373,56 @@ if(HAVE_BSD_SYSCTL)
 	add_compile_definitions(HAVE_BSD_SYSCTL)
 endif()
 
+set(CMAKE_REQUIRED_LIBRARIES ${Iconv_LIBRARIES})
+set(CMAKE_REQUIRED_INCLUDES ${Iconv_INCLUDE_DIRS})
+
+check_c_source_compiles("
+#include <iconv.h>
+
+extern size_t iconv(iconv_t cd,
+		char **inbuf, size_t *inbytesleft,
+		char **outbuf, size_t *outbytesleft);
+
+int main(){return 0;}"
+HAVE_NEW_ICONV)
+if(HAVE_NEW_ICONV)
+	set(HAVE_OLD_ICONV 0)
+else()
+	set(HAVE_OLD_ICONV 1)
+endif()
+
+check_c_source_runs("
+#include <iconv.h>
+#if ${HAVE_OLD_ICONV}
+typedef const char *iconv_ibp;
+#else
+typedef char *iconv_ibp;
+#endif
+
+int main()
+{
+	int v;
+	iconv_t conv;
+	char in[] = \"a\"; iconv_ibp pin = in;

CMakeLists.txt if(HAVE_BSD_SYSCTL) · line 416

Quoted 10 lines
CMakeLists.txt +10 -0
+	char out[20] = \"\"; char *pout = out;
+	size_t isz = sizeof in;
+	size_t osz = sizeof out;
+
+	conv = iconv_open(\"UTF-16\", \"UTF-8\");
+	iconv(conv, &pin, &isz, &pout, &osz);
+	iconv_close(conv);
+	v = (unsigned char)(out[0]) + (unsigned char)(out[1]);
+	return v != 0xfe + 0xff;
+}"

I think the closing double-quote should be placed in a newline, in order to make sure the source file ended with newline, old C standard requires final newline.

Signature · 1 line
Danh
#103 lore raw

Re: [PATCH v2 08/11] cmake: added checks for struct stat and libiconv

Quoted 7 lines · Đoàn Trần Công Danh
Quoted 5 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

The CMake script now checks whether st_blocks is a member of struct stat and set the compile definition NO_ST_BLOCKS_IN_STRUCT_STAT accordingly.

Quoted 6 lines
Quoted 1 line

The check for whether ICONV_OMITS_BOM is also added as requested by Danh.

Please don't write my name in the commit message like this. This maybe rephased to:

While we're as it, add the check for ICONV_OMITS_BOM.

Sure, will remove your name from the message.
I added it because gitgitgadget PR bot suggested it as a good practice.

Quoted 88 lines
Quoted 88 lines
---
 CMakeLists.txt | 59 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 57 insertions(+), 2 deletions(-)
CMakeLists.txt +44 -2
index 4353080b708..975791c8b89 100644
@@ -22,6 +22,7 @@ project(git
 include(CheckTypeSize)
 include(CheckCSourceRuns)
 include(CheckCSourceCompiles)
+include(CheckCSourceRuns)
 include(CheckIncludeFile)
 include(CheckFunctionExists)
 include(CheckSymbolExists)
@@ -128,7 +129,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
      include_directories(compat/win32)
      add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
                              _CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
-                             NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0 NO_ST_BLOCKS_IN_STRUCT_STAT
+                             NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0
                              USE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP
                              UNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)
      list(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c
@@ -280,6 +281,11 @@ if(HAVE_CLOCK_MONOTONIC)
      add_compile_definitions(HAVE_CLOCK_MONOTONIC)
 endif()
 
+#check for st_blocks in struct stat
+check_struct_has_member("struct stat" st_blocks "sys/stat.h" STRUCT_STAT_HAS_ST_BLOCKS)
+if(NOT STRUCT_STAT_HAS_ST_BLOCKS)
+     add_compile_definitions(NO_ST_BLOCKS_IN_STRUCT_STAT)
+endif()
 
 #compile checks
 check_c_source_runs("
@@ -344,7 +350,6 @@ if(NOT HAVE_REGEX)
      add_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)
 endif()
 
-
 check_c_source_compiles("
 #include <stddef.h>
 #include <sys/types.h>
@@ -368,6 +373,56 @@ if(HAVE_BSD_SYSCTL)
      add_compile_definitions(HAVE_BSD_SYSCTL)
 endif()
 
+set(CMAKE_REQUIRED_LIBRARIES ${Iconv_LIBRARIES})
+set(CMAKE_REQUIRED_INCLUDES ${Iconv_INCLUDE_DIRS})
+
+check_c_source_compiles("
+#include <iconv.h>
+
+extern size_t iconv(iconv_t cd,
+             char **inbuf, size_t *inbytesleft,
+             char **outbuf, size_t *outbytesleft);
+
+int main(){return 0;}"
+HAVE_NEW_ICONV)
+if(HAVE_NEW_ICONV)
+     set(HAVE_OLD_ICONV 0)
+else()
+     set(HAVE_OLD_ICONV 1)
+endif()
+
+check_c_source_runs("
+#include <iconv.h>
+#if ${HAVE_OLD_ICONV}
+typedef const char *iconv_ibp;
+#else
+typedef char *iconv_ibp;
+#endif
+
+int main()
+{
+     int v;
+     iconv_t conv;
+     char in[] = \"a\"; iconv_ibp pin = in;
+     char out[20] = \"\"; char *pout = out;
+     size_t isz = sizeof in;
+     size_t osz = sizeof out;
+
+     conv = iconv_open(\"UTF-16\", \"UTF-8\");
+     iconv(conv, &pin, &isz, &pout, &osz);
Quoted 9 lines

CMakeLists.txt if(HAVE_BSD_SYSCTL) · line 416

Quoted 4 lines
CMakeLists.txt +4 -0
+     iconv_close(conv);
+     v = (unsigned char)(out[0]) + (unsigned char)(out[1]);
+     return v != 0xfe + 0xff;
+}"

I think the closing double-quote should be placed in a newline, in order to make sure the source file ended with newline, old C standard requires final newline.

Okay

Thank You,
Sibi Siddharthan

Quoted 3 lines

--
Danh

#104 lore raw

PATCH v2 9/11 cmake: relocated script file contrib/buildsystems

In reply to Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

The CMake script has been relocated to contrib/buildsystems. The changes made to the script involves pointing to correct location of the source files.

---
 .../buildsystems/CMakeLists.txt               | 76 +++++++++++--------
 1 file changed, 45 insertions(+), 31 deletions(-)
 rename CMakeLists.txt => contrib/buildsystems/CMakeLists.txt (92%)
contrib/buildsystems/CMakeLists.txt renamed from CMakeLists.txt +45 -31
similarity index 92%
rename from CMakeLists.txt
rename to contrib/buildsystems/CMakeLists.txt
index 975791c8b89..e0ce069dc2a 100644
@@ -4,6 +4,9 @@
 
 cmake_minimum_required(VERSION 3.15)
 
+#set the source directory to root of git
+set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
+
 #Parse GIT-VERSION-GEN to get the version
 file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX "DEF_VER=v(.*)")
 string(REPLACE "DEF_VER=v" "" git_version ${git_version})
@@ -123,10 +126,10 @@ endif()
 #Platform Specific
 if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
 	if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
-		include_directories(compat/vcbuild/include)
+		include_directories(${CMAKE_SOURCE_DIR}/compat/vcbuild/include)
 		add_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)
 	endif()
-	include_directories(compat/win32)
+	include_directories(${CMAKE_SOURCE_DIR}/compat/win32)
 	add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
 				_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
 				NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0
@@ -224,7 +227,7 @@ foreach(f ${function_checks})
 endforeach()
 
 if(NOT HAVE_POLL_H OR NOT HAVE_SYS_POLL_H OR NOT HAVE_POLL)
-	include_directories(compat/poll)
+	include_directories(${CMAKE_SOURCE_DIR}/compat/poll)
 	add_compile_definitions(NO_POLL)
 	list(APPEND compat_SOURCES compat/poll/poll.c)
 endif()
@@ -345,7 +348,7 @@ check_c_source_compiles("
 int main(){return 0;}"
 HAVE_REGEX)
 if(NOT HAVE_REGEX)
-	include_directories(compat/regex )
+	include_directories(${CMAKE_SOURCE_DIR}/compat/regex)
 	list(APPEND compat_SOURCES compat/regex/regex.c )
 	add_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)
 endif()
@@ -467,21 +470,23 @@ endforeach()
 list(APPEND EXCLUSION_PROGS empty)
 set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING "Programs not built" FORCE)
 
-if(NOT EXISTS ${CMAKE_SOURCE_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)
+if(NOT EXISTS ${CMAKE_BINARY_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)
 	list(REMOVE_ITEM EXCLUSION_PROGS empty)
 	message("Generating command-list.h")
 	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt
 			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
-			OUTPUT_FILE ${CMAKE_SOURCE_DIR}/command-list.h)
+			OUTPUT_FILE ${CMAKE_BINARY_DIR}/command-list.h)
 endif()
 
-if(NOT EXISTS ${CMAKE_SOURCE_DIR}/config-list.h)
+if(NOT EXISTS ${CMAKE_BINARY_DIR}/config-list.h)
 	message("Generating config-list.h")
 	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh
 			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
-			OUTPUT_FILE ${CMAKE_SOURCE_DIR}/config-list.h)
+			OUTPUT_FILE ${CMAKE_BINARY_DIR}/config-list.h)
 endif()
 
+include_directories(${CMAKE_BINARY_DIR})
+
 
 #build
 set(libgit_SOURCES
@@ -521,16 +526,22 @@ set(libgit_SOURCES
 	worktree.c wrapper.c write-or-die.c ws.c wt-status.c xdiff-interface.c
 	zlib.c)
 
+list(TRANSFORM libgit_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
+list(TRANSFORM compat_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
 add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})
 
 set(libxdiff_SOURCES
 	xdiff/xdiffi.c xdiff/xprepare.c xdiff/xutils.c xdiff/xemit.c
 	xdiff/xmerge.c xdiff/xpatience.c xdiff/xhistogram.c)
+
+list(TRANSFORM libxdiff_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
 add_library(xdiff STATIC ${libxdiff_SOURCES})
 
 set(libvcs-svn_SOURCES
 	vcs-svn/line_buffer.c vcs-svn/sliding_window.c vcs-svn/fast_export.c
 	vcs-svn/svndiff.c vcs-svn/svndump.c)
+
+list(TRANSFORM libvcs-svn_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
 add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
 
 if(WIN32)
@@ -553,7 +564,7 @@ if(WIN32)
 endif()
 
 #link all required libraries to common-main
-add_library(common-main OBJECT common-main.c)
+add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)
 
 target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})
 if(Intl_FOUND)
@@ -612,56 +623,57 @@ set(git_SOURCES
 	builtin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c
 	builtin/verify-tag.c builtin/worktree.c builtin/write-tree.c)
 
-add_executable(git git.c ${git_SOURCES})
+list(TRANSFORM git_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
+add_executable(git ${CMAKE_SOURCE_DIR}/git.c ${git_SOURCES})
 target_link_libraries(git common-main )
 
-add_executable(git-bugreport bugreport.c)
+add_executable(git-bugreport ${CMAKE_SOURCE_DIR}/bugreport.c)
 target_link_libraries(git-bugreport common-main)
 
-add_executable(git-credential-store credential-store.c)
+add_executable(git-credential-store ${CMAKE_SOURCE_DIR}/credential-store.c)
 target_link_libraries(git-credential-store common-main)
 
-add_executable(git-daemon daemon.c)
+add_executable(git-daemon ${CMAKE_SOURCE_DIR}/daemon.c)
 target_link_libraries(git-daemon common-main)
 
-add_executable(git-fast-import fast-import.c)
+add_executable(git-fast-import ${CMAKE_SOURCE_DIR}/fast-import.c)
 target_link_libraries(git-fast-import common-main)
 
-add_executable(git-http-backend http-backend.c)
+add_executable(git-http-backend ${CMAKE_SOURCE_DIR}/http-backend.c)
 target_link_libraries(git-http-backend common-main)
 
-add_executable(git-sh-i18n--envsubst sh-i18n--envsubst.c)
+add_executable(git-sh-i18n--envsubst ${CMAKE_SOURCE_DIR}/sh-i18n--envsubst.c)
 target_link_libraries(git-sh-i18n--envsubst common-main)
 
-add_executable(git-shell shell.c)
+add_executable(git-shell ${CMAKE_SOURCE_DIR}/shell.c)
 target_link_libraries(git-shell common-main)
 
 if(CURL_FOUND)
-	add_library(http_obj OBJECT http.c)
+	add_library(http_obj OBJECT ${CMAKE_SOURCE_DIR}/http.c)
 
-	add_executable(git-imap-send imap-send.c)
+	add_executable(git-imap-send ${CMAKE_SOURCE_DIR}/imap-send.c)
 	target_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})
 
-	add_executable(git-http-fetch http-walker.c http-fetch.c)
+	add_executable(git-http-fetch ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/http-fetch.c)
 	target_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})
 
-	add_executable(git-remote-http http-walker.c remote-curl.c)
+	add_executable(git-remote-http ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/remote-curl.c)
 	target_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )
 
 	if(EXPAT_FOUND)
-		add_executable(git-http-push http-push.c)
+		add_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)
 		target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
 	endif()
 endif()
 
-add_executable(git-remote-testsvn remote-testsvn.c)
+add_executable(git-remote-testsvn ${CMAKE_SOURCE_DIR}/remote-testsvn.c)
 target_link_libraries(git-remote-testsvn common-main vcs-svn)
 
 if(NOT NO_UNIX_SOCKETS)
-	add_executable(git-credential-cache credential-cache.c)
+	add_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)
 	target_link_libraries(git-credential-cache common-main)
 
-	add_executable(git-credential-cache--daemon credential-cache--daemon.c)
+	add_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)
 	target_link_libraries(git-credential-cache--daemon common-main)
 endif()
 
@@ -673,7 +685,7 @@ set(git_builtin_extra
 
 #Creating hardlinks
 foreach(s ${git_SOURCES} ${git_builtin_extra})
-	string(REPLACE "builtin/" "" s ${s})
+	string(REPLACE "${CMAKE_SOURCE_DIR}/builtin/" "" s ${s})
 	string(REPLACE ".c" "" s ${s})
 	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git${EXE_EXTENSION} git-${s}${EXE_EXTENSION})\n")
 	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s}${EXE_EXTENSION})
@@ -831,7 +843,7 @@ endforeach()
 install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
 	DESTINATION libexec/git-core)
 
-install(DIRECTORY mergetools DESTINATION libexec/git-core)
+install(DIRECTORY ${CMAKE_SOURCE_DIR}/mergetools DESTINATION libexec/git-core)
 install(DIRECTORY ${CMAKE_BINARY_DIR}/perl/build/lib/ DESTINATION share/perl5
 	FILES_MATCHING PATTERN "*.pm")
 install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/templates)
@@ -844,13 +856,13 @@ endif()
 if(BUILD_TESTING)
 
 #tests-helpers
-add_executable(test-fake-ssh t/helper/test-fake-ssh.c)
+add_executable(test-fake-ssh ${CMAKE_SOURCE_DIR}/t/helper/test-fake-ssh.c)
 target_link_libraries(test-fake-ssh common-main)
 
-add_executable(test-line-buffer t/helper/test-line-buffer.c)
+add_executable(test-line-buffer ${CMAKE_SOURCE_DIR}/t/helper/test-line-buffer.c)
 target_link_libraries(test-line-buffer common-main vcs-svn)
 
-add_executable(test-svn-fe t/helper/test-svn-fe.c)
+add_executable(test-svn-fe ${CMAKE_SOURCE_DIR}/t/helper/test-svn-fe.c)
 target_link_libraries(test-svn-fe common-main vcs-svn)
 
 set(test-tool_SOURCES
@@ -875,6 +887,7 @@ set(test-tool_SOURCES
 	t/helper/test-trace2.c t/helper/test-urlmatch-normalization.c t/helper/test-xml-encode.c
 	t/helper/test-wildmatch.c t/helper/test-windows-named-pipe.c t/helper/test-write-cache.c)
 
+list(TRANSFORM test-tool_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
 add_executable(test-tool ${test-tool_SOURCES})
 target_link_libraries(test-tool common-main)
 
@@ -978,7 +991,8 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PRE
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
 
 #Make the tests work when building out of the source tree
-if(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
+get_filename_component(CACHE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../CMakeCache.txt ABSOLUTE)
+if(NOT ${CMAKE_BINARY_DIR}/CMakeCache.txt STREQUAL ${CACHE_PATH})
 	file(RELATIVE_PATH BUILD_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/CMakeCache.txt)
 	string(REPLACE "/CMakeCache.txt" "" BUILD_DIR_RELATIVE ${BUILD_DIR_RELATIVE})
 	#Setting the build directory in test-lib.sh before running tests
Signature · 1 line
gitgitgadget
#105 lore raw

Re: [PATCH v2 09/11] cmake: relocated script file contrib/buildsystems

Quoted 5 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

The CMake script has been relocated to contrib/buildsystems. The changes made to the script involves pointing to correct location of the source files.

This does match what the list agreed to do. Why isn't this done as part of [01/11]? If there is no technical reason not to, I'd strongly prefer to see it done from the very beginning. The same comment applies to the next step.

Thanks.

Quoted 5 lines
---
 .../buildsystems/CMakeLists.txt               | 76 +++++++++++--------
 1 file changed, 45 insertions(+), 31 deletions(-)
 rename CMakeLists.txt => contrib/buildsystems/CMakeLists.txt (92%)
#106 lore raw

Re: [PATCH v2 09/11] cmake: relocated script file contrib/buildsystems

Quoted 5 lines · Junio C Hamano
Quoted 2 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

Quoted 8 lines
Quoted 3 lines

The CMake script has been relocated to contrib/buildsystems. The changes made to the script involves pointing to correct location of the source files.

This does match what the list agreed to do. Why isn't this done as part of [01/11]? If there is no technical reason not to, I'd strongly prefer to see it done from the very beginning. The same comment applies to the next step.

Okay

Quoted 8 lines

Thanks.

Quoted 5 lines
---
 .../buildsystems/CMakeLists.txt               | 76 +++++++++++--------
 1 file changed, 45 insertions(+), 31 deletions(-)
 rename CMakeLists.txt => contrib/buildsystems/CMakeLists.txt (92%)
#107 lore raw

PATCH v2 10/11 cmake: parse the makefile for the sources.

In reply to Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

The CMake script parses the Makefile for:
SCRIPT_SH
SCRIPT_PERL
TEST_BUILTINS_OBJS
LIB_OBJS
BUILTIN_OBJS
XDIFF_OBJS
VCSSVN_OBJS

By doing this we avoid duplication of text between the Makefile and the CMake script.

---
 contrib/buildsystems/CMakeLists.txt | 137 ++++++----------------------
 1 file changed, 30 insertions(+), 107 deletions(-)
contrib/buildsystems/CMakeLists.txt +30 -107
index e0ce069dc2a..4592ce614cf 100644
@@ -21,6 +21,25 @@ project(git
 #TODO Enable NLS on windows natively
 #TODO Add pcre support
 
+#macros for parsing the Makefile for sources and scripts
+macro(parse_makefile_for_sources list_var regex)
+	file(STRINGS ${CMAKE_SOURCE_DIR}/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(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
+	list(REMOVE_ITEM ${list_var} "") #remove empty list elements
+endmacro()
+
+macro(parse_makefile_for_scripts list_var regex lang)
+	file(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX "^${regex} \\+=(.*)")
+	string(REPLACE "${regex} +=" "" ${list_var} ${${list_var}})
+	string(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces
+	string(REPLACE " " ";" ${list_var} ${${list_var}}) #convert string to a list
+	list(TRANSFORM ${list_var} REPLACE "${lang}" "") #do the replacement
+endmacro()
+
 
 include(CheckTypeSize)
 include(CheckCSourceRuns)
@@ -489,57 +508,18 @@ include_directories(${CMAKE_BINARY_DIR})
 
 
 #build
-set(libgit_SOURCES
-	abspath.c add-interactive.c add-patch.c advice.c alias.c
-	alloc.c apply.c archive.c archive-tar.c archive-zip.c argv-array.c
-	attr.c base85.c bisect.c blame.c blob.c bloom.c branch.c bulk-checkin.c
-	bundle.c cache-tree.c chdir-notify.c checkout.c color.c column.c
-	combine-diff.c commit.c commit-graph.c commit-reach.c compat/obstack.c
-	compat/terminal.c config.c connect.c connected.c convert.c copy.c credential.c
-	csum-file.c ctype.c date.c decorate.c delta-islands.c diffcore-break.c
-	diffcore-delta.c diffcore-order.c diffcore-pickaxe.c diffcore-rename.c
-	diff-delta.c diff-lib.c diff-no-index.c diff.c dir.c dir-iterator.c editor.c
-	entry.c environment.c ewah/bitmap.c ewah/ewah_bitmap.c ewah/ewah_io.c
-	ewah/ewah_rlw.c exec-cmd.c fetch-negotiator.c fetch-pack.c fmt-merge-msg.c fsck.c fsmonitor.c
-	gettext.c gpg-interface.c graph.c grep.c hashmap.c linear-assignment.c help.c hex.c
-	ident.c interdiff.c json-writer.c kwset.c levenshtein.c line-log.c line-range.c list-objects.c
-	list-objects-filter.c list-objects-filter-options.c ll-merge.c lockfile.c
-	log-tree.c ls-refs.c mailinfo.c mailmap.c match-trees.c mem-pool.c merge.c merge-blobs.c
-	merge-recursive.c mergesort.c midx.c name-hash.c negotiator/default.c
-	negotiator/skipping.c notes.c notes-cache.c notes-merge.c notes-utils.c object.c oidmap.c
-	oidset.c oid-array.c packfile.c pack-bitmap.c pack-bitmap-write.c pack-check.c pack-objects.c
-	pack-revindex.c pack-write.c pager.c parse-options.c parse-options-cb.c patch-delta.c
-	patch-ids.c path.c pathspec.c pkt-line.c preload-index.c pretty.c prio-queue.c progress.c
-	promisor-remote.c prompt.c protocol.c prune-packed.c quote.c range-diff.c reachable.c read-cache.c rebase.c
-	rebase-interactive.c reflog-walk.c refs.c refs/files-backend.c refs/iterator.c
-	refs/packed-backend.c refs/ref-cache.c refspec.c ref-filter.c remote.c replace-object.c
-	repo-settings.c repository.c rerere.c reset.c resolve-undo.c revision.c run-command.c
-	send-pack.c sequencer.c serve.c server-info.c setup.c sha1-lookup.c
-	sha1-file.c sha1-name.c shallow.c sideband.c sigchain.c split-index.c
-	stable-qsort.c strbuf.c streaming.c string-list.c submodule.c submodule-config.c
-	sub-process.c symlinks.c tag.c tempfile.c thread-utils.c tmp-objdir.c
-	trace.c trace2.c trace2/tr2_cfg.c trace2/tr2_cmd_name.c trace2/tr2_dst.c
-	trace2/tr2_sid.c trace2/tr2_sysenv.c trace2/tr2_tbuf.c trace2/tr2_tgt_event.c
-	trace2/tr2_tgt_normal.c trace2/tr2_tgt_perf.c trace2/tr2_tls.c trailer.c transport.c
-	transport-helper.c tree-diff.c tree.c tree-walk.c unpack-trees.c upload-pack.c url.c
-	urlmatch.c usage.c userdiff.c utf8.c varint.c version.c versioncmp.c walker.c wildmatch.c
-	worktree.c wrapper.c write-or-die.c ws.c wt-status.c xdiff-interface.c
-	zlib.c)
+parse_makefile_for_sources(libgit_SOURCES "LIB_OBJS")
 
 list(TRANSFORM libgit_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
 list(TRANSFORM compat_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
 add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})
 
-set(libxdiff_SOURCES
-	xdiff/xdiffi.c xdiff/xprepare.c xdiff/xutils.c xdiff/xemit.c
-	xdiff/xmerge.c xdiff/xpatience.c xdiff/xhistogram.c)
+parse_makefile_for_sources(libxdiff_SOURCES "XDIFF_OBJS")
 
 list(TRANSFORM libxdiff_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
 add_library(xdiff STATIC ${libxdiff_SOURCES})
 
-set(libvcs-svn_SOURCES
-	vcs-svn/line_buffer.c vcs-svn/sliding_window.c vcs-svn/fast_export.c
-	vcs-svn/svndiff.c vcs-svn/svndump.c)
+parse_makefile_for_sources(libvcs-svn_SOURCES "VCSSVN_OBJS")
 
 list(TRANSFORM libvcs-svn_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
 add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
@@ -588,40 +568,7 @@ elseif(UNIX)
 endif()
 
 
-set(git_SOURCES
-	builtin/add.c builtin/am.c builtin/annotate.c builtin/apply.c
-	builtin/archive.c builtin/bisect--helper.c builtin/blame.c
-	builtin/branch.c builtin/bundle.c builtin/cat-file.c builtin/check-attr.c
-	builtin/check-ignore.c builtin/check-mailmap.c builtin/check-ref-format.c
-	builtin/checkout-index.c builtin/checkout.c builtin/clean.c
-	builtin/clone.c builtin/column.c builtin/commit-tree.c
-	builtin/commit.c builtin/commit-graph.c builtin/config.c
-	builtin/count-objects.c builtin/credential.c builtin/describe.c
-	builtin/diff-files.c builtin/diff-index.c builtin/diff-tree.c
-	builtin/diff.c builtin/difftool.c builtin/env--helper.c
-	builtin/fast-export.c builtin/fetch-pack.c builtin/fetch.c builtin/fmt-merge-msg.c
-	builtin/for-each-ref.c builtin/fsck.c builtin/gc.c
-	builtin/get-tar-commit-id.c builtin/grep.c builtin/hash-object.c
-	builtin/help.c builtin/index-pack.c builtin/init-db.c
-	builtin/interpret-trailers.c builtin/log.c builtin/ls-files.c
-	builtin/ls-remote.c builtin/ls-tree.c builtin/mailinfo.c builtin/mailsplit.c
-	builtin/merge.c builtin/merge-base.c builtin/merge-file.c builtin/merge-index.c
-	builtin/merge-ours.c builtin/merge-recursive.c builtin/merge-tree.c
-	builtin/mktag.c builtin/mktree.c builtin/multi-pack-index.c builtin/mv.c
-	builtin/name-rev.c builtin/notes.c builtin/pack-objects.c builtin/pack-redundant.c
-	builtin/pack-refs.c builtin/patch-id.c builtin/prune-packed.c builtin/prune.c
-	builtin/pull.c builtin/push.c builtin/range-diff.c builtin/read-tree.c
-	builtin/rebase.c builtin/receive-pack.c builtin/reflog.c builtin/remote.c
-	builtin/remote-ext.c builtin/remote-fd.c builtin/repack.c builtin/replace.c
-	builtin/rerere.c builtin/reset.c builtin/rev-list.c builtin/rev-parse.c
-	builtin/revert.c builtin/rm.c builtin/send-pack.c builtin/shortlog.c
-	builtin/show-branch.c builtin/show-index.c builtin/show-ref.c
-	builtin/sparse-checkout.c builtin/stash.c builtin/stripspace.c
-	builtin/submodule--helper.c builtin/symbolic-ref.c builtin/tag.c
-	builtin/unpack-file.c builtin/unpack-objects.c builtin/update-index.c
-	builtin/update-ref.c builtin/update-server-info.c builtin/upload-archive.c
-	builtin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c
-	builtin/verify-tag.c builtin/worktree.c builtin/write-tree.c)
+parse_makefile_for_sources(git_SOURCES "BUILTIN_OBJS")
 
 list(TRANSFORM git_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
 add_executable(git ${CMAKE_SOURCE_DIR}/git.c ${git_SOURCES})
@@ -714,11 +661,9 @@ set(GITWEBDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)
 set(INSTLIBDIR ${FALLBACK_RUNTIME_PREFIX}/share/perl5)
 
 #shell scripts
+parse_makefile_for_scripts(git_sh_scripts "SCRIPT_SH" ".sh")
 set(git_shell_scripts
-	git-bisect git-difftool--helper git-filter-branch
-	git-merge-octopus git-merge-one-file git-merge-resolve
-	git-mergetool git-quiltimport
-	git-request-pull git-submodule git-web--browse
+	${git_sh_scripts}
 	git-mergetool--lib git-parse-remote git-rebase--preserve-merges
 	git-sh-setup git-sh-i18n git-instaweb)
 
@@ -738,9 +683,7 @@ foreach(script ${git_shell_scripts})
 endforeach()
 
 #perl scripts
-set(git_perl_scripts
-	git-add--interactive git-archimport git-cvsexportcommit
-	git-cvsimport git-cvsserver git-send-email git-svn)
+parse_makefile_for_scripts(git_perl_scripts "SCRIPT_PERL" ".perl")
 
 #create perl header
 file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )
@@ -865,30 +808,10 @@ target_link_libraries(test-line-buffer common-main vcs-svn)
 add_executable(test-svn-fe ${CMAKE_SOURCE_DIR}/t/helper/test-svn-fe.c)
 target_link_libraries(test-svn-fe common-main vcs-svn)
 
-set(test-tool_SOURCES
-	t/helper/test-tool.c t/helper/test-advise.c t/helper/test-bloom.c t/helper/test-chmtime.c
-	t/helper/test-config.c t/helper/test-ctype.c t/helper/test-date.c t/helper/test-delta.c
-	t/helper/test-dir-iterator.c t/helper/test-drop-caches.c t/helper/test-dump-cache-tree.c
-	t/helper/test-dump-fsmonitor.c t/helper/test-dump-split-index.c
-	t/helper/test-dump-untracked-cache.c t/helper/test-example-decorate.c
-	t/helper/test-genrandom.c t/helper/test-genzeros.c t/helper/test-hash.c
-	t/helper/test-hashmap.c t/helper/test-hash-speed.c t/helper/test-index-version.c
-	t/helper/test-json-writer.c t/helper/test-lazy-init-name-hash.c
-	t/helper/test-match-trees.c t/helper/test-mergesort.c t/helper/test-mktemp.c
-	t/helper/test-oidmap.c t/helper/test-online-cpus.c t/helper/test-parse-options.c
-	t/helper/test-parse-pathspec-file.c t/helper/test-path-utils.c t/helper/test-pkt-line.c
-	t/helper/test-prio-queue.c t/helper/test-progress.c t/helper/test-reach.c
-	t/helper/test-read-cache.c t/helper/test-read-graph.c t/helper/test-read-midx.c
-	t/helper/test-ref-store.c t/helper/test-regex.c t/helper/test-repository.c
-	t/helper/test-revision-walking.c t/helper/test-run-command.c t/helper/test-scrap-cache-tree.c
-	t/helper/test-serve-v2.c t/helper/test-sha1.c t/helper/test-oid-array.c t/helper/test-sha256.c
-	t/helper/test-sigchain.c t/helper/test-strcmp-offset.c t/helper/test-string-list.c
-	t/helper/test-submodule-config.c t/helper/test-submodule-nested-repo-config.c t/helper/test-subprocess.c
-	t/helper/test-trace2.c t/helper/test-urlmatch-normalization.c t/helper/test-xml-encode.c
-	t/helper/test-wildmatch.c t/helper/test-windows-named-pipe.c t/helper/test-write-cache.c)
-
-list(TRANSFORM test-tool_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
-add_executable(test-tool ${test-tool_SOURCES})
+parse_makefile_for_sources(test-tool_SOURCES "TEST_BUILTINS_OBJS")
+
+list(TRANSFORM test-tool_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/t/helper/")
+add_executable(test-tool ${CMAKE_SOURCE_DIR}/t/helper/test-tool.c ${test-tool_SOURCES})
 target_link_libraries(test-tool common-main)
 
 set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
Signature · 1 line
gitgitgadget
#108 lore raw

Re: [PATCH v2 10/11] cmake: parse the makefile for the sources.

Quoted 11 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

The CMake script parses the Makefile for:
SCRIPT_SH
SCRIPT_PERL
TEST_BUILTINS_OBJS
LIB_OBJS
BUILTIN_OBJS
XDIFF_OBJS
VCSSVN_OBJS

Quoted 2 lines

By doing this we avoid duplication of text between the Makefile and the CMake script.

Thanks, this makes perfect sense, but it probably should have been done from the very beginning, without copying the huge list manually in the step [01/11].

How robust is the "parser"? Do we need to leave an instruction to Makefile writers to conform to certain style to help CMake users as an additional comment in the Makefile, or is any reasonable textual drift still accepted?

#109 lore raw

Re: [PATCH v2 10/11] cmake: parse the makefile for the sources.

Quoted 17 lines · Junio C Hamano
Quoted 11 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

The CMake script parses the Makefile for:
SCRIPT_SH
SCRIPT_PERL
TEST_BUILTINS_OBJS
LIB_OBJS
BUILTIN_OBJS
XDIFF_OBJS
VCSSVN_OBJS

Quoted 2 lines

By doing this we avoid duplication of text between the Makefile and the CMake script.

Quoted 9 lines

Thanks, this makes perfect sense, but it probably should have been done from the very beginning, without copying the huge list manually in the step [01/11].

How robust is the "parser"? Do we need to leave an instruction to Makefile writers to conform to certain style to help CMake users as an additional comment in the Makefile, or is any reasonable textual drift still accepted?

The parser just uses a regex capture like this "SCRIPT_SH += (.*)". If the current source/script definition in the Makefile is continued things will be fine.

On a side note, why are we using SCRIPT_SH and SCRIPT_LIB separately? Can't we combine them into one? If we can then I can also add it to the list above.

Thank You,
Sibi Siddharthan

#110 lore raw

Re: [PATCH v2 10/11] cmake: parse the makefile for the sources.

Quoted 1 line · Sibi Siddharthan

On a side note, why are we using SCRIPT_SH and SCRIPT_LIB separately?

I think _SH are commands to be installed as executable, while _LIB are to be dot-included and installed as non-executable.

There may be other differences; they (i.e. what the Makefile uses these lists for, how the elements on these lists are treated, etc.) are something you need to know before you can reimplement the logic of building and installing used by the current system in a different build system.

Thanks.

#111 lore raw

PATCH v2 11/11 ci: modification of main.yml to use cmake for vs-build job

In reply to Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>

This patch modifies .github/workflows/main.yml to use CMake for Visual Studio builds.

Modified the vs-test step to match windows-test step. This speeds up the vs-test. Calling git-cmd from powershell and then calling git-bash to perform the tests slows things down(factor of about 6). So git-bash is directly called from powershell to perform the tests using prove.

NOTE: Since GitHub keeps the same directory for each job (with respect to path) absolute paths are used in the bin-wrapper scripts.

GitHub has switched to CMake 3.17.1 which changed the behaviour of FindCURL module. An extra definition (-DCURL_NO_CURL_CMAKE=ON) has been added to revert to the old behaviour.

Edit(Explanation for the reordering of build steps):
In the configuration phase CMake looks for the required libraries for building git (eg zlib,libiconv). So we extract the libraries before we configure.

Changes:
The CMake script has been relocated to contib/buildsystems, so point to the CMakeLists.txt in the invocation commands.

The generation command now uses the absolute paths for the generation step.

To check for ICONV_OMITS_BOM libiconv.dll needs to be in the working directory of script or path. So we copy the dlls before we configure.

---
 .github/workflows/main.yml | 46 +++++++++++++++++++++-----------------
 1 file changed, 26 insertions(+), 20 deletions(-)
.github/workflows/main.yml +26 -20
index fd4df939b50..7a65cc0764f 100644
@@ -80,13 +80,6 @@ jobs:
     - name: download git-sdk-64-minimal
       shell: bash
       run: a=git-sdk-64-minimal && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
-    - name: generate Visual Studio solution
-      shell: powershell
-      run: |
-        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
-          make NDEBUG=1 DEVELOPER=1 vcxproj
-        "@
-        if (!$?) { exit(1) }
     - name: download vcpkg artifacts
       shell: powershell
       run: |
@@ -98,6 +91,14 @@ jobs:
         Remove-Item compat.zip
     - name: add msbuild to PATH
       uses: microsoft/[email protected]
+    - name: copy dlls to root
+      shell: powershell
+      run: |
+        & compat\vcbuild\vcpkg_copy_dlls.bat release
+        if (!$?) { exit(1) }
+    - name: generate Visual Studio solution
+      shell: bash
+      run: cmake `pwd`/contrib/buildsystems/ -DCMAKE_PREFIX_PATH=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows -DMSGFMT_EXE=`pwd`/git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
     - name: MSBuild
       run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142
     - name: bundle artifact tar
@@ -106,8 +107,6 @@ jobs:
         MSVC: 1
         VCPKG_ROOT: ${{github.workspace}}\compat\vcbuild\vcpkg
       run: |
-        & compat\vcbuild\vcpkg_copy_dlls.bat release
-        if (!$?) { exit(1) }
         & git-sdk-64-minimal\usr\bin\bash.exe -lc @"
           mkdir -p artifacts &&
           eval \"`$(make -n artifacts-tar INCLUDE_DLLS_IN_ARTIFACTS=YesPlease ARTIFACTS_DIRECTORY=artifacts 2>&1 | grep ^tar)\"
@@ -125,9 +124,9 @@ jobs:
         nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
     steps:
     - uses: actions/checkout@v1
-    - name: download git-64-portable
+    - name: download git-sdk-64-minimal
       shell: bash
-      run: a=git-64-portable && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
+      run: a=git-sdk-64-minimal && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
     - name: download build artifacts
       uses: actions/download-artifact@v1
       with:
@@ -136,23 +135,30 @@ jobs:
     - name: extract build artifacts
       shell: bash
       run: tar xf artifacts.tar.gz
-    - name: test (parallel)
+    - name: test
       shell: powershell
       env:
         MSYSTEM: MINGW64
         NO_SVN_TESTS: 1
         GIT_TEST_SKIP_REBASE_P: 1
       run: |
-        & git-64-portable\git-cmd.exe --command=usr\bin\bash.exe -lc @"
-          # Let Git ignore the SDK and the test-cache
-          printf '%s\n' /git-64-portable/ /test-cache/ >>.git/info/exclude
+        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
+          # Let Git ignore the SDK
+          printf '%s\n' /git-sdk-64-minimal/ >>.git/info/exclude
 
-          cd t &&
-          PATH=\"`$PWD/helper:`$PATH\" &&
-          test-tool.exe run-command testsuite --jobs=10 -V -x --write-junit-xml \
-                  `$(test-tool.exe path-utils slice-tests \
-                          ${{matrix.nr}} 10 t[0-9]*.sh)
+          ci/run-test-slice.sh ${{matrix.nr}} 10
         "@
+    - name: ci/print-test-failures.sh
+      if: failure()
+      shell: powershell
+      run: |
+        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc ci/print-test-failures.sh
+    - name: Upload failed tests' directories
+      if: failure() && env.FAILED_TEST_ARTIFACTS != ''
+      uses: actions/upload-artifact@v1
+      with:
+        name: failed-tests-windows
+        path: ${{env.FAILED_TEST_ARTIFACTS}}
   regular:
     strategy:
       matrix:
Signature · 1 line
gitgitgadget
#112 lore raw

Re: [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job

Quoted 2 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>
Subject: Re: [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job

Yay!

Quoted 3 lines

This patch modifies .github/workflows/main.yml to use CMake for Visual Studio builds.
Modified the vs-test step to match windows-test step. This speeds

Teach .github/workflows/main.yml to use Cmake for VS builds. Modify vs-test step to match windows-test step to speed up the vs-test.

Quoted 3 lines

Changes:
The CMake script has been relocated to contib/buildsystems, so point to the CMakeLists.txt in the invocation commands.

This does not belong to the log message for this (or any for that matter) commit, no? Up to this point, nothing in main.yml used CMake script from anywhere, and "has been relocated" is irrelevant.

And if we add CMake script to contrib/buildsystems/ from the beginning in [01/11], there won't be any "relocation" the readers of the log message of this step need to know about.

Quoted 2 lines

The generation command now uses the absolute paths for the generation step.

"now uses"? Is that something the readers of the log message of this step need to know about, or is it "in contrast to an earlier attempt to add CMake script"? If the latter, it only confuses the readers of our history, as most of them will not even know about an earlier attempt.

Thanks.

#113 lore raw

Re: [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job

Quoted 16 lines · Junio C Hamano
Quoted 2 lines · Sibi Siddharthan via GitGitGadget

From: Sibi Siddharthan <[email protected]>
Subject: Re: [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job

Yay!

Quoted 3 lines

This patch modifies .github/workflows/main.yml to use CMake for Visual Studio builds.
Modified the vs-test step to match windows-test step. This speeds

Teach .github/workflows/main.yml to use Cmake for VS builds. Modify vs-test step to match windows-test step to speed up the vs-test.

Quoted 8 lines
Quoted 3 lines

Changes:
The CMake script has been relocated to contib/buildsystems, so point to the CMakeLists.txt in the invocation commands.

This does not belong to the log message for this (or any for that matter) commit, no? Up to this point, nothing in main.yml used CMake script from anywhere, and "has been relocated" is irrelevant.

Will remove this.

Quoted 4 lines

And if we add CMake script to contrib/buildsystems/ from the beginning in [01/11], there won't be any "relocation" the readers of the log message of this step need to know about.

Quoted 8 lines
Quoted 2 lines

The generation command now uses the absolute paths for the generation step.

"now uses"? Is that something the readers of the log message of this step need to know about, or is it "in contrast to an earlier attempt to add CMake script"? If the latter, it only confuses the readers of our history, as most of them will not even know about an earlier attempt.

Will also remove this.

Quoted 2 lines

Thanks.

Thank You,
Sibi Siddharthan

#114 lore raw

Re: [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job

Hi Junio,

I have finished the changes you have asked for.
1) Relocating the CMake script to contrib/buildsystems from patch 01/xx.
2) Parse the Makefile for sources from patch 01/xx.
3) Reworded the commit messages you pointed out.
4) Rebased the ST_BLOCKS_IN_STRUCT_STAT and ICONV_OMITS_BOM to patch 01/xx to make the review process easier.

No new features will be introduced in the script, to make the review process easier.

I have looked at the GIT-VERSION-GEN script and the logic it uses to determine the version of git.
The logic is a bit complicated to be implemented in a CMake script, so I am skipping it for now.

Any other changes I should make before I submit PATCH v3?

Thank You,
Sibi Siddharthan

#115 lore raw

Re: [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job

Quoted 8 lines · Sibi Siddharthan

1) Relocating the CMake script to contrib/buildsystems from patch 01/xx.
2) Parse the Makefile for sources from patch 01/xx.
3) Reworded the commit messages you pointed out.
4) Rebased the ST_BLOCKS_IN_STRUCT_STAT and ICONV_OMITS_BOM to patch 01/xx to make the review process easier.
...
No new features will be introduced in the script, to make the review process easier.

You did not answer <[email protected]>, so I have to guess.

I am guessing that your answer would be that if we keep this series concentrate only on Windows support from the beginning and do not add support for any other platform at all, the scope and necessary effort to bring the patches in reviewable shape would be reduced dramatically. And if that is the case, that would be great.

In other words, I'd prefer not just "no new features", but "with much less features, now we do not even add support for Linux or macOS to the initial patch series".

But because I haven't heard the question answered, I cannot tell if that level of simplification is possible and if that is already what you did in (silent) response to my questions.

Quoted 4 lines

I have looked at the GIT-VERSION-GEN script and the logic it uses to determine the version of git.
The logic is a bit complicated to be implemented in a CMake script, so I am skipping it for now.

Regarding the generation of GIT-VERSION-FILE, I asked you why you need to hand-parse, instead of running the script itself, which is the way you generate the config-list.h file in the same patch, which is done with execute_process() to run generate-cmdlist.sh.

You did not answer the question, either, so I have to guess.

I am guessing that it was an oversight that you did not update the procedure to handle GIT-VERSION-FILE because you wrote the "let's string-find in the GIT-VERSION-GEN script" approach way before you wrote the other parts of the CMake thing, and with the experience and hindsight of having written command-list-h support, you now realize that running the script to ensure that you get the result consistent with folks who use Makefile would be much better. After all, the logic being more complex than your CMake support can express shouldn't be an issue, if you just let the logic execute itself, no?

But that is also merely my guess, so...

Quoted 1 line

Any other changes I should make before I submit PATCH v3?

... at this point, it is too early for me to answer that question.

#116 lore raw

Re: [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job

Quoted 12 lines · Junio C Hamano
Quoted 8 lines · Sibi Siddharthan

1) Relocating the CMake script to contrib/buildsystems from patch 01/xx.
2) Parse the Makefile for sources from patch 01/xx.
3) Reworded the commit messages you pointed out.
4) Rebased the ST_BLOCKS_IN_STRUCT_STAT and ICONV_OMITS_BOM to patch 01/xx to make the review process easier.
...
No new features will be introduced in the script, to make the review process easier.

Quoted 2 lines

You did not answer <[email protected]>, so I have to guess.

Sorry, was going to reply to that, but forgot about it along the way.

As for my reply to that for windows only support we do not need a few of the checks namely:
1) HAVE_BSD_SYSCTL
2) ICONV_OMITS_BOM (because we are using GNU libiconv 1.16)

The functions checks (check_function_exists) is needed. A few of the header checks are unnecessary(paths.h sys/sysinfo.h).

The difference in build between Linux platforms and Windows would be 8-15 lines of code atmost . I see no point in the extra Linux stuff to be a burden for the reviewers.

There is another way of just copying the configurations in config.mak.uname, but this hurts the purpose of configuring in the first place.

Quoted 10 lines

I am guessing that your answer would be that if we keep this series concentrate only on Windows support from the beginning and do not add support for any other platform at all, the scope and necessary effort to bring the patches in reviewable shape would be reduced dramatically. And if that is the case, that would be great.

In other words, I'd prefer not just "no new features", but "with much less features, now we do not even add support for Linux or macOS to the initial patch series".

macOS support is ways off, needs quite a bit of work.

In terms of Linux support apart from the function, header checks there is nothing special
implemented here.

Quoted 17 lines

But because I haven't heard the question answered, I cannot tell if that level of simplification is possible and if that is already what you did in (silent) response to my questions.

Quoted 4 lines

I have looked at the GIT-VERSION-GEN script and the logic it uses to determine the version of git.
The logic is a bit complicated to be implemented in a CMake script, so I am skipping it for now.

Regarding the generation of GIT-VERSION-FILE, I asked you why you need to hand-parse, instead of running the script itself, which is the way you generate the config-list.h file in the same patch, which is done with execute_process() to run generate-cmdlist.sh.

You did not answer the question, either, so I have to guess.

Quoted 11 lines

I am guessing that it was an oversight that you did not update the procedure to handle GIT-VERSION-FILE because you wrote the "let's string-find in the GIT-VERSION-GEN script" approach way before you wrote the other parts of the CMake thing, and with the experience and hindsight of having written command-list-h support, you now realize that running the script to ensure that you get the result consistent with folks who use Makefile would be much better. After all, the logic being more complex than your CMake support can express shouldn't be an issue, if you just let the logic execute itself, no?

Yes, fair point.

Have executed GIT-VERSION-GEN, then parsed the GIT-VERSION-FILE for version info.
Added it to the list of changes.

Quoted 5 lines

But that is also merely my guess, so...

Quoted 1 line

Any other changes I should make before I submit PATCH v3?

... at this point, it is too early for me to answer that question.

Thank You,
Sibi Siddharthan

#117 lore raw

Re: [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job

Hi Sibi,

Quoted 3 lines · Sibi Siddharthan

The difference in build between Linux platforms and Windows would be 8-15 lines of code atmost . I see no point in the extra Linux stuff to be a burden for the reviewers.

I agree that this does not constitute a big burden.

Linux support in the CMake system _might_ come in real handy in certain circumstances. For example, if I understand correctly cppcheck uses the CMake configuration to figure out which source files to analyze, and with which #define's.

So there might be some previously-underappreciated benefit to having a CMake configuration that works on Linux, even if it is not the recommended way to build Git on Linux.

Thank you for your incredible work on the CMake front, Dscho

#118 lore raw

v3 cover CMake build system for git

In reply to Sibi Siddharthan via GitGitGadget

This is an attempt to build Git using CMake. CMake is cross-platform build generator which works well on a variety of platforms(primarily Linux and Windows). Using CMake we can check whether certain headers exist, certain functions exist, the required libraries are present and configure the build accordingly. Using CMake we can also build and test Git out of source, resulting in a clean source tree.

Tested platforms

Ubuntu 18.04 GCC 7.4 Clang 8.0.1

Windows MinGW GCC 9.2 Clang 9 Visual Studio 2015,2017,2019

Changes:

1) The CMake script has been relocated to contrib/buildsystems 2) The CMake script parses the Makefile for the sources. 3) Philip suggested to change the error message if sh/bash was not found on windows. 4) CMake now tests for ICONV_OMITS_BOM, NO_ST_BLOCKS_IN_STRUCT_STAT

Changes v2: Changes 1,2,4 have been rebased to PATCH 01/xx CMake uses GIT-VERSION-GEN to get the version of Git

Sibi Siddharthan (8):
Introduce CMake support for configuring Git
cmake: generate the shell/perl/python scripts and templates,
translations
cmake: installation support for git
cmake: support for testing git with ctest
cmake: support for testing git when building out of the source tree
cmake: support for building git on windows with mingw
cmake: support for building git on windows with msvc and clang.
ci: modification of main.yml to use cmake for vs-build job

 .github/workflows/main.yml          |  38 +-
 contrib/buildsystems/CMakeLists.txt | 987 ++++++++++++++++++++++++++++
 2 files changed, 1009 insertions(+), 16 deletions(-)
 create mode 100644 contrib/buildsystems/CMakeLists.txt

base-commit: 90737beb8258c0a99181b6308eef898d77979c71
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-614%2FSibiSiddharthan%2Fgit-og-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-614/SibiSiddharthan/git-og-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/614

Range-diff vs v2:

1: 70ab1f03dd5 ! 1: 09c972de52b Introduce CMake support for configuring Git on Linux

     @@ Metadata
      Author: Sibi Siddharthan <[email protected]>
      
       ## Commit message ##
     -    Introduce CMake support for configuring Git on Linux
     +    Introduce CMake support for configuring Git
      
          At the moment, the recommended way to configure Git's builds is to
          simply run `make`. If that does not work, the recommended strategy is to
     @@ Commit message
          occupies around two gigabytes (!) on disk and downloads about three
          quarters of a gigabyte worth of Git objects).
      
     -    To make this a little less awkward, the Git for Windows project offers
     -    the `vs/master` branch which has a full Visual Studio solution generated
     -    and committed. This branch can therefore be used to tinker with Git in
     -    Visual Studio _without_ having to download the full Git for Windows SDK.
     -    Unfortunatly, that branch is auto-generated from Git for Windows'
     -    `master`. If a developer wants to tinker, say, with `pu`, they are out
     -    of luck.
     -
     -    CMake was invented to make this sort of problem go away, by providing a
     -    more standardized, cross-platform way to configure builds.
     +    The build infrastructure for Git is written around being able to run
     +    make, which is not supported natively on Windows.
     +    To help Windows developers a CMake build script is introduced here.
      
          With a working support CMake, developers on Windows need only install
          CMake, configure their build, load the generated Visual Studio solution
     @@ Commit message
          With a CMake script an out of source build of git is possible resulting
          in a clean source tree.
      
     -    Note: earlier endeavors on the Git mailing list to introduce CMake ended
     -    up in dead water. The primary reason for that was that reviewers
     -    _expected_ CMake support to fall out of maintenance, unless the
     -    contributor would promise to keep an eye on keeping CMake support up to
     -    date. However, in the meantime, support for automated testing has been
     -    introduced in Git's source code, and a later patch will modify the
     -    (still experimental) GitHub workflow to continually verify that CMake
     -    support is still complete. That will make maintenance reasonably easy.
     -
          Note: this patch asks for the minimum version v3.14 of CMake (which is
          not all that old as of time of writing) because that is the first
          version to offer a platform-independent way to generate hardlinks as
          part of the build. This is needed to generate all those hardlinks for
          the built-in commands of Git.
      
     -    Instructions to run CMake:
     -
     -    cmake `relative-path-to-srcdir` -DCMAKE_BUILD_TYPE=Release
     +    Changes
     +    The CMake script parses the Makefile for:
     +    LIB_OBJS
     +    BUILTIN_OBJS
     +    XDIFF_OBJS
     +    VCSSVN_OBJS
     +    TEST_BUILTINS_OBJS
      
     -    Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding
     -    compiler flags
     -    Debug : -g
     -    Release: -O3
     -    RelWithDebInfo : -O2 -g
     -    MinSizeRel : -Os
     -    empty(default) :
     +    By doing this we avoid duplication of text between the Makefile and
     +    the CMake script.
      
     -    NOTE: -DCMAKE_BUILD_TYPE is optional
     +    The CMake script has been relocated to contrib/buildsystems.
      
     -    This process generates a Makefile.
     -    Then run `make` to build Git.
     -
     -    NOTE: By default CMake uses Makefile as the build tool on Linux, to use
     -    another tool say `ninja` add this to the command line when configuring.
     -    `-G Ninja`
     +    The CMake script uses GIT-VERSION-GEN to determine the version of Git
     +    being built.
      
          Signed-off-by: Sibi Siddharthan <[email protected]>
      
     - ## CMakeLists.txt (new) ##
     + ## contrib/buildsystems/CMakeLists.txt (new) ##
      @@
      +#
      +#	Copyright (c) 2020 Sibi Siddharthan
      +#
      +
     ++#[[
     ++
     ++Instructions to run CMake:
     ++
     ++cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release
     ++
     ++Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding
     ++compiler flags
     ++Debug : -g
     ++Release: -O3
     ++RelWithDebInfo : -O2 -g
     ++MinSizeRel : -Os
     ++empty(default) :
     ++
     ++NOTE: -DCMAKE_BUILD_TYPE is optional. For multi-config generators like Visual Studio
     ++this option is ignored
     ++
     ++This process generates a Makefile(Linux) , Visual Studio solution(Windows) by default.
     ++Run `make` to build Git on Linux.
     ++Open git.sln on Windows and build Git.
     ++
     ++NOTE: By default CMake uses Makefile as the build tool on Linux and Visual Studio in Windows,
     ++to use another tool say `ninja` add this to the command line when configuring.
     ++`-G Ninja`
     ++
     ++]]
      +cmake_minimum_required(VERSION 3.14)
      +
     -+#Parse GIT-VERSION-GEN to get the version
     -+file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX "DEF_VER=v(.*)")
     -+string(REPLACE "DEF_VER=v" "" git_version ${git_version})
     -+string(REPLACE ".GIT" ".0" git_version ${git_version})#for building from a snapshot
     ++#set the source directory to root of git
     ++set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
     ++
     ++find_program(SH_EXE sh)
     ++
     ++#Create GIT-VERSION-FILE using GIT-VERSION-GEN
     ++if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)
     ++	message("Generating GIT-VERSION-FILE")
     ++	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN
     ++		WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
     ++endif()
     ++
     ++#Parse GIT-VERSION-FILE to get the version
     ++file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE git_version REGEX "GIT_VERSION = (.*)")
     ++string(REPLACE "GIT_VERSION = " "" git_version ${git_version})
     ++string(FIND ${git_version} "GIT" location)
     ++if(location EQUAL -1)
     ++	string(REGEX MATCH "[0-9]*\\.[0-9]*\\.[0-9]*" git_version ${git_version})
     ++else()
     ++	string(REGEX MATCH "[0-9]*\\.[0-9]*" git_version ${git_version})
     ++	string(APPEND git_version ".0") #for building from a snapshot
     ++endif()
      +
      +project(git
      +	VERSION ${git_version}
      +	LANGUAGES C)
      +
      +
     ++#macros for parsing the Makefile for sources
     ++macro(parse_makefile_for_sources list_var regex)
     ++	file(STRINGS ${CMAKE_SOURCE_DIR}/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(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
     ++	list(REMOVE_ITEM ${list_var} "") #remove empty list elements
     ++endmacro()
     ++
      +include(CheckTypeSize)
      +include(CheckCSourceRuns)
      +include(CheckCSourceCompiles)
     @@ CMakeLists.txt (new)
      +	include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
      +endif()
      +
     -+find_program(SH_EXE sh)
     -+
      +#default behaviour
      +include_directories(${CMAKE_SOURCE_DIR})
      +add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
     @@ CMakeLists.txt (new)
      +#function checks
      +set(function_checks
      +	strcasestr memmem strlcpy strtoimax strtoumax strtoull
     -+	setenv  mkdtemp poll pread  memmem unsetenv hstrerror)
     ++	setenv mkdtemp poll pread memmem unsetenv hstrerror)
      +
      +foreach(f ${function_checks})
      +	string(TOUPPER ${f} uf)
     @@ CMakeLists.txt (new)
      +endforeach()
      +
      +if(NOT HAVE_POLL_H OR NOT HAVE_SYS_POLL_H OR NOT HAVE_POLL)
     -+	include_directories(compat/poll)
     ++	include_directories(${CMAKE_SOURCE_DIR}/compat/poll)
      +	add_compile_definitions(NO_POLL)
      +	list(APPEND compat_SOURCES compat/poll/poll.c)
      +endif()
     @@ CMakeLists.txt (new)
      +	add_compile_definitions(HAVE_CLOCK_MONOTONIC)
      +endif()
      +
     ++#check for st_blocks in struct stat
     ++check_struct_has_member("struct stat" st_blocks "sys/stat.h" STRUCT_STAT_HAS_ST_BLOCKS)
     ++if(NOT STRUCT_STAT_HAS_ST_BLOCKS)
     ++	add_compile_definitions(NO_ST_BLOCKS_IN_STRUCT_STAT)
     ++endif()
      +
      +#compile checks
      +check_c_source_runs("
     @@ CMakeLists.txt (new)
      +int main(){return 0;}"
      +HAVE_REGEX)
      +if(NOT HAVE_REGEX)
     -+	include_directories(compat/regex )
     ++	include_directories(${CMAKE_SOURCE_DIR}/compat/regex)
      +	list(APPEND compat_SOURCES compat/regex/regex.c )
      +	add_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)
      +endif()
     @@ CMakeLists.txt (new)
      +	add_compile_definitions(HAVE_BSD_SYSCTL)
      +endif()
      +
     ++set(CMAKE_REQUIRED_LIBRARIES ${Iconv_LIBRARIES})
     ++set(CMAKE_REQUIRED_INCLUDES ${Iconv_INCLUDE_DIRS})
     ++
     ++check_c_source_compiles("
     ++#include <iconv.h>
     ++
     ++extern size_t iconv(iconv_t cd,
     ++		char **inbuf, size_t *inbytesleft,
     ++		char **outbuf, size_t *outbytesleft);
     ++
     ++int main(){return 0;}"
     ++HAVE_NEW_ICONV)
     ++if(HAVE_NEW_ICONV)
     ++	set(HAVE_OLD_ICONV 0)
     ++else()
     ++	set(HAVE_OLD_ICONV 1)
     ++endif()
     ++
     ++check_c_source_runs("
     ++#include <iconv.h>
     ++#if ${HAVE_OLD_ICONV}
     ++typedef const char *iconv_ibp;
     ++#else
     ++typedef char *iconv_ibp;
     ++#endif
     ++
     ++int main()
     ++{
     ++	int v;
     ++	iconv_t conv;
     ++	char in[] = \"a\"; iconv_ibp pin = in;
     ++	char out[20] = \"\"; char *pout = out;
     ++	size_t isz = sizeof in;
     ++	size_t osz = sizeof out;
     ++
     ++	conv = iconv_open(\"UTF-16\", \"UTF-8\");
     ++	iconv(conv, &pin, &isz, &pout, &osz);
     ++	iconv_close(conv);
     ++	v = (unsigned char)(out[0]) + (unsigned char)(out[1]);
     ++	return v != 0xfe + 0xff;
     ++}"
     ++ICONV_DOESNOT_OMIT_BOM)
     ++if(NOT ICONV_DOESNOT_OMIT_BOM)
     ++	add_compile_definitions(ICONV_OMITS_BOM)
     ++endif()
     ++
     ++unset(CMAKE_REQUIRED_LIBRARIES)
     ++unset(CMAKE_REQUIRED_INCLUDES)
     ++
     ++
      +#programs
      +set(PROGRAMS_BUILT
      +	git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
     @@ CMakeLists.txt (new)
      +list(APPEND EXCLUSION_PROGS empty)
      +set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING "Programs not built" FORCE)
      +
     -+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)
     ++if(NOT EXISTS ${CMAKE_BINARY_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)
      +	list(REMOVE_ITEM EXCLUSION_PROGS empty)
      +	message("Generating command-list.h")
      +	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt
      +			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
     -+			OUTPUT_FILE ${CMAKE_SOURCE_DIR}/command-list.h)
     ++			OUTPUT_FILE ${CMAKE_BINARY_DIR}/command-list.h)
      +endif()
      +
     -+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/config-list.h)
     ++if(NOT EXISTS ${CMAKE_BINARY_DIR}/config-list.h)
      +	message("Generating config-list.h")
      +	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh
      +			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
     -+			OUTPUT_FILE ${CMAKE_SOURCE_DIR}/config-list.h)
     ++			OUTPUT_FILE ${CMAKE_BINARY_DIR}/config-list.h)
      +endif()
      +
     ++include_directories(${CMAKE_BINARY_DIR})
      +
      +#build
     -+set(libgit_SOURCES
     -+	abspath.c add-interactive.c add-patch.c advice.c alias.c
     -+	alloc.c apply.c archive.c archive-tar.c archive-zip.c argv-array.c
     -+	attr.c base85.c bisect.c blame.c blob.c bloom.c branch.c bulk-checkin.c
     -+	bundle.c cache-tree.c chdir-notify.c checkout.c color.c column.c
     -+	combine-diff.c commit.c commit-graph.c commit-reach.c compat/obstack.c
     -+	compat/terminal.c config.c connect.c connected.c convert.c copy.c credential.c
     -+	csum-file.c ctype.c date.c decorate.c delta-islands.c diffcore-break.c
     -+	diffcore-delta.c diffcore-order.c diffcore-pickaxe.c diffcore-rename.c
     -+	diff-delta.c diff-lib.c diff-no-index.c diff.c dir.c dir-iterator.c editor.c
     -+	entry.c environment.c ewah/bitmap.c ewah/ewah_bitmap.c ewah/ewah_io.c
     -+	ewah/ewah_rlw.c exec-cmd.c fetch-negotiator.c fetch-pack.c fmt-merge-msg.c fsck.c fsmonitor.c
     -+	gettext.c gpg-interface.c graph.c grep.c hashmap.c linear-assignment.c help.c hex.c
     -+	ident.c interdiff.c json-writer.c kwset.c levenshtein.c line-log.c line-range.c list-objects.c
     -+	list-objects-filter.c list-objects-filter-options.c ll-merge.c lockfile.c
     -+	log-tree.c ls-refs.c mailinfo.c mailmap.c match-trees.c mem-pool.c merge.c merge-blobs.c
     -+	merge-recursive.c mergesort.c midx.c name-hash.c negotiator/default.c
     -+	negotiator/skipping.c notes.c notes-cache.c notes-merge.c notes-utils.c object.c oidmap.c
     -+	oidset.c oid-array.c packfile.c pack-bitmap.c pack-bitmap-write.c pack-check.c pack-objects.c
     -+	pack-revindex.c pack-write.c pager.c parse-options.c parse-options-cb.c patch-delta.c
     -+	patch-ids.c path.c pathspec.c pkt-line.c preload-index.c pretty.c prio-queue.c progress.c
     -+	promisor-remote.c prompt.c protocol.c prune-packed.c quote.c range-diff.c reachable.c read-cache.c rebase.c
     -+	rebase-interactive.c reflog-walk.c refs.c refs/files-backend.c refs/iterator.c
     -+	refs/packed-backend.c refs/ref-cache.c refspec.c ref-filter.c remote.c replace-object.c
     -+	repo-settings.c repository.c rerere.c reset.c resolve-undo.c revision.c run-command.c
     -+	send-pack.c sequencer.c serve.c server-info.c setup.c sha1-lookup.c
     -+	sha1-file.c sha1-name.c shallow.c sideband.c sigchain.c split-index.c
     -+	stable-qsort.c strbuf.c streaming.c string-list.c submodule.c submodule-config.c
     -+	sub-process.c symlinks.c tag.c tempfile.c thread-utils.c tmp-objdir.c
     -+	trace.c trace2.c trace2/tr2_cfg.c trace2/tr2_cmd_name.c trace2/tr2_dst.c
     -+	trace2/tr2_sid.c trace2/tr2_sysenv.c trace2/tr2_tbuf.c trace2/tr2_tgt_event.c
     -+	trace2/tr2_tgt_normal.c trace2/tr2_tgt_perf.c trace2/tr2_tls.c trailer.c transport.c
     -+	transport-helper.c tree-diff.c tree.c tree-walk.c unpack-trees.c upload-pack.c url.c
     -+	urlmatch.c usage.c userdiff.c utf8.c varint.c version.c versioncmp.c walker.c wildmatch.c
     -+	worktree.c wrapper.c write-or-die.c ws.c wt-status.c xdiff-interface.c
     -+	zlib.c)
     ++#libgit
     ++parse_makefile_for_sources(libgit_SOURCES "LIB_OBJS")
      +
     ++list(TRANSFORM libgit_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
     ++list(TRANSFORM compat_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
      +add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})
      +
     -+set(libxdiff_SOURCES
     -+	xdiff/xdiffi.c xdiff/xprepare.c xdiff/xutils.c xdiff/xemit.c
     -+	xdiff/xmerge.c xdiff/xpatience.c xdiff/xhistogram.c)
     ++#libxdiff
     ++parse_makefile_for_sources(libxdiff_SOURCES "XDIFF_OBJS")
     ++
     ++list(TRANSFORM libxdiff_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
      +add_library(xdiff STATIC ${libxdiff_SOURCES})
      +
     -+set(libvcs-svn_SOURCES
     -+	vcs-svn/line_buffer.c vcs-svn/sliding_window.c vcs-svn/fast_export.c
     -+	vcs-svn/svndiff.c vcs-svn/svndump.c)
     ++#libvcs-svn
     ++parse_makefile_for_sources(libvcs-svn_SOURCES "VCSSVN_OBJS")
     ++
     ++list(TRANSFORM libvcs-svn_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
      +add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
      +
      +#link all required libraries to common-main
     -+add_library(common-main OBJECT common-main.c)
     ++add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)
      +target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
      +if(Intl_FOUND)
      +	target_link_libraries(common-main ${Intl_LIBRARIES})
     @@ CMakeLists.txt (new)
      +	target_link_libraries(common-main ${Iconv_LIBRARIES})
      +endif()
      +
     ++#git
     ++parse_makefile_for_sources(git_SOURCES "BUILTIN_OBJS")
     ++
     ++list(TRANSFORM git_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
     ++add_executable(git ${CMAKE_SOURCE_DIR}/git.c ${git_SOURCES})
     ++target_link_libraries(git common-main)
      +
     -+set(git_SOURCES
     -+	builtin/add.c builtin/am.c builtin/annotate.c builtin/apply.c
     -+	builtin/archive.c builtin/bisect--helper.c builtin/blame.c
     -+	builtin/branch.c builtin/bundle.c builtin/cat-file.c builtin/check-attr.c
     -+	builtin/check-ignore.c builtin/check-mailmap.c builtin/check-ref-format.c
     -+	builtin/checkout-index.c builtin/checkout.c builtin/clean.c
     -+	builtin/clone.c builtin/column.c builtin/commit-tree.c
     -+	builtin/commit.c builtin/commit-graph.c builtin/config.c
     -+	builtin/count-objects.c builtin/credential.c builtin/describe.c
     -+	builtin/diff-files.c builtin/diff-index.c builtin/diff-tree.c
     -+	builtin/diff.c builtin/difftool.c builtin/env--helper.c
     -+	builtin/fast-export.c builtin/fetch-pack.c builtin/fetch.c builtin/fmt-merge-msg.c
     -+	builtin/for-each-ref.c builtin/fsck.c builtin/gc.c
     -+	builtin/get-tar-commit-id.c builtin/grep.c builtin/hash-object.c
     -+	builtin/help.c builtin/index-pack.c builtin/init-db.c
     -+	builtin/interpret-trailers.c builtin/log.c builtin/ls-files.c
     -+	builtin/ls-remote.c builtin/ls-tree.c builtin/mailinfo.c builtin/mailsplit.c
     -+	builtin/merge.c builtin/merge-base.c builtin/merge-file.c builtin/merge-index.c
     -+	builtin/merge-ours.c builtin/merge-recursive.c builtin/merge-tree.c
     -+	builtin/mktag.c builtin/mktree.c builtin/multi-pack-index.c builtin/mv.c
     -+	builtin/name-rev.c builtin/notes.c builtin/pack-objects.c builtin/pack-redundant.c
     -+	builtin/pack-refs.c builtin/patch-id.c builtin/prune-packed.c builtin/prune.c
     -+	builtin/pull.c builtin/push.c builtin/range-diff.c builtin/read-tree.c
     -+	builtin/rebase.c builtin/receive-pack.c builtin/reflog.c builtin/remote.c
     -+	builtin/remote-ext.c builtin/remote-fd.c builtin/repack.c builtin/replace.c
     -+	builtin/rerere.c builtin/reset.c builtin/rev-list.c builtin/rev-parse.c
     -+	builtin/revert.c builtin/rm.c builtin/send-pack.c builtin/shortlog.c
     -+	builtin/show-branch.c builtin/show-index.c builtin/show-ref.c
     -+	builtin/sparse-checkout.c builtin/stash.c builtin/stripspace.c
     -+	builtin/submodule--helper.c builtin/symbolic-ref.c builtin/tag.c
     -+	builtin/unpack-file.c builtin/unpack-objects.c builtin/update-index.c
     -+	builtin/update-ref.c builtin/update-server-info.c builtin/upload-archive.c
     -+	builtin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c
     -+	builtin/verify-tag.c builtin/worktree.c builtin/write-tree.c)
     -+
     -+add_executable(git git.c ${git_SOURCES})
     -+target_link_libraries(git common-main )
     -+
     -+add_executable(git-bugreport bugreport.c)
     ++add_executable(git-bugreport ${CMAKE_SOURCE_DIR}/bugreport.c)
      +target_link_libraries(git-bugreport common-main)
      +
     -+add_executable(git-credential-store credential-store.c)
     ++add_executable(git-credential-store ${CMAKE_SOURCE_DIR}/credential-store.c)
      +target_link_libraries(git-credential-store common-main)
      +
     -+add_executable(git-daemon daemon.c)
     ++add_executable(git-daemon ${CMAKE_SOURCE_DIR}/daemon.c)
      +target_link_libraries(git-daemon common-main)
      +
     -+add_executable(git-fast-import fast-import.c)
     ++add_executable(git-fast-import ${CMAKE_SOURCE_DIR}/fast-import.c)
      +target_link_libraries(git-fast-import common-main)
      +
     -+add_executable(git-http-backend http-backend.c)
     ++add_executable(git-http-backend ${CMAKE_SOURCE_DIR}/http-backend.c)
      +target_link_libraries(git-http-backend common-main)
      +
     -+add_executable(git-sh-i18n--envsubst sh-i18n--envsubst.c)
     ++add_executable(git-sh-i18n--envsubst ${CMAKE_SOURCE_DIR}/sh-i18n--envsubst.c)
      +target_link_libraries(git-sh-i18n--envsubst common-main)
      +
     -+add_executable(git-shell shell.c)
     ++add_executable(git-shell ${CMAKE_SOURCE_DIR}/shell.c)
      +target_link_libraries(git-shell common-main)
      +
      +if(CURL_FOUND)
     -+	add_library(http_obj OBJECT http.c)
     ++	add_library(http_obj OBJECT ${CMAKE_SOURCE_DIR}/http.c)
      +
     -+	add_executable(git-imap-send imap-send.c)
     ++	add_executable(git-imap-send ${CMAKE_SOURCE_DIR}/imap-send.c)
      +	target_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})
      +
     -+	add_executable(git-http-fetch http-walker.c http-fetch.c)
     ++	add_executable(git-http-fetch ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/http-fetch.c)
      +	target_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})
      +
     -+	add_executable(git-remote-http http-walker.c remote-curl.c)
     ++	add_executable(git-remote-http ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/remote-curl.c)
      +	target_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )
      +
      +	if(EXPAT_FOUND)
     -+		add_executable(git-http-push http-push.c)
     ++		add_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)
      +		target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
      +	endif()
      +endif()
      +
     -+add_executable(git-remote-testsvn remote-testsvn.c)
     ++add_executable(git-remote-testsvn ${CMAKE_SOURCE_DIR}/remote-testsvn.c)
      +target_link_libraries(git-remote-testsvn common-main vcs-svn)
      +
     -+add_executable(git-credential-cache credential-cache.c)
     ++add_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)
      +target_link_libraries(git-credential-cache common-main)
      +
     -+add_executable(git-credential-cache--daemon credential-cache--daemon.c)
     ++add_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)
      +target_link_libraries(git-credential-cache--daemon common-main)
      +
      +
     @@ CMakeLists.txt (new)
      +
      +#Creating hardlinks
      +foreach(s ${git_SOURCES} ${git_builtin_extra})
     -+	string(REPLACE "builtin/" "" s ${s})
     ++	string(REPLACE "${CMAKE_SOURCE_DIR}/builtin/" "" s ${s})
      +	string(REPLACE ".c" "" s ${s})
      +	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git git-${s})\n")
      +	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})
     @@ CMakeLists.txt (new)
      +		COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
      +		DEPENDS git git-remote-http)
      +add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
     - \ No newline at end of file

2: ca242cf5bda ! 2: f19794fdbc0 cmake: generate the shell/perl/python scripts and templates, translations
@@ Metadata
## Commit message ##
cmake: generate the shell/perl/python scripts and templates, translations

- This patch implements the placeholder substitution to generate, say,
- git-request-pull from git-request-pull.sh.
+ Implement the placeholder substitution to generate scripted
+ Porcelain commands, e.g. git-request-pull out of
+ git-request-pull.sh

- The shell/perl/python scripts and template are generated using CMake
- (very similar to what sed does).
+ Generate shell/perl/python scripts and template using CMake instead of
+ using sed like the build procedure in the Makefile does.

The text translations are only build if msgfmt is found in your path.

NOTE: The scripts and templates are generated during configuration.

+ Changes
+ The CMake script parses the Makefile for:
+ SCRIPT_SH
+ SCRIPT_PERL
+

- ## CMakeLists.txt ##
-@@ CMakeLists.txt: endif()
+ ## contrib/buildsystems/CMakeLists.txt ##
+@@ contrib/buildsystems/CMakeLists.txt: project(git
+ LANGUAGES C)
+
+
+-#macros for parsing the Makefile for sources
++#macros for parsing the Makefile for sources and scripts
+ macro(parse_makefile_for_sources list_var regex)
+ file(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX "^${regex} \\+=(.*)")
+ string(REPLACE "${regex} +=" "" ${list_var} ${${list_var}})
+@@ contrib/buildsystems/CMakeLists.txt: macro(parse_makefile_for_sources list_var regex)
+ list(REMOVE_ITEM ${list_var} "") #remove empty list elements
+ endmacro()

- find_program(SH_EXE sh) ++macro(parse_makefile_for_scripts list_var regex lang)
++ file(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX "^${regex} \\+=(.*)")
++ string(REPLACE "${regex} +=" "" ${list_var} ${${list_var}})
++ string(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces
++ string(REPLACE " " ";" ${list_var} ${${list_var}}) #convert string to a list
++ list(TRANSFORM ${list_var} REPLACE "${lang}" "") #do the replacement
++endmacro()
++
+ include(CheckTypeSize)
+ include(CheckCSourceRuns)
+ include(CheckCSourceCompiles)
+@@ contrib/buildsystems/CMakeLists.txt: if(Intl_FOUND)
+ include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
+ endif()

+find_program(MSGFMT_EXE msgfmt)
+if(NOT MSGFMT_EXE)
@@ CMakeLists.txt: endif()
#default behaviour
include_directories(${CMAKE_SOURCE_DIR}) add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
-@@ CMakeLists.txt: endif()
- add_custom_command(OUTPUT ${git_links} ${git_http_links}
+@@ contrib/buildsystems/CMakeLists.txt: add_custom_command(OUTPUT ${git_links} ${git_http_links}
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake DEPENDS git git-remote-http)
--add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
- \ No newline at end of file
-+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
+ add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
+
+
+#creating required scripts
@@ CMakeLists.txt: endif()
+set(INSTLIBDIR ${FALLBACK_RUNTIME_PREFIX}/share/perl5)
+
+#shell scripts
++parse_makefile_for_scripts(git_sh_scripts "SCRIPT_SH" ".sh")
+set(git_shell_scripts
-+ git-bisect git-difftool--helper git-filter-branch
-+ git-merge-octopus git-merge-one-file git-merge-resolve
-+ git-mergetool git-quiltimport
-+ git-request-pull git-submodule git-web--browse
++ ${git_sh_scripts}
+ git-mergetool--lib git-parse-remote git-rebase--preserve-merges
+ git-sh-setup git-sh-i18n git-instaweb)
+
@@ CMakeLists.txt: endif()
+endforeach()
+
+#perl scripts
-+set(git_perl_scripts
-+ git-add--interactive git-archimport git-cvsexportcommit
-+ git-cvsimport git-cvsserver git-send-email git-svn)
++parse_makefile_for_scripts(git_perl_scripts "SCRIPT_PERL" ".perl")
+
+#create perl header
+file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )
3: b2974432d77 ! 3: 6ec73d3e967 cmake: installation support for git
@@ Metadata
## Commit message ##
cmake: installation support for git

- This patch provides the facility to install the built binaries and
- scripts.
+ Install the built binaries and scripts using CMake

This is very similar to make install.
By default the destination directory(DESTDIR) is /usr/local/ on Linux
@@ Commit message

- ## CMakeLists.txt ##
-@@ CMakeLists.txt: project(git
+ ## contrib/buildsystems/CMakeLists.txt ## +@@ contrib/buildsystems/CMakeLists.txt: project(git VERSION ${git_version}
LANGUAGES C)

+#TODO gitk git-gui gitweb
+#TODO Add pcre support

- include(CheckTypeSize)
- include(CheckCSourceRuns)
-@@ CMakeLists.txt: if(MSGFMT_EXE)
+ #macros for parsing the Makefile for sources and scripts
+ macro(parse_makefile_for_sources list_var regex)
+@@ contrib/buildsystems/CMakeLists.txt: if(MSGFMT_EXE)
endforeach()
add_custom_target(po-gen ALL DEPENDS ${po_gen})
endif()
@@ CMakeLists.txt: if(MSGFMT_EXE)
+install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
+ DESTINATION libexec/git-core)
+
-+install(DIRECTORY mergetools DESTINATION libexec/git-core) ++install(DIRECTORY ${CMAKE_SOURCE_DIR}/mergetools DESTINATION libexec/git-core)
+install(DIRECTORY ${CMAKE_BINARY_DIR}/perl/build/lib/ DESTINATION share/perl5
+ FILES_MATCHING PATTERN "*.pm")
+install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/templates)
4: 2bd8870fb96 ! 4: cdc53172b3f cmake: support for testing git with ctest
@@ Commit message

- ## CMakeLists.txt ##
-@@ CMakeLists.txt: include(CheckIncludeFile)
+ ## contrib/buildsystems/CMakeLists.txt ##
+@@ contrib/buildsystems/CMakeLists.txt: include(CheckIncludeFile)
include(CheckFunctionExists) include(CheckSymbolExists) include(CheckStructHasMember)
@@ CMakeLists.txt: include(CheckIncludeFile)

find_package(ZLIB REQUIRED)
find_package(CURL)
-@@ CMakeLists.txt: install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/ +@@ contrib/buildsystems/CMakeLists.txt: install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/
if(MSGFMT_EXE)
install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)
endif()
@@ CMakeLists.txt: install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION
+if(BUILD_TESTING)
+
+#tests-helpers
-+add_executable(test-fake-ssh t/helper/test-fake-ssh.c)
++add_executable(test-fake-ssh ${CMAKE_SOURCE_DIR}/t/helper/test-fake-ssh.c)
+target_link_libraries(test-fake-ssh common-main)
+
-+add_executable(test-line-buffer t/helper/test-line-buffer.c)
++add_executable(test-line-buffer ${CMAKE_SOURCE_DIR}/t/helper/test-line-buffer.c)
+target_link_libraries(test-line-buffer common-main vcs-svn)
+
-+add_executable(test-svn-fe t/helper/test-svn-fe.c)
++add_executable(test-svn-fe ${CMAKE_SOURCE_DIR}/t/helper/test-svn-fe.c)
+target_link_libraries(test-svn-fe common-main vcs-svn)
+
-+set(test-tool_SOURCES
-+ t/helper/test-tool.c t/helper/test-advise.c t/helper/test-bloom.c t/helper/test-chmtime.c
-+ t/helper/test-config.c t/helper/test-ctype.c t/helper/test-date.c t/helper/test-delta.c
-+ t/helper/test-dir-iterator.c t/helper/test-drop-caches.c t/helper/test-dump-cache-tree.c
-+ t/helper/test-dump-fsmonitor.c t/helper/test-dump-split-index.c
-+ t/helper/test-dump-untracked-cache.c t/helper/test-example-decorate.c
-+ t/helper/test-genrandom.c t/helper/test-genzeros.c t/helper/test-hash.c
-+ t/helper/test-hashmap.c t/helper/test-hash-speed.c t/helper/test-index-version.c
-+ t/helper/test-json-writer.c t/helper/test-lazy-init-name-hash.c
-+ t/helper/test-match-trees.c t/helper/test-mergesort.c t/helper/test-mktemp.c
-+ t/helper/test-oidmap.c t/helper/test-online-cpus.c t/helper/test-parse-options.c
-+ t/helper/test-parse-pathspec-file.c t/helper/test-path-utils.c t/helper/test-pkt-line.c
-+ t/helper/test-prio-queue.c t/helper/test-progress.c t/helper/test-reach.c
-+ t/helper/test-read-cache.c t/helper/test-read-graph.c t/helper/test-read-midx.c
-+ t/helper/test-ref-store.c t/helper/test-regex.c t/helper/test-repository.c
-+ t/helper/test-revision-walking.c t/helper/test-run-command.c t/helper/test-scrap-cache-tree.c
-+ t/helper/test-serve-v2.c t/helper/test-sha1.c t/helper/test-oid-array.c t/helper/test-sha256.c
-+ t/helper/test-sigchain.c t/helper/test-strcmp-offset.c t/helper/test-string-list.c
-+ t/helper/test-submodule-config.c t/helper/test-submodule-nested-repo-config.c t/helper/test-subprocess.c
-+ t/helper/test-trace2.c t/helper/test-urlmatch-normalization.c t/helper/test-xml-encode.c
-+ t/helper/test-wildmatch.c t/helper/test-windows-named-pipe.c t/helper/test-write-cache.c)
-+
-+add_executable(test-tool ${test-tool_SOURCES})
++#test-tool
++parse_makefile_for_sources(test-tool_SOURCES "TEST_BUILTINS_OBJS")
++
++list(TRANSFORM test-tool_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/t/helper/") ++add_executable(test-tool ${CMAKE_SOURCE_DIR}/t/helper/test-tool.c ${test-tool_SOURCES})
+target_link_libraries(test-tool common-main)
+
+set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
@@ CMakeLists.txt: install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION
+endforeach()
+
+endif()#BUILD_TESTING
- \ No newline at end of file
5: 096f6311ad5 ! 5: cdc68f102cb cmake: support for testing git when building out of the source tree

     @@ Commit message
      
          Signed-off-by: Sibi Siddharthan <[email protected]>
      
     - ## CMakeLists.txt ##
     -@@ CMakeLists.txt: file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n"
     + ## contrib/buildsystems/CMakeLists.txt ##
     +@@ contrib/buildsystems/CMakeLists.txt: file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n"
       file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
       file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
       
      +#Make the tests work when building out of the source tree
     -+if(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
     ++get_filename_component(CACHE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../CMakeCache.txt ABSOLUTE)
     ++if(NOT ${CMAKE_BINARY_DIR}/CMakeCache.txt STREQUAL ${CACHE_PATH})
      +	file(RELATIVE_PATH BUILD_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/CMakeCache.txt)
      +	string(REPLACE "/CMakeCache.txt" "" BUILD_DIR_RELATIVE ${BUILD_DIR_RELATIVE})
      +	#Setting the build directory in test-lib.sh before running tests

6: 00cae10bbb7 ! 6: f41cbd43081 cmake: support for building git on windows with mingw
@@ Commit message
Changed the error message when sh.exe is not found on Windows as suggested by Philip Oakley <[email protected]>

+ v2:
+ Fixed a bug where a Windows user can pose as Linux user and vice versa.
+

- ## CMakeLists.txt ##
-@@ CMakeLists.txt: project(git
+ ## contrib/buildsystems/CMakeLists.txt ##
+@@ contrib/buildsystems/CMakeLists.txt: cmake_minimum_required(VERSION 3.14)
+ set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
+
+ find_program(SH_EXE sh)
++if(NOT SH_EXE)
++ message(FATAL_ERROR "sh: shell interpreter was not found in your path, please install one."
++ "On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/")
++endif()
+
+ #Create GIT-VERSION-FILE using GIT-VERSION-GEN
+ if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)
+@@ contrib/buildsystems/CMakeLists.txt: project(git
VERSION ${git_version}
LANGUAGES C)

@@ CMakeLists.txt: project(git
+#TODO Enable NLS on windows natively
#TODO Add pcre support

-+
- include(CheckTypeSize)
- include(CheckCSourceRuns)
- include(CheckCSourceCompiles)
-@@ CMakeLists.txt: find_package(EXPAT)
+ #macros for parsing the Makefile for sources and scripts +@@ contrib/buildsystems/CMakeLists.txt: find_package(EXPAT) find_package(Iconv)
find_package(Intl)

@@ CMakeLists.txt: find_package(EXPAT)
if(NOT Intl_FOUND)
add_compile_definitions(NO_GETTEXT)
if(NOT Iconv_FOUND)
-@@ CMakeLists.txt: if(Intl_FOUND)
+@@ contrib/buildsystems/CMakeLists.txt: if(Intl_FOUND)
+ include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
endif()

- find_program(SH_EXE sh)
-+if(NOT SH_EXE)
-+ message(FATAL_ERROR "sh: shell interpreter was not found in your path, please install one."
-+ "On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/")
-+endif()
+
+if(WIN32)
+ find_program(WINDRES_EXE windres)
@@ CMakeLists.txt: if(Intl_FOUND)
+ message(FATAL_ERROR "Install windres on Windows for resource files")
+ endif()
+endif()
-
++
find_program(MSGFMT_EXE msgfmt)
if(NOT MSGFMT_EXE)
-@@ CMakeLists.txt: add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
+ message(WARNING "Text Translations won't be build")
+@@ contrib/buildsystems/CMakeLists.txt: add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
BINDIR="bin"
GIT_BUILT_FROM_COMMIT="")

@@ CMakeLists.txt: add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
-list(APPEND compat_SOURCES unix-socket.c)
+
+#Platform Specific
-+if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
-+ include_directories(compat/win32)
++if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
++ include_directories(${CMAKE_SOURCE_DIR}/compat/win32)
+ add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
+ _CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe" NO_SYMLINK_HEAD UNRELIABLE_FSTAT
-+ NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0 NO_ST_BLOCKS_IN_STRUCT_STAT
++ NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0
+ USE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP
+ UNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)
+ list(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c
@@ CMakeLists.txt: add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
+ compat/nedmalloc/nedmalloc.c compat/strdup.c)
+ set(NO_UNIX_SOCKETS 1)
+
-+elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") ++elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
+ list(APPEND compat_SOURCES unix-socket.c)
+endif()
@@ CMakeLists.txt: add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"

#header checks
check_include_file(libgen.h HAVE_LIBGEN_H)
-@@ CMakeLists.txt: endif()
+@@ contrib/buildsystems/CMakeLists.txt: endif()
#function checks
set(function_checks
strcasestr memmem strlcpy strtoimax strtoumax strtoull
-- setenv mkdtemp poll pread memmem unsetenv hstrerror)
-+ setenv mkdtemp poll pread memmem)
+- setenv mkdtemp poll pread memmem unsetenv hstrerror)
++ setenv mkdtemp poll pread memmem)
+
+#unsetenv,hstrerror are incompatible with windows build +if(NOT WIN32)
@@ CMakeLists.txt: endif()

foreach(f ${function_checks})
string(TOUPPER ${f} uf)
-@@ CMakeLists.txt: endif()
+@@ contrib/buildsystems/CMakeLists.txt: unset(CMAKE_REQUIRED_INCLUDES)
#programs
set(PROGRAMS_BUILT
git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
@@ CMakeLists.txt: endif()

if(NOT CURL_FOUND)
list(APPEND excluded_progs git-http-fetch git-http-push)
-@@ CMakeLists.txt: set(libvcs-svn_SOURCES
- vcs-svn/svndiff.c vcs-svn/svndump.c)
+@@ contrib/buildsystems/CMakeLists.txt: parse_makefile_for_sources(libvcs-svn_SOURCES "VCSSVN_OBJS")
+ list(TRANSFORM libvcs-svn_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/") add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})

+#add git.rc for gcc
@@ CMakeLists.txt: set(libvcs-svn_SOURCES
+endif()
+
#link all required libraries to common-main
- add_library(common-main OBJECT common-main.c)
+ add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c) -target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt) +
+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})
@@ CMakeLists.txt: set(libvcs-svn_SOURCES
+ target_link_libraries(common-main pthread rt)
+endif()

-
- set(git_SOURCES
-@@ CMakeLists.txt: endif()
- add_executable(git-remote-testsvn remote-testsvn.c)
+ #git
+ parse_makefile_for_sources(git_SOURCES "BUILTIN_OBJS")
+@@ contrib/buildsystems/CMakeLists.txt: endif()
+ add_executable(git-remote-testsvn ${CMAKE_SOURCE_DIR}/remote-testsvn.c) target_link_libraries(git-remote-testsvn common-main vcs-svn)

--add_executable(git-credential-cache credential-cache.c) +-add_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)
-target_link_libraries(git-credential-cache common-main) +if(NOT NO_UNIX_SOCKETS)
-+ add_executable(git-credential-cache credential-cache.c)
++ add_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)
+ target_link_libraries(git-credential-cache common-main)

--add_executable(git-credential-cache--daemon credential-cache--daemon.c) +-add_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)
-target_link_libraries(git-credential-cache--daemon common-main)
-+ add_executable(git-credential-cache--daemon credential-cache--daemon.c)
++ add_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)
+ target_link_libraries(git-credential-cache--daemon common-main)
+endif()

set(git_builtin_extra
-@@ CMakeLists.txt: set(git_builtin_extra
+@@ contrib/buildsystems/CMakeLists.txt: set(git_builtin_extra
foreach(s ${git_SOURCES} ${git_builtin_extra})
- string(REPLACE "builtin/" "" s ${s})
+ string(REPLACE "${CMAKE_SOURCE_DIR}/builtin/" "" s ${s})
string(REPLACE ".c" "" s ${s})
- file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git git-${s})\n")
- list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})
@@ CMakeLists.txt: set(git_builtin_extra
endforeach()
endif()

-@@ CMakeLists.txt: set(bin_links
+@@ contrib/buildsystems/CMakeLists.txt: set(bin_links
git-receive-pack git-upload-archive git-upload-pack)

foreach(b ${bin_links})
@@ CMakeLists.txt: set(bin_links
endforeach()

install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
-@@ CMakeLists.txt: set(wrapper_test_scripts
+@@ contrib/buildsystems/CMakeLists.txt: set(wrapper_test_scripts
foreach(script ${wrapper_scripts})
file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME) string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
@@ CMakeLists.txt: set(wrapper_test_scripts
file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
endforeach()

-@@ CMakeLists.txt: file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\
+@@ contrib/buildsystems/CMakeLists.txt: file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\
file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\n") file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PAGER_ENV='${PAGER_ENV}'\n")
file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DC_SHA1='${DC_SHA1}'\n")
7: af6c606881d ! 7: 8f36e30cd22 cmake: support for building git on windows with msvc and clang.
@@ Commit message

- ## CMakeLists.txt ##
-@@
- # Copyright (c) 2020 Sibi Siddharthan
- #
-
--cmake_minimum_required(VERSION 3.14) -+cmake_minimum_required(VERSION 3.15)
-
- #Parse GIT-VERSION-GEN to get the version
- file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX "DEF_VER=v(.*)") -@@ CMakeLists.txt: find_package(ZLIB REQUIRED)
+ ## contrib/buildsystems/CMakeLists.txt ##
+@@ contrib/buildsystems/CMakeLists.txt: find_package(ZLIB REQUIRED)
find_package(CURL)
find_package(EXPAT)
find_package(Iconv)
@@ CMakeLists.txt: find_package(ZLIB REQUIRED)

if(NOT Intl_FOUND)
add_compile_definitions(NO_GETTEXT)
-@@ CMakeLists.txt: if(NOT SH_EXE)
- "On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/")
+@@ contrib/buildsystems/CMakeLists.txt: if(Intl_FOUND)
endif()

+
-if(WIN32)
+if(WIN32 AND NOT MSVC)#not required for visual studio builds
find_program(WINDRES_EXE windres)
if(NOT WINDRES_EXE)
message(FATAL_ERROR "Install windres on Windows for resource files")
-@@ CMakeLists.txt: if(NOT MSGFMT_EXE)
+@@ contrib/buildsystems/CMakeLists.txt: if(NOT MSGFMT_EXE)
message(WARNING "Text Translations won't be build")
endif()

@@ CMakeLists.txt: if(NOT MSGFMT_EXE)
#default behaviour include_directories(${CMAKE_SOURCE_DIR}) add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
-@@ CMakeLists.txt: endif()
+@@ contrib/buildsystems/CMakeLists.txt: endif()

#Platform Specific
- if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+ if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
-+ include_directories(compat/vcbuild/include)
++ include_directories(${CMAKE_SOURCE_DIR}/compat/vcbuild/include)
+ add_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)
+ endif()
- include_directories(compat/win32)
+ include_directories(${CMAKE_SOURCE_DIR}/compat/win32)
add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe" NO_SYMLINK_HEAD UNRELIABLE_FSTAT
-@@ CMakeLists.txt: set(libvcs-svn_SOURCES
- vcs-svn/svndiff.c vcs-svn/svndump.c)
+@@ contrib/buildsystems/CMakeLists.txt: parse_makefile_for_sources(libvcs-svn_SOURCES "VCSSVN_OBJS")
+ list(TRANSFORM libvcs-svn_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})

-#add git.rc for gcc
@@ CMakeLists.txt: set(libvcs-svn_SOURCES
add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)
endif()

-@@ CMakeLists.txt: endif()
+@@ contrib/buildsystems/CMakeLists.txt: endif()
if(WIN32)
target_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res) add_dependencies(common-main git-rc)
@@ CMakeLists.txt: endif()
elseif(UNIX)
target_link_libraries(common-main pthread rt)
endif()
-@@ CMakeLists.txt: target_link_libraries(test-tool common-main)
+@@ contrib/buildsystems/CMakeLists.txt: target_link_libraries(test-tool common-main)
set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)

  8:  f496cd7d8aa <  -:  ----------- cmake: added checks for struct stat and libiconv
  9:  9c674372fb5 <  -:  ----------- cmake: relocated script file contrib/buildsystems
 10:  b0a321a714a <  -:  ----------- cmake: parse the makefile for the sources.
 11:  fa1b8032906 !  8:  bb329d16ce0 ci: modification of main.yml to use cmake for vs-build job

@@
## Metadata ##
-Author: Sibi Siddharthan <[email protected]> +Author: Sibi Siddharthan <[email protected]>

## Commit message ##
ci: modification of main.yml to use cmake for vs-build job

- This patch modifies .github/workflows/main.yml to use CMake for
- Visual Studio builds.
+ Teach .github/workflows/main.yml to use CMake for VS builds.

Modified the vs-test step to match windows-test step. This speeds up the vs-test. Calling git-cmd from powershell and then calling git-bash
@@ Commit message
building git (eg zlib,libiconv). So we extract the libraries before we configure.

- Changes:
- The CMake script has been relocated to contib/buildsystems, so point
- to the CMakeLists.txt in the invocation commands.
-
- The generation command now uses the absolute paths for the generation
- step.
-
To check for ICONV_OMITS_BOM libiconv.dll needs to be in the working directory of script or path. So we copy the dlls before we configure.

- Signed-off-by: Sibi Siddharthan <[email protected]>
+ Signed-off-by: Sibi Siddharthan <[email protected]>

## .github/workflows/main.yml ##
@@ .github/workflows/main.yml: jobs:
- - name: download git-sdk-64-minimal
- shell: bash
- run: a=git-sdk-64-minimal && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
+ ## Unzip and remove the artifact
+ unzip artifacts.zip
+ rm artifacts.zip
- - name: generate Visual Studio solution
- shell: powershell
- run: |
@@ .github/workflows/main.yml: jobs:
& git-sdk-64-minimal\usr\bin\bash.exe -lc @"
mkdir -p artifacts &&
eval \"`$(make -n artifacts-tar INCLUDE_DLLS_IN_ARTIFACTS=YesPlease ARTIFACTS_DIRECTORY=artifacts 2>&1 | grep ^tar)\"
-@@ .github/workflows/main.yml: jobs:
- nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
- steps:
- - uses: actions/checkout@v1
-- - name: download git-64-portable
-+ - name: download git-sdk-64-minimal
- shell: bash
-- run: a=git-64-portable && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
-+ run: a=git-sdk-64-minimal && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
- - name: download build artifacts
- uses: actions/download-artifact@v1
- with:
@@ .github/workflows/main.yml: jobs:
- name: extract build artifacts
shell: bash
@@ .github/workflows/main.yml: jobs:
shell: powershell
env:
MSYSTEM: MINGW64
- NO_SVN_TESTS: 1
- GIT_TEST_SKIP_REBASE_P: 1
- run: |
-- & git-64-portable\git-cmd.exe --command=usr\bin\bash.exe -lc @"
-- # Let Git ignore the SDK and the test-cache
-- printf '%s\n' /git-64-portable/ /test-cache/ >>.git/info/exclude
-+ & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
-+ # Let Git ignore the SDK
-+ printf '%s\n' /git-sdk-64-minimal/ >>.git/info/exclude
+@@ .github/workflows/main.yml: jobs:
+ # Let Git ignore the SDK and the test-cache
+ printf '%s\n' /git-sdk-64-minimal/ /test-cache/ >>.git/info/exclude

- cd t &&
- PATH=\"$PWD/helper:$PATH\" &&
@@ .github/workflows/main.yml: jobs:
+ name: failed-tests-windows
+ path: ${{env.FAILED_TEST_ARTIFACTS}}
regular:
- strategy:
- matrix:
+ needs: ci-config
+ if: needs.ci-config.outputs.enabled == 'yes'
+@@ .github/workflows/main.yml: jobs:
+ steps:
+ - uses: actions/checkout@v1
+ - run: ci/install-dependencies.sh
+- - run: ci/test-documentation.sh
++ - run: ci/test-documentation.sh
+ \ No newline at end of file

Signature · 1 line
gitgitgadget