{"thread":{"id":"53305","subject":"[PATCH 0/8] CMake build system for git","startedAt":"2020-04-24T04:01:41Z","lastAt":"2020-07-01T17:50:02Z","messageCount":179,"participants":["Sibi Siddharthan via GitGitGadget","Danh Doan","Philip Oakley","Junio C Hamano","Sibi Siddharthan","Johannes Schindelin","brian m. carlson","Randall S. Becker","Jeff King","Michal Suchánek","Elijah Newren","Konstantin Tokarev","Đoàn Trần Công Danh","Øystein Walle","David Aguilar"],"isPatch":true,"patchVersion":1,"patchTotal":8},"messages":[{"id":"396094","messageId":"pull.614.git.1587700897.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":null,"subject":"[PATCH 0/8] CMake build system for git","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-04-24T04:01:29Z","receivedAt":"2020-04-24T04:01:41Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"This is an attempt to build Git using CMake. CMake is cross-platform build\ngenerator which works well on a variety of platforms(primarily Linux and\nWindows). Using CMake we can check whether certain headers exist, certain\nfunctions exist, the required libraries are present and configure the build\naccordingly. Using CMake we can also build and test Git out of source,\nresulting in a clean source tree.\n\nTested platforms\n\nUbuntu 18.04 GCC 7.4 Clang 8.0.1\n\nWindows MinGW GCC 9.2 Clang 9 Visual Studio 2015,2017,2019\n\nSibi Siddharthan (8):\n  Introduce CMake support for configuring Git on Linux\n  cmake: generate the shell/perl/python scripts and templates,\n    translations\n  cmake: installation support for git\n  cmake: support for testing git with ctest\n  cmake: support for testing git when building out of the source tree\n  cmake: support for building git on windows with mingw\n  cmake: support for building git on windows with msvc and clang.\n  ci: modification of main.yml to use cmake for vs-build job\n\n .github/workflows/main.yml |  43 +-\n CMakeLists.txt             | 952 +++++++++++++++++++++++++++++++++++++\n 2 files changed, 977 insertions(+), 18 deletions(-)\n create mode 100644 CMakeLists.txt\n\n\nbase-commit: 744177e7f7fd407c26e9e4aa3b19696859010c48\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-614%2FSibiSiddharthan%2Fgit-og-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-614/SibiSiddharthan/git-og-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/614\n-- \ngitgitgadget\n"},{"id":"396097","messageId":"ca242cf5bda74aafca6c169ad53ce33a62761027.1587700897.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.git.1587700897.gitgitgadget@gmail.com","subject":"[PATCH 2/8] cmake: generate the shell/perl/python scripts and templates, translations","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-04-24T04:01:31Z","receivedAt":"2020-04-24T04:01:44Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThis patch implements the placeholder substitution to generate, say,\n`git-request-pull` from `git-request-pull.sh`.\n\nThe shell/perl/python scripts and template are generated using CMake\n(very similar to what sed does).\n\nThe text translations are only build if `msgfmt` is found in your path.\n\nNOTE: The scripts and templates are generated during configuration.\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n CMakeLists.txt | 107 ++++++++++++++++++++++++++++++++++++++++++++++++-\n 1 file changed, 106 insertions(+), 1 deletion(-)\n\ndiff --git a/CMakeLists.txt b/CMakeLists.txt\nindex 73703bd321f..788b53be873 100644\n--- a/CMakeLists.txt\n+++ b/CMakeLists.txt\n@@ -51,6 +51,11 @@ endif()\n \n find_program(SH_EXE sh)\n \n+find_program(MSGFMT_EXE msgfmt)\n+if(NOT MSGFMT_EXE)\n+\tmessage(WARNING \"Text Translations won't be build\")\n+endif()\n+\n #default behaviour\n include_directories(${CMAKE_SOURCE_DIR})\n add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n@@ -525,4 +530,104 @@ endif()\n add_custom_command(OUTPUT ${git_links} ${git_http_links}\n \t\tCOMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake\n \t\tDEPENDS git git-remote-http)\n-add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})\n\\ No newline at end of file\n+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})\n+\n+\n+#creating required scripts\n+set(SHELL_PATH /bin/sh)\n+set(PERL_PATH /usr/bin/perl)\n+set(LOCALEDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)\n+set(GITWEBDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)\n+set(INSTLIBDIR ${FALLBACK_RUNTIME_PREFIX}/share/perl5)\n+\n+#shell scripts\n+set(git_shell_scripts\n+\tgit-bisect git-difftool--helper git-filter-branch\n+\tgit-merge-octopus git-merge-one-file git-merge-resolve\n+\tgit-mergetool git-quiltimport\n+\tgit-request-pull git-submodule git-web--browse\n+\tgit-mergetool--lib git-parse-remote git-rebase--preserve-merges\n+\tgit-sh-setup git-sh-i18n git-instaweb)\n+\n+foreach(script ${git_shell_scripts})\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/${script}.sh content NEWLINE_CONSUME)\n+\tstring(REPLACE \"@SHELL_PATH@\" \"${SHELL_PATH}\" content \"${content}\")\n+\tstring(REPLACE \"@@DIFF@@\" \"diff\" content \"${content}\")\n+\tstring(REPLACE \"@LOCALEDIR@\" \"${LOCALEDIR}\" content \"${content}\")\n+\tstring(REPLACE \"@GITWEBDIR@\" \"${GITWEBDIR}\" content \"${content}\")\n+\tstring(REPLACE \"@@NO_CURL@@\" \"\" content \"${content}\")\n+\tstring(REPLACE \"@@USE_GETTEXT_SCHEME@@\" \"\" content \"${content}\")\n+\tstring(REPLACE \"# @@BROKEN_PATH_FIX@@\" \"\" content \"${content}\")\n+\tstring(REPLACE \"@@PERL@@\" \"${PERL_PATH}\" content \"${content}\")\n+\tstring(REPLACE \"@@SANE_TEXT_GREP@@\" \"-a\" content \"${content}\")\n+\tstring(REPLACE \"@@PAGER_ENV@@\" \"LESS=FRX LV=-c\" content \"${content}\")\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})\n+endforeach()\n+\n+#perl scripts\n+set(git_perl_scripts\n+\tgit-add--interactive git-archimport git-cvsexportcommit\n+\tgit-cvsimport git-cvsserver git-send-email git-svn)\n+\n+#create perl header\n+file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )\n+string(REPLACE \"@@PATHSEP@@\" \":\" perl_header \"${perl_header}\")\n+string(REPLACE \"@@INSTLIBDIR@@\" \"${INSTLIBDIR}\" perl_header \"${perl_header}\")\n+\n+foreach(script ${git_perl_scripts})\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/${script}.perl content NEWLINE_CONSUME)\n+\tstring(REPLACE \"#!/usr/bin/perl\" \"#!/usr/bin/perl\\n${perl_header}\\n\" content \"${content}\")\n+\tstring(REPLACE \"@@GIT_VERSION@@\" \"${PROJECT_VERSION}\" content \"${content}\")\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})\n+endforeach()\n+\n+#python script\n+file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)\n+string(REPLACE \"#!/usr/bin/env python\" \"#!/usr/bin/python\" content \"${content}\")\n+file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})\n+\n+#perl modules\n+file(GLOB_RECURSE perl_modules \"${CMAKE_SOURCE_DIR}/perl/*.pm\")\n+\n+foreach(pm ${perl_modules})\n+\tstring(REPLACE \"${CMAKE_SOURCE_DIR}/perl/\" \"\" file_path ${pm})\n+\tfile(STRINGS ${pm} content NEWLINE_CONSUME)\n+\tstring(REPLACE \"@@LOCALEDIR@@\" \"${LOCALEDIR}\" content \"${content}\")\n+\tstring(REPLACE \"@@NO_PERL_CPAN_FALLBACKS@@\" \"\" content \"${content}\")\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})\n+#test-lib.sh requires perl/build/lib to be the build directory of perl modules\n+endforeach()\n+\n+\n+#templates\n+file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches\n+set(hooks_templates\n+\tapplypatch-msg.sample pre-applypatch.sample pre-push.sample\n+\tcommit-msg.sample pre-commit.sample pre-rebase.sample\n+\tfsmonitor-watchman.sample pre-merge-commit.sample pre-receive.sample\n+\tpost-update.sample prepare-commit-msg.sample update.sample)\n+\n+#templates have @.*@ replacement so use configure_file instead\n+#hooks\n+foreach(tm ${hooks_templates})\n+\tconfigure_file(${CMAKE_SOURCE_DIR}/templates/hooks--${tm} ${CMAKE_BINARY_DIR}/templates/blt/hooks/${tm} @ONLY)\n+endforeach()\n+\n+#info\n+configure_file(${CMAKE_SOURCE_DIR}/templates/info--exclude ${CMAKE_BINARY_DIR}/templates/blt/info/exclude @ONLY)\n+\n+#this\n+configure_file(${CMAKE_SOURCE_DIR}/templates/this--description ${CMAKE_BINARY_DIR}/templates/blt/description @ONLY)\n+\n+\n+#translations\n+if(MSGFMT_EXE)\n+\tset(po_files bg  ca  de  el  es  fr  is  it  ko  pt_PT  ru  sv  tr  vi  zh_CN  zh_TW)\n+\tforeach(po ${po_files})\n+\t\tfile(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES)\n+\t\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo\n+\t\t\t\tCOMMAND ${MSGFMT_EXE} --check --statistics -o ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo ${CMAKE_SOURCE_DIR}/po/${po}.po)\n+\t\tlist(APPEND po_gen ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo)\n+\tendforeach()\n+\tadd_custom_target(po-gen ALL DEPENDS ${po_gen})\n+endif()\n-- \ngitgitgadget\n\n"},{"id":"396095","messageId":"10390063a398feab86519ba4e4fd9d03f38cd0fd.1587700897.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.git.1587700897.gitgitgadget@gmail.com","subject":"[PATCH 3/8] cmake: installation support for git","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-04-24T04:01:32Z","receivedAt":"2020-04-24T04:01:46Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThis patch provides the facility to install the built binaries and\nscripts.\n\nThis is very similar to `make install`.\nBy default the destination directory(DESTDIR) is /usr/local/ on Linux\nTo set a custom installation path do this:\ncmake `relative-path-to-srcdir`\n\t-DCMAKE_INSTALL_PREFIX=`preferred-install-path`\n\nThen run `make install`\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n CMakeLists.txt | 49 +++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 49 insertions(+)\n\ndiff --git a/CMakeLists.txt b/CMakeLists.txt\nindex 788b53be873..25de5b5bc35 100644\n--- a/CMakeLists.txt\n+++ b/CMakeLists.txt\n@@ -13,6 +13,8 @@ project(git\n \tVERSION ${git_version}\n \tLANGUAGES C)\n \n+#TODO gitk git-gui gitweb\n+#TODO Add pcre support\n \n include(CheckTypeSize)\n include(CheckCSourceRuns)\n@@ -631,3 +633,50 @@ if(MSGFMT_EXE)\n \tendforeach()\n \tadd_custom_target(po-gen ALL DEPENDS ${po_gen})\n endif()\n+\n+\n+#to help with the install\n+list(TRANSFORM git_shell_scripts PREPEND \"${CMAKE_BINARY_DIR}/\")\n+list(TRANSFORM git_perl_scripts PREPEND \"${CMAKE_BINARY_DIR}/\")\n+\n+#install\n+install(TARGETS git git-shell\n+\tRUNTIME DESTINATION bin)\n+install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver  #${CMAKE_SOURCE_DIR}/gitk-git/gitk check\n+\tDESTINATION bin)\n+\n+list(REMOVE_ITEM PROGRAMS_BUILT git git-shell)\n+install(TARGETS ${PROGRAMS_BUILT}\n+\tRUNTIME DESTINATION libexec/git-core)\n+\n+set(bin_links\n+\tgit-receive-pack git-upload-archive git-upload-pack)\n+\n+foreach(b ${bin_links})\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})\")\n+endforeach()\n+\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)\")\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)\")\n+\n+foreach(b ${git_links})\n+\tstring(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n+\tinstall(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n+endforeach()\n+\n+foreach(b ${git_http_links})\n+\tstring(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n+\tinstall(CODE \"file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n+endforeach()\n+\n+install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4\n+\tDESTINATION libexec/git-core)\n+\n+install(DIRECTORY mergetools DESTINATION libexec/git-core)\n+install(DIRECTORY ${CMAKE_BINARY_DIR}/perl/build/lib/ DESTINATION share/perl5\n+\tFILES_MATCHING PATTERN \"*.pm\")\n+install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/templates)\n+\n+if(MSGFMT_EXE)\n+\tinstall(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)\n+endif()\n-- \ngitgitgadget\n\n"},{"id":"396098","messageId":"70ab1f03dd5413256166bf9db47be47b746ea6b1.1587700897.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.git.1587700897.gitgitgadget@gmail.com","subject":"[PATCH 1/8] Introduce CMake support for configuring Git on Linux","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-04-24T04:01:30Z","receivedAt":"2020-04-24T04:01:46Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nAt the moment, the recommended way to configure Git's builds is to\nsimply run `make`. If that does not work, the recommended strategy is to\nlook at the top of the `Makefile` to see whether any \"Makefile knob\" has\nto be turned on/off, e.g. `make NO_OPENSSL=YesPlease`.\n\nAlternatively, Git also has an `autoconf` setup which allows configuring\nbuilds via `./configure [<option>...]`.\n\nBoth of these options are fine if the developer works on Unix or Linux.\nBut on Windows, we have to jump through hoops to configure a build\n(read: we force the user to install a full Git for Windows SDK, which\noccupies around two gigabytes (!) on disk and downloads about three\nquarters of a gigabyte worth of Git objects).\n\nTo make this a little less awkward, the Git for Windows project offers\nthe `vs/master` branch which has a full Visual Studio solution generated\nand committed. This branch can therefore be used to tinker with Git in\nVisual Studio _without_ having to download the full Git for Windows SDK.\nUnfortunatly, that branch is auto-generated from Git for Windows'\n`master`. If a developer wants to tinker, say, with `pu`, they are out\nof luck.\n\nCMake was invented to make this sort of problem go away, by providing a\nmore standardized, cross-platform way to configure builds.\n\nWith a working support CMake, developers on Windows need only install\nCMake, configure their build, load the generated Visual Studio solution\nand immediately start modifying the code and build their own version of\nGit. Likewise, developers on other platforms can use the convenient GUI\ntools provided by CMake to configure their build.\n\nSo let's start building CMake support for Git.\n\nThis is only the first step, and to make it easier to review, it only\nallows for configuring builds on the platform that is easiest to\nconfigure for: Linux.\n\nThe CMake script checks whether the headers are present(eg. libgen.h),\nwhether the functions are present(eg. memmem), whether the funtions work\nproperly (eg. snprintf) and generate the required compile definitions\nfor the platform. The script also searches for the required libraries,\nif it fails to find the required libraries the respective executables\nwon't be built.(eg. If libcurl is not found then git-remote-http won't\nbe built). This will help building Git easier.\n\nWith a CMake script an out of source build of git is possible resulting\nin a clean source tree.\n\nNote: earlier endeavors on the Git mailing list to introduce CMake ended\nup in dead water. The primary reason for that was that reviewers\n_expected_ CMake support to fall out of maintenance, unless the\ncontributor would promise to keep an eye on keeping CMake support up to\ndate. However, in the meantime, support for automated testing has been\nintroduced in Git's source code, and a later patch will modify the\n(still experimental) GitHub workflow to continually verify that CMake\nsupport is still complete. That will make maintenance reasonably easy.\n\nNote: this patch asks for the minimum version v3.14 of CMake (which is\nnot all that old as of time of writing) because that is the first\nversion to offer a platform-independent way to generate hardlinks as\npart of the build. This is needed to generate all those hardlinks for\nthe built-in commands of Git.\n\nInstructions to run CMake:\n\ncmake `relative-path-to-srcdir` -DCMAKE_BUILD_TYPE=Release\n\nPossible build configurations(-DCMAKE_BUILD_TYPE) with corresponding\ncompiler flags\nDebug : -g\nRelease: -O3\nRelWithDebInfo : -O2 -g\nMinSizeRel : -Os\nempty(default) :\n\nNOTE: -DCMAKE_BUILD_TYPE is optional\n\nThis process generates a Makefile.\nThen run `make` to build Git.\n\nNOTE: By default CMake uses Makefile as the build tool on Linux, to use\nanother tool say `ninja` add this to the command line when configuring.\n`-G Ninja`\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n CMakeLists.txt | 528 +++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 528 insertions(+)\n create mode 100644 CMakeLists.txt\n\ndiff --git a/CMakeLists.txt b/CMakeLists.txt\nnew file mode 100644\nindex 00000000000..73703bd321f\n--- /dev/null\n+++ b/CMakeLists.txt\n@@ -0,0 +1,528 @@\n+#\n+#\tCopyright (c) 2020 Sibi Siddharthan\n+#\n+\n+cmake_minimum_required(VERSION 3.14)\n+\n+#Parse GIT-VERSION-GEN to get the version\n+file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX \"DEF_VER=v(.*)\")\n+string(REPLACE \"DEF_VER=v\" \"\" git_version ${git_version})\n+string(REPLACE \".GIT\" \".0\" git_version ${git_version})#for building from a snapshot\n+\n+project(git\n+\tVERSION ${git_version}\n+\tLANGUAGES C)\n+\n+\n+include(CheckTypeSize)\n+include(CheckCSourceRuns)\n+include(CheckCSourceCompiles)\n+include(CheckIncludeFile)\n+include(CheckFunctionExists)\n+include(CheckSymbolExists)\n+include(CheckStructHasMember)\n+\n+find_package(ZLIB REQUIRED)\n+find_package(CURL)\n+find_package(EXPAT)\n+find_package(Iconv)\n+find_package(Intl)\n+\n+if(NOT Intl_FOUND)\n+\tadd_compile_definitions(NO_GETTEXT)\n+\tif(NOT Iconv_FOUND)\n+\t\tadd_compile_definitions(NO_ICONV)\n+\tendif()\n+endif()\n+\n+include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})\n+if(CURL_FOUND)\n+\tinclude_directories(SYSTEM ${CURL_INCLUDE_DIRS})\n+endif()\n+if(EXPAT_FOUND)\n+\tinclude_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})\n+endif()\n+if(Iconv_FOUND)\n+\tinclude_directories(SYSTEM ${Iconv_INCLUDE_DIRS})\n+endif()\n+if(Intl_FOUND)\n+\tinclude_directories(SYSTEM ${Intl_INCLUDE_DIRS})\n+endif()\n+\n+find_program(SH_EXE sh)\n+\n+#default behaviour\n+include_directories(${CMAKE_SOURCE_DIR})\n+add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n+add_compile_definitions(SHA256_BLK INTERNAL_QSORT RUNTIME_PREFIX)\n+add_compile_definitions(NO_OPENSSL SHA1_DC SHA1DC_NO_STANDARD_INCLUDES\n+\t\t\tSHA1DC_INIT_SAFE_HASH_DEFAULT=0\n+\t\t\tSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"cache.h\"\n+\t\t\tSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"git-compat-util.h\" )\n+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)\n+\n+\n+add_compile_definitions(PAGER_ENV=\"LESS=FRX LV=-c\"\n+\t\t\tETC_GITATTRIBUTES=\"etc/gitattributes\"\n+\t\t\tETC_GITCONFIG=\"etc/gitconfig\"\n+\t\t\tGIT_EXEC_PATH=\"libexec/git-core\"\n+\t\t\tGIT_LOCALE_PATH=\"share/locale\"\n+\t\t\tGIT_MAN_PATH=\"share/man\"\n+\t\t\tGIT_INFO_PATH=\"share/info\"\n+\t\t\tGIT_HTML_PATH=\"share/doc/git-doc\"\n+\t\t\tDEFAULT_HELP_FORMAT=\"html\"\n+\t\t\tDEFAULT_GIT_TEMPLATE_DIR=\"share/git-core/templates\"\n+\t\t\tGIT_VERSION=\"${PROJECT_VERSION}.GIT\"\n+\t\t\tGIT_USER_AGENT=\"git/${PROJECT_VERSION}.GIT\"\n+\t\t\tBINDIR=\"bin\"\n+\t\t\tGIT_BUILT_FROM_COMMIT=\"\")\n+\n+set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n+add_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n+\n+add_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n+list(APPEND compat_SOURCES unix-socket.c)\n+\n+#header checks\n+check_include_file(libgen.h HAVE_LIBGEN_H)\n+if(NOT HAVE_LIBGEN_H)\n+\tadd_compile_definitions(NO_LIBGEN_H)\n+\tlist(APPEND compat_SOURCES compat/basename.c)\n+endif()\n+\n+check_include_file(sys/sysinfo.h HAVE_SYSINFO)\n+if(HAVE_SYSINFO)\n+\tadd_compile_definitions(HAVE_SYSINFO)\n+endif()\n+\n+check_c_source_compiles(\"\n+#include <alloca.h>\n+int\n+main ()\n+{\n+char *p = (char *) alloca (2 * sizeof (int));\n+\tif (p) return 0;\n+\treturn 0;\n+}\"\n+HAVE_ALLOCA_H)\n+if(HAVE_ALLOCA_H)\n+\tadd_compile_definitions(HAVE_ALLOCA_H)\n+endif()\n+\n+check_include_file(strings.h HAVE_STRINGS_H)\n+if(HAVE_STRINGS_H)\n+\tadd_compile_definitions(HAVE_STRINGS_H)\n+endif()\n+\n+check_include_file(sys/select.h HAVE_SYS_SELECT_H)\n+if(NOT HAVE_SYS_SELECT_H)\n+\tadd_compile_definitions(NO_SYS_SELECT_H)\n+endif()\n+\n+check_include_file(sys/poll.h HAVE_SYS_POLL_H)\n+if(NOT HAVE_SYS_POLL_H)\n+\tadd_compile_definitions(NO_SYS_POLL_H)\n+endif()\n+\n+check_include_file(poll.h HAVE_POLL_H)\n+if(NOT HAVE_POLL_H)\n+\tadd_compile_definitions(NO_POLL_H)\n+endif()\n+\n+check_include_file(inttypes.h HAVE_INTTYPES_H)\n+if(NOT HAVE_INTTYPES_H)\n+\tadd_compile_definitions(NO_INTTYPES_H)\n+endif()\n+\n+check_include_file(paths.h HAVE_PATHS_H)\n+if(HAVE_PATHS_H)\n+\tadd_compile_definitions(HAVE_PATHS_H)\n+endif()\n+\n+#function checks\n+set(function_checks\n+\tstrcasestr memmem strlcpy strtoimax strtoumax strtoull\n+\tsetenv  mkdtemp poll pread  memmem unsetenv hstrerror)\n+\n+foreach(f ${function_checks})\n+\tstring(TOUPPER ${f} uf)\n+\tcheck_function_exists(${f} HAVE_${uf})\n+\tif(NOT HAVE_${uf})\n+\t\tadd_compile_definitions(NO_${uf})\n+\tendif()\n+endforeach()\n+\n+if(NOT HAVE_POLL_H OR NOT HAVE_SYS_POLL_H OR NOT HAVE_POLL)\n+\tinclude_directories(compat/poll)\n+\tadd_compile_definitions(NO_POLL)\n+\tlist(APPEND compat_SOURCES compat/poll/poll.c)\n+endif()\n+\n+if(NOT HAVE_STRCASESTR)\n+\tlist(APPEND compat_SOURCES compat/strcasestr.c)\n+endif()\n+\n+if(NOT HAVE_STRLCPY)\n+\tlist(APPEND compat_SOURCES compat/strlcpy.c)\n+endif()\n+\n+if(NOT HAVE_STRTOUMAX)\n+\tlist(APPEND compat_SOURCES compat/strtoumax.c compat/strtoimax.c)\n+endif()\n+\n+if(NOT HAVE_SETENV)\n+\tlist(APPEND compat_SOURCES compat/setenv.c)\n+endif()\n+\n+if(NOT HAVE_MKDTEMP)\n+\tlist(APPEND compat_SOURCES compat/mkdtemp.c)\n+endif()\n+\n+if(NOT HAVE_PREAD)\n+\tlist(APPEND compat_SOURCES compat/pread.c)\n+endif()\n+\n+if(NOT HAVE_MEMMEM)\n+\tlist(APPEND compat_SOURCES compat/memmem.c)\n+endif()\n+\n+if(NOT WIN32)\n+\tif(NOT HAVE_UNSETENV)\n+\t\tlist(APPEND compat_SOURCES compat/unsetenv.c)\n+\tendif()\n+\n+\tif(NOT HAVE_HSTRERROR)\n+\t\tlist(APPEND compat_SOURCES compat/hstrerror.c)\n+\tendif()\n+endif()\n+\n+check_function_exists(getdelim HAVE_GETDELIM)\n+if(HAVE_GETDELIM)\n+\tadd_compile_definitions(HAVE_GETDELIM)\n+endif()\n+\n+check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)\n+check_symbol_exists(CLOCK_MONOTONIC \"time.h\" HAVE_CLOCK_MONOTONIC)\n+if(HAVE_CLOCK_GETTIME)\n+\tadd_compile_definitions(HAVE_CLOCK_GETTIME)\n+endif()\n+if(HAVE_CLOCK_MONOTONIC)\n+\tadd_compile_definitions(HAVE_CLOCK_MONOTONIC)\n+endif()\n+\n+\n+#compile checks\n+check_c_source_runs(\"\n+#include<stdio.h>\n+#include<stdarg.h>\n+#include<string.h>\n+#include<stdlib.h>\n+int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)\n+{\n+\tint ret;\n+\tva_list ap;\n+\n+\tva_start(ap, format);\n+\tret = vsnprintf(str, maxsize, format, ap);\n+\tva_end(ap);\n+\treturn ret;\n+}\n+\n+int\n+main ()\n+{\n+\tchar buf[6];\n+\tif (test_vsnprintf(buf, 3, \\\"%s\\\", \\\"12345\\\") != 5\n+\t\t|| strcmp(buf, \\\"12\\\")) return 1;\n+\tif (snprintf(buf, 3, \\\"%s\\\", \\\"12345\\\") != 5\n+\t\t|| strcmp(buf, \\\"12\\\")) return 1;\n+\n+\treturn 0;\n+}\"\n+SNPRINTF_OK)\n+if(NOT SNPRINTF_OK)\n+\tadd_compile_definitions(SNPRINTF_RETURNS_BOGUS)\n+\tlist(APPEND compat_SOURCES compat/snprintf.c)\n+endif()\n+\n+check_c_source_runs(\"\n+#include<stdio.h>\n+int\n+main ()\n+{\n+\tFILE *f = fopen(\\\".\\\", \\\"r\\\");\n+\treturn f != NULL;\n+\n+\treturn 0;\n+}\"\n+FREAD_READS_DIRECTORIES_NO)\n+if(NOT FREAD_READS_DIRECTORIES_NO)\n+\tadd_compile_definitions(FREAD_READS_DIRECTORIES)\n+\tlist(APPEND compat_SOURCES compat/fopen.c)\n+endif()\n+\n+check_c_source_compiles(\"\n+#include <regex.h>\n+#ifndef REG_STARTEND\n+#error oops we dont have it\n+#endif\n+int main(){return 0;}\"\n+HAVE_REGEX)\n+if(NOT HAVE_REGEX)\n+\tinclude_directories(compat/regex )\n+\tlist(APPEND compat_SOURCES compat/regex/regex.c )\n+\tadd_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)\n+endif()\n+\n+\n+check_c_source_compiles(\"\n+#include <stddef.h>\n+#include <sys/types.h>\n+#include <sys/sysctl.h>\n+\n+int\n+main ()\n+{\n+\tint val, mib[2];\n+\tsize_t len;\n+\n+\tmib[0] = CTL_HW;\n+\tmib[1] = 1;\n+\tlen = sizeof(val);\n+\treturn sysctl(mib, 2, &val, &len, NULL, 0) ? 1 : 0;\n+\n+\treturn 0;\n+}\"\n+HAVE_BSD_SYSCTL)\n+if(HAVE_BSD_SYSCTL)\n+\tadd_compile_definitions(HAVE_BSD_SYSCTL)\n+endif()\n+\n+#programs\n+set(PROGRAMS_BUILT\n+\tgit git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst\n+\tgit-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)\n+\n+if(NOT CURL_FOUND)\n+\tlist(APPEND excluded_progs git-http-fetch git-http-push)\n+\tadd_compile_definitions(NO_CURL)\n+\tmessage(WARNING \"git-http-push and git-http-fetch will not be built\")\n+else()\n+\tlist(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)\n+\tif(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)\n+\t\tadd_compile_definitions(USE_CURL_FOR_IMAP_SEND)\n+\tendif()\n+endif()\n+\n+if(NOT EXPAT_FOUND)\n+\tlist(APPEND excluded_progs git-http-push)\n+\tadd_compile_definitions(NO_EXPAT)\n+else()\n+\tlist(APPEND PROGRAMS_BUILT git-http-push)\n+\tif(EXPAT_VERSION_STRING VERSION_LESS_EQUAL 1.2)\n+\t\tadd_compile_definitions(EXPAT_NEEDS_XMLPARSE_H)\n+\tendif()\n+endif()\n+\n+list(REMOVE_DUPLICATES excluded_progs)\n+list(REMOVE_DUPLICATES PROGRAMS_BUILT)\n+\n+\n+foreach(p ${excluded_progs})\n+\tlist(APPEND EXCLUSION_PROGS --exclude-program ${p} )\n+endforeach()\n+\n+#for comparing null values\n+list(APPEND EXCLUSION_PROGS empty)\n+set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING \"Programs not built\" FORCE)\n+\n+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)\n+\tlist(REMOVE_ITEM EXCLUSION_PROGS empty)\n+\tmessage(\"Generating command-list.h\")\n+\texecute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt\n+\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n+\t\t\tOUTPUT_FILE ${CMAKE_SOURCE_DIR}/command-list.h)\n+endif()\n+\n+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/config-list.h)\n+\tmessage(\"Generating config-list.h\")\n+\texecute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh\n+\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n+\t\t\tOUTPUT_FILE ${CMAKE_SOURCE_DIR}/config-list.h)\n+endif()\n+\n+\n+#build\n+set(libgit_SOURCES\n+\tabspath.c add-interactive.c add-patch.c advice.c alias.c\n+\talloc.c apply.c archive.c archive-tar.c archive-zip.c argv-array.c\n+\tattr.c base85.c bisect.c blame.c blob.c bloom.c branch.c bulk-checkin.c\n+\tbundle.c cache-tree.c chdir-notify.c checkout.c color.c column.c\n+\tcombine-diff.c commit.c commit-graph.c commit-reach.c compat/obstack.c\n+\tcompat/terminal.c config.c connect.c connected.c convert.c copy.c credential.c\n+\tcsum-file.c ctype.c date.c decorate.c delta-islands.c diffcore-break.c\n+\tdiffcore-delta.c diffcore-order.c diffcore-pickaxe.c diffcore-rename.c\n+\tdiff-delta.c diff-lib.c diff-no-index.c diff.c dir.c dir-iterator.c editor.c\n+\tentry.c environment.c ewah/bitmap.c ewah/ewah_bitmap.c ewah/ewah_io.c\n+\tewah/ewah_rlw.c exec-cmd.c fetch-negotiator.c fetch-pack.c fmt-merge-msg.c fsck.c fsmonitor.c\n+\tgettext.c gpg-interface.c graph.c grep.c hashmap.c linear-assignment.c help.c hex.c\n+\tident.c interdiff.c json-writer.c kwset.c levenshtein.c line-log.c line-range.c list-objects.c\n+\tlist-objects-filter.c list-objects-filter-options.c ll-merge.c lockfile.c\n+\tlog-tree.c ls-refs.c mailinfo.c mailmap.c match-trees.c mem-pool.c merge.c merge-blobs.c\n+\tmerge-recursive.c mergesort.c midx.c name-hash.c negotiator/default.c\n+\tnegotiator/skipping.c notes.c notes-cache.c notes-merge.c notes-utils.c object.c oidmap.c\n+\toidset.c oid-array.c packfile.c pack-bitmap.c pack-bitmap-write.c pack-check.c pack-objects.c\n+\tpack-revindex.c pack-write.c pager.c parse-options.c parse-options-cb.c patch-delta.c\n+\tpatch-ids.c path.c pathspec.c pkt-line.c preload-index.c pretty.c prio-queue.c progress.c\n+\tpromisor-remote.c prompt.c protocol.c prune-packed.c quote.c range-diff.c reachable.c read-cache.c rebase.c\n+\trebase-interactive.c reflog-walk.c refs.c refs/files-backend.c refs/iterator.c\n+\trefs/packed-backend.c refs/ref-cache.c refspec.c ref-filter.c remote.c replace-object.c\n+\trepo-settings.c repository.c rerere.c reset.c resolve-undo.c revision.c run-command.c\n+\tsend-pack.c sequencer.c serve.c server-info.c setup.c sha1-lookup.c\n+\tsha1-file.c sha1-name.c shallow.c sideband.c sigchain.c split-index.c\n+\tstable-qsort.c strbuf.c streaming.c string-list.c submodule.c submodule-config.c\n+\tsub-process.c symlinks.c tag.c tempfile.c thread-utils.c tmp-objdir.c\n+\ttrace.c trace2.c trace2/tr2_cfg.c trace2/tr2_cmd_name.c trace2/tr2_dst.c\n+\ttrace2/tr2_sid.c trace2/tr2_sysenv.c trace2/tr2_tbuf.c trace2/tr2_tgt_event.c\n+\ttrace2/tr2_tgt_normal.c trace2/tr2_tgt_perf.c trace2/tr2_tls.c trailer.c transport.c\n+\ttransport-helper.c tree-diff.c tree.c tree-walk.c unpack-trees.c upload-pack.c url.c\n+\turlmatch.c usage.c userdiff.c utf8.c varint.c version.c versioncmp.c walker.c wildmatch.c\n+\tworktree.c wrapper.c write-or-die.c ws.c wt-status.c xdiff-interface.c\n+\tzlib.c)\n+\n+add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})\n+\n+set(libxdiff_SOURCES\n+\txdiff/xdiffi.c xdiff/xprepare.c xdiff/xutils.c xdiff/xemit.c\n+\txdiff/xmerge.c xdiff/xpatience.c xdiff/xhistogram.c)\n+add_library(xdiff STATIC ${libxdiff_SOURCES})\n+\n+set(libvcs-svn_SOURCES\n+\tvcs-svn/line_buffer.c vcs-svn/sliding_window.c vcs-svn/fast_export.c\n+\tvcs-svn/svndiff.c vcs-svn/svndump.c)\n+add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})\n+\n+#link all required libraries to common-main\n+add_library(common-main OBJECT common-main.c)\n+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)\n+if(Intl_FOUND)\n+\ttarget_link_libraries(common-main ${Intl_LIBRARIES})\n+endif()\n+if(Iconv_FOUND)\n+\ttarget_link_libraries(common-main ${Iconv_LIBRARIES})\n+endif()\n+\n+\n+set(git_SOURCES\n+\tbuiltin/add.c builtin/am.c builtin/annotate.c builtin/apply.c\n+\tbuiltin/archive.c builtin/bisect--helper.c builtin/blame.c\n+\tbuiltin/branch.c builtin/bundle.c builtin/cat-file.c builtin/check-attr.c\n+\tbuiltin/check-ignore.c builtin/check-mailmap.c builtin/check-ref-format.c\n+\tbuiltin/checkout-index.c builtin/checkout.c builtin/clean.c\n+\tbuiltin/clone.c builtin/column.c builtin/commit-tree.c\n+\tbuiltin/commit.c builtin/commit-graph.c builtin/config.c\n+\tbuiltin/count-objects.c builtin/credential.c builtin/describe.c\n+\tbuiltin/diff-files.c builtin/diff-index.c builtin/diff-tree.c\n+\tbuiltin/diff.c builtin/difftool.c builtin/env--helper.c\n+\tbuiltin/fast-export.c builtin/fetch-pack.c builtin/fetch.c builtin/fmt-merge-msg.c\n+\tbuiltin/for-each-ref.c builtin/fsck.c builtin/gc.c\n+\tbuiltin/get-tar-commit-id.c builtin/grep.c builtin/hash-object.c\n+\tbuiltin/help.c builtin/index-pack.c builtin/init-db.c\n+\tbuiltin/interpret-trailers.c builtin/log.c builtin/ls-files.c\n+\tbuiltin/ls-remote.c builtin/ls-tree.c builtin/mailinfo.c builtin/mailsplit.c\n+\tbuiltin/merge.c builtin/merge-base.c builtin/merge-file.c builtin/merge-index.c\n+\tbuiltin/merge-ours.c builtin/merge-recursive.c builtin/merge-tree.c\n+\tbuiltin/mktag.c builtin/mktree.c builtin/multi-pack-index.c builtin/mv.c\n+\tbuiltin/name-rev.c builtin/notes.c builtin/pack-objects.c builtin/pack-redundant.c\n+\tbuiltin/pack-refs.c builtin/patch-id.c builtin/prune-packed.c builtin/prune.c\n+\tbuiltin/pull.c builtin/push.c builtin/range-diff.c builtin/read-tree.c\n+\tbuiltin/rebase.c builtin/receive-pack.c builtin/reflog.c builtin/remote.c\n+\tbuiltin/remote-ext.c builtin/remote-fd.c builtin/repack.c builtin/replace.c\n+\tbuiltin/rerere.c builtin/reset.c builtin/rev-list.c builtin/rev-parse.c\n+\tbuiltin/revert.c builtin/rm.c builtin/send-pack.c builtin/shortlog.c\n+\tbuiltin/show-branch.c builtin/show-index.c builtin/show-ref.c\n+\tbuiltin/sparse-checkout.c builtin/stash.c builtin/stripspace.c\n+\tbuiltin/submodule--helper.c builtin/symbolic-ref.c builtin/tag.c\n+\tbuiltin/unpack-file.c builtin/unpack-objects.c builtin/update-index.c\n+\tbuiltin/update-ref.c builtin/update-server-info.c builtin/upload-archive.c\n+\tbuiltin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c\n+\tbuiltin/verify-tag.c builtin/worktree.c builtin/write-tree.c)\n+\n+add_executable(git git.c ${git_SOURCES})\n+target_link_libraries(git common-main )\n+\n+add_executable(git-bugreport bugreport.c)\n+target_link_libraries(git-bugreport common-main)\n+\n+add_executable(git-credential-store credential-store.c)\n+target_link_libraries(git-credential-store common-main)\n+\n+add_executable(git-daemon daemon.c)\n+target_link_libraries(git-daemon common-main)\n+\n+add_executable(git-fast-import fast-import.c)\n+target_link_libraries(git-fast-import common-main)\n+\n+add_executable(git-http-backend http-backend.c)\n+target_link_libraries(git-http-backend common-main)\n+\n+add_executable(git-sh-i18n--envsubst sh-i18n--envsubst.c)\n+target_link_libraries(git-sh-i18n--envsubst common-main)\n+\n+add_executable(git-shell shell.c)\n+target_link_libraries(git-shell common-main)\n+\n+if(CURL_FOUND)\n+\tadd_library(http_obj OBJECT http.c)\n+\n+\tadd_executable(git-imap-send imap-send.c)\n+\ttarget_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})\n+\n+\tadd_executable(git-http-fetch http-walker.c http-fetch.c)\n+\ttarget_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})\n+\n+\tadd_executable(git-remote-http http-walker.c remote-curl.c)\n+\ttarget_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )\n+\n+\tif(EXPAT_FOUND)\n+\t\tadd_executable(git-http-push http-push.c)\n+\t\ttarget_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})\n+\tendif()\n+endif()\n+\n+add_executable(git-remote-testsvn remote-testsvn.c)\n+target_link_libraries(git-remote-testsvn common-main vcs-svn)\n+\n+add_executable(git-credential-cache credential-cache.c)\n+target_link_libraries(git-credential-cache common-main)\n+\n+add_executable(git-credential-cache--daemon credential-cache--daemon.c)\n+target_link_libraries(git-credential-cache--daemon common-main)\n+\n+\n+set(git_builtin_extra\n+\tcherry cherry-pick format-patch fsck-objects\n+\tinit merge-subtree restore show\n+\tstage status switch whatchanged)\n+\n+#Creating hardlinks\n+foreach(s ${git_SOURCES} ${git_builtin_extra})\n+\tstring(REPLACE \"builtin/\" \"\" s ${s})\n+\tstring(REPLACE \".c\" \"\" s ${s})\n+\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git git-${s})\\n\")\n+\tlist(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})\n+endforeach()\n+\n+if(CURL_FOUND)\n+\tset(remote_exes\n+\t\tgit-remote-https git-remote-ftp git-remote-ftps)\n+\tforeach(s ${remote_exes})\n+\t\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git-remote-http ${s})\\n\")\n+\t\tlist(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})\n+\tendforeach()\n+endif()\n+\n+add_custom_command(OUTPUT ${git_links} ${git_http_links}\n+\t\tCOMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake\n+\t\tDEPENDS git git-remote-http)\n+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})\n\\ No newline at end of file\n-- \ngitgitgadget\n\n"},{"id":"396096","messageId":"166b78f71755bb3f9967b32bfe282210c2bb240d.1587700897.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.git.1587700897.gitgitgadget@gmail.com","subject":"[PATCH 5/8] cmake: support for testing git when building out of the source tree","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-04-24T04:01:34Z","receivedAt":"2020-04-24T04:01:48Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThis patch allows git to be tested when performin out of source builds.\n\nThis involves changing GIT_BUILD_DIR in t/test-lib.sh to point to the\nbuild directory. Also some miscellaneous copies from the source directory\nto the build directory.\nThe copies are:\nt/chainlint.sed needed by a bunch of test scripts\npo/is.po needed by t0204-gettext-rencode-sanity\nmergetools/tkdiff needed by t7800-difftool\ncontrib/completion/git-prompt.sh needed by t9903-bash-prompt\ncontrib/completion/git-completion.bash needed by t9902-completion\ncontrib/svn-fe/svnrdump_sim.py needed by t9020-remote-svn\n\nNOTE: t/test-lib.sh is only modified when tests are run not during\nthe build or configure.\nThe trash directory is still srcdir/t\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n CMakeLists.txt | 19 +++++++++++++++++++\n 1 file changed, 19 insertions(+)\n\ndiff --git a/CMakeLists.txt b/CMakeLists.txt\nindex 141ccefa559..29a23eb11f7 100644\n--- a/CMakeLists.txt\n+++ b/CMakeLists.txt\n@@ -812,6 +812,25 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_GETTEXT='${NO_GETTEXT}'\\n\"\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"RUNTIME_PREFIX='${RUNTIME_PREFIX}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PYTHON='${NO_PYTHON}'\\n\")\n \n+#Make the tests work when building out of the source tree\n+if(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})\n+\tfile(RELATIVE_PATH BUILD_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/CMakeCache.txt)\n+\tstring(REPLACE \"/CMakeCache.txt\" \"\" BUILD_DIR_RELATIVE ${BUILD_DIR_RELATIVE})\n+\t#Setting the build directory in test-lib.sh before running tests\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.cmake\n+\t\t\"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh GIT_BUILD_DIR_REPL REGEX \\\"GIT_BUILD_DIR=(.*)\\\")\\n\"\n+\t\t\"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh content NEWLINE_CONSUME)\\n\"\n+\t\t\"string(REPLACE \\\"\\${GIT_BUILD_DIR_REPL}\\\" \\\"GIT_BUILD_DIR=\\\\\\\"$TEST_DIRECTORY\\\\\\\"/../${BUILD_DIR_RELATIVE}\\\" content \\\"\\${content}\\\")\\n\"\n+\t\t\"file(WRITE ${CMAKE_SOURCE_DIR}/t/test-lib.sh \\${content})\")\n+\t#misc copies\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.sed DESTINATION ${CMAKE_BINARY_DIR}/t/)\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/po/is.po DESTINATION ${CMAKE_BINARY_DIR}/po/)\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/mergetools/tkdiff DESTINATION ${CMAKE_BINARY_DIR}/mergetools/)\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-prompt.sh DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-completion.bash DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/contrib/svn-fe/svnrdump_sim.py DESTINATION ${CMAKE_BINARY_DIR}/contrib/svn-fe/)\n+endif()\n+\n file(GLOB test_scipts \"${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh\")\n \n #test\n-- \ngitgitgadget\n\n"},{"id":"396099","messageId":"0577d7bf0a84f94396bd956bd7f6bbc711d3bf26.1587700897.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.git.1587700897.gitgitgadget@gmail.com","subject":"[PATCH 7/8] cmake: support for building git on windows with msvc and clang.","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-04-24T04:01:36Z","receivedAt":"2020-04-24T04:01:48Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThis patch adds support for Visual Studio and Clang builds\n\nThe minimum required version of CMake is upgraded to 3.15 because\nthis version offers proper support for Clang builds on Windows.\n\nLibintl is not searched for when building with Visual Studio or Clang\nbecause there is no binary compatible version available yet.\n\nNOTE: In the link options invalidcontinue.obj has to be included.\nThe reason for this is because by default, Windows calls abort()'s\ninstead of setting errno=EINVAL when invalid arguments are passed to\nstandard functions.\nThis commit explains it in detail:\n4b623d80f73528a632576990ca51e34c333d5dd6\n\nOn Windows the default generator is Visual Studio,so for Visual Studio\nbuilds do this:\n\ncmake `relative-path-to-srcdir`\n\nNOTE: Visual Studio generator is a multi config generator, which means\nthat Debug and Release builds can be done on the same build directory.\n\nFor Clang builds do this:\n\nOn bash\nCC=Clang cmake `relative-path-to-srcdir` -G Ninja\n\t\t-DCMAKE_BUILD_TYPE=[Debug or Release]\n\nOn cmd\nset CC=Clang\ncmake `relative-path-to-srcdir` -G Ninja\n\t\t-DCMAKE_BUILD_TYPE=[Debug or Release]\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n CMakeLists.txt | 57 ++++++++++++++++++++++++++++++++++++++++----------\n 1 file changed, 46 insertions(+), 11 deletions(-)\n\ndiff --git a/CMakeLists.txt b/CMakeLists.txt\nindex d9eb1060390..5ad3a2557f7 100644\n--- a/CMakeLists.txt\n+++ b/CMakeLists.txt\n@@ -2,7 +2,7 @@\n #\tCopyright (c) 2020 Sibi Siddharthan\n #\n \n-cmake_minimum_required(VERSION 3.14)\n+cmake_minimum_required(VERSION 3.15)\n \n #Parse GIT-VERSION-GEN to get the version\n file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX \"DEF_VER=v(.*)\")\n@@ -32,8 +32,11 @@ find_package(ZLIB REQUIRED)\n find_package(CURL)\n find_package(EXPAT)\n find_package(Iconv)\n-find_package(Intl)\n \n+#Don't use libintl on Windows Visual Studio and Clang builds\n+if(NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL \"MSVC\" OR CMAKE_C_COMPILER_ID STREQUAL \"Clang\")))\n+\tfind_package(Intl)\n+endif()\n \n if(NOT Intl_FOUND)\n \tadd_compile_definitions(NO_GETTEXT)\n@@ -61,7 +64,7 @@ if(NOT SH_EXE)\n \tmessage(FATAL_ERROR \"sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/\")\n endif()\n \n-if(WIN32)\n+if(WIN32 AND NOT MSVC)#not required for visual studio builds\n \tfind_program(WINDRES_EXE windres)\n \tif(NOT WINDRES_EXE)\n \t\tmessage(FATAL_ERROR \"Install windres on Windows for resource files\")\n@@ -73,6 +76,13 @@ if(NOT MSGFMT_EXE)\n \tmessage(WARNING \"Text Translations won't be build\")\n endif()\n \n+#Force all visual studio outputs to CMAKE_BINARY_DIR\n+if(CMAKE_C_COMPILER_ID STREQUAL \"MSVC\")\n+\tset(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})\n+\tset(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})\n+\tadd_compile_options(/MP)\n+endif()\n+\n #default behaviour\n include_directories(${CMAKE_SOURCE_DIR})\n add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n@@ -110,6 +120,10 @@ endif()\n \n #Platform Specific\n if(${CMAKE_SYSTEM_NAME} STREQUAL \"Windows\")\n+\tif(CMAKE_C_COMPILER_ID STREQUAL \"MSVC\" OR CMAKE_C_COMPILER_ID STREQUAL \"Clang\")\n+\t\tinclude_directories(compat/vcbuild/include)\n+\t\tadd_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)\n+\tendif()\n \tinclude_directories(compat/win32)\n \tadd_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32\n \t\t\t\t_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=\".exe\"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT\n@@ -463,14 +477,22 @@ set(libvcs-svn_SOURCES\n \tvcs-svn/svndiff.c vcs-svn/svndump.c)\n add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})\n \n-#add git.rc for gcc\n if(WIN32)\n-\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n-\t\t\tCOMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}\n-\t\t\t\t-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION=\"\\\\\\\"${PROJECT_VERSION}.GIT\\\\\\\"\"\n-\t\t\t\t-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res\n-\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n-\t\t\tVERBATIM)\n+\tif(NOT MSVC)#use windres when compiling with gcc and clang\n+\t\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n+\t\t\t\tCOMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}\n+\t\t\t\t\t-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION=\"\\\\\\\"${PROJECT_VERSION}.GIT\\\\\\\"\"\n+\t\t\t\t\t-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res\n+\t\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n+\t\t\t\tVERBATIM)\n+\telse()#MSVC use rc\n+\t\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n+\t\t\t\tCOMMAND ${CMAKE_RC_COMPILER} /d MAJOR=${PROJECT_VERSION_MAJOR} /d MINOR=${PROJECT_VERSION_MINOR}\n+\t\t\t\t\t/d MICRO=${PROJECT_VERSION_PATCH} /d PATCHLEVEL=0 /d GIT_VERSION=\"${PROJECT_VERSION}.GIT\"\n+\t\t\t\t\t/fo ${CMAKE_BINARY_DIR}/git.res ${CMAKE_SOURCE_DIR}/git.rc\n+\t\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n+\t\t\t\tVERBATIM)\n+\tendif()\n \tadd_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)\n endif()\n \n@@ -487,7 +509,13 @@ endif()\n if(WIN32)\n \ttarget_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)\n \tadd_dependencies(common-main git-rc)\n-\ttarget_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)\n+\tif(CMAKE_C_COMPILER_ID STREQUAL \"GNU\")\n+\t\ttarget_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)\n+\telseif(CMAKE_C_COMPILER_ID STREQUAL \"Clang\")\n+\t\ttarget_link_options(common-main PUBLIC -municode -Wl,-nxcompat -Wl,-dynamicbase -Wl,-entry:wmainCRTStartup -Wl,invalidcontinue.obj)\n+\telseif(CMAKE_C_COMPILER_ID STREQUAL \"MSVC\")\n+\t\ttarget_link_options(common-main PUBLIC /IGNORE:4217 /IGNORE:4049 /NOLOGO /ENTRY:wmainCRTStartup /SUBSYSTEM:CONSOLE invalidcontinue.obj)\n+\tendif()\n elseif(UNIX)\n \ttarget_link_libraries(common-main pthread rt)\n endif()\n@@ -797,6 +825,13 @@ target_link_libraries(test-tool common-main)\n set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool\n \t\t\tPROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)\n \n+if(MSVC)\n+\tset_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool\n+\t\t\t\tPROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/t/helper)\n+\tset_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool\n+\t\t\t\tPROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/helper)\n+endif()\n+\n #wrapper scripts\n set(wrapper_scripts\n \tgit git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)\n-- \ngitgitgadget\n\n"},{"id":"396100","messageId":"35a3554df3e4be98f20837ecb08bf6a7a890aadb.1587700897.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.git.1587700897.gitgitgadget@gmail.com","subject":"[PATCH 4/8] cmake: support for testing git with ctest","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-04-24T04:01:33Z","receivedAt":"2020-04-24T04:01:50Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThis patch provides an alternate way to test git using ctest.\nCTest ships with CMake, so there is no additional dependency being\nintroduced.\n\nTo perform the tests with ctest do this after building:\nctest -j[number of jobs]\n\nNOTE: -j is optional, the default number of jobs is 1\n\nEach of the jobs does this:\ncd t/ && sh t[something].sh\n\nThe reason for using CTest is that it logs the output of the tests\nin a neat way, which can be helpful during diagnosis of failures.\n\nAfter the tests have run ctest generates three log files located in\n`build-directory`/Testing/Temporary/\n\nThese log files are:\n\nCTestCostData.txt:\nThis file contains the time taken to complete each test.\n\nLastTestsFailed.log:\nThis log file contains the names of the tests that have failed in the\nrun.\n\nLastTest.log:\nThis log file contains the log of all the tests that have run.\nA snippet of the file is given below.\n\n10/901 Testing: D:/my/git-master/t/t0009-prio-queue.sh\n10/901 Test: D:/my/git-master/t/t0009-prio-queue.sh\nCommand: \"sh.exe\" \"D:/my/git-master/t/t0009-prio-queue.sh\"\nDirectory: D:/my/git-master/t\n\"D:/my/git-master/t/t0009-prio-queue.sh\"\nOutput:\n----------------------------------------------------------\nok 1 - basic ordering\nok 2 - mixed put and get\nok 3 - notice empty queue\nok 4 - stack order\npassed all 4 test(s)\n1..4\n<end of output>\nTest time =   1.11 sec\n\nNOTE: Testing only works when building in source for now.\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n CMakeLists.txt | 142 +++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 142 insertions(+)\n\ndiff --git a/CMakeLists.txt b/CMakeLists.txt\nindex 25de5b5bc35..141ccefa559 100644\n--- a/CMakeLists.txt\n+++ b/CMakeLists.txt\n@@ -23,6 +23,7 @@ include(CheckIncludeFile)\n include(CheckFunctionExists)\n include(CheckSymbolExists)\n include(CheckStructHasMember)\n+include(CTest)\n \n find_package(ZLIB REQUIRED)\n find_package(CURL)\n@@ -680,3 +681,144 @@ install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/\n if(MSGFMT_EXE)\n \tinstall(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)\n endif()\n+\n+\n+if(BUILD_TESTING)\n+\n+#tests-helpers\n+add_executable(test-fake-ssh t/helper/test-fake-ssh.c)\n+target_link_libraries(test-fake-ssh common-main)\n+\n+add_executable(test-line-buffer t/helper/test-line-buffer.c)\n+target_link_libraries(test-line-buffer common-main vcs-svn)\n+\n+add_executable(test-svn-fe t/helper/test-svn-fe.c)\n+target_link_libraries(test-svn-fe common-main vcs-svn)\n+\n+set(test_helper_sources\n+\tt/helper/test-tool.c t/helper/test-advise.c t/helper/test-bloom.c t/helper/test-chmtime.c\n+\tt/helper/test-config.c t/helper/test-ctype.c t/helper/test-date.c t/helper/test-delta.c\n+\tt/helper/test-dir-iterator.c t/helper/test-drop-caches.c t/helper/test-dump-cache-tree.c\n+\tt/helper/test-dump-fsmonitor.c t/helper/test-dump-split-index.c\n+\tt/helper/test-dump-untracked-cache.c t/helper/test-example-decorate.c\n+\tt/helper/test-genrandom.c t/helper/test-genzeros.c t/helper/test-hash.c\n+\tt/helper/test-hashmap.c t/helper/test-hash-speed.c t/helper/test-index-version.c\n+\tt/helper/test-json-writer.c t/helper/test-lazy-init-name-hash.c\n+\tt/helper/test-match-trees.c t/helper/test-mergesort.c t/helper/test-mktemp.c\n+\tt/helper/test-oidmap.c t/helper/test-online-cpus.c t/helper/test-parse-options.c\n+\tt/helper/test-parse-pathspec-file.c t/helper/test-path-utils.c t/helper/test-pkt-line.c\n+\tt/helper/test-prio-queue.c t/helper/test-progress.c t/helper/test-reach.c\n+\tt/helper/test-read-cache.c t/helper/test-read-graph.c t/helper/test-read-midx.c\n+\tt/helper/test-ref-store.c t/helper/test-regex.c t/helper/test-repository.c\n+\tt/helper/test-revision-walking.c t/helper/test-run-command.c t/helper/test-scrap-cache-tree.c\n+\tt/helper/test-serve-v2.c t/helper/test-sha1.c t/helper/test-oid-array.c t/helper/test-sha256.c\n+\tt/helper/test-sigchain.c t/helper/test-strcmp-offset.c t/helper/test-string-list.c\n+\tt/helper/test-submodule-config.c t/helper/test-submodule-nested-repo-config.c t/helper/test-subprocess.c\n+\tt/helper/test-trace2.c t/helper/test-urlmatch-normalization.c t/helper/test-xml-encode.c\n+\tt/helper/test-wildmatch.c t/helper/test-windows-named-pipe.c t/helper/test-write-cache.c)\n+\n+add_executable(test-tool ${test_helper_sources})\n+target_link_libraries(test-tool common-main)\n+\n+set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool\n+\t\t\tPROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)\n+\n+#wrapper scripts\n+set(wrapper_scripts\n+\tgit git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)\n+\n+set(wrapper_test_scripts\n+\ttest-fake-ssh test-line-buffer test-svn-fe test-tool)\n+\n+\n+foreach(script ${wrapper_scripts})\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n+\tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n+\tstring(REPLACE \"@@PROG@@\" \"${script}\" content \"${content}\")\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n+endforeach()\n+\n+foreach(script ${wrapper_test_scripts})\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n+\tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n+\tstring(REPLACE \"@@PROG@@\" \"t/helper/${script}\" content \"${content}\")\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n+endforeach()\n+\n+file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n+string(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n+string(REPLACE \"@@PROG@@\" \"git-cvsserver\" content \"${content}\")\n+file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})\n+\n+#options for configuring test options\n+option(PERL_TESTS \"Perform tests that use perl\" ON)\n+option(PYTHON_TESTS \"Perform tests that use python\" ON)\n+\n+#GIT-BUILD-OPTIONS\n+set(TEST_SHELL_PATH ${SHELL_PATH})\n+set(DIFF diff)\n+set(PYTHON_PATH /usr/bin/python)\n+set(TAR tar)\n+set(NO_CURL )\n+set(NO_EXPAT )\n+set(USE_LIBPCRE1 )\n+set(USE_LIBPCRE2 )\n+set(NO_LIBPCRE1_JIT )\n+set(NO_PERL )\n+set(NO_PTHREADS )\n+set(NO_PYTHON )\n+set(PAGER_ENV \"LESS=FRX LV=-c\")\n+set(DC_SHA1 YesPlease)\n+set(RUNTIME_PREFIX true)\n+set(NO_GETTEXT )\n+\n+if(NOT CURL_FOUND)\n+\tset(NO_CURL 1)\n+endif()\n+\n+if(NOT EXPAT_FOUND)\n+\tset(NO_EXPAT 1)\n+endif()\n+\n+if(NOT Intl_FOUND)\n+\tset(NO_GETTEXT 1)\n+endif()\n+\n+if(NOT PERL_TESTS)\n+\tset(NO_PERL 1)\n+endif()\n+\n+if(NOT PYTHON_TESTS)\n+\tset(NO_PYTHON 1)\n+endif()\n+\n+file(WRITE ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"SHELL_PATH='${SHELL_PATH}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"TEST_SHELL_PATH='${TEST_SHELL_PATH}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PERL_PATH='${PERL_PATH}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"DIFF='${DIFF}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PYTHON_PATH='${PYTHON_PATH}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"TAR='${TAR}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_CURL='${NO_CURL}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_EXPAT='${NO_EXPAT}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"USE_LIBPCRE1='${USE_LIBPCRE1}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_LIBPCRE1_JIT='${NO_LIBPCRE1_JIT}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PERL='${NO_PERL}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PTHREADS='${NO_PTHREADS}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PAGER_ENV='${PAGER_ENV}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"DC_SHA1='${DC_SHA1}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"X=''\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_GETTEXT='${NO_GETTEXT}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"RUNTIME_PREFIX='${RUNTIME_PREFIX}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PYTHON='${NO_PYTHON}'\\n\")\n+\n+file(GLOB test_scipts \"${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh\")\n+\n+#test\n+foreach(tsh ${test_scipts})\n+\tadd_test(NAME ${tsh}\n+\t\tCOMMAND ${SH_EXE} ${tsh}\n+\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t)\n+endforeach()\n+\n+endif()#BUILD_TESTING\n\\ No newline at end of file\n-- \ngitgitgadget\n\n"},{"id":"396101","messageId":"f0294be3f1151526fe002a55fb79015bd35606b2.1587700897.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.git.1587700897.gitgitgadget@gmail.com","subject":"[PATCH 8/8] ci: modification of main.yml to use cmake for vs-build job","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-04-24T04:01:37Z","receivedAt":"2020-04-24T04:01:51Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThis patch modifies .github/workflows/main.yml to use CMake for\nVisual Studio builds.\n\nModified the vs-test step to match windows-test step. This speeds\nup the vs-test. Calling git-cmd from powershell and then calling git-bash\nto perform the tests slows things down(factor of about 6). So git-bash\nis directly called from powershell to perform the tests using prove.\n\nNOTE: Since GitHub keeps the same directory for each job\n(with respect to path) absolute paths are used in the bin-wrapper\nscripts.\n\nGitHub has switched to CMake 3.17.1 which changed the behaviour of\nFindCURL module. An extra definition (-DCURL_NO_CURL_CMAKE=ON) has been\nadded to revert to the old behaviour.\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n .github/workflows/main.yml | 43 ++++++++++++++++++++++----------------\n 1 file changed, 25 insertions(+), 18 deletions(-)\n\ndiff --git a/.github/workflows/main.yml b/.github/workflows/main.yml\nindex fd4df939b50..94f9a385225 100644\n--- a/.github/workflows/main.yml\n+++ b/.github/workflows/main.yml\n@@ -80,13 +80,6 @@ jobs:\n     - name: download git-sdk-64-minimal\n       shell: bash\n       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 -\n-    - name: generate Visual Studio solution\n-      shell: powershell\n-      run: |\n-        & .\\git-sdk-64-minimal\\usr\\bin\\bash.exe -lc @\"\n-          make NDEBUG=1 DEVELOPER=1 vcxproj\n-        \"@\n-        if (!$?) { exit(1) }\n     - name: download vcpkg artifacts\n       shell: powershell\n       run: |\n@@ -98,6 +91,13 @@ jobs:\n         Remove-Item compat.zip\n     - name: add msbuild to PATH\n       uses: microsoft/setup-msbuild@v1.0.0\n+    - name: generate Visual Studio solution\n+      shell: powershell\n+      run: |\n+        & .\\git-sdk-64-minimal\\usr\\bin\\bash.exe -lc @\"\n+          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\n+        \"@\n+        if (!$?) { exit(1) }\n     - name: MSBuild\n       run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142\n     - name: bundle artifact tar\n@@ -125,9 +125,9 @@ jobs:\n         nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n     steps:\n     - uses: actions/checkout@v1\n-    - name: download git-64-portable\n+    - name: download git-sdk-64-minimal\n       shell: bash\n-      run: a=git-64-portable && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -\n+      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 -\n     - name: download build artifacts\n       uses: actions/download-artifact@v1\n       with:\n@@ -136,23 +136,30 @@ jobs:\n     - name: extract build artifacts\n       shell: bash\n       run: tar xf artifacts.tar.gz\n-    - name: test (parallel)\n+    - name: test\n       shell: powershell\n       env:\n         MSYSTEM: MINGW64\n         NO_SVN_TESTS: 1\n         GIT_TEST_SKIP_REBASE_P: 1\n       run: |\n-        & git-64-portable\\git-cmd.exe --command=usr\\bin\\bash.exe -lc @\"\n-          # Let Git ignore the SDK and the test-cache\n-          printf '%s\\n' /git-64-portable/ /test-cache/ >>.git/info/exclude\n+        & .\\git-sdk-64-minimal\\usr\\bin\\bash.exe -lc @\"\n+          # Let Git ignore the SDK\n+          printf '%s\\n' /git-sdk-64-minimal/ >>.git/info/exclude\n \n-          cd t &&\n-          PATH=\\\"`$PWD/helper:`$PATH\\\" &&\n-          test-tool.exe run-command testsuite --jobs=10 -V -x --write-junit-xml \\\n-                  `$(test-tool.exe path-utils slice-tests \\\n-                          ${{matrix.nr}} 10 t[0-9]*.sh)\n+          ci/run-test-slice.sh ${{matrix.nr}} 10\n         \"@\n+    - name: ci/print-test-failures.sh\n+      if: failure()\n+      shell: powershell\n+      run: |\n+        & .\\git-sdk-64-minimal\\usr\\bin\\bash.exe -lc ci/print-test-failures.sh\n+    - name: Upload failed tests' directories\n+      if: failure() && env.FAILED_TEST_ARTIFACTS != ''\n+      uses: actions/upload-artifact@v1\n+      with:\n+        name: failed-tests-windows\n+        path: ${{env.FAILED_TEST_ARTIFACTS}}\n   regular:\n     strategy:\n       matrix:\n-- \ngitgitgadget\n"},{"id":"396102","messageId":"d6c630028bf43ea74ef1ac3b60d49aea252b3f4b.1587700897.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.git.1587700897.gitgitgadget@gmail.com","subject":"[PATCH 6/8] cmake: support for building git on windows with mingw","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-04-24T04:01:35Z","receivedAt":"2020-04-24T04:01:53Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThis patch facilitates building git on Windows with CMake using MinGW\n\nNOTE: The funtions unsetenv and hstrerror are not checked in Windows\nbuilds.\nReasons\nNO_UNSETENV is not compatible with Windows builds.\nlines 262-264 compat/mingw.h\n\ncompat/mingw.h(line 25) provides a definition of hstrerror which\nconflicts with the definition provided in\ngit-compat-util.h(lines 733-736).\n\nTo use CMake on Windows with MinGW do this:\ncmake `relative-path-to-srcdir` -G \"MinGW Makefiles\"\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n CMakeLists.txt | 120 +++++++++++++++++++++++++++++++++++++++----------\n 1 file changed, 97 insertions(+), 23 deletions(-)\n\ndiff --git a/CMakeLists.txt b/CMakeLists.txt\nindex 29a23eb11f7..d9eb1060390 100644\n--- a/CMakeLists.txt\n+++ b/CMakeLists.txt\n@@ -13,9 +13,12 @@ project(git\n \tVERSION ${git_version}\n \tLANGUAGES C)\n \n+\n #TODO gitk git-gui gitweb\n+#TODO Enable NLS on windows natively\n #TODO Add pcre support\n \n+\n include(CheckTypeSize)\n include(CheckCSourceRuns)\n include(CheckCSourceCompiles)\n@@ -31,6 +34,7 @@ find_package(EXPAT)\n find_package(Iconv)\n find_package(Intl)\n \n+\n if(NOT Intl_FOUND)\n \tadd_compile_definitions(NO_GETTEXT)\n \tif(NOT Iconv_FOUND)\n@@ -53,6 +57,16 @@ if(Intl_FOUND)\n endif()\n \n find_program(SH_EXE sh)\n+if(NOT SH_EXE)\n+\tmessage(FATAL_ERROR \"sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/\")\n+endif()\n+\n+if(WIN32)\n+\tfind_program(WINDRES_EXE windres)\n+\tif(NOT WINDRES_EXE)\n+\t\tmessage(FATAL_ERROR \"Install windres on Windows for resource files\")\n+\tendif()\n+endif()\n \n find_program(MSGFMT_EXE msgfmt)\n if(NOT MSGFMT_EXE)\n@@ -85,11 +99,39 @@ add_compile_definitions(PAGER_ENV=\"LESS=FRX LV=-c\"\n \t\t\tBINDIR=\"bin\"\n \t\t\tGIT_BUILT_FROM_COMMIT=\"\")\n \n-set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n-add_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n+if(WIN32)\n+\tset(FALLBACK_RUNTIME_PREFIX /mingw64)\n+\tadd_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n+else()\n+\tset(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n+\tadd_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n+endif()\n \n-add_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n-list(APPEND compat_SOURCES unix-socket.c)\n+\n+#Platform Specific\n+if(${CMAKE_SYSTEM_NAME} STREQUAL \"Windows\")\n+\tinclude_directories(compat/win32)\n+\tadd_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32\n+\t\t\t\t_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=\".exe\"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT\n+\t\t\t\tNOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0 NO_ST_BLOCKS_IN_STRUCT_STAT\n+\t\t\t\tUSE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP\n+\t\t\t\tUNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)\n+\tlist(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c\n+\t\tcompat/win32/pthread.c compat/win32mmap.c compat/win32/syslog.c\n+\t\tcompat/win32/trace2_win32_process_info.c compat/win32/dirent.c\n+\t\tcompat/nedmalloc/nedmalloc.c compat/strdup.c)\n+\tset(NO_UNIX_SOCKETS 1)\n+\n+elseif(${CMAKE_SYSTEM_NAME} STREQUAL \"Linux\")\n+\tadd_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n+\tlist(APPEND compat_SOURCES unix-socket.c)\n+endif()\n+\n+if(WIN32)\n+\tset(EXE_EXTENSION .exe)\n+else()\n+\tset(EXE_EXTENSION)\n+endif()\n \n #header checks\n check_include_file(libgen.h HAVE_LIBGEN_H)\n@@ -150,7 +192,12 @@ endif()\n #function checks\n set(function_checks\n \tstrcasestr memmem strlcpy strtoimax strtoumax strtoull\n-\tsetenv  mkdtemp poll pread  memmem unsetenv hstrerror)\n+\tsetenv  mkdtemp poll pread  memmem)\n+\n+#unsetenv,hstrerror are incompatible with windows build\n+if(NOT WIN32)\n+\tlist(APPEND function_checks unsetenv hstrerror)\n+endif()\n \n foreach(f ${function_checks})\n \tstring(TOUPPER ${f} uf)\n@@ -309,7 +356,13 @@ endif()\n #programs\n set(PROGRAMS_BUILT\n \tgit git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst\n-\tgit-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)\n+\tgit-shell git-remote-testsvn)\n+\n+if(NO_UNIX_SOCKETS)\n+\tlist(APPEND excluded_progs git-credential-cache git-credential-cache--daemon)\n+else()\n+\tlist(APPEND PROGRAMS_BUILT git-credential-cache git-credential-cache--daemon)\n+endif()\n \n if(NOT CURL_FOUND)\n \tlist(APPEND excluded_progs git-http-fetch git-http-push)\n@@ -410,15 +463,34 @@ set(libvcs-svn_SOURCES\n \tvcs-svn/svndiff.c vcs-svn/svndump.c)\n add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})\n \n+#add git.rc for gcc\n+if(WIN32)\n+\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n+\t\t\tCOMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}\n+\t\t\t\t-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION=\"\\\\\\\"${PROJECT_VERSION}.GIT\\\\\\\"\"\n+\t\t\t\t-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res\n+\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n+\t\t\tVERBATIM)\n+\tadd_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)\n+endif()\n+\n #link all required libraries to common-main\n add_library(common-main OBJECT common-main.c)\n-target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)\n+\n+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})\n if(Intl_FOUND)\n \ttarget_link_libraries(common-main ${Intl_LIBRARIES})\n endif()\n if(Iconv_FOUND)\n \ttarget_link_libraries(common-main ${Iconv_LIBRARIES})\n endif()\n+if(WIN32)\n+\ttarget_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)\n+\tadd_dependencies(common-main git-rc)\n+\ttarget_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)\n+elseif(UNIX)\n+\ttarget_link_libraries(common-main pthread rt)\n+endif()\n \n \n set(git_SOURCES\n@@ -501,11 +573,13 @@ endif()\n add_executable(git-remote-testsvn remote-testsvn.c)\n target_link_libraries(git-remote-testsvn common-main vcs-svn)\n \n-add_executable(git-credential-cache credential-cache.c)\n-target_link_libraries(git-credential-cache common-main)\n+if(NOT NO_UNIX_SOCKETS)\n+\tadd_executable(git-credential-cache credential-cache.c)\n+\ttarget_link_libraries(git-credential-cache common-main)\n \n-add_executable(git-credential-cache--daemon credential-cache--daemon.c)\n-target_link_libraries(git-credential-cache--daemon common-main)\n+\tadd_executable(git-credential-cache--daemon credential-cache--daemon.c)\n+\ttarget_link_libraries(git-credential-cache--daemon common-main)\n+endif()\n \n \n set(git_builtin_extra\n@@ -517,16 +591,16 @@ set(git_builtin_extra\n foreach(s ${git_SOURCES} ${git_builtin_extra})\n \tstring(REPLACE \"builtin/\" \"\" s ${s})\n \tstring(REPLACE \".c\" \"\" s ${s})\n-\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git git-${s})\\n\")\n-\tlist(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})\n+\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git${EXE_EXTENSION} git-${s}${EXE_EXTENSION})\\n\")\n+\tlist(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s}${EXE_EXTENSION})\n endforeach()\n \n if(CURL_FOUND)\n \tset(remote_exes\n \t\tgit-remote-https git-remote-ftp git-remote-ftps)\n \tforeach(s ${remote_exes})\n-\t\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git-remote-http ${s})\\n\")\n-\t\tlist(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})\n+\t\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git-remote-http${EXE_EXTENSION} ${s}${EXE_EXTENSION})\\n\")\n+\t\tlist(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s}${EXE_EXTENSION})\n \tendforeach()\n endif()\n \n@@ -654,20 +728,20 @@ set(bin_links\n \tgit-receive-pack git-upload-archive git-upload-pack)\n \n foreach(b ${bin_links})\n-install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})\")\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/bin/${b}${EXE_EXTENSION})\")\n endforeach()\n \n-install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)\")\n-install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)\")\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git${EXE_EXTENSION})\")\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell${EXE_EXTENSION})\")\n \n foreach(b ${git_links})\n \tstring(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n-\tinstall(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n+\tinstall(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})\")\n endforeach()\n \n foreach(b ${git_http_links})\n \tstring(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n-\tinstall(CODE \"file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n+\tinstall(CODE \"file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})\")\n endforeach()\n \n install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4\n@@ -734,14 +808,14 @@ set(wrapper_test_scripts\n foreach(script ${wrapper_scripts})\n \tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n \tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n-\tstring(REPLACE \"@@PROG@@\" \"${script}\" content \"${content}\")\n+\tstring(REPLACE \"@@PROG@@\" \"${script}${EXE_EXTENSION}\" content \"${content}\")\n \tfile(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n endforeach()\n \n foreach(script ${wrapper_test_scripts})\n \tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n \tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n-\tstring(REPLACE \"@@PROG@@\" \"t/helper/${script}\" content \"${content}\")\n+\tstring(REPLACE \"@@PROG@@\" \"t/helper/${script}${EXE_EXTENSION}\" content \"${content}\")\n \tfile(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n endforeach()\n \n@@ -807,7 +881,7 @@ 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\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PAGER_ENV='${PAGER_ENV}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"DC_SHA1='${DC_SHA1}'\\n\")\n-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"X=''\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"X='${EXE_EXTENSION}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_GETTEXT='${NO_GETTEXT}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"RUNTIME_PREFIX='${RUNTIME_PREFIX}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PYTHON='${NO_PYTHON}'\\n\")\n-- \ngitgitgadget\n\n"},{"id":"396152","messageId":"20200424170540.GH1949@danh.dev","threadId":"53305","inReplyTo":"70ab1f03dd5413256166bf9db47be47b746ea6b1.1587700897.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 1/8] Introduce CMake support for configuring Git on Linux","fromName":"Danh Doan","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-04-24T17:05:40Z","receivedAt":"2020-04-24T17:05:45Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2020-04-24 04:01:30+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:\n\nPlease excuse my hatred for CMake.\n\nI guess it's my own fault for not learning how to write CMake\nproperly, or is it too hard to write correct CMake?\n\n> To make this a little less awkward, the Git for Windows project offers\n> the `vs/master` branch which has a full Visual Studio solution generated\n> and committed. This branch can therefore be used to tinker with Git in\n> Visual Studio _without_ having to download the full Git for Windows SDK.\n> Unfortunatly, that branch is auto-generated from Git for Windows'\n> `master`. If a developer wants to tinker, say, with `pu`, they are out\n> of luck.\n\nI thought:\n\tmake NDEBUG=1 DEVELOPER=1 vcxproj\n\nwas invented for this use case?\n\n> CMake was invented to make this sort of problem go away, by providing a\n> more standardized, cross-platform way to configure builds.\n\nThere is something fun with that *cross*\nIs cmake able to cross-compile cmake by cmake now?\n \n> With a working support CMake, developers on Windows need only install\n> CMake, configure their build, load the generated Visual Studio solution\n> and immediately start modifying the code and build their own version of\n> Git. Likewise, developers on other platforms can use the convenient GUI\n> tools provided by CMake to configure their build.\n\nOK, that's fine if it works for you.\nPlease don't drop support for autoconf and Makefile, though.\n(I haven't look into other patches)\n\n> So let's start building CMake support for Git.\n> \n> This is only the first step, and to make it easier to review, it only\n> allows for configuring builds on the platform that is easiest to\n> configure for: Linux.\n> \n> The CMake script checks whether the headers are present(eg. libgen.h),\n> whether the functions are present(eg. memmem), whether the funtions work\n> properly (eg. snprintf) and generate the required compile definitions\n> for the platform. The script also searches for the required libraries,\n> if it fails to find the required libraries the respective executables\n> won't be built.(eg. If libcurl is not found then git-remote-http won't\n> be built). This will help building Git easier.\n> \n> With a CMake script an out of source build of git is possible resulting\n> in a clean source tree.\n> \n> Note: earlier endeavors on the Git mailing list to introduce CMake ended\n> up in dead water. The primary reason for that was that reviewers\n> _expected_ CMake support to fall out of maintenance, unless the\n> contributor would promise to keep an eye on keeping CMake support up to\n> date. However, in the meantime, support for automated testing has been\n> introduced in Git's source code, and a later patch will modify the\n> (still experimental) GitHub workflow to continually verify that CMake\n> support is still complete. That will make maintenance reasonably easy.\n> \n> Note: this patch asks for the minimum version v3.14 of CMake (which is\n> not all that old as of time of writing) because that is the first\n\nDebian Buster (current stable) ships v3.13.4, I think I don't need to\nmention old-stable of Debian (Stretch or Jessie).\n\n\n> version to offer a platform-independent way to generate hardlinks as\n> part of the build. This is needed to generate all those hardlinks for\n> the built-in commands of Git.\n> \n> Instructions to run CMake:\n> \n> cmake `relative-path-to-srcdir` -DCMAKE_BUILD_TYPE=Release\n> \n> Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding\n> compiler flags\n> Debug : -g\n> Release: -O3\n\nIIRC, Linus and Junio used to said noone ever needs \"-03\"\n\n> RelWithDebInfo : -O2 -g\n> MinSizeRel : -Os\n> empty(default) :\n> \n> NOTE: -DCMAKE_BUILD_TYPE is optional\n> \n> This process generates a Makefile.\n> Then run `make` to build Git.\n> \n> NOTE: By default CMake uses Makefile as the build tool on Linux, to use\n> another tool say `ninja` add this to the command line when configuring.\n> `-G Ninja`\n> \n> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> ---\n>  CMakeLists.txt | 528 +++++++++++++++++++++++++++++++++++++++++++++++++\n>  1 file changed, 528 insertions(+)\n>  create mode 100644 CMakeLists.txt\n> \n> diff --git a/CMakeLists.txt b/CMakeLists.txt\n> new file mode 100644\n> index 00000000000..73703bd321f\n> --- /dev/null\n> +++ b/CMakeLists.txt\n> @@ -0,0 +1,528 @@\n> +#\n> +#\tCopyright (c) 2020 Sibi Siddharthan\n> +#\n> +\n> +cmake_minimum_required(VERSION 3.14)\n> +\n> +#Parse GIT-VERSION-GEN to get the version\n> +file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX \"DEF_VER=v(.*)\")\n> +string(REPLACE \"DEF_VER=v\" \"\" git_version ${git_version})\n> +string(REPLACE \".GIT\" \".0\" git_version ${git_version})#for building from a snapshot\n\nDoes it work with e.g. 2.26.1?\n\n> +\n> +project(git\n> +\tVERSION ${git_version}\n> +\tLANGUAGES C)\n> +\n> +\n> +include(CheckTypeSize)\n> +include(CheckCSourceRuns)\n> +include(CheckCSourceCompiles)\n> +include(CheckIncludeFile)\n> +include(CheckFunctionExists)\n> +include(CheckSymbolExists)\n> +include(CheckStructHasMember)\n> +\n> +find_package(ZLIB REQUIRED)\n> +find_package(CURL)\n\nRight now, we should --with-zlib=/path/to/zlib/root\nDoes this `find_package` support it?\n\n> +find_package(EXPAT)\n> +find_package(Iconv)\n> +find_package(Intl)\n> +\n\n> +if(NOT Intl_FOUND)\n> +\tadd_compile_definitions(NO_GETTEXT)\n\nfind_package(Gettext)?\n\n> +\tif(NOT Iconv_FOUND)\n> +\t\tadd_compile_definitions(NO_ICONV)\n> +\tendif()\n> +endif()\n\nICONV_OMITS_BOM?\n\n> +\n> +include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})\n> +if(CURL_FOUND)\n> +\tinclude_directories(SYSTEM ${CURL_INCLUDE_DIRS})\n> +endif()\n> +if(EXPAT_FOUND)\n> +\tinclude_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})\n> +endif()\n> +if(Iconv_FOUND)\n> +\tinclude_directories(SYSTEM ${Iconv_INCLUDE_DIRS})\n> +endif()\n> +if(Intl_FOUND)\n> +\tinclude_directories(SYSTEM ${Intl_INCLUDE_DIRS})\n> +endif()\n> +\n> +find_program(SH_EXE sh)\n\nWe want to find usable sh, not just sh, no?\n\nIt's matter on Solaris, HP-UX\n\n> +\n> +#default behaviour\n> +include_directories(${CMAKE_SOURCE_DIR})\n> +add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n> +add_compile_definitions(SHA256_BLK INTERNAL_QSORT RUNTIME_PREFIX)\n> +add_compile_definitions(NO_OPENSSL SHA1_DC SHA1DC_NO_STANDARD_INCLUDES\n> +\t\t\tSHA1DC_INIT_SAFE_HASH_DEFAULT=0\n> +\t\t\tSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"cache.h\"\n> +\t\t\tSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"git-compat-util.h\" )\n> +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)\n> +\n> +\n> +add_compile_definitions(PAGER_ENV=\"LESS=FRX LV=-c\"\n> +\t\t\tETC_GITATTRIBUTES=\"etc/gitattributes\"\n> +\t\t\tETC_GITCONFIG=\"etc/gitconfig\"\n> +\t\t\tGIT_EXEC_PATH=\"libexec/git-core\"\n> +\t\t\tGIT_LOCALE_PATH=\"share/locale\"\n> +\t\t\tGIT_MAN_PATH=\"share/man\"\n> +\t\t\tGIT_INFO_PATH=\"share/info\"\n> +\t\t\tGIT_HTML_PATH=\"share/doc/git-doc\"\n> +\t\t\tDEFAULT_HELP_FORMAT=\"html\"\n> +\t\t\tDEFAULT_GIT_TEMPLATE_DIR=\"share/git-core/templates\"\n> +\t\t\tGIT_VERSION=\"${PROJECT_VERSION}.GIT\"\n> +\t\t\tGIT_USER_AGENT=\"git/${PROJECT_VERSION}.GIT\"\n> +\t\t\tBINDIR=\"bin\"\n> +\t\t\tGIT_BUILT_FROM_COMMIT=\"\")\n\nI wish I could verify this.\nHave you check this part on a default build system for a Linux distro,\nFreeBSD? For things started with \"etc/\"\n\n> +\n> +set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n> +add_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n> +\n> +add_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n\n/proc/self/exe is Linux only, no?\n\n> +list(APPEND compat_SOURCES unix-socket.c)\n> +\n> +#header checks\n> +check_include_file(libgen.h HAVE_LIBGEN_H)\n> +if(NOT HAVE_LIBGEN_H)\n> +\tadd_compile_definitions(NO_LIBGEN_H)\n> +\tlist(APPEND compat_SOURCES compat/basename.c)\n> +endif()\n> +\n> +check_include_file(sys/sysinfo.h HAVE_SYSINFO)\n> +if(HAVE_SYSINFO)\n> +\tadd_compile_definitions(HAVE_SYSINFO)\n> +endif()\n> +\n> +check_c_source_compiles(\"\n> +#include <alloca.h>\n> +int\n> +main ()\n> +{\n> +char *p = (char *) alloca (2 * sizeof (int));\n> +\tif (p) return 0;\n> +\treturn 0;\n\nAll code path will return 0?\n\n> +}\"\n> +HAVE_ALLOCA_H)\n> +if(HAVE_ALLOCA_H)\n> +\tadd_compile_definitions(HAVE_ALLOCA_H)\n> +endif()\n> +\n> +check_include_file(strings.h HAVE_STRINGS_H)\n> +if(HAVE_STRINGS_H)\n> +\tadd_compile_definitions(HAVE_STRINGS_H)\n> +endif()\n> +\n> +check_include_file(sys/select.h HAVE_SYS_SELECT_H)\n> +if(NOT HAVE_SYS_SELECT_H)\n> +\tadd_compile_definitions(NO_SYS_SELECT_H)\n> +endif()\n> +\n> +check_include_file(sys/poll.h HAVE_SYS_POLL_H)\n> +if(NOT HAVE_SYS_POLL_H)\n> +\tadd_compile_definitions(NO_SYS_POLL_H)\n> +endif()\n> +\n> +check_include_file(poll.h HAVE_POLL_H)\n\nPOSIX defined poll.h instead of sys/poll.h\n\n> +if(NOT HAVE_POLL_H)\n> +\tadd_compile_definitions(NO_POLL_H)\n> +endif()\n> +\n> +check_include_file(inttypes.h HAVE_INTTYPES_H)\n> +if(NOT HAVE_INTTYPES_H)\n> +\tadd_compile_definitions(NO_INTTYPES_H)\n> +endif()\n> +\n> +check_include_file(paths.h HAVE_PATHS_H)\n> +if(HAVE_PATHS_H)\n> +\tadd_compile_definitions(HAVE_PATHS_H)\n> +endif()\n> +\n> +#function checks\n> +set(function_checks\n> +\tstrcasestr memmem strlcpy strtoimax strtoumax strtoull\n> +\tsetenv  mkdtemp poll pread  memmem unsetenv hstrerror)\n> +\n> +foreach(f ${function_checks})\n> +\tstring(TOUPPER ${f} uf)\n> +\tcheck_function_exists(${f} HAVE_${uf})\n> +\tif(NOT HAVE_${uf})\n> +\t\tadd_compile_definitions(NO_${uf})\n> +\tendif()\n> +endforeach()\n> +\n> +if(NOT HAVE_POLL_H OR NOT HAVE_SYS_POLL_H OR NOT HAVE_POLL)\n> +\tinclude_directories(compat/poll)\n> +\tadd_compile_definitions(NO_POLL)\n> +\tlist(APPEND compat_SOURCES compat/poll/poll.c)\n> +endif()\n> +\n> +if(NOT HAVE_STRCASESTR)\n> +\tlist(APPEND compat_SOURCES compat/strcasestr.c)\n> +endif()\n> +\n> +if(NOT HAVE_STRLCPY)\n> +\tlist(APPEND compat_SOURCES compat/strlcpy.c)\n> +endif()\n> +\n> +if(NOT HAVE_STRTOUMAX)\n> +\tlist(APPEND compat_SOURCES compat/strtoumax.c compat/strtoimax.c)\n> +endif()\n> +\n> +if(NOT HAVE_SETENV)\n> +\tlist(APPEND compat_SOURCES compat/setenv.c)\n> +endif()\n> +\n> +if(NOT HAVE_MKDTEMP)\n> +\tlist(APPEND compat_SOURCES compat/mkdtemp.c)\n> +endif()\n> +\n> +if(NOT HAVE_PREAD)\n> +\tlist(APPEND compat_SOURCES compat/pread.c)\n> +endif()\n> +\n> +if(NOT HAVE_MEMMEM)\n> +\tlist(APPEND compat_SOURCES compat/memmem.c)\n> +endif()\n> +\n> +if(NOT WIN32)\n> +\tif(NOT HAVE_UNSETENV)\n> +\t\tlist(APPEND compat_SOURCES compat/unsetenv.c)\n> +\tendif()\n> +\n> +\tif(NOT HAVE_HSTRERROR)\n> +\t\tlist(APPEND compat_SOURCES compat/hstrerror.c)\n> +\tendif()\n> +endif()\n> +\n> +check_function_exists(getdelim HAVE_GETDELIM)\n> +if(HAVE_GETDELIM)\n> +\tadd_compile_definitions(HAVE_GETDELIM)\n> +endif()\n> +\n> +check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)\n> +check_symbol_exists(CLOCK_MONOTONIC \"time.h\" HAVE_CLOCK_MONOTONIC)\n> +if(HAVE_CLOCK_GETTIME)\n> +\tadd_compile_definitions(HAVE_CLOCK_GETTIME)\n> +endif()\n> +if(HAVE_CLOCK_MONOTONIC)\n> +\tadd_compile_definitions(HAVE_CLOCK_MONOTONIC)\n> +endif()\n> +\n> +\n> +#compile checks\n> +check_c_source_runs(\"\n> +#include<stdio.h>\n> +#include<stdarg.h>\n> +#include<string.h>\n> +#include<stdlib.h>\n> +int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)\n> +{\n> +\tint ret;\n> +\tva_list ap;\n> +\n> +\tva_start(ap, format);\n> +\tret = vsnprintf(str, maxsize, format, ap);\n> +\tva_end(ap);\n> +\treturn ret;\n> +}\n> +\n> +int\n> +main ()\n> +{\n> +\tchar buf[6];\n> +\tif (test_vsnprintf(buf, 3, \\\"%s\\\", \\\"12345\\\") != 5\n> +\t\t|| strcmp(buf, \\\"12\\\")) return 1;\n> +\tif (snprintf(buf, 3, \\\"%s\\\", \\\"12345\\\") != 5\n> +\t\t|| strcmp(buf, \\\"12\\\")) return 1;\n> +\n> +\treturn 0;\n> +}\"\n> +SNPRINTF_OK)\n> +if(NOT SNPRINTF_OK)\n> +\tadd_compile_definitions(SNPRINTF_RETURNS_BOGUS)\n> +\tlist(APPEND compat_SOURCES compat/snprintf.c)\n> +endif()\n> +\n> +check_c_source_runs(\"\n> +#include<stdio.h>\n> +int\n> +main ()\n> +{\n> +\tFILE *f = fopen(\\\".\\\", \\\"r\\\");\n> +\treturn f != NULL;\n> +\n> +\treturn 0;\n> +}\"\n> +FREAD_READS_DIRECTORIES_NO)\n> +if(NOT FREAD_READS_DIRECTORIES_NO)\n> +\tadd_compile_definitions(FREAD_READS_DIRECTORIES)\n> +\tlist(APPEND compat_SOURCES compat/fopen.c)\n> +endif()\n> +\n> +check_c_source_compiles(\"\n> +#include <regex.h>\n> +#ifndef REG_STARTEND\n> +#error oops we dont have it\n> +#endif\n> +int main(){return 0;}\"\n> +HAVE_REGEX)\n> +if(NOT HAVE_REGEX)\n> +\tinclude_directories(compat/regex )\n> +\tlist(APPEND compat_SOURCES compat/regex/regex.c )\n> +\tadd_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)\n> +endif()\n> +\n> +\n> +check_c_source_compiles(\"\n> +#include <stddef.h>\n> +#include <sys/types.h>\n> +#include <sys/sysctl.h>\n> +\n> +int\n> +main ()\n> +{\n> +\tint val, mib[2];\n> +\tsize_t len;\n> +\n> +\tmib[0] = CTL_HW;\n> +\tmib[1] = 1;\n> +\tlen = sizeof(val);\n> +\treturn sysctl(mib, 2, &val, &len, NULL, 0) ? 1 : 0;\n> +\n> +\treturn 0;\n> +}\"\n> +HAVE_BSD_SYSCTL)\n> +if(HAVE_BSD_SYSCTL)\n> +\tadd_compile_definitions(HAVE_BSD_SYSCTL)\n> +endif()\n> +\n> +#programs\n> +set(PROGRAMS_BUILT\n> +\tgit git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst\n> +\tgit-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)\n> +\n> +if(NOT CURL_FOUND)\n> +\tlist(APPEND excluded_progs git-http-fetch git-http-push)\n> +\tadd_compile_definitions(NO_CURL)\n> +\tmessage(WARNING \"git-http-push and git-http-fetch will not be built\")\n> +else()\n> +\tlist(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)\n> +\tif(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)\n> +\t\tadd_compile_definitions(USE_CURL_FOR_IMAP_SEND)\n> +\tendif()\n> +endif()\n> +\n> +if(NOT EXPAT_FOUND)\n> +\tlist(APPEND excluded_progs git-http-push)\n> +\tadd_compile_definitions(NO_EXPAT)\n> +else()\n> +\tlist(APPEND PROGRAMS_BUILT git-http-push)\n> +\tif(EXPAT_VERSION_STRING VERSION_LESS_EQUAL 1.2)\n> +\t\tadd_compile_definitions(EXPAT_NEEDS_XMLPARSE_H)\n> +\tendif()\n> +endif()\n> +\n> +list(REMOVE_DUPLICATES excluded_progs)\n> +list(REMOVE_DUPLICATES PROGRAMS_BUILT)\n> +\n> +\n> +foreach(p ${excluded_progs})\n> +\tlist(APPEND EXCLUSION_PROGS --exclude-program ${p} )\n> +endforeach()\n> +\n> +#for comparing null values\n> +list(APPEND EXCLUSION_PROGS empty)\n> +set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING \"Programs not built\" FORCE)\n> +\n> +if(NOT EXISTS ${CMAKE_SOURCE_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)\n> +\tlist(REMOVE_ITEM EXCLUSION_PROGS empty)\n> +\tmessage(\"Generating command-list.h\")\n> +\texecute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt\n> +\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n> +\t\t\tOUTPUT_FILE ${CMAKE_SOURCE_DIR}/command-list.h)\n> +endif()\n> +\n> +if(NOT EXISTS ${CMAKE_SOURCE_DIR}/config-list.h)\n> +\tmessage(\"Generating config-list.h\")\n> +\texecute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh\n> +\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n> +\t\t\tOUTPUT_FILE ${CMAKE_SOURCE_DIR}/config-list.h)\n> +endif()\n> +\n> +\n> +#build\n> +set(libgit_SOURCES\n> +\tabspath.c add-interactive.c add-patch.c advice.c alias.c\n> +\talloc.c apply.c archive.c archive-tar.c archive-zip.c argv-array.c\n> +\tattr.c base85.c bisect.c blame.c blob.c bloom.c branch.c bulk-checkin.c\n> +\tbundle.c cache-tree.c chdir-notify.c checkout.c color.c column.c\n> +\tcombine-diff.c commit.c commit-graph.c commit-reach.c compat/obstack.c\n> +\tcompat/terminal.c config.c connect.c connected.c convert.c copy.c credential.c\n> +\tcsum-file.c ctype.c date.c decorate.c delta-islands.c diffcore-break.c\n> +\tdiffcore-delta.c diffcore-order.c diffcore-pickaxe.c diffcore-rename.c\n> +\tdiff-delta.c diff-lib.c diff-no-index.c diff.c dir.c dir-iterator.c editor.c\n> +\tentry.c environment.c ewah/bitmap.c ewah/ewah_bitmap.c ewah/ewah_io.c\n> +\tewah/ewah_rlw.c exec-cmd.c fetch-negotiator.c fetch-pack.c fmt-merge-msg.c fsck.c fsmonitor.c\n> +\tgettext.c gpg-interface.c graph.c grep.c hashmap.c linear-assignment.c help.c hex.c\n> +\tident.c interdiff.c json-writer.c kwset.c levenshtein.c line-log.c line-range.c list-objects.c\n> +\tlist-objects-filter.c list-objects-filter-options.c ll-merge.c lockfile.c\n> +\tlog-tree.c ls-refs.c mailinfo.c mailmap.c match-trees.c mem-pool.c merge.c merge-blobs.c\n> +\tmerge-recursive.c mergesort.c midx.c name-hash.c negotiator/default.c\n> +\tnegotiator/skipping.c notes.c notes-cache.c notes-merge.c notes-utils.c object.c oidmap.c\n> +\toidset.c oid-array.c packfile.c pack-bitmap.c pack-bitmap-write.c pack-check.c pack-objects.c\n> +\tpack-revindex.c pack-write.c pager.c parse-options.c parse-options-cb.c patch-delta.c\n> +\tpatch-ids.c path.c pathspec.c pkt-line.c preload-index.c pretty.c prio-queue.c progress.c\n> +\tpromisor-remote.c prompt.c protocol.c prune-packed.c quote.c range-diff.c reachable.c read-cache.c rebase.c\n> +\trebase-interactive.c reflog-walk.c refs.c refs/files-backend.c refs/iterator.c\n> +\trefs/packed-backend.c refs/ref-cache.c refspec.c ref-filter.c remote.c replace-object.c\n> +\trepo-settings.c repository.c rerere.c reset.c resolve-undo.c revision.c run-command.c\n> +\tsend-pack.c sequencer.c serve.c server-info.c setup.c sha1-lookup.c\n> +\tsha1-file.c sha1-name.c shallow.c sideband.c sigchain.c split-index.c\n> +\tstable-qsort.c strbuf.c streaming.c string-list.c submodule.c submodule-config.c\n> +\tsub-process.c symlinks.c tag.c tempfile.c thread-utils.c tmp-objdir.c\n> +\ttrace.c trace2.c trace2/tr2_cfg.c trace2/tr2_cmd_name.c trace2/tr2_dst.c\n> +\ttrace2/tr2_sid.c trace2/tr2_sysenv.c trace2/tr2_tbuf.c trace2/tr2_tgt_event.c\n> +\ttrace2/tr2_tgt_normal.c trace2/tr2_tgt_perf.c trace2/tr2_tls.c trailer.c transport.c\n> +\ttransport-helper.c tree-diff.c tree.c tree-walk.c unpack-trees.c upload-pack.c url.c\n> +\turlmatch.c usage.c userdiff.c utf8.c varint.c version.c versioncmp.c walker.c wildmatch.c\n> +\tworktree.c wrapper.c write-or-die.c ws.c wt-status.c xdiff-interface.c\n> +\tzlib.c)\n> +\n> +add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})\n> +\n> +set(libxdiff_SOURCES\n> +\txdiff/xdiffi.c xdiff/xprepare.c xdiff/xutils.c xdiff/xemit.c\n> +\txdiff/xmerge.c xdiff/xpatience.c xdiff/xhistogram.c)\n> +add_library(xdiff STATIC ${libxdiff_SOURCES})\n> +\n> +set(libvcs-svn_SOURCES\n> +\tvcs-svn/line_buffer.c vcs-svn/sliding_window.c vcs-svn/fast_export.c\n> +\tvcs-svn/svndiff.c vcs-svn/svndump.c)\n> +add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})\n> +\n> +#link all required libraries to common-main\n> +add_library(common-main OBJECT common-main.c)\n> +target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)\n> +if(Intl_FOUND)\n> +\ttarget_link_libraries(common-main ${Intl_LIBRARIES})\n> +endif()\n> +if(Iconv_FOUND)\n> +\ttarget_link_libraries(common-main ${Iconv_LIBRARIES})\n> +endif()\n> +\n> +\n> +set(git_SOURCES\n> +\tbuiltin/add.c builtin/am.c builtin/annotate.c builtin/apply.c\n> +\tbuiltin/archive.c builtin/bisect--helper.c builtin/blame.c\n> +\tbuiltin/branch.c builtin/bundle.c builtin/cat-file.c builtin/check-attr.c\n> +\tbuiltin/check-ignore.c builtin/check-mailmap.c builtin/check-ref-format.c\n> +\tbuiltin/checkout-index.c builtin/checkout.c builtin/clean.c\n> +\tbuiltin/clone.c builtin/column.c builtin/commit-tree.c\n> +\tbuiltin/commit.c builtin/commit-graph.c builtin/config.c\n> +\tbuiltin/count-objects.c builtin/credential.c builtin/describe.c\n> +\tbuiltin/diff-files.c builtin/diff-index.c builtin/diff-tree.c\n> +\tbuiltin/diff.c builtin/difftool.c builtin/env--helper.c\n> +\tbuiltin/fast-export.c builtin/fetch-pack.c builtin/fetch.c builtin/fmt-merge-msg.c\n> +\tbuiltin/for-each-ref.c builtin/fsck.c builtin/gc.c\n> +\tbuiltin/get-tar-commit-id.c builtin/grep.c builtin/hash-object.c\n> +\tbuiltin/help.c builtin/index-pack.c builtin/init-db.c\n> +\tbuiltin/interpret-trailers.c builtin/log.c builtin/ls-files.c\n> +\tbuiltin/ls-remote.c builtin/ls-tree.c builtin/mailinfo.c builtin/mailsplit.c\n> +\tbuiltin/merge.c builtin/merge-base.c builtin/merge-file.c builtin/merge-index.c\n> +\tbuiltin/merge-ours.c builtin/merge-recursive.c builtin/merge-tree.c\n> +\tbuiltin/mktag.c builtin/mktree.c builtin/multi-pack-index.c builtin/mv.c\n> +\tbuiltin/name-rev.c builtin/notes.c builtin/pack-objects.c builtin/pack-redundant.c\n> +\tbuiltin/pack-refs.c builtin/patch-id.c builtin/prune-packed.c builtin/prune.c\n> +\tbuiltin/pull.c builtin/push.c builtin/range-diff.c builtin/read-tree.c\n> +\tbuiltin/rebase.c builtin/receive-pack.c builtin/reflog.c builtin/remote.c\n> +\tbuiltin/remote-ext.c builtin/remote-fd.c builtin/repack.c builtin/replace.c\n> +\tbuiltin/rerere.c builtin/reset.c builtin/rev-list.c builtin/rev-parse.c\n> +\tbuiltin/revert.c builtin/rm.c builtin/send-pack.c builtin/shortlog.c\n> +\tbuiltin/show-branch.c builtin/show-index.c builtin/show-ref.c\n> +\tbuiltin/sparse-checkout.c builtin/stash.c builtin/stripspace.c\n> +\tbuiltin/submodule--helper.c builtin/symbolic-ref.c builtin/tag.c\n> +\tbuiltin/unpack-file.c builtin/unpack-objects.c builtin/update-index.c\n> +\tbuiltin/update-ref.c builtin/update-server-info.c builtin/upload-archive.c\n> +\tbuiltin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c\n> +\tbuiltin/verify-tag.c builtin/worktree.c builtin/write-tree.c)\n> +\n> +add_executable(git git.c ${git_SOURCES})\n> +target_link_libraries(git common-main )\n> +\n> +add_executable(git-bugreport bugreport.c)\n> +target_link_libraries(git-bugreport common-main)\n> +\n> +add_executable(git-credential-store credential-store.c)\n> +target_link_libraries(git-credential-store common-main)\n> +\n> +add_executable(git-daemon daemon.c)\n> +target_link_libraries(git-daemon common-main)\n> +\n> +add_executable(git-fast-import fast-import.c)\n> +target_link_libraries(git-fast-import common-main)\n> +\n> +add_executable(git-http-backend http-backend.c)\n> +target_link_libraries(git-http-backend common-main)\n> +\n> +add_executable(git-sh-i18n--envsubst sh-i18n--envsubst.c)\n> +target_link_libraries(git-sh-i18n--envsubst common-main)\n> +\n> +add_executable(git-shell shell.c)\n> +target_link_libraries(git-shell common-main)\n> +\n> +if(CURL_FOUND)\n> +\tadd_library(http_obj OBJECT http.c)\n> +\n> +\tadd_executable(git-imap-send imap-send.c)\n> +\ttarget_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})\n> +\n> +\tadd_executable(git-http-fetch http-walker.c http-fetch.c)\n> +\ttarget_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})\n> +\n> +\tadd_executable(git-remote-http http-walker.c remote-curl.c)\n> +\ttarget_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )\n> +\n> +\tif(EXPAT_FOUND)\n> +\t\tadd_executable(git-http-push http-push.c)\n> +\t\ttarget_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})\n> +\tendif()\n> +endif()\n> +\n> +add_executable(git-remote-testsvn remote-testsvn.c)\n> +target_link_libraries(git-remote-testsvn common-main vcs-svn)\n> +\n> +add_executable(git-credential-cache credential-cache.c)\n> +target_link_libraries(git-credential-cache common-main)\n> +\n> +add_executable(git-credential-cache--daemon credential-cache--daemon.c)\n> +target_link_libraries(git-credential-cache--daemon common-main)\n> +\n> +\n> +set(git_builtin_extra\n> +\tcherry cherry-pick format-patch fsck-objects\n> +\tinit merge-subtree restore show\n> +\tstage status switch whatchanged)\n> +\n> +#Creating hardlinks\n> +foreach(s ${git_SOURCES} ${git_builtin_extra})\n> +\tstring(REPLACE \"builtin/\" \"\" s ${s})\n> +\tstring(REPLACE \".c\" \"\" s ${s})\n> +\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git git-${s})\\n\")\n> +\tlist(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})\n> +endforeach()\n> +\n> +if(CURL_FOUND)\n> +\tset(remote_exes\n> +\t\tgit-remote-https git-remote-ftp git-remote-ftps)\n> +\tforeach(s ${remote_exes})\n> +\t\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git-remote-http ${s})\\n\")\n> +\t\tlist(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})\n> +\tendforeach()\n> +endif()\n> +\n> +add_custom_command(OUTPUT ${git_links} ${git_http_links}\n> +\t\tCOMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake\n> +\t\tDEPENDS git git-remote-http)\n> +add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})\n> \\ No newline at end of file\n\nNo new line at end of line always leave a bad taste in my mount!\n\n\n-- \nDanh\n"},{"id":"396158","messageId":"20200424171959.GI1949@danh.dev","threadId":"53305","inReplyTo":"ca242cf5bda74aafca6c169ad53ce33a62761027.1587700897.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 2/8] cmake: generate the shell/perl/python scripts and templates, translations","fromName":"Danh Doan","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-04-24T17:19:59Z","receivedAt":"2020-04-24T17:20:04Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2020-04-24 04:01:31+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> \n> This patch implements the placeholder substitution to generate, say,\n> `git-request-pull` from `git-request-pull.sh`.\n> \n> The shell/perl/python scripts and template are generated using CMake\n> (very similar to what sed does).\n> \n> The text translations are only build if `msgfmt` is found in your path.\n> \n> NOTE: The scripts and templates are generated during configuration.\n> \n> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> ---\n>  CMakeLists.txt | 107 ++++++++++++++++++++++++++++++++++++++++++++++++-\n>  1 file changed, 106 insertions(+), 1 deletion(-)\n> \n> diff --git a/CMakeLists.txt b/CMakeLists.txt\n> index 73703bd321f..788b53be873 100644\n> --- a/CMakeLists.txt\n> +++ b/CMakeLists.txt\n> @@ -51,6 +51,11 @@ endif()\n>  \n>  find_program(SH_EXE sh)\n>  \n> +find_program(MSGFMT_EXE msgfmt)\n\nI suppose find_package(Gettext) can do most of this work?\n\n> +if(NOT MSGFMT_EXE)\n> +\tmessage(WARNING \"Text Translations won't be build\")\n> +endif()\n> +\n>  #default behaviour\n>  include_directories(${CMAKE_SOURCE_DIR})\n>  add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n> @@ -525,4 +530,104 @@ endif()\n>  add_custom_command(OUTPUT ${git_links} ${git_http_links}\n>  \t\tCOMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake\n>  \t\tDEPENDS git git-remote-http)\n> -add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})\n> \\ No newline at end of file\n\nNo newline at end of file?\n\n> +add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})\n> +\n> +\n> +#creating required scripts\n> +set(SHELL_PATH /bin/sh)\n> +set(PERL_PATH /usr/bin/perl)\n\nReally?\nHave you tried on, let's say FreeBSD?\n\n> +set(LOCALEDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)\n> +set(GITWEBDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)\n> +set(INSTLIBDIR ${FALLBACK_RUNTIME_PREFIX}/share/perl5)\n> +\n> +#shell scripts\n> +set(git_shell_scripts\n> +\tgit-bisect git-difftool--helper git-filter-branch\n> +\tgit-merge-octopus git-merge-one-file git-merge-resolve\n> +\tgit-mergetool git-quiltimport\n> +\tgit-request-pull git-submodule git-web--browse\n> +\tgit-mergetool--lib git-parse-remote git-rebase--preserve-merges\n> +\tgit-sh-setup git-sh-i18n git-instaweb)\n> +\n> +foreach(script ${git_shell_scripts})\n> +\tfile(STRINGS ${CMAKE_SOURCE_DIR}/${script}.sh content NEWLINE_CONSUME)\n> +\tstring(REPLACE \"@SHELL_PATH@\" \"${SHELL_PATH}\" content \"${content}\")\n> +\tstring(REPLACE \"@@DIFF@@\" \"diff\" content \"${content}\")\n> +\tstring(REPLACE \"@LOCALEDIR@\" \"${LOCALEDIR}\" content \"${content}\")\n> +\tstring(REPLACE \"@GITWEBDIR@\" \"${GITWEBDIR}\" content \"${content}\")\n> +\tstring(REPLACE \"@@NO_CURL@@\" \"\" content \"${content}\")\n> +\tstring(REPLACE \"@@USE_GETTEXT_SCHEME@@\" \"\" content \"${content}\")\n> +\tstring(REPLACE \"# @@BROKEN_PATH_FIX@@\" \"\" content \"${content}\")\n> +\tstring(REPLACE \"@@PERL@@\" \"${PERL_PATH}\" content \"${content}\")\n> +\tstring(REPLACE \"@@SANE_TEXT_GREP@@\" \"-a\" content \"${content}\")\n> +\tstring(REPLACE \"@@PAGER_ENV@@\" \"LESS=FRX LV=-c\" content \"${content}\")\n> +\tfile(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})\n> +endforeach()\n\nI assume this do most of sed magic?\n\n> +\n> +#perl scripts\n> +set(git_perl_scripts\n> +\tgit-add--interactive git-archimport git-cvsexportcommit\n> +\tgit-cvsimport git-cvsserver git-send-email git-svn)\n> +\n> +#create perl header\n> +file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )\n> +string(REPLACE \"@@PATHSEP@@\" \":\" perl_header \"${perl_header}\")\n> +string(REPLACE \"@@INSTLIBDIR@@\" \"${INSTLIBDIR}\" perl_header \"${perl_header}\")\n> +\n> +foreach(script ${git_perl_scripts})\n> +\tfile(STRINGS ${CMAKE_SOURCE_DIR}/${script}.perl content NEWLINE_CONSUME)\n> +\tstring(REPLACE \"#!/usr/bin/perl\" \"#!/usr/bin/perl\\n${perl_header}\\n\" content \"${content}\")\n\nHoped that this is tried on BSD?\n\n> +\tstring(REPLACE \"@@GIT_VERSION@@\" \"${PROJECT_VERSION}\" content \"${content}\")\n> +\tfile(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})\n> +endforeach()\n> +\n> +#python script\n> +file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)\n> +string(REPLACE \"#!/usr/bin/env python\" \"#!/usr/bin/python\" content \"${content}\")\n> +file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})\n> +\n> +#perl modules\n> +file(GLOB_RECURSE perl_modules \"${CMAKE_SOURCE_DIR}/perl/*.pm\")\n> +\n> +foreach(pm ${perl_modules})\n> +\tstring(REPLACE \"${CMAKE_SOURCE_DIR}/perl/\" \"\" file_path ${pm})\n\nSo, the real source code have reference to CMAKE_SOURCE_DIR?\nI don't think so? It's purely my guess from previous patch, this\nfunction will do\nstring(REPLACE from to file something_I_have_not_checked)\n\n> +\tfile(STRINGS ${pm} content NEWLINE_CONSUME)\n> +\tstring(REPLACE \"@@LOCALEDIR@@\" \"${LOCALEDIR}\" content \"${content}\")\n> +\tstring(REPLACE \"@@NO_PERL_CPAN_FALLBACKS@@\" \"\" content \"${content}\")\n> +\tfile(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})\n> +#test-lib.sh requires perl/build/lib to be the build directory of perl modules\n> +endforeach()\n> +\n> +\n> +#templates\n> +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches\n> +set(hooks_templates\n> +\tapplypatch-msg.sample pre-applypatch.sample pre-push.sample\n> +\tcommit-msg.sample pre-commit.sample pre-rebase.sample\n> +\tfsmonitor-watchman.sample pre-merge-commit.sample pre-receive.sample\n> +\tpost-update.sample prepare-commit-msg.sample update.sample)\n\nToo much things merged into one line, I hate it.\n\n> +\n> +#templates have @.*@ replacement so use configure_file instead\n> +#hooks\n> +foreach(tm ${hooks_templates})\n> +\tconfigure_file(${CMAKE_SOURCE_DIR}/templates/hooks--${tm} ${CMAKE_BINARY_DIR}/templates/blt/hooks/${tm} @ONLY)\n> +endforeach()\n\nWhat does this really means?\n\n> +\n> +#info\n> +configure_file(${CMAKE_SOURCE_DIR}/templates/info--exclude ${CMAKE_BINARY_DIR}/templates/blt/info/exclude @ONLY)\n> +\n> +#this\n> +configure_file(${CMAKE_SOURCE_DIR}/templates/this--description ${CMAKE_BINARY_DIR}/templates/blt/description @ONLY)\n> +\n> +\n> +#translations\n> +if(MSGFMT_EXE)\n> +\tset(po_files bg  ca  de  el  es  fr  is  it  ko  pt_PT  ru  sv  tr  vi  zh_CN  zh_TW)\n\nhard coded, so this is a regression, compared to old Makefile?\n\n> +\tforeach(po ${po_files})\n> +\t\tfile(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES)\n> +\t\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo\n> +\t\t\t\tCOMMAND ${MSGFMT_EXE} --check --statistics -o ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo ${CMAKE_SOURCE_DIR}/po/${po}.po)\n\nfind_package(Gettext) defines MSGFMT_EXECUTABLE, I think.\nHave you check Solaris option?\nOr is this tranlated from current Makefile?\nI haven't checked current source code!\n\n> +\t\tlist(APPEND po_gen ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo)\n> +\tendforeach()\n> +\tadd_custom_target(po-gen ALL DEPENDS ${po_gen})\n> +endif()\n> -- \n> gitgitgadget\n> \n\n-- \nDanh\n"},{"id":"396160","messageId":"20200424172312.GJ1949@danh.dev","threadId":"53305","inReplyTo":"10390063a398feab86519ba4e4fd9d03f38cd0fd.1587700897.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 3/8] cmake: installation support for git","fromName":"Danh Doan","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-04-24T17:23:12Z","receivedAt":"2020-04-24T17:23:17Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2020-04-24 04:01:32+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> \n> This patch provides the facility to install the built binaries and\n> scripts.\n> \n> This is very similar to `make install`.\n> By default the destination directory(DESTDIR) is /usr/local/ on Linux\n> To set a custom installation path do this:\n> cmake `relative-path-to-srcdir`\n> \t-DCMAKE_INSTALL_PREFIX=`preferred-install-path`\n> \n> Then run `make install`\n> \n> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> ---\n>  CMakeLists.txt | 49 +++++++++++++++++++++++++++++++++++++++++++++++++\n>  1 file changed, 49 insertions(+)\n> \n> diff --git a/CMakeLists.txt b/CMakeLists.txt\n> index 788b53be873..25de5b5bc35 100644\n> --- a/CMakeLists.txt\n> +++ b/CMakeLists.txt\n> @@ -13,6 +13,8 @@ project(git\n>  \tVERSION ${git_version}\n>  \tLANGUAGES C)\n>  \n> +#TODO gitk git-gui gitweb\n> +#TODO Add pcre support\n>  \n>  include(CheckTypeSize)\n>  include(CheckCSourceRuns)\n> @@ -631,3 +633,50 @@ if(MSGFMT_EXE)\n>  \tendforeach()\n>  \tadd_custom_target(po-gen ALL DEPENDS ${po_gen})\n>  endif()\n> +\n> +\n> +#to help with the install\n> +list(TRANSFORM git_shell_scripts PREPEND \"${CMAKE_BINARY_DIR}/\")\n> +list(TRANSFORM git_perl_scripts PREPEND \"${CMAKE_BINARY_DIR}/\")\n> +\n> +#install\n> +install(TARGETS git git-shell\n> +\tRUNTIME DESTINATION bin)\n> +install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver  #${CMAKE_SOURCE_DIR}/gitk-git/gitk check\n\ncheck? What does it mean?\n\n> +\tDESTINATION bin)\n> +\n> +list(REMOVE_ITEM PROGRAMS_BUILT git git-shell)\n> +install(TARGETS ${PROGRAMS_BUILT}\n> +\tRUNTIME DESTINATION libexec/git-core)\n\nUbuntu install exec file to /usr/lib/git-core?\n\n> +\n> +set(bin_links\n> +\tgit-receive-pack git-upload-archive git-upload-pack)\n> +\n> +foreach(b ${bin_links})\n> +install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})\")\n> +endforeach()\n> +\n> +install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)\")\n> +install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)\")\n> +\n> +foreach(b ${git_links})\n> +\tstring(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n> +\tinstall(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n> +endforeach()\n> +\n> +foreach(b ${git_http_links})\n> +\tstring(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n> +\tinstall(CODE \"file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n> +endforeach()\n> +\n> +install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4\n> +\tDESTINATION libexec/git-core)\n> +\n> +install(DIRECTORY mergetools DESTINATION libexec/git-core)\n> +install(DIRECTORY ${CMAKE_BINARY_DIR}/perl/build/lib/ DESTINATION share/perl5\n> +\tFILES_MATCHING PATTERN \"*.pm\")\n\nI think distro gonna complans about this pattern!\n\n> +install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/templates)\n> +\n> +if(MSGFMT_EXE)\n> +\tinstall(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)\n> +endif()\n\nI thought we want to check for NO_GETTEXT?\n\n-- \nDanh\n"},{"id":"396161","messageId":"20200424172823.GK1949@danh.dev","threadId":"53305","inReplyTo":"35a3554df3e4be98f20837ecb08bf6a7a890aadb.1587700897.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 4/8] cmake: support for testing git with ctest","fromName":"Danh Doan","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-04-24T17:28:23Z","receivedAt":"2020-04-24T17:28:37Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2020-04-24 04:01:33+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> \n> This patch provides an alternate way to test git using ctest.\n> CTest ships with CMake, so there is no additional dependency being\n> introduced.\n> \n> To perform the tests with ctest do this after building:\n> ctest -j[number of jobs]\n> \n> NOTE: -j is optional, the default number of jobs is 1\n> \n> Each of the jobs does this:\n> cd t/ && sh t[something].sh\n> \n> The reason for using CTest is that it logs the output of the tests\n> in a neat way, which can be helpful during diagnosis of failures.\n> \n> After the tests have run ctest generates three log files located in\n> `build-directory`/Testing/Temporary/\n> \n> These log files are:\n> \n> CTestCostData.txt:\n> This file contains the time taken to complete each test.\n> \n> LastTestsFailed.log:\n> This log file contains the names of the tests that have failed in the\n> run.\n> \n> LastTest.log:\n> This log file contains the log of all the tests that have run.\n> A snippet of the file is given below.\n> \n> 10/901 Testing: D:/my/git-master/t/t0009-prio-queue.sh\n> 10/901 Test: D:/my/git-master/t/t0009-prio-queue.sh\n> Command: \"sh.exe\" \"D:/my/git-master/t/t0009-prio-queue.sh\"\n> Directory: D:/my/git-master/t\n> \"D:/my/git-master/t/t0009-prio-queue.sh\"\n> Output:\n> ----------------------------------------------------------\n> ok 1 - basic ordering\n> ok 2 - mixed put and get\n> ok 3 - notice empty queue\n> ok 4 - stack order\n> passed all 4 test(s)\n> 1..4\n> <end of output>\n> Test time =   1.11 sec\n> \n> NOTE: Testing only works when building in source for now.\n> \n> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> ---\n>  CMakeLists.txt | 142 +++++++++++++++++++++++++++++++++++++++++++++++++\n>  1 file changed, 142 insertions(+)\n> \n> diff --git a/CMakeLists.txt b/CMakeLists.txt\n> index 25de5b5bc35..141ccefa559 100644\n> --- a/CMakeLists.txt\n> +++ b/CMakeLists.txt\n> @@ -23,6 +23,7 @@ include(CheckIncludeFile)\n>  include(CheckFunctionExists)\n>  include(CheckSymbolExists)\n>  include(CheckStructHasMember)\n> +include(CTest)\n>  \n>  find_package(ZLIB REQUIRED)\n>  find_package(CURL)\n> @@ -680,3 +681,144 @@ install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/\n>  if(MSGFMT_EXE)\n>  \tinstall(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)\n>  endif()\n> +\n> +\n> +if(BUILD_TESTING)\n> +\n> +#tests-helpers\n> +add_executable(test-fake-ssh t/helper/test-fake-ssh.c)\n> +target_link_libraries(test-fake-ssh common-main)\n> +\n> +add_executable(test-line-buffer t/helper/test-line-buffer.c)\n> +target_link_libraries(test-line-buffer common-main vcs-svn)\n> +\n> +add_executable(test-svn-fe t/helper/test-svn-fe.c)\n> +target_link_libraries(test-svn-fe common-main vcs-svn)\n> +\n> +set(test_helper_sources\n> +\tt/helper/test-tool.c t/helper/test-advise.c t/helper/test-bloom.c t/helper/test-chmtime.c\n> +\tt/helper/test-config.c t/helper/test-ctype.c t/helper/test-date.c t/helper/test-delta.c\n> +\tt/helper/test-dir-iterator.c t/helper/test-drop-caches.c t/helper/test-dump-cache-tree.c\n> +\tt/helper/test-dump-fsmonitor.c t/helper/test-dump-split-index.c\n> +\tt/helper/test-dump-untracked-cache.c t/helper/test-example-decorate.c\n> +\tt/helper/test-genrandom.c t/helper/test-genzeros.c t/helper/test-hash.c\n> +\tt/helper/test-hashmap.c t/helper/test-hash-speed.c t/helper/test-index-version.c\n> +\tt/helper/test-json-writer.c t/helper/test-lazy-init-name-hash.c\n> +\tt/helper/test-match-trees.c t/helper/test-mergesort.c t/helper/test-mktemp.c\n> +\tt/helper/test-oidmap.c t/helper/test-online-cpus.c t/helper/test-parse-options.c\n> +\tt/helper/test-parse-pathspec-file.c t/helper/test-path-utils.c t/helper/test-pkt-line.c\n> +\tt/helper/test-prio-queue.c t/helper/test-progress.c t/helper/test-reach.c\n> +\tt/helper/test-read-cache.c t/helper/test-read-graph.c t/helper/test-read-midx.c\n> +\tt/helper/test-ref-store.c t/helper/test-regex.c t/helper/test-repository.c\n> +\tt/helper/test-revision-walking.c t/helper/test-run-command.c t/helper/test-scrap-cache-tree.c\n> +\tt/helper/test-serve-v2.c t/helper/test-sha1.c t/helper/test-oid-array.c t/helper/test-sha256.c\n> +\tt/helper/test-sigchain.c t/helper/test-strcmp-offset.c t/helper/test-string-list.c\n> +\tt/helper/test-submodule-config.c t/helper/test-submodule-nested-repo-config.c t/helper/test-subprocess.c\n> +\tt/helper/test-trace2.c t/helper/test-urlmatch-normalization.c t/helper/test-xml-encode.c\n> +\tt/helper/test-wildmatch.c t/helper/test-windows-named-pipe.c t/helper/test-write-cache.c)\n> +\n> +add_executable(test-tool ${test_helper_sources})\n> +target_link_libraries(test-tool common-main)\n> +\n> +set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool\n> +\t\t\tPROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)\n> +\n> +#wrapper scripts\n> +set(wrapper_scripts\n> +\tgit git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)\n> +\n> +set(wrapper_test_scripts\n> +\ttest-fake-ssh test-line-buffer test-svn-fe test-tool)\n> +\n> +\n> +foreach(script ${wrapper_scripts})\n> +\tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n> +\tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n> +\tstring(REPLACE \"@@PROG@@\" \"${script}\" content \"${content}\")\n> +\tfile(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n> +endforeach()\n> +\n> +foreach(script ${wrapper_test_scripts})\n> +\tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n> +\tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n> +\tstring(REPLACE \"@@PROG@@\" \"t/helper/${script}\" content \"${content}\")\n> +\tfile(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n> +endforeach()\n> +\n> +file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n> +string(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n> +string(REPLACE \"@@PROG@@\" \"git-cvsserver\" content \"${content}\")\n> +file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})\n> +\n> +#options for configuring test options\n> +option(PERL_TESTS \"Perform tests that use perl\" ON)\n> +option(PYTHON_TESTS \"Perform tests that use python\" ON)\n> +\n> +#GIT-BUILD-OPTIONS\n> +set(TEST_SHELL_PATH ${SHELL_PATH})\n> +set(DIFF diff)\n> +set(PYTHON_PATH /usr/bin/python)\n> +set(TAR tar)\n> +set(NO_CURL )\n> +set(NO_EXPAT )\n> +set(USE_LIBPCRE1 )\n> +set(USE_LIBPCRE2 )\n\nHm, really?\n\n\n> +set(NO_LIBPCRE1_JIT )\n> +set(NO_PERL )\n> +set(NO_PTHREADS )\n> +set(NO_PYTHON )\n> +set(PAGER_ENV \"LESS=FRX LV=-c\")\n> +set(DC_SHA1 YesPlease)\n> +set(RUNTIME_PREFIX true)\n> +set(NO_GETTEXT )\n> +\n> +if(NOT CURL_FOUND)\n> +\tset(NO_CURL 1)\n> +endif()\n> +\n> +if(NOT EXPAT_FOUND)\n> +\tset(NO_EXPAT 1)\n> +endif()\n> +\n> +if(NOT Intl_FOUND)\n> +\tset(NO_GETTEXT 1)\n> +endif()\n> +\n> +if(NOT PERL_TESTS)\n> +\tset(NO_PERL 1)\n> +endif()\n> +\n> +if(NOT PYTHON_TESTS)\n> +\tset(NO_PYTHON 1)\n> +endif()\n\nI hope we have something like:\n\nPYTHON_PATH=/path/to/my/yet/to/release/python/to/check/if/it/works/with/current/git\n\nIf it's ready, thanks.\nIf it isn't, no, I'm stressed enough by CMake.\n\n> +\n> +file(WRITE ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"SHELL_PATH='${SHELL_PATH}'\\n\")\n> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"TEST_SHELL_PATH='${TEST_SHELL_PATH}'\\n\")\n> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PERL_PATH='${PERL_PATH}'\\n\")\n> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"DIFF='${DIFF}'\\n\")\n> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PYTHON_PATH='${PYTHON_PATH}'\\n\")\n> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"TAR='${TAR}'\\n\")\n> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_CURL='${NO_CURL}'\\n\")\n> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_EXPAT='${NO_EXPAT}'\\n\")\n> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"USE_LIBPCRE1='${USE_LIBPCRE1}'\\n\")\n> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_LIBPCRE1_JIT='${NO_LIBPCRE1_JIT}'\\n\")\n> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PERL='${NO_PERL}'\\n\")\n> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PTHREADS='${NO_PTHREADS}'\\n\")\n> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\\n\")\n> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PAGER_ENV='${PAGER_ENV}'\\n\")\n> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"DC_SHA1='${DC_SHA1}'\\n\")\n> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"X=''\\n\")\n> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_GETTEXT='${NO_GETTEXT}'\\n\")\n> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"RUNTIME_PREFIX='${RUNTIME_PREFIX}'\\n\")\n> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PYTHON='${NO_PYTHON}'\\n\")\n> +\n> +file(GLOB test_scipts \"${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh\")\n\nCMake recommends to not use GLOB for this kind of things, themselves, no?\n\n> +\n> +#test\n> +foreach(tsh ${test_scipts})\n> +\tadd_test(NAME ${tsh}\n> +\t\tCOMMAND ${SH_EXE} ${tsh}\n> +\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t)\n> +endforeach()\n> +\n> +endif()#BUILD_TESTING\n> \\ No newline at end of file\n\nPlease fix your editor!\n\n-- \nDanh\n"},{"id":"396164","messageId":"20200424173433.GL1949@danh.dev","threadId":"53305","inReplyTo":"166b78f71755bb3f9967b32bfe282210c2bb240d.1587700897.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 5/8] cmake: support for testing git when building out of the source tree","fromName":"Danh Doan","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-04-24T17:34:33Z","receivedAt":"2020-04-24T17:34:38Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2020-04-24 04:01:34+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> \n> This patch allows git to be tested when performin out of source builds.\n> \n> This involves changing GIT_BUILD_DIR in t/test-lib.sh to point to the\n> build directory. Also some miscellaneous copies from the source directory\n> to the build directory.\n> The copies are:\n> t/chainlint.sed needed by a bunch of test scripts\n> po/is.po needed by t0204-gettext-rencode-sanity\n> mergetools/tkdiff needed by t7800-difftool\n> contrib/completion/git-prompt.sh needed by t9903-bash-prompt\n> contrib/completion/git-completion.bash needed by t9902-completion\n> contrib/svn-fe/svnrdump_sim.py needed by t9020-remote-svn\n> \n> NOTE: t/test-lib.sh is only modified when tests are run not during\n> the build or configure.\n> The trash directory is still srcdir/t\n> \n> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> ---\n>  CMakeLists.txt | 19 +++++++++++++++++++\n>  1 file changed, 19 insertions(+)\n> \n> diff --git a/CMakeLists.txt b/CMakeLists.txt\n> index 141ccefa559..29a23eb11f7 100644\n> --- a/CMakeLists.txt\n> +++ b/CMakeLists.txt\n> @@ -812,6 +812,25 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_GETTEXT='${NO_GETTEXT}'\\n\"\n>  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"RUNTIME_PREFIX='${RUNTIME_PREFIX}'\\n\")\n>  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PYTHON='${NO_PYTHON}'\\n\")\n>  \n> +#Make the tests work when building out of the source tree\n> +if(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})\n\nIIRC, CMake recommends _NOT_ expand variable inside if()\nThis very inconsistent recommendation of CMake (when should I use\n${var} and when should I use var?) is one of reason I hate CMake\n\n> +\tfile(RELATIVE_PATH BUILD_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/CMakeCache.txt)\n> +\tstring(REPLACE \"/CMakeCache.txt\" \"\" BUILD_DIR_RELATIVE ${BUILD_DIR_RELATIVE})\n\nI don't know what is going on here!\n\n> +\t#Setting the build directory in test-lib.sh before running tests\n> +\tfile(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.cmake\n> +\t\t\"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh GIT_BUILD_DIR_REPL REGEX \\\"GIT_BUILD_DIR=(.*)\\\")\\n\"\n> +\t\t\"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh content NEWLINE_CONSUME)\\n\"\n> +\t\t\"string(REPLACE \\\"\\${GIT_BUILD_DIR_REPL}\\\" \\\"GIT_BUILD_DIR=\\\\\\\"$TEST_DIRECTORY\\\\\\\"/../${BUILD_DIR_RELATIVE}\\\" content \\\"\\${content}\\\")\\n\"\n> +\t\t\"file(WRITE ${CMAKE_SOURCE_DIR}/t/test-lib.sh \\${content})\")\n> +\t#misc copies\n> +\tfile(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.sed DESTINATION ${CMAKE_BINARY_DIR}/t/)\n\nSo, some sed will be used in Windows without POSIX-like system,\ninteresting!\n\n> +\tfile(COPY ${CMAKE_SOURCE_DIR}/po/is.po DESTINATION ${CMAKE_BINARY_DIR}/po/)\n> +\tfile(COPY ${CMAKE_SOURCE_DIR}/mergetools/tkdiff DESTINATION ${CMAKE_BINARY_DIR}/mergetools/)\n> +\tfile(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-prompt.sh DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)\n> +\tfile(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-completion.bash DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)\n> +\tfile(COPY ${CMAKE_SOURCE_DIR}/contrib/svn-fe/svnrdump_sim.py DESTINATION ${CMAKE_BINARY_DIR}/contrib/svn-fe/)\n> +endif()\n> +\n>  file(GLOB test_scipts \"${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh\")\n\nRemember cmake won't be re-run if nothing was changed in CMakeList.txt\nIf I only change some code, and I decided the change I make should be\ntested by a-new-and-independent-test-script.\nI need to re-run cmake manually! I don't like it, at all.\n\n\n-- \nDanh\n"},{"id":"396165","messageId":"3fd87ba7-654c-ff5e-2951-7bbbe3c5d119@iee.email","threadId":"53305","inReplyTo":"d6c630028bf43ea74ef1ac3b60d49aea252b3f4b.1587700897.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 6/8] cmake: support for building git on windows with mingw","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.email","sentAt":"2020-04-24T17:39:18Z","receivedAt":"2020-04-24T17:39:33Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"Hi Sibi,\n\nOn 24/04/2020 05:01, Sibi Siddharthan via GitGitGadget wrote:\n> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n>\n> This patch facilitates building git on Windows with CMake using MinGW\n>\n> NOTE: The funtions unsetenv and hstrerror are not checked in Windows\n> builds.\n> Reasons\n> NO_UNSETENV is not compatible with Windows builds.\n> lines 262-264 compat/mingw.h\n>\n> compat/mingw.h(line 25) provides a definition of hstrerror which\n> conflicts with the definition provided in\n> git-compat-util.h(lines 733-736).\n>\n> To use CMake on Windows with MinGW do this:\n> cmake `relative-path-to-srcdir` -G \"MinGW Makefiles\"\n>\n> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> ---\n>  CMakeLists.txt | 120 +++++++++++++++++++++++++++++++++++++++----------\n>  1 file changed, 97 insertions(+), 23 deletions(-)\n>\n> diff --git a/CMakeLists.txt b/CMakeLists.txt\n> index 29a23eb11f7..d9eb1060390 100644\n> --- a/CMakeLists.txt\n> +++ b/CMakeLists.txt\n> @@ -13,9 +13,12 @@ project(git\n>  \tVERSION ${git_version}\n>  \tLANGUAGES C)\n>  \n> +\n>  #TODO gitk git-gui gitweb\n> +#TODO Enable NLS on windows natively\n>  #TODO Add pcre support\n>  \n> +\n>  include(CheckTypeSize)\n>  include(CheckCSourceRuns)\n>  include(CheckCSourceCompiles)\n> @@ -31,6 +34,7 @@ find_package(EXPAT)\n>  find_package(Iconv)\n>  find_package(Intl)\n>  \n> +\n>  if(NOT Intl_FOUND)\n>  \tadd_compile_definitions(NO_GETTEXT)\n>  \tif(NOT Iconv_FOUND)\n> @@ -53,6 +57,16 @@ if(Intl_FOUND)\n>  endif()\n>  \n>  find_program(SH_EXE sh)\n> +if(NOT SH_EXE)\n> +\tmessage(FATAL_ERROR \"sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/\")\nEither the error message or the web page it points to need to coordinate\non the 'sh interpreter' reference to help the script kiddies follow the\nthread. At the moment there is no 'interp..' on the gitforwindows web\npage. Would someone attempting to use cmake need to use the Download or\nthe Contribute buttons, or some other route to acquire the missing SH_EXE?\n\n(this is also a context line in the next patch)\n> +endif()\n> +\n> +if(WIN32)\n> +\tfind_program(WINDRES_EXE windres)\n> +\tif(NOT WINDRES_EXE)\n> +\t\tmessage(FATAL_ERROR \"Install windres on Windows for resource files\")\n> +\tendif()\n> +endif()\n>  \n>  find_program(MSGFMT_EXE msgfmt)\n>  if(NOT MSGFMT_EXE)\n> @@ -85,11 +99,39 @@ add_compile_definitions(PAGER_ENV=\"LESS=FRX LV=-c\"\n>  \t\t\tBINDIR=\"bin\"\n>  \t\t\tGIT_BUILT_FROM_COMMIT=\"\")\n>  \n> -set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n> -add_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n> +if(WIN32)\n> +\tset(FALLBACK_RUNTIME_PREFIX /mingw64)\n> +\tadd_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n> +else()\n> +\tset(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n> +\tadd_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n> +endif()\n>  \n> -add_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n> -list(APPEND compat_SOURCES unix-socket.c)\n> +\n> +#Platform Specific\n> +if(${CMAKE_SYSTEM_NAME} STREQUAL \"Windows\")\n> +\tinclude_directories(compat/win32)\n> +\tadd_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32\n> +\t\t\t\t_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=\".exe\"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT\n> +\t\t\t\tNOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0 NO_ST_BLOCKS_IN_STRUCT_STAT\n> +\t\t\t\tUSE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP\n> +\t\t\t\tUNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)\n> +\tlist(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c\n> +\t\tcompat/win32/pthread.c compat/win32mmap.c compat/win32/syslog.c\n> +\t\tcompat/win32/trace2_win32_process_info.c compat/win32/dirent.c\n> +\t\tcompat/nedmalloc/nedmalloc.c compat/strdup.c)\n> +\tset(NO_UNIX_SOCKETS 1)\n> +\n> +elseif(${CMAKE_SYSTEM_NAME} STREQUAL \"Linux\")\n> +\tadd_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n> +\tlist(APPEND compat_SOURCES unix-socket.c)\n> +endif()\n> +\n> +if(WIN32)\n> +\tset(EXE_EXTENSION .exe)\n> +else()\n> +\tset(EXE_EXTENSION)\n> +endif()\n>  \n>  #header checks\n>  check_include_file(libgen.h HAVE_LIBGEN_H)\n> @@ -150,7 +192,12 @@ endif()\n>  #function checks\n>  set(function_checks\n>  \tstrcasestr memmem strlcpy strtoimax strtoumax strtoull\n> -\tsetenv  mkdtemp poll pread  memmem unsetenv hstrerror)\n> +\tsetenv  mkdtemp poll pread  memmem)\n> +\n> +#unsetenv,hstrerror are incompatible with windows build\n> +if(NOT WIN32)\n> +\tlist(APPEND function_checks unsetenv hstrerror)\n> +endif()\n>  \n>  foreach(f ${function_checks})\n>  \tstring(TOUPPER ${f} uf)\n> @@ -309,7 +356,13 @@ endif()\n>  #programs\n>  set(PROGRAMS_BUILT\n>  \tgit git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst\n> -\tgit-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)\n> +\tgit-shell git-remote-testsvn)\n> +\n> +if(NO_UNIX_SOCKETS)\n> +\tlist(APPEND excluded_progs git-credential-cache git-credential-cache--daemon)\n> +else()\n> +\tlist(APPEND PROGRAMS_BUILT git-credential-cache git-credential-cache--daemon)\n> +endif()\n>  \n>  if(NOT CURL_FOUND)\n>  \tlist(APPEND excluded_progs git-http-fetch git-http-push)\n> @@ -410,15 +463,34 @@ set(libvcs-svn_SOURCES\n>  \tvcs-svn/svndiff.c vcs-svn/svndump.c)\n>  add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})\n>  \n> +#add git.rc for gcc\n> +if(WIN32)\n> +\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n> +\t\t\tCOMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}\n> +\t\t\t\t-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION=\"\\\\\\\"${PROJECT_VERSION}.GIT\\\\\\\"\"\n> +\t\t\t\t-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res\n> +\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n> +\t\t\tVERBATIM)\n> +\tadd_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)\n> +endif()\n> +\n>  #link all required libraries to common-main\n>  add_library(common-main OBJECT common-main.c)\n> -target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)\n> +\n> +target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})\n>  if(Intl_FOUND)\n>  \ttarget_link_libraries(common-main ${Intl_LIBRARIES})\n>  endif()\n>  if(Iconv_FOUND)\n>  \ttarget_link_libraries(common-main ${Iconv_LIBRARIES})\n>  endif()\n> +if(WIN32)\n> +\ttarget_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)\n> +\tadd_dependencies(common-main git-rc)\n> +\ttarget_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)\n> +elseif(UNIX)\n> +\ttarget_link_libraries(common-main pthread rt)\n> +endif()\n>  \n>  \n>  set(git_SOURCES\n> @@ -501,11 +573,13 @@ endif()\n>  add_executable(git-remote-testsvn remote-testsvn.c)\n>  target_link_libraries(git-remote-testsvn common-main vcs-svn)\n>  \n> -add_executable(git-credential-cache credential-cache.c)\n> -target_link_libraries(git-credential-cache common-main)\n> +if(NOT NO_UNIX_SOCKETS)\n> +\tadd_executable(git-credential-cache credential-cache.c)\n> +\ttarget_link_libraries(git-credential-cache common-main)\n>  \n> -add_executable(git-credential-cache--daemon credential-cache--daemon.c)\n> -target_link_libraries(git-credential-cache--daemon common-main)\n> +\tadd_executable(git-credential-cache--daemon credential-cache--daemon.c)\n> +\ttarget_link_libraries(git-credential-cache--daemon common-main)\n> +endif()\n>  \n>  \n>  set(git_builtin_extra\n> @@ -517,16 +591,16 @@ set(git_builtin_extra\n>  foreach(s ${git_SOURCES} ${git_builtin_extra})\n>  \tstring(REPLACE \"builtin/\" \"\" s ${s})\n>  \tstring(REPLACE \".c\" \"\" s ${s})\n> -\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git git-${s})\\n\")\n> -\tlist(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})\n> +\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git${EXE_EXTENSION} git-${s}${EXE_EXTENSION})\\n\")\n> +\tlist(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s}${EXE_EXTENSION})\n>  endforeach()\n>  \n>  if(CURL_FOUND)\n>  \tset(remote_exes\n>  \t\tgit-remote-https git-remote-ftp git-remote-ftps)\n>  \tforeach(s ${remote_exes})\n> -\t\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git-remote-http ${s})\\n\")\n> -\t\tlist(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})\n> +\t\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git-remote-http${EXE_EXTENSION} ${s}${EXE_EXTENSION})\\n\")\n> +\t\tlist(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s}${EXE_EXTENSION})\n>  \tendforeach()\n>  endif()\n>  \n> @@ -654,20 +728,20 @@ set(bin_links\n>  \tgit-receive-pack git-upload-archive git-upload-pack)\n>  \n>  foreach(b ${bin_links})\n> -install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})\")\n> +install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/bin/${b}${EXE_EXTENSION})\")\n>  endforeach()\n>  \n> -install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)\")\n> -install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)\")\n> +install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git${EXE_EXTENSION})\")\n> +install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell${EXE_EXTENSION})\")\n>  \n>  foreach(b ${git_links})\n>  \tstring(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n> -\tinstall(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n> +\tinstall(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})\")\n>  endforeach()\n>  \n>  foreach(b ${git_http_links})\n>  \tstring(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n> -\tinstall(CODE \"file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n> +\tinstall(CODE \"file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})\")\n>  endforeach()\n>  \n>  install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4\n> @@ -734,14 +808,14 @@ set(wrapper_test_scripts\n>  foreach(script ${wrapper_scripts})\n>  \tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n>  \tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n> -\tstring(REPLACE \"@@PROG@@\" \"${script}\" content \"${content}\")\n> +\tstring(REPLACE \"@@PROG@@\" \"${script}${EXE_EXTENSION}\" content \"${content}\")\n>  \tfile(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n>  endforeach()\n>  \n>  foreach(script ${wrapper_test_scripts})\n>  \tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n>  \tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n> -\tstring(REPLACE \"@@PROG@@\" \"t/helper/${script}\" content \"${content}\")\n> +\tstring(REPLACE \"@@PROG@@\" \"t/helper/${script}${EXE_EXTENSION}\" content \"${content}\")\n>  \tfile(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n>  endforeach()\n>  \n> @@ -807,7 +881,7 @@ 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\")\n>  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PAGER_ENV='${PAGER_ENV}'\\n\")\n>  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"DC_SHA1='${DC_SHA1}'\\n\")\n> -file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"X=''\\n\")\n> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"X='${EXE_EXTENSION}'\\n\")\n>  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_GETTEXT='${NO_GETTEXT}'\\n\")\n>  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"RUNTIME_PREFIX='${RUNTIME_PREFIX}'\\n\")\n>  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PYTHON='${NO_PYTHON}'\\n\")\n\n"},{"id":"396166","messageId":"20200424173951.GM1949@danh.dev","threadId":"53305","inReplyTo":"0577d7bf0a84f94396bd956bd7f6bbc711d3bf26.1587700897.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 7/8] cmake: support for building git on windows with msvc and clang.","fromName":"Danh Doan","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-04-24T17:39:51Z","receivedAt":"2020-04-24T17:39:56Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2020-04-24 04:01:36+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> \n> This patch adds support for Visual Studio and Clang builds\n> \n> The minimum required version of CMake is upgraded to 3.15 because\n> this version offers proper support for Clang builds on Windows.\n> \n> Libintl is not searched for when building with Visual Studio or Clang\n> because there is no binary compatible version available yet.\n> \n> NOTE: In the link options invalidcontinue.obj has to be included.\n> The reason for this is because by default, Windows calls abort()'s\n> instead of setting errno=EINVAL when invalid arguments are passed to\n> standard functions.\n> This commit explains it in detail:\n> 4b623d80f73528a632576990ca51e34c333d5dd6\n> \n> On Windows the default generator is Visual Studio,so for Visual Studio\n> builds do this:\n> \n> cmake `relative-path-to-srcdir`\n> \n> NOTE: Visual Studio generator is a multi config generator, which means\n> that Debug and Release builds can be done on the same build directory.\n> \n> For Clang builds do this:\n> \n> On bash\n> CC=Clang cmake `relative-path-to-srcdir` -G Ninja\n> \t\t-DCMAKE_BUILD_TYPE=[Debug or Release]\n> \n> On cmd\n> set CC=Clang\n> cmake `relative-path-to-srcdir` -G Ninja\n> \t\t-DCMAKE_BUILD_TYPE=[Debug or Release]\n> \n> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> ---\n>  CMakeLists.txt | 57 ++++++++++++++++++++++++++++++++++++++++----------\n>  1 file changed, 46 insertions(+), 11 deletions(-)\n> \n> diff --git a/CMakeLists.txt b/CMakeLists.txt\n> index d9eb1060390..5ad3a2557f7 100644\n> --- a/CMakeLists.txt\n> +++ b/CMakeLists.txt\n> @@ -2,7 +2,7 @@\n>  #\tCopyright (c) 2020 Sibi Siddharthan\n>  #\n>  \n> -cmake_minimum_required(VERSION 3.14)\n> +cmake_minimum_required(VERSION 3.15)\n\n3.14 is a step too far, and, now, we want CMake 3.15?\n\n>  \n>  #Parse GIT-VERSION-GEN to get the version\n>  file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX \"DEF_VER=v(.*)\")\n> @@ -32,8 +32,11 @@ find_package(ZLIB REQUIRED)\n>  find_package(CURL)\n>  find_package(EXPAT)\n>  find_package(Iconv)\n> -find_package(Intl)\n>  \n> +#Don't use libintl on Windows Visual Studio and Clang builds\n> +if(NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL \"MSVC\" OR CMAKE_C_COMPILER_ID STREQUAL \"Clang\")))\n> +\tfind_package(Intl)\n> +endif()\n>  \n>  if(NOT Intl_FOUND)\n>  \tadd_compile_definitions(NO_GETTEXT)\n> @@ -61,7 +64,7 @@ if(NOT SH_EXE)\n>  \tmessage(FATAL_ERROR \"sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/\")\n>  endif()\n>  \n> -if(WIN32)\n> +if(WIN32 AND NOT MSVC)#not required for visual studio builds\n>  \tfind_program(WINDRES_EXE windres)\n>  \tif(NOT WINDRES_EXE)\n>  \t\tmessage(FATAL_ERROR \"Install windres on Windows for resource files\")\n> @@ -73,6 +76,13 @@ if(NOT MSGFMT_EXE)\n>  \tmessage(WARNING \"Text Translations won't be build\")\n>  endif()\n>  \n> +#Force all visual studio outputs to CMAKE_BINARY_DIR\n> +if(CMAKE_C_COMPILER_ID STREQUAL \"MSVC\")\n> +\tset(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})\n> +\tset(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})\n> +\tadd_compile_options(/MP)\n> +endif()\n> +\n>  #default behaviour\n>  include_directories(${CMAKE_SOURCE_DIR})\n>  add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n> @@ -110,6 +120,10 @@ endif()\n>  \n>  #Platform Specific\n>  if(${CMAKE_SYSTEM_NAME} STREQUAL \"Windows\")\n> +\tif(CMAKE_C_COMPILER_ID STREQUAL \"MSVC\" OR CMAKE_C_COMPILER_ID STREQUAL \"Clang\")\n> +\t\tinclude_directories(compat/vcbuild/include)\n> +\t\tadd_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)\n\nThis is fair, I hate those warning, too.\n\nIs _CRT_NONSTDC_NO_DEPRECATE implied when _CRT_SECURE_NO_WARNINGS\ndefined? Or otherwise around?\n\n\n-- \nDanh\n"},{"id":"396167","messageId":"20200424174544.GN1949@danh.dev","threadId":"53305","inReplyTo":"f0294be3f1151526fe002a55fb79015bd35606b2.1587700897.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 8/8] ci: modification of main.yml to use cmake for vs-build job","fromName":"Danh Doan","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-04-24T17:45:44Z","receivedAt":"2020-04-24T17:45:48Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2020-04-24 04:01:37+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> \n> This patch modifies .github/workflows/main.yml to use CMake for\n> Visual Studio builds.\n> \n> Modified the vs-test step to match windows-test step. This speeds\n> up the vs-test. Calling git-cmd from powershell and then calling git-bash\n> to perform the tests slows things down(factor of about 6). So git-bash\n> is directly called from powershell to perform the tests using prove.\n> \n> NOTE: Since GitHub keeps the same directory for each job\n> (with respect to path) absolute paths are used in the bin-wrapper\n> scripts.\n> \n> GitHub has switched to CMake 3.17.1 which changed the behaviour of\n> FindCURL module. An extra definition (-DCURL_NO_CURL_CMAKE=ON) has been\n> added to revert to the old behaviour.\n> \n> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> ---\n>  .github/workflows/main.yml | 43 ++++++++++++++++++++++----------------\n>  1 file changed, 25 insertions(+), 18 deletions(-)\n> \n> diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml\n> index fd4df939b50..94f9a385225 100644\n> --- a/.github/workflows/main.yml\n> +++ b/.github/workflows/main.yml\n> @@ -80,13 +80,6 @@ jobs:\n>      - name: download git-sdk-64-minimal\n>        shell: bash\n>        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 -\n> -    - name: generate Visual Studio solution\n> -      shell: powershell\n> -      run: |\n> -        & .\\git-sdk-64-minimal\\usr\\bin\\bash.exe -lc @\"\n> -          make NDEBUG=1 DEVELOPER=1 vcxproj\n> -        \"@\n> -        if (!$?) { exit(1) }\n>      - name: download vcpkg artifacts\n>        shell: powershell\n>        run: |\n> @@ -98,6 +91,13 @@ jobs:\n>          Remove-Item compat.zip\n>      - name: add msbuild to PATH\n>        uses: microsoft/setup-msbuild@v1.0.0\n> +    - name: generate Visual Studio solution\n> +      shell: powershell\n> +      run: |\n> +        & .\\git-sdk-64-minimal\\usr\\bin\\bash.exe -lc @\"\n> +          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\n> +        \"@\n> +        if (!$?) { exit(1) }\n\nIf you intended to modified some steps to provide a better script for\nthat step, I believe you should change in that step.\n\nIf the order of those steps need to be changed, please clarify your\nreasoning!\n\n>      - name: MSBuild\n>        run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142\n>      - name: bundle artifact tar\n> @@ -125,9 +125,9 @@ jobs:\n>          nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n>      steps:\n>      - uses: actions/checkout@v1\n> -    - name: download git-64-portable\n> +    - name: download git-sdk-64-minimal\n>        shell: bash\n> -      run: a=git-64-portable && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -\n> +      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 -\n>      - name: download build artifacts\n>        uses: actions/download-artifact@v1\n>        with:\n> @@ -136,23 +136,30 @@ jobs:\n>      - name: extract build artifacts\n>        shell: bash\n>        run: tar xf artifacts.tar.gz\n> -    - name: test (parallel)\n> +    - name: test\n\nSo the test couldn't be run in parallel anymore?\nIt's a regression!\nAnd we don't need the matrix anymore!!!!!\n\nI wonder if Dscho's effort is wasted, he tried very hard to make\nthose tests run in parallel.\nHe even tried to re-order the matrix in GfW project to let longest\ntest run first!\n\n\n>        shell: powershell\n>        env:\n>          MSYSTEM: MINGW64\n>          NO_SVN_TESTS: 1\n>          GIT_TEST_SKIP_REBASE_P: 1\n>        run: |\n> -        & git-64-portable\\git-cmd.exe --command=usr\\bin\\bash.exe -lc @\"\n> -          # Let Git ignore the SDK and the test-cache\n> -          printf '%s\\n' /git-64-portable/ /test-cache/ >>.git/info/exclude\n> +        & .\\git-sdk-64-minimal\\usr\\bin\\bash.exe -lc @\"\n> +          # Let Git ignore the SDK\n> +          printf '%s\\n' /git-sdk-64-minimal/ >>.git/info/exclude\n>  \n> -          cd t &&\n> -          PATH=\\\"`$PWD/helper:`$PATH\\\" &&\n> -          test-tool.exe run-command testsuite --jobs=10 -V -x --write-junit-xml \\\n> -                  `$(test-tool.exe path-utils slice-tests \\\n> -                          ${{matrix.nr}} 10 t[0-9]*.sh)\n> +          ci/run-test-slice.sh ${{matrix.nr}} 10\n>          \"@\n> +    - name: ci/print-test-failures.sh\n> +      if: failure()\n> +      shell: powershell\n> +      run: |\n> +        & .\\git-sdk-64-minimal\\usr\\bin\\bash.exe -lc ci/print-test-failures.sh\n\nWhat is changed?\n\n-- \nDanh\n"},{"id":"396169","messageId":"xmqqv9lod85m.fsf@gitster.c.googlers.com","threadId":"53305","inReplyTo":"pull.614.git.1587700897.gitgitgadget@gmail.com","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-04-24T18:56:53Z","receivedAt":"2020-04-24T18:57:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Sibi Siddharthan via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> This is an attempt to build Git using CMake.\n\nWhat is your longer-term plan on this one?  Would the ultimate goal\nbe \n\n (1) to maintain both CMake and Makefile and keep them in sync?\n\n (2) force all the Git developers (not users or binary packagers)\n     start using cmake and abandon Makefile, and let CMake generate\n     Makefile?\n\n (3) something else?\n\nGiven that bootstrapping CMake typically takes a working \"make\", by\ndefinition, if you drop Makefile from our shipped source tree, the\naudience you can support on minority platforms would be smaller than\nwhat we have.  It is not negotiable that we keep Makefile as a valid\nway to build Git, and the Makefile must be tweakable for those on a\nminority platforms when things do not go the way they want to (the\ntweakability is most needed on minority/exotic platforms).\n\nW ith either (1) or (2) above, I have a feeling that engineering\nburden to divert resources to add cmake support (with sustainable\nplan to keep \"fixable/tweakable\" Makefile that is in sync) alone\nwould already be high enough.  It is unclear the reason why we want\nto pay all that cost---to gain what?  Other than to make those who\nlike CMake feel happier, that is.\n\nI do not want to sound overly negative in my first response, but you\nmight thank whoever says \"no\" early before you invest too much time\non this topic, so I'll send the above before even reading these 8\npatches.\n\nThanks for your interest in the project.\n\n"},{"id":"396170","messageId":"CAKiG+9V_nZUXf2a689vZ54rG+xTCFMGcJe_7Av-khaxxuijERg@mail.gmail.com","threadId":"53305","inReplyTo":"xmqqv9lod85m.fsf@gitster.c.googlers.com","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-04-24T19:50:27Z","receivedAt":"2020-04-24T19:50:41Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Sat, Apr 25, 2020 at 12:26 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> \"Sibi Siddharthan via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>\n> > This is an attempt to build Git using CMake.\n>\n> What is your longer-term plan on this one?  Would the ultimate goal\n> be\n>\n>  (1) to maintain both CMake and Makefile and keep them in sync?\n>\n>  (2) force all the Git developers (not users or binary packagers)\n>      start using cmake and abandon Makefile, and let CMake generate\n>      Makefile?\n>\n>  (3) something else?\n>\n> Given that bootstrapping CMake typically takes a working \"make\", by\n> definition, if you drop Makefile from our shipped source tree, the\n> audience you can support on minority platforms would be smaller than\n> what we have.  It is not negotiable that we keep Makefile as a valid\n> way to build Git, and the Makefile must be tweakable for those on a\n> minority platforms when things do not go the way they want to (the\n> tweakability is most needed on minority/exotic platforms).\n>\n> W ith either (1) or (2) above, I have a feeling that engineering\n> burden to divert resources to add cmake support (with sustainable\n> plan to keep \"fixable/tweakable\" Makefile that is in sync) alone\n> would already be high enough.  It is unclear the reason why we want\n> to pay all that cost---to gain what?  Other than to make those who\n> like CMake feel happier, that is.\n>\n> I do not want to sound overly negative in my first response, but you\n> might thank whoever says \"no\" early before you invest too much time\n> on this topic, so I'll send the above before even reading these 8\n> patches.\n>\n> Thanks for your interest in the project.\n>\n\nHi Junio,\n\nThe goal would be to maintain a CMake build for Git keeping it in sync\nwith the Makefile.\nThe Makefile is not going to be replaced at all. The CMake script for\nnow only supports Linux and Windows.\nIt does not support BSD, Solaris and others, whereas the Makefile does\nsupport them.\n\nThe reason for introducing CMake is primarily for compiling git on\nWindows and to do out of source builds.\nI think the CMake script makes it easier to build Git as it does the\nnecessary function and header checks and generates the\nrequired compile definitions.\n\nI would like to say that the proposed CMake build system is meant to\ncomplement the currently used Makefile, not to replace it at all.\n\nThank You,\nSibi Siddharthan\n\nPS: Sorry for the multiple emails:)\n"},{"id":"396178","messageId":"CAKiG+9V9N5zV=dxZwVmAaEFYQbswnSNLVqKMx5ti=zaPatZdkg@mail.gmail.com","threadId":"53305","inReplyTo":"3fd87ba7-654c-ff5e-2951-7bbbe3c5d119@iee.email","subject":"Re: [PATCH 6/8] cmake: support for building git on windows with mingw","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-04-24T20:29:24Z","receivedAt":"2020-04-24T20:35:30Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"Hi Philip,\n\nOn Fri, Apr 24, 2020 at 11:09 PM Philip Oakley <philipoakley@iee.email> wrote:\n>\n> Hi Sibi,\n>\n> On 24/04/2020 05:01, Sibi Siddharthan via GitGitGadget wrote:\n> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> >\n> > This patch facilitates building git on Windows with CMake using MinGW\n> >\n> > NOTE: The funtions unsetenv and hstrerror are not checked in Windows\n> > builds.\n> > Reasons\n> > NO_UNSETENV is not compatible with Windows builds.\n> > lines 262-264 compat/mingw.h\n> >\n> > compat/mingw.h(line 25) provides a definition of hstrerror which\n> > conflicts with the definition provided in\n> > git-compat-util.h(lines 733-736).\n> >\n> > To use CMake on Windows with MinGW do this:\n> > cmake `relative-path-to-srcdir` -G \"MinGW Makefiles\"\n> >\n> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> > ---\n> >  CMakeLists.txt | 120 +++++++++++++++++++++++++++++++++++++++----------\n> >  1 file changed, 97 insertions(+), 23 deletions(-)\n> >\n> > diff --git a/CMakeLists.txt b/CMakeLists.txt\n> > index 29a23eb11f7..d9eb1060390 100644\n> > --- a/CMakeLists.txt\n> > +++ b/CMakeLists.txt\n> > @@ -13,9 +13,12 @@ project(git\n> >       VERSION ${git_version}\n> >       LANGUAGES C)\n> >\n> > +\n> >  #TODO gitk git-gui gitweb\n> > +#TODO Enable NLS on windows natively\n> >  #TODO Add pcre support\n> >\n> > +\n> >  include(CheckTypeSize)\n> >  include(CheckCSourceRuns)\n> >  include(CheckCSourceCompiles)\n> > @@ -31,6 +34,7 @@ find_package(EXPAT)\n> >  find_package(Iconv)\n> >  find_package(Intl)\n> >\n> > +\n> >  if(NOT Intl_FOUND)\n> >       add_compile_definitions(NO_GETTEXT)\n> >       if(NOT Iconv_FOUND)\n> > @@ -53,6 +57,16 @@ if(Intl_FOUND)\n> >  endif()\n> >\n> >  find_program(SH_EXE sh)\n> > +if(NOT SH_EXE)\n> > +     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/\")\n> Either the error message or the web page it points to need to coordinate\n> on the 'sh interpreter' reference to help the script kiddies follow the\n> thread. At the moment there is no 'interp..' on the gitforwindows web\n> page. Would someone attempting to use cmake need to use the Download or\n> the Contribute buttons, or some other route to acquire the missing SH_EXE?\n>\nOn Windows, if you are using Git Bash, then you don't have a problem.\nThis message was for people trying to Git on Windows without a bash shell.\n\nI can rephrase the message saying\n\"On Windows go to https://gitforwindows.org/ and download the Git\ninstaller which ships with a sh interpreter(bash).\"\n\nWould you suggest something else?\n\n> (this is also a context line in the next patch)\n> > +endif()\n> > +\n> > +if(WIN32)\n> > +     find_program(WINDRES_EXE windres)\n> > +     if(NOT WINDRES_EXE)\n> > +             message(FATAL_ERROR \"Install windres on Windows for resource files\")\n> > +     endif()\n> > +endif()\n> >\n> >  find_program(MSGFMT_EXE msgfmt)\n> >  if(NOT MSGFMT_EXE)\n> > @@ -85,11 +99,39 @@ add_compile_definitions(PAGER_ENV=\"LESS=FRX LV=-c\"\n> >                       BINDIR=\"bin\"\n> >                       GIT_BUILT_FROM_COMMIT=\"\")\n> >\n> > -set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n> > -add_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n> > +if(WIN32)\n> > +     set(FALLBACK_RUNTIME_PREFIX /mingw64)\n> > +     add_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n> > +else()\n> > +     set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n> > +     add_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n> > +endif()\n> >\n> > -add_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n> > -list(APPEND compat_SOURCES unix-socket.c)\n> > +\n> > +#Platform Specific\n> > +if(${CMAKE_SYSTEM_NAME} STREQUAL \"Windows\")\n> > +     include_directories(compat/win32)\n> > +     add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32\n> > +                             _CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=\".exe\"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT\n> > +                             NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0 NO_ST_BLOCKS_IN_STRUCT_STAT\n> > +                             USE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP\n> > +                             UNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)\n> > +     list(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c\n> > +             compat/win32/pthread.c compat/win32mmap.c compat/win32/syslog.c\n> > +             compat/win32/trace2_win32_process_info.c compat/win32/dirent.c\n> > +             compat/nedmalloc/nedmalloc.c compat/strdup.c)\n> > +     set(NO_UNIX_SOCKETS 1)\n> > +\n> > +elseif(${CMAKE_SYSTEM_NAME} STREQUAL \"Linux\")\n> > +     add_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n> > +     list(APPEND compat_SOURCES unix-socket.c)\n> > +endif()\n> > +\n> > +if(WIN32)\n> > +     set(EXE_EXTENSION .exe)\n> > +else()\n> > +     set(EXE_EXTENSION)\n> > +endif()\n> >\n> >  #header checks\n> >  check_include_file(libgen.h HAVE_LIBGEN_H)\n> > @@ -150,7 +192,12 @@ endif()\n> >  #function checks\n> >  set(function_checks\n> >       strcasestr memmem strlcpy strtoimax strtoumax strtoull\n> > -     setenv  mkdtemp poll pread  memmem unsetenv hstrerror)\n> > +     setenv  mkdtemp poll pread  memmem)\n> > +\n> > +#unsetenv,hstrerror are incompatible with windows build\n> > +if(NOT WIN32)\n> > +     list(APPEND function_checks unsetenv hstrerror)\n> > +endif()\n> >\n> >  foreach(f ${function_checks})\n> >       string(TOUPPER ${f} uf)\n> > @@ -309,7 +356,13 @@ endif()\n> >  #programs\n> >  set(PROGRAMS_BUILT\n> >       git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst\n> > -     git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)\n> > +     git-shell git-remote-testsvn)\n> > +\n> > +if(NO_UNIX_SOCKETS)\n> > +     list(APPEND excluded_progs git-credential-cache git-credential-cache--daemon)\n> > +else()\n> > +     list(APPEND PROGRAMS_BUILT git-credential-cache git-credential-cache--daemon)\n> > +endif()\n> >\n> >  if(NOT CURL_FOUND)\n> >       list(APPEND excluded_progs git-http-fetch git-http-push)\n> > @@ -410,15 +463,34 @@ set(libvcs-svn_SOURCES\n> >       vcs-svn/svndiff.c vcs-svn/svndump.c)\n> >  add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})\n> >\n> > +#add git.rc for gcc\n> > +if(WIN32)\n> > +     add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n> > +                     COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}\n> > +                             -DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION=\"\\\\\\\"${PROJECT_VERSION}.GIT\\\\\\\"\"\n> > +                             -i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res\n> > +                     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n> > +                     VERBATIM)\n> > +     add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)\n> > +endif()\n> > +\n> >  #link all required libraries to common-main\n> >  add_library(common-main OBJECT common-main.c)\n> > -target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)\n> > +\n> > +target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})\n> >  if(Intl_FOUND)\n> >       target_link_libraries(common-main ${Intl_LIBRARIES})\n> >  endif()\n> >  if(Iconv_FOUND)\n> >       target_link_libraries(common-main ${Iconv_LIBRARIES})\n> >  endif()\n> > +if(WIN32)\n> > +     target_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)\n> > +     add_dependencies(common-main git-rc)\n> > +     target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)\n> > +elseif(UNIX)\n> > +     target_link_libraries(common-main pthread rt)\n> > +endif()\n> >\n> >\n> >  set(git_SOURCES\n> > @@ -501,11 +573,13 @@ endif()\n> >  add_executable(git-remote-testsvn remote-testsvn.c)\n> >  target_link_libraries(git-remote-testsvn common-main vcs-svn)\n> >\n> > -add_executable(git-credential-cache credential-cache.c)\n> > -target_link_libraries(git-credential-cache common-main)\n> > +if(NOT NO_UNIX_SOCKETS)\n> > +     add_executable(git-credential-cache credential-cache.c)\n> > +     target_link_libraries(git-credential-cache common-main)\n> >\n> > -add_executable(git-credential-cache--daemon credential-cache--daemon.c)\n> > -target_link_libraries(git-credential-cache--daemon common-main)\n> > +     add_executable(git-credential-cache--daemon credential-cache--daemon.c)\n> > +     target_link_libraries(git-credential-cache--daemon common-main)\n> > +endif()\n> >\n> >\n> >  set(git_builtin_extra\n> > @@ -517,16 +591,16 @@ set(git_builtin_extra\n> >  foreach(s ${git_SOURCES} ${git_builtin_extra})\n> >       string(REPLACE \"builtin/\" \"\" s ${s})\n> >       string(REPLACE \".c\" \"\" s ${s})\n> > -     file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git git-${s})\\n\")\n> > -     list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})\n> > +     file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git${EXE_EXTENSION} git-${s}${EXE_EXTENSION})\\n\")\n> > +     list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s}${EXE_EXTENSION})\n> >  endforeach()\n> >\n> >  if(CURL_FOUND)\n> >       set(remote_exes\n> >               git-remote-https git-remote-ftp git-remote-ftps)\n> >       foreach(s ${remote_exes})\n> > -             file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git-remote-http ${s})\\n\")\n> > -             list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})\n> > +             file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git-remote-http${EXE_EXTENSION} ${s}${EXE_EXTENSION})\\n\")\n> > +             list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s}${EXE_EXTENSION})\n> >       endforeach()\n> >  endif()\n> >\n> > @@ -654,20 +728,20 @@ set(bin_links\n> >       git-receive-pack git-upload-archive git-upload-pack)\n> >\n> >  foreach(b ${bin_links})\n> > -install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})\")\n> > +install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/bin/${b}${EXE_EXTENSION})\")\n> >  endforeach()\n> >\n> > -install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)\")\n> > -install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)\")\n> > +install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git${EXE_EXTENSION})\")\n> > +install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell${EXE_EXTENSION})\")\n> >\n> >  foreach(b ${git_links})\n> >       string(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n> > -     install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n> > +     install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})\")\n> >  endforeach()\n> >\n> >  foreach(b ${git_http_links})\n> >       string(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n> > -     install(CODE \"file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n> > +     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})\")\n> >  endforeach()\n> >\n> >  install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4\n> > @@ -734,14 +808,14 @@ set(wrapper_test_scripts\n> >  foreach(script ${wrapper_scripts})\n> >       file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n> >       string(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n> > -     string(REPLACE \"@@PROG@@\" \"${script}\" content \"${content}\")\n> > +     string(REPLACE \"@@PROG@@\" \"${script}${EXE_EXTENSION}\" content \"${content}\")\n> >       file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n> >  endforeach()\n> >\n> >  foreach(script ${wrapper_test_scripts})\n> >       file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n> >       string(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n> > -     string(REPLACE \"@@PROG@@\" \"t/helper/${script}\" content \"${content}\")\n> > +     string(REPLACE \"@@PROG@@\" \"t/helper/${script}${EXE_EXTENSION}\" content \"${content}\")\n> >       file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n> >  endforeach()\n> >\n> > @@ -807,7 +881,7 @@ 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\")\n> >  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PAGER_ENV='${PAGER_ENV}'\\n\")\n> >  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"DC_SHA1='${DC_SHA1}'\\n\")\n> > -file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"X=''\\n\")\n> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"X='${EXE_EXTENSION}'\\n\")\n> >  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_GETTEXT='${NO_GETTEXT}'\\n\")\n> >  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"RUNTIME_PREFIX='${RUNTIME_PREFIX}'\\n\")\n> >  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PYTHON='${NO_PYTHON}'\\n\")\n>\n\nThank You,\nSibi Siddharthan\n"},{"id":"396183","messageId":"CAKiG+9VxPkqq-iLCu9pj=jf_4Lgq+05aFb9avfH8dtDtNVzy4w@mail.gmail.com","threadId":"53305","inReplyTo":"20200424170540.GH1949@danh.dev","subject":"Re: [PATCH 1/8] Introduce CMake support for configuring Git on Linux","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-04-24T21:06:12Z","receivedAt":"2020-04-24T21:06:26Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"Hi Danh,\nThank You for your feedback.\nBefore I answer your comments, I would like to say that the CMake script\nonly supports Linux and Windows.\nI don't have BSD, Solaris or Apple systems to test the script on.\nThe Makefile will still be used for those systems and won't be replaced.\nAlso, I am sorry for not leaving a newline at the end.\n\nOn Fri, Apr 24, 2020 at 10:35 PM Danh Doan <congdanhqx@gmail.com> wrote:\n>\n> On 2020-04-24 04:01:30+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:\n>\n> Please excuse my hatred for CMake.\n>\n> I guess it's my own fault for not learning how to write CMake\n> properly, or is it too hard to write correct CMake?\n>\n> > To make this a little less awkward, the Git for Windows project offers\n> > the `vs/master` branch which has a full Visual Studio solution generated\n> > and committed. This branch can therefore be used to tinker with Git in\n> > Visual Studio _without_ having to download the full Git for Windows SDK.\n> > Unfortunatly, that branch is auto-generated from Git for Windows'\n> > `master`. If a developer wants to tinker, say, with `pu`, they are out\n> > of luck.\n>\n> I thought:\n>         make NDEBUG=1 DEVELOPER=1 vcxproj\n>\n> was invented for this use case?\n>\n\nYes,\nBut with CMake a lot more can be done with Visual Studio. For example\nwe can also target clang-cl now.\n\n> > CMake was invented to make this sort of problem go away, by providing a\n> > more standardized, cross-platform way to configure builds.\n>\n> There is something fun with that *cross*\n> Is cmake able to cross-compile cmake by cmake now?\n>\n> > With a working support CMake, developers on Windows need only install\n> > CMake, configure their build, load the generated Visual Studio solution\n> > and immediately start modifying the code and build their own version of\n> > Git. Likewise, developers on other platforms can use the convenient GUI\n> > tools provided by CMake to configure their build.\n>\n> OK, that's fine if it works for you.\n> Please don't drop support for autoconf and Makefile, though.\n> (I haven't look into other patches)\n>\n\nThe Makefile is not going away at all. The CMake script is intended to\ncomplement\nthe already existing Makefile by giving people flexibility.\n\n> > So let's start building CMake support for Git.\n> >\n> > This is only the first step, and to make it easier to review, it only\n> > allows for configuring builds on the platform that is easiest to\n> > configure for: Linux.\n> >\n> > The CMake script checks whether the headers are present(eg. libgen.h),\n> > whether the functions are present(eg. memmem), whether the funtions work\n> > properly (eg. snprintf) and generate the required compile definitions\n> > for the platform. The script also searches for the required libraries,\n> > if it fails to find the required libraries the respective executables\n> > won't be built.(eg. If libcurl is not found then git-remote-http won't\n> > be built). This will help building Git easier.\n> >\n> > With a CMake script an out of source build of git is possible resulting\n> > in a clean source tree.\n> >\n> > Note: earlier endeavors on the Git mailing list to introduce CMake ended\n> > up in dead water. The primary reason for that was that reviewers\n> > _expected_ CMake support to fall out of maintenance, unless the\n> > contributor would promise to keep an eye on keeping CMake support up to\n> > date. However, in the meantime, support for automated testing has been\n> > introduced in Git's source code, and a later patch will modify the\n> > (still experimental) GitHub workflow to continually verify that CMake\n> > support is still complete. That will make maintenance reasonably easy.\n> >\n> > Note: this patch asks for the minimum version v3.14 of CMake (which is\n> > not all that old as of time of writing) because that is the first\n>\n> Debian Buster (current stable) ships v3.13.4, I think I don't need to\n> mention old-stable of Debian (Stretch or Jessie).\n>\n>\n> > version to offer a platform-independent way to generate hardlinks as\n> > part of the build. This is needed to generate all those hardlinks for\n> > the built-in commands of Git.\n> >\n> > Instructions to run CMake:\n> >\n> > cmake `relative-path-to-srcdir` -DCMAKE_BUILD_TYPE=Release\n> >\n> > Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding\n> > compiler flags\n> > Debug : -g\n> > Release: -O3\n>\n> IIRC, Linus and Junio used to said noone ever needs \"-03\"\n>\n\nOkay, there is still a way to for \"-O2\" on Release builds, if you\nprefer to do that.\n\n> > RelWithDebInfo : -O2 -g\n> > MinSizeRel : -Os\n> > empty(default) :\n> >\n> > NOTE: -DCMAKE_BUILD_TYPE is optional\n> >\n> > This process generates a Makefile.\n> > Then run `make` to build Git.\n> >\n> > NOTE: By default CMake uses Makefile as the build tool on Linux, to use\n> > another tool say `ninja` add this to the command line when configuring.\n> > `-G Ninja`\n> >\n> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> > ---\n> >  CMakeLists.txt | 528 +++++++++++++++++++++++++++++++++++++++++++++++++\n> >  1 file changed, 528 insertions(+)\n> >  create mode 100644 CMakeLists.txt\n> >\n> > diff --git a/CMakeLists.txt b/CMakeLists.txt\n> > new file mode 100644\n> > index 00000000000..73703bd321f\n> > --- /dev/null\n> > +++ b/CMakeLists.txt\n> > @@ -0,0 +1,528 @@\n> > +#\n> > +#    Copyright (c) 2020 Sibi Siddharthan\n> > +#\n> > +\n> > +cmake_minimum_required(VERSION 3.14)\n> > +\n> > +#Parse GIT-VERSION-GEN to get the version\n> > +file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX \"DEF_VER=v(.*)\")\n> > +string(REPLACE \"DEF_VER=v\" \"\" git_version ${git_version})\n> > +string(REPLACE \".GIT\" \".0\" git_version ${git_version})#for building from a snapshot\n>\n> Does it work with e.g. 2.26.1?\n>\n\nYes it does, the snapshots have \".GIT\" at the end the versions whereas\nthe tags have \"2.26.1\".\nThis was a hack for setting the patch level to 0 for the snapshot builds.\n\n> > +\n> > +project(git\n> > +     VERSION ${git_version}\n> > +     LANGUAGES C)\n> > +\n> > +\n> > +include(CheckTypeSize)\n> > +include(CheckCSourceRuns)\n> > +include(CheckCSourceCompiles)\n> > +include(CheckIncludeFile)\n> > +include(CheckFunctionExists)\n> > +include(CheckSymbolExists)\n> > +include(CheckStructHasMember)\n> > +\n> > +find_package(ZLIB REQUIRED)\n> > +find_package(CURL)\n>\n> Right now, we should --with-zlib=/path/to/zlib/root\n> Does this `find_package` support it?\n>\n\nYes it does,\nall you have to do is -DZLIB_ROOT=/path/to/zlib/root\n\n> > +find_package(EXPAT)\n> > +find_package(Iconv)\n> > +find_package(Intl)\n> > +\n>\n> > +if(NOT Intl_FOUND)\n> > +     add_compile_definitions(NO_GETTEXT)\n>\n> find_package(Gettext)?\n>\n\nfind_package(Gettext) does not define libintl and libintl.h.\nIf NO_GETTEXT is not defined, it means that libintl.h is present.\nSo, we use find_package(Intl) for libintl\n\n> > +     if(NOT Iconv_FOUND)\n> > +             add_compile_definitions(NO_ICONV)\n> > +     endif()\n> > +endif()\n>\n> ICONV_OMITS_BOM?\n>\n\nForgot about this, will add it.\n\n> > +\n> > +include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})\n> > +if(CURL_FOUND)\n> > +     include_directories(SYSTEM ${CURL_INCLUDE_DIRS})\n> > +endif()\n> > +if(EXPAT_FOUND)\n> > +     include_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})\n> > +endif()\n> > +if(Iconv_FOUND)\n> > +     include_directories(SYSTEM ${Iconv_INCLUDE_DIRS})\n> > +endif()\n> > +if(Intl_FOUND)\n> > +     include_directories(SYSTEM ${Intl_INCLUDE_DIRS})\n> > +endif()\n> > +\n> > +find_program(SH_EXE sh)\n>\n> We want to find usable sh, not just sh, no?\n>\n> It's matter on Solaris, HP-UX\n>\n\nHow do I check for this, can you help?\nAlso, the script is not supported on Solaris and HP-UX.\n\n> > +\n> > +#default behaviour\n> > +include_directories(${CMAKE_SOURCE_DIR})\n> > +add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n> > +add_compile_definitions(SHA256_BLK INTERNAL_QSORT RUNTIME_PREFIX)\n> > +add_compile_definitions(NO_OPENSSL SHA1_DC SHA1DC_NO_STANDARD_INCLUDES\n> > +                     SHA1DC_INIT_SAFE_HASH_DEFAULT=0\n> > +                     SHA1DC_CUSTOM_INCLUDE_SHA1_C=\"cache.h\"\n> > +                     SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"git-compat-util.h\" )\n> > +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)\n> > +\n> > +\n> > +add_compile_definitions(PAGER_ENV=\"LESS=FRX LV=-c\"\n> > +                     ETC_GITATTRIBUTES=\"etc/gitattributes\"\n> > +                     ETC_GITCONFIG=\"etc/gitconfig\"\n> > +                     GIT_EXEC_PATH=\"libexec/git-core\"\n> > +                     GIT_LOCALE_PATH=\"share/locale\"\n> > +                     GIT_MAN_PATH=\"share/man\"\n> > +                     GIT_INFO_PATH=\"share/info\"\n> > +                     GIT_HTML_PATH=\"share/doc/git-doc\"\n> > +                     DEFAULT_HELP_FORMAT=\"html\"\n> > +                     DEFAULT_GIT_TEMPLATE_DIR=\"share/git-core/templates\"\n> > +                     GIT_VERSION=\"${PROJECT_VERSION}.GIT\"\n> > +                     GIT_USER_AGENT=\"git/${PROJECT_VERSION}.GIT\"\n> > +                     BINDIR=\"bin\"\n> > +                     GIT_BUILT_FROM_COMMIT=\"\")\n>\n> I wish I could verify this.\n> Have you check this part on a default build system for a Linux distro,\n> FreeBSD? For things started with \"etc/\"\n>\n\nThese are the values I got when I looked at the build logs from the\nMakefile (make -n) in Linux and Windows.\nDon't know about FreeBSD\n\n> > +\n> > +set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n> > +add_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n> > +\n> > +add_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n>\n> /proc/self/exe is Linux only, no?\n>\n\nYes, it is. This first patch only supports Linux build.\n\n> > +list(APPEND compat_SOURCES unix-socket.c)\n> > +\n> > +#header checks\n> > +check_include_file(libgen.h HAVE_LIBGEN_H)\n> > +if(NOT HAVE_LIBGEN_H)\n> > +     add_compile_definitions(NO_LIBGEN_H)\n> > +     list(APPEND compat_SOURCES compat/basename.c)\n> > +endif()\n> > +\n> > +check_include_file(sys/sysinfo.h HAVE_SYSINFO)\n> > +if(HAVE_SYSINFO)\n> > +     add_compile_definitions(HAVE_SYSINFO)\n> > +endif()\n> > +\n> > +check_c_source_compiles(\"\n> > +#include <alloca.h>\n> > +int\n> > +main ()\n> > +{\n> > +char *p = (char *) alloca (2 * sizeof (int));\n> > +     if (p) return 0;\n> > +     return 0;\n>\n> All code path will return 0?\n>\n\nThis check is for a working alloca.h.\nSome systems define alloca in malloc.h (Windows)\n\n> > +}\"\n> > +HAVE_ALLOCA_H)\n> > +if(HAVE_ALLOCA_H)\n> > +     add_compile_definitions(HAVE_ALLOCA_H)\n> > +endif()\n> > +\n> > +check_include_file(strings.h HAVE_STRINGS_H)\n> > +if(HAVE_STRINGS_H)\n> > +     add_compile_definitions(HAVE_STRINGS_H)\n> > +endif()\n> > +\n> > +check_include_file(sys/select.h HAVE_SYS_SELECT_H)\n> > +if(NOT HAVE_SYS_SELECT_H)\n> > +     add_compile_definitions(NO_SYS_SELECT_H)\n> > +endif()\n> > +\n> > +check_include_file(sys/poll.h HAVE_SYS_POLL_H)\n> > +if(NOT HAVE_SYS_POLL_H)\n> > +     add_compile_definitions(NO_SYS_POLL_H)\n> > +endif()\n> > +\n> > +check_include_file(poll.h HAVE_POLL_H)\n>\n> POSIX defined poll.h instead of sys/poll.h\n>\n> > +if(NOT HAVE_POLL_H)\n> > +     add_compile_definitions(NO_POLL_H)\n> > +endif()\n> > +\n> > +check_include_file(inttypes.h HAVE_INTTYPES_H)\n> > +if(NOT HAVE_INTTYPES_H)\n> > +     add_compile_definitions(NO_INTTYPES_H)\n> > +endif()\n> > +\n> > +check_include_file(paths.h HAVE_PATHS_H)\n> > +if(HAVE_PATHS_H)\n> > +     add_compile_definitions(HAVE_PATHS_H)\n> > +endif()\n> > +\n> > +#function checks\n> > +set(function_checks\n> > +     strcasestr memmem strlcpy strtoimax strtoumax strtoull\n> > +     setenv  mkdtemp poll pread  memmem unsetenv hstrerror)\n> > +\n> > +foreach(f ${function_checks})\n> > +     string(TOUPPER ${f} uf)\n> > +     check_function_exists(${f} HAVE_${uf})\n> > +     if(NOT HAVE_${uf})\n> > +             add_compile_definitions(NO_${uf})\n> > +     endif()\n> > +endforeach()\n> > +\n> > +if(NOT HAVE_POLL_H OR NOT HAVE_SYS_POLL_H OR NOT HAVE_POLL)\n> > +     include_directories(compat/poll)\n> > +     add_compile_definitions(NO_POLL)\n> > +     list(APPEND compat_SOURCES compat/poll/poll.c)\n> > +endif()\n> > +\n> > +if(NOT HAVE_STRCASESTR)\n> > +     list(APPEND compat_SOURCES compat/strcasestr.c)\n> > +endif()\n> > +\n> > +if(NOT HAVE_STRLCPY)\n> > +     list(APPEND compat_SOURCES compat/strlcpy.c)\n> > +endif()\n> > +\n> > +if(NOT HAVE_STRTOUMAX)\n> > +     list(APPEND compat_SOURCES compat/strtoumax.c compat/strtoimax.c)\n> > +endif()\n> > +\n> > +if(NOT HAVE_SETENV)\n> > +     list(APPEND compat_SOURCES compat/setenv.c)\n> > +endif()\n> > +\n> > +if(NOT HAVE_MKDTEMP)\n> > +     list(APPEND compat_SOURCES compat/mkdtemp.c)\n> > +endif()\n> > +\n> > +if(NOT HAVE_PREAD)\n> > +     list(APPEND compat_SOURCES compat/pread.c)\n> > +endif()\n> > +\n> > +if(NOT HAVE_MEMMEM)\n> > +     list(APPEND compat_SOURCES compat/memmem.c)\n> > +endif()\n> > +\n> > +if(NOT WIN32)\n> > +     if(NOT HAVE_UNSETENV)\n> > +             list(APPEND compat_SOURCES compat/unsetenv.c)\n> > +     endif()\n> > +\n> > +     if(NOT HAVE_HSTRERROR)\n> > +             list(APPEND compat_SOURCES compat/hstrerror.c)\n> > +     endif()\n> > +endif()\n> > +\n> > +check_function_exists(getdelim HAVE_GETDELIM)\n> > +if(HAVE_GETDELIM)\n> > +     add_compile_definitions(HAVE_GETDELIM)\n> > +endif()\n> > +\n> > +check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)\n> > +check_symbol_exists(CLOCK_MONOTONIC \"time.h\" HAVE_CLOCK_MONOTONIC)\n> > +if(HAVE_CLOCK_GETTIME)\n> > +     add_compile_definitions(HAVE_CLOCK_GETTIME)\n> > +endif()\n> > +if(HAVE_CLOCK_MONOTONIC)\n> > +     add_compile_definitions(HAVE_CLOCK_MONOTONIC)\n> > +endif()\n> > +\n> > +\n> > +#compile checks\n> > +check_c_source_runs(\"\n> > +#include<stdio.h>\n> > +#include<stdarg.h>\n> > +#include<string.h>\n> > +#include<stdlib.h>\n> > +int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)\n> > +{\n> > +     int ret;\n> > +     va_list ap;\n> > +\n> > +     va_start(ap, format);\n> > +     ret = vsnprintf(str, maxsize, format, ap);\n> > +     va_end(ap);\n> > +     return ret;\n> > +}\n> > +\n> > +int\n> > +main ()\n> > +{\n> > +     char buf[6];\n> > +     if (test_vsnprintf(buf, 3, \\\"%s\\\", \\\"12345\\\") != 5\n> > +             || strcmp(buf, \\\"12\\\")) return 1;\n> > +     if (snprintf(buf, 3, \\\"%s\\\", \\\"12345\\\") != 5\n> > +             || strcmp(buf, \\\"12\\\")) return 1;\n> > +\n> > +     return 0;\n> > +}\"\n> > +SNPRINTF_OK)\n> > +if(NOT SNPRINTF_OK)\n> > +     add_compile_definitions(SNPRINTF_RETURNS_BOGUS)\n> > +     list(APPEND compat_SOURCES compat/snprintf.c)\n> > +endif()\n> > +\n> > +check_c_source_runs(\"\n> > +#include<stdio.h>\n> > +int\n> > +main ()\n> > +{\n> > +     FILE *f = fopen(\\\".\\\", \\\"r\\\");\n> > +     return f != NULL;\n> > +\n> > +     return 0;\n> > +}\"\n> > +FREAD_READS_DIRECTORIES_NO)\n> > +if(NOT FREAD_READS_DIRECTORIES_NO)\n> > +     add_compile_definitions(FREAD_READS_DIRECTORIES)\n> > +     list(APPEND compat_SOURCES compat/fopen.c)\n> > +endif()\n> > +\n> > +check_c_source_compiles(\"\n> > +#include <regex.h>\n> > +#ifndef REG_STARTEND\n> > +#error oops we dont have it\n> > +#endif\n> > +int main(){return 0;}\"\n> > +HAVE_REGEX)\n> > +if(NOT HAVE_REGEX)\n> > +     include_directories(compat/regex )\n> > +     list(APPEND compat_SOURCES compat/regex/regex.c )\n> > +     add_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)\n> > +endif()\n> > +\n> > +\n> > +check_c_source_compiles(\"\n> > +#include <stddef.h>\n> > +#include <sys/types.h>\n> > +#include <sys/sysctl.h>\n> > +\n> > +int\n> > +main ()\n> > +{\n> > +     int val, mib[2];\n> > +     size_t len;\n> > +\n> > +     mib[0] = CTL_HW;\n> > +     mib[1] = 1;\n> > +     len = sizeof(val);\n> > +     return sysctl(mib, 2, &val, &len, NULL, 0) ? 1 : 0;\n> > +\n> > +     return 0;\n> > +}\"\n> > +HAVE_BSD_SYSCTL)\n> > +if(HAVE_BSD_SYSCTL)\n> > +     add_compile_definitions(HAVE_BSD_SYSCTL)\n> > +endif()\n> > +\n> > +#programs\n> > +set(PROGRAMS_BUILT\n> > +     git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst\n> > +     git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)\n> > +\n> > +if(NOT CURL_FOUND)\n> > +     list(APPEND excluded_progs git-http-fetch git-http-push)\n> > +     add_compile_definitions(NO_CURL)\n> > +     message(WARNING \"git-http-push and git-http-fetch will not be built\")\n> > +else()\n> > +     list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)\n> > +     if(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)\n> > +             add_compile_definitions(USE_CURL_FOR_IMAP_SEND)\n> > +     endif()\n> > +endif()\n> > +\n> > +if(NOT EXPAT_FOUND)\n> > +     list(APPEND excluded_progs git-http-push)\n> > +     add_compile_definitions(NO_EXPAT)\n> > +else()\n> > +     list(APPEND PROGRAMS_BUILT git-http-push)\n> > +     if(EXPAT_VERSION_STRING VERSION_LESS_EQUAL 1.2)\n> > +             add_compile_definitions(EXPAT_NEEDS_XMLPARSE_H)\n> > +     endif()\n> > +endif()\n> > +\n> > +list(REMOVE_DUPLICATES excluded_progs)\n> > +list(REMOVE_DUPLICATES PROGRAMS_BUILT)\n> > +\n> > +\n> > +foreach(p ${excluded_progs})\n> > +     list(APPEND EXCLUSION_PROGS --exclude-program ${p} )\n> > +endforeach()\n> > +\n> > +#for comparing null values\n> > +list(APPEND EXCLUSION_PROGS empty)\n> > +set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING \"Programs not built\" FORCE)\n> > +\n> > +if(NOT EXISTS ${CMAKE_SOURCE_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)\n> > +     list(REMOVE_ITEM EXCLUSION_PROGS empty)\n> > +     message(\"Generating command-list.h\")\n> > +     execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt\n> > +                     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n> > +                     OUTPUT_FILE ${CMAKE_SOURCE_DIR}/command-list.h)\n> > +endif()\n> > +\n> > +if(NOT EXISTS ${CMAKE_SOURCE_DIR}/config-list.h)\n> > +     message(\"Generating config-list.h\")\n> > +     execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh\n> > +                     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n> > +                     OUTPUT_FILE ${CMAKE_SOURCE_DIR}/config-list.h)\n> > +endif()\n> > +\n> > +\n> > +#build\n> > +set(libgit_SOURCES\n> > +     abspath.c add-interactive.c add-patch.c advice.c alias.c\n> > +     alloc.c apply.c archive.c archive-tar.c archive-zip.c argv-array.c\n> > +     attr.c base85.c bisect.c blame.c blob.c bloom.c branch.c bulk-checkin.c\n> > +     bundle.c cache-tree.c chdir-notify.c checkout.c color.c column.c\n> > +     combine-diff.c commit.c commit-graph.c commit-reach.c compat/obstack.c\n> > +     compat/terminal.c config.c connect.c connected.c convert.c copy.c credential.c\n> > +     csum-file.c ctype.c date.c decorate.c delta-islands.c diffcore-break.c\n> > +     diffcore-delta.c diffcore-order.c diffcore-pickaxe.c diffcore-rename.c\n> > +     diff-delta.c diff-lib.c diff-no-index.c diff.c dir.c dir-iterator.c editor.c\n> > +     entry.c environment.c ewah/bitmap.c ewah/ewah_bitmap.c ewah/ewah_io.c\n> > +     ewah/ewah_rlw.c exec-cmd.c fetch-negotiator.c fetch-pack.c fmt-merge-msg.c fsck.c fsmonitor.c\n> > +     gettext.c gpg-interface.c graph.c grep.c hashmap.c linear-assignment.c help.c hex.c\n> > +     ident.c interdiff.c json-writer.c kwset.c levenshtein.c line-log.c line-range.c list-objects.c\n> > +     list-objects-filter.c list-objects-filter-options.c ll-merge.c lockfile.c\n> > +     log-tree.c ls-refs.c mailinfo.c mailmap.c match-trees.c mem-pool.c merge.c merge-blobs.c\n> > +     merge-recursive.c mergesort.c midx.c name-hash.c negotiator/default.c\n> > +     negotiator/skipping.c notes.c notes-cache.c notes-merge.c notes-utils.c object.c oidmap.c\n> > +     oidset.c oid-array.c packfile.c pack-bitmap.c pack-bitmap-write.c pack-check.c pack-objects.c\n> > +     pack-revindex.c pack-write.c pager.c parse-options.c parse-options-cb.c patch-delta.c\n> > +     patch-ids.c path.c pathspec.c pkt-line.c preload-index.c pretty.c prio-queue.c progress.c\n> > +     promisor-remote.c prompt.c protocol.c prune-packed.c quote.c range-diff.c reachable.c read-cache.c rebase.c\n> > +     rebase-interactive.c reflog-walk.c refs.c refs/files-backend.c refs/iterator.c\n> > +     refs/packed-backend.c refs/ref-cache.c refspec.c ref-filter.c remote.c replace-object.c\n> > +     repo-settings.c repository.c rerere.c reset.c resolve-undo.c revision.c run-command.c\n> > +     send-pack.c sequencer.c serve.c server-info.c setup.c sha1-lookup.c\n> > +     sha1-file.c sha1-name.c shallow.c sideband.c sigchain.c split-index.c\n> > +     stable-qsort.c strbuf.c streaming.c string-list.c submodule.c submodule-config.c\n> > +     sub-process.c symlinks.c tag.c tempfile.c thread-utils.c tmp-objdir.c\n> > +     trace.c trace2.c trace2/tr2_cfg.c trace2/tr2_cmd_name.c trace2/tr2_dst.c\n> > +     trace2/tr2_sid.c trace2/tr2_sysenv.c trace2/tr2_tbuf.c trace2/tr2_tgt_event.c\n> > +     trace2/tr2_tgt_normal.c trace2/tr2_tgt_perf.c trace2/tr2_tls.c trailer.c transport.c\n> > +     transport-helper.c tree-diff.c tree.c tree-walk.c unpack-trees.c upload-pack.c url.c\n> > +     urlmatch.c usage.c userdiff.c utf8.c varint.c version.c versioncmp.c walker.c wildmatch.c\n> > +     worktree.c wrapper.c write-or-die.c ws.c wt-status.c xdiff-interface.c\n> > +     zlib.c)\n> > +\n> > +add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})\n> > +\n> > +set(libxdiff_SOURCES\n> > +     xdiff/xdiffi.c xdiff/xprepare.c xdiff/xutils.c xdiff/xemit.c\n> > +     xdiff/xmerge.c xdiff/xpatience.c xdiff/xhistogram.c)\n> > +add_library(xdiff STATIC ${libxdiff_SOURCES})\n> > +\n> > +set(libvcs-svn_SOURCES\n> > +     vcs-svn/line_buffer.c vcs-svn/sliding_window.c vcs-svn/fast_export.c\n> > +     vcs-svn/svndiff.c vcs-svn/svndump.c)\n> > +add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})\n> > +\n> > +#link all required libraries to common-main\n> > +add_library(common-main OBJECT common-main.c)\n> > +target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)\n> > +if(Intl_FOUND)\n> > +     target_link_libraries(common-main ${Intl_LIBRARIES})\n> > +endif()\n> > +if(Iconv_FOUND)\n> > +     target_link_libraries(common-main ${Iconv_LIBRARIES})\n> > +endif()\n> > +\n> > +\n> > +set(git_SOURCES\n> > +     builtin/add.c builtin/am.c builtin/annotate.c builtin/apply.c\n> > +     builtin/archive.c builtin/bisect--helper.c builtin/blame.c\n> > +     builtin/branch.c builtin/bundle.c builtin/cat-file.c builtin/check-attr.c\n> > +     builtin/check-ignore.c builtin/check-mailmap.c builtin/check-ref-format.c\n> > +     builtin/checkout-index.c builtin/checkout.c builtin/clean.c\n> > +     builtin/clone.c builtin/column.c builtin/commit-tree.c\n> > +     builtin/commit.c builtin/commit-graph.c builtin/config.c\n> > +     builtin/count-objects.c builtin/credential.c builtin/describe.c\n> > +     builtin/diff-files.c builtin/diff-index.c builtin/diff-tree.c\n> > +     builtin/diff.c builtin/difftool.c builtin/env--helper.c\n> > +     builtin/fast-export.c builtin/fetch-pack.c builtin/fetch.c builtin/fmt-merge-msg.c\n> > +     builtin/for-each-ref.c builtin/fsck.c builtin/gc.c\n> > +     builtin/get-tar-commit-id.c builtin/grep.c builtin/hash-object.c\n> > +     builtin/help.c builtin/index-pack.c builtin/init-db.c\n> > +     builtin/interpret-trailers.c builtin/log.c builtin/ls-files.c\n> > +     builtin/ls-remote.c builtin/ls-tree.c builtin/mailinfo.c builtin/mailsplit.c\n> > +     builtin/merge.c builtin/merge-base.c builtin/merge-file.c builtin/merge-index.c\n> > +     builtin/merge-ours.c builtin/merge-recursive.c builtin/merge-tree.c\n> > +     builtin/mktag.c builtin/mktree.c builtin/multi-pack-index.c builtin/mv.c\n> > +     builtin/name-rev.c builtin/notes.c builtin/pack-objects.c builtin/pack-redundant.c\n> > +     builtin/pack-refs.c builtin/patch-id.c builtin/prune-packed.c builtin/prune.c\n> > +     builtin/pull.c builtin/push.c builtin/range-diff.c builtin/read-tree.c\n> > +     builtin/rebase.c builtin/receive-pack.c builtin/reflog.c builtin/remote.c\n> > +     builtin/remote-ext.c builtin/remote-fd.c builtin/repack.c builtin/replace.c\n> > +     builtin/rerere.c builtin/reset.c builtin/rev-list.c builtin/rev-parse.c\n> > +     builtin/revert.c builtin/rm.c builtin/send-pack.c builtin/shortlog.c\n> > +     builtin/show-branch.c builtin/show-index.c builtin/show-ref.c\n> > +     builtin/sparse-checkout.c builtin/stash.c builtin/stripspace.c\n> > +     builtin/submodule--helper.c builtin/symbolic-ref.c builtin/tag.c\n> > +     builtin/unpack-file.c builtin/unpack-objects.c builtin/update-index.c\n> > +     builtin/update-ref.c builtin/update-server-info.c builtin/upload-archive.c\n> > +     builtin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c\n> > +     builtin/verify-tag.c builtin/worktree.c builtin/write-tree.c)\n> > +\n> > +add_executable(git git.c ${git_SOURCES})\n> > +target_link_libraries(git common-main )\n> > +\n> > +add_executable(git-bugreport bugreport.c)\n> > +target_link_libraries(git-bugreport common-main)\n> > +\n> > +add_executable(git-credential-store credential-store.c)\n> > +target_link_libraries(git-credential-store common-main)\n> > +\n> > +add_executable(git-daemon daemon.c)\n> > +target_link_libraries(git-daemon common-main)\n> > +\n> > +add_executable(git-fast-import fast-import.c)\n> > +target_link_libraries(git-fast-import common-main)\n> > +\n> > +add_executable(git-http-backend http-backend.c)\n> > +target_link_libraries(git-http-backend common-main)\n> > +\n> > +add_executable(git-sh-i18n--envsubst sh-i18n--envsubst.c)\n> > +target_link_libraries(git-sh-i18n--envsubst common-main)\n> > +\n> > +add_executable(git-shell shell.c)\n> > +target_link_libraries(git-shell common-main)\n> > +\n> > +if(CURL_FOUND)\n> > +     add_library(http_obj OBJECT http.c)\n> > +\n> > +     add_executable(git-imap-send imap-send.c)\n> > +     target_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})\n> > +\n> > +     add_executable(git-http-fetch http-walker.c http-fetch.c)\n> > +     target_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})\n> > +\n> > +     add_executable(git-remote-http http-walker.c remote-curl.c)\n> > +     target_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )\n> > +\n> > +     if(EXPAT_FOUND)\n> > +             add_executable(git-http-push http-push.c)\n> > +             target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})\n> > +     endif()\n> > +endif()\n> > +\n> > +add_executable(git-remote-testsvn remote-testsvn.c)\n> > +target_link_libraries(git-remote-testsvn common-main vcs-svn)\n> > +\n> > +add_executable(git-credential-cache credential-cache.c)\n> > +target_link_libraries(git-credential-cache common-main)\n> > +\n> > +add_executable(git-credential-cache--daemon credential-cache--daemon.c)\n> > +target_link_libraries(git-credential-cache--daemon common-main)\n> > +\n> > +\n> > +set(git_builtin_extra\n> > +     cherry cherry-pick format-patch fsck-objects\n> > +     init merge-subtree restore show\n> > +     stage status switch whatchanged)\n> > +\n> > +#Creating hardlinks\n> > +foreach(s ${git_SOURCES} ${git_builtin_extra})\n> > +     string(REPLACE \"builtin/\" \"\" s ${s})\n> > +     string(REPLACE \".c\" \"\" s ${s})\n> > +     file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git git-${s})\\n\")\n> > +     list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})\n> > +endforeach()\n> > +\n> > +if(CURL_FOUND)\n> > +     set(remote_exes\n> > +             git-remote-https git-remote-ftp git-remote-ftps)\n> > +     foreach(s ${remote_exes})\n> > +             file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git-remote-http ${s})\\n\")\n> > +             list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})\n> > +     endforeach()\n> > +endif()\n> > +\n> > +add_custom_command(OUTPUT ${git_links} ${git_http_links}\n> > +             COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake\n> > +             DEPENDS git git-remote-http)\n> > +add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})\n> > \\ No newline at end of file\n>\n> No new line at end of line always leave a bad taste in my mount!\n>\n>\n> --\n> Danh\n\nThank You,\nSibi Siddharthan\n"},{"id":"396185","messageId":"CAKiG+9Vs1nFR4Lfrh4g=7sNUu_yRr4mz-w=gRm_U7PqY9W5QBg@mail.gmail.com","threadId":"53305","inReplyTo":"20200424171959.GI1949@danh.dev","subject":"Re: [PATCH 2/8] cmake: generate the shell/perl/python scripts and templates, translations","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-04-24T21:19:55Z","receivedAt":"2020-04-24T21:20:13Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Fri, Apr 24, 2020 at 10:50 PM Danh Doan <congdanhqx@gmail.com> wrote:\n>\n> On 2020-04-24 04:01:31+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> >\n> > This patch implements the placeholder substitution to generate, say,\n> > `git-request-pull` from `git-request-pull.sh`.\n> >\n> > The shell/perl/python scripts and template are generated using CMake\n> > (very similar to what sed does).\n> >\n> > The text translations are only build if `msgfmt` is found in your path.\n> >\n> > NOTE: The scripts and templates are generated during configuration.\n> >\n> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> > ---\n> >  CMakeLists.txt | 107 ++++++++++++++++++++++++++++++++++++++++++++++++-\n> >  1 file changed, 106 insertions(+), 1 deletion(-)\n> >\n> > diff --git a/CMakeLists.txt b/CMakeLists.txt\n> > index 73703bd321f..788b53be873 100644\n> > --- a/CMakeLists.txt\n> > +++ b/CMakeLists.txt\n> > @@ -51,6 +51,11 @@ endif()\n> >\n> >  find_program(SH_EXE sh)\n> >\n> > +find_program(MSGFMT_EXE msgfmt)\n>\n> I suppose find_package(Gettext) can do most of this work?\n>\n\nWill change it using gettext.\n\n> > +if(NOT MSGFMT_EXE)\n> > +     message(WARNING \"Text Translations won't be build\")\n> > +endif()\n> > +\n> >  #default behaviour\n> >  include_directories(${CMAKE_SOURCE_DIR})\n> >  add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n> > @@ -525,4 +530,104 @@ endif()\n> >  add_custom_command(OUTPUT ${git_links} ${git_http_links}\n> >               COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake\n> >               DEPENDS git git-remote-http)\n> > -add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})\n> > \\ No newline at end of file\n>\n> No newline at end of file?\n>\n> > +add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})\n> > +\n> > +\n> > +#creating required scripts\n> > +set(SHELL_PATH /bin/sh)\n> > +set(PERL_PATH /usr/bin/perl)\n>\n> Really?\n> Have you tried on, let's say FreeBSD?\n>\n> > +set(LOCALEDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)\n> > +set(GITWEBDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)\n> > +set(INSTLIBDIR ${FALLBACK_RUNTIME_PREFIX}/share/perl5)\n> > +\n> > +#shell scripts\n> > +set(git_shell_scripts\n> > +     git-bisect git-difftool--helper git-filter-branch\n> > +     git-merge-octopus git-merge-one-file git-merge-resolve\n> > +     git-mergetool git-quiltimport\n> > +     git-request-pull git-submodule git-web--browse\n> > +     git-mergetool--lib git-parse-remote git-rebase--preserve-merges\n> > +     git-sh-setup git-sh-i18n git-instaweb)\n> > +\n> > +foreach(script ${git_shell_scripts})\n> > +     file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.sh content NEWLINE_CONSUME)\n> > +     string(REPLACE \"@SHELL_PATH@\" \"${SHELL_PATH}\" content \"${content}\")\n> > +     string(REPLACE \"@@DIFF@@\" \"diff\" content \"${content}\")\n> > +     string(REPLACE \"@LOCALEDIR@\" \"${LOCALEDIR}\" content \"${content}\")\n> > +     string(REPLACE \"@GITWEBDIR@\" \"${GITWEBDIR}\" content \"${content}\")\n> > +     string(REPLACE \"@@NO_CURL@@\" \"\" content \"${content}\")\n> > +     string(REPLACE \"@@USE_GETTEXT_SCHEME@@\" \"\" content \"${content}\")\n> > +     string(REPLACE \"# @@BROKEN_PATH_FIX@@\" \"\" content \"${content}\")\n> > +     string(REPLACE \"@@PERL@@\" \"${PERL_PATH}\" content \"${content}\")\n> > +     string(REPLACE \"@@SANE_TEXT_GREP@@\" \"-a\" content \"${content}\")\n> > +     string(REPLACE \"@@PAGER_ENV@@\" \"LESS=FRX LV=-c\" content \"${content}\")\n> > +     file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})\n> > +endforeach()\n>\n> I assume this do most of sed magic?\n>\n\nYes\n\n> > +\n> > +#perl scripts\n> > +set(git_perl_scripts\n> > +     git-add--interactive git-archimport git-cvsexportcommit\n> > +     git-cvsimport git-cvsserver git-send-email git-svn)\n> > +\n> > +#create perl header\n> > +file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )\n> > +string(REPLACE \"@@PATHSEP@@\" \":\" perl_header \"${perl_header}\")\n> > +string(REPLACE \"@@INSTLIBDIR@@\" \"${INSTLIBDIR}\" perl_header \"${perl_header}\")\n> > +\n> > +foreach(script ${git_perl_scripts})\n> > +     file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.perl content NEWLINE_CONSUME)\n> > +     string(REPLACE \"#!/usr/bin/perl\" \"#!/usr/bin/perl\\n${perl_header}\\n\" content \"${content}\")\n>\n> Hoped that this is tried on BSD?\n>\n> > +     string(REPLACE \"@@GIT_VERSION@@\" \"${PROJECT_VERSION}\" content \"${content}\")\n> > +     file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})\n> > +endforeach()\n> > +\n> > +#python script\n> > +file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)\n> > +string(REPLACE \"#!/usr/bin/env python\" \"#!/usr/bin/python\" content \"${content}\")\n> > +file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})\n> > +\n> > +#perl modules\n> > +file(GLOB_RECURSE perl_modules \"${CMAKE_SOURCE_DIR}/perl/*.pm\")\n> > +\n> > +foreach(pm ${perl_modules})\n> > +     string(REPLACE \"${CMAKE_SOURCE_DIR}/perl/\" \"\" file_path ${pm})\n>\n> So, the real source code have reference to CMAKE_SOURCE_DIR?\n> I don't think so? It's purely my guess from previous patch, this\n> function will do\n> string(REPLACE from to file something_I_have_not_checked)\n>\n\nThis if for getting the built perl modules in the right place \"perl/build/lib\"\nOnce I glob the files, their paths are absolute, hence a replacement.\n\n> > +     file(STRINGS ${pm} content NEWLINE_CONSUME)\n> > +     string(REPLACE \"@@LOCALEDIR@@\" \"${LOCALEDIR}\" content \"${content}\")\n> > +     string(REPLACE \"@@NO_PERL_CPAN_FALLBACKS@@\" \"\" content \"${content}\")\n> > +     file(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})\n> > +#test-lib.sh requires perl/build/lib to be the build directory of perl modules\n> > +endforeach()\n> > +\n> > +\n> > +#templates\n> > +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches\n> > +set(hooks_templates\n> > +     applypatch-msg.sample pre-applypatch.sample pre-push.sample\n> > +     commit-msg.sample pre-commit.sample pre-rebase.sample\n> > +     fsmonitor-watchman.sample pre-merge-commit.sample pre-receive.sample\n> > +     post-update.sample prepare-commit-msg.sample update.sample)\n>\n> Too much things merged into one line, I hate it.\n>\n\nwould you prefer something like this\nset(hooks_templates\n    applypatch-msg.sample\n    pre-applypatch.sample\n    ...)\n\n\n> > +\n> > +#templates have @.*@ replacement so use configure_file instead\n> > +#hooks\n> > +foreach(tm ${hooks_templates})\n> > +     configure_file(${CMAKE_SOURCE_DIR}/templates/hooks--${tm} ${CMAKE_BINARY_DIR}/templates/blt/hooks/${tm} @ONLY)\n> > +endforeach()\n>\n> What does this really means?\n>\n\nThe way above replacements(sed magic) use @@.*@@, whereas the\ntemplates use @.*@.\nThis pattern is what autoconf uses to configure Makefile.in, CMake\nalso has a similar feature (configure_file)\n\n> > +\n> > +#info\n> > +configure_file(${CMAKE_SOURCE_DIR}/templates/info--exclude ${CMAKE_BINARY_DIR}/templates/blt/info/exclude @ONLY)\n> > +\n> > +#this\n> > +configure_file(${CMAKE_SOURCE_DIR}/templates/this--description ${CMAKE_BINARY_DIR}/templates/blt/description @ONLY)\n> > +\n> > +\n> > +#translations\n> > +if(MSGFMT_EXE)\n> > +     set(po_files bg  ca  de  el  es  fr  is  it  ko  pt_PT  ru  sv  tr  vi  zh_CN  zh_TW)\n>\n> hard coded, so this is a regression, compared to old Makefile?\n>\n> > +     foreach(po ${po_files})\n> > +             file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES)\n> > +             add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo\n> > +                             COMMAND ${MSGFMT_EXE} --check --statistics -o ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo ${CMAKE_SOURCE_DIR}/po/${po}.po)\n>\n> find_package(Gettext) defines MSGFMT_EXECUTABLE, I think.\n> Have you check Solaris option?\n> Or is this tranlated from current Makefile?\n> I haven't checked current source code!\n>\n> > +             list(APPEND po_gen ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo)\n> > +     endforeach()\n> > +     add_custom_target(po-gen ALL DEPENDS ${po_gen})\n> > +endif()\n> > --\n> > gitgitgadget\n> >\n>\n> --\n> Danh\n\nThank You,\nSibi Siddharthan\n"},{"id":"396188","messageId":"CAKiG+9XWjASSJBx-=HWJ7-8_7fdJbEth2ZdMeSZLkviyUza1hQ@mail.gmail.com","threadId":"53305","inReplyTo":"20200424172312.GJ1949@danh.dev","subject":"Re: [PATCH 3/8] cmake: installation support for git","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-04-24T21:24:42Z","receivedAt":"2020-04-24T21:24:56Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Fri, Apr 24, 2020 at 10:53 PM Danh Doan <congdanhqx@gmail.com> wrote:\n>\n> On 2020-04-24 04:01:32+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> >\n> > This patch provides the facility to install the built binaries and\n> > scripts.\n> >\n> > This is very similar to `make install`.\n> > By default the destination directory(DESTDIR) is /usr/local/ on Linux\n> > To set a custom installation path do this:\n> > cmake `relative-path-to-srcdir`\n> >       -DCMAKE_INSTALL_PREFIX=`preferred-install-path`\n> >\n> > Then run `make install`\n> >\n> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> > ---\n> >  CMakeLists.txt | 49 +++++++++++++++++++++++++++++++++++++++++++++++++\n> >  1 file changed, 49 insertions(+)\n> >\n> > diff --git a/CMakeLists.txt b/CMakeLists.txt\n> > index 788b53be873..25de5b5bc35 100644\n> > --- a/CMakeLists.txt\n> > +++ b/CMakeLists.txt\n> > @@ -13,6 +13,8 @@ project(git\n> >       VERSION ${git_version}\n> >       LANGUAGES C)\n> >\n> > +#TODO gitk git-gui gitweb\n> > +#TODO Add pcre support\n> >\n> >  include(CheckTypeSize)\n> >  include(CheckCSourceRuns)\n> > @@ -631,3 +633,50 @@ if(MSGFMT_EXE)\n> >       endforeach()\n> >       add_custom_target(po-gen ALL DEPENDS ${po_gen})\n> >  endif()\n> > +\n> > +\n> > +#to help with the install\n> > +list(TRANSFORM git_shell_scripts PREPEND \"${CMAKE_BINARY_DIR}/\")\n> > +list(TRANSFORM git_perl_scripts PREPEND \"${CMAKE_BINARY_DIR}/\")\n> > +\n> > +#install\n> > +install(TARGETS git git-shell\n> > +     RUNTIME DESTINATION bin)\n> > +install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver  #${CMAKE_SOURCE_DIR}/gitk-git/gitk check\n>\n> check? What does it mean?\n>\n\nIt is part of a TODO for gitk, will remove it. Sorry\n\n> > +     DESTINATION bin)\n> > +\n> > +list(REMOVE_ITEM PROGRAMS_BUILT git git-shell)\n> > +install(TARGETS ${PROGRAMS_BUILT}\n> > +     RUNTIME DESTINATION libexec/git-core)\n>\n> Ubuntu install exec file to /usr/lib/git-core?\n>\n\nYes it does, but when I do `make install` the programs go to libexec/git-core\n\n> > +\n> > +set(bin_links\n> > +     git-receive-pack git-upload-archive git-upload-pack)\n> > +\n> > +foreach(b ${bin_links})\n> > +install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})\")\n> > +endforeach()\n> > +\n> > +install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)\")\n> > +install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)\")\n> > +\n> > +foreach(b ${git_links})\n> > +     string(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n> > +     install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n> > +endforeach()\n> > +\n> > +foreach(b ${git_http_links})\n> > +     string(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n> > +     install(CODE \"file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n> > +endforeach()\n> > +\n> > +install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4\n> > +     DESTINATION libexec/git-core)\n> > +\n> > +install(DIRECTORY mergetools DESTINATION libexec/git-core)\n> > +install(DIRECTORY ${CMAKE_BINARY_DIR}/perl/build/lib/ DESTINATION share/perl5\n> > +     FILES_MATCHING PATTERN \"*.pm\")\n>\n> I think distro gonna complans about this pattern!\n>\n\nWhat are you trying to say? Can you explain a bit more.\n\n> > +install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/templates)\n> > +\n> > +if(MSGFMT_EXE)\n> > +     install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)\n> > +endif()\n>\n> I thought we want to check for NO_GETTEXT?\n>\n> --\n> Danh\n\nThank You,\nSibi Siddharthan\n"},{"id":"396189","messageId":"CAKiG+9VTWuLvi3b+ynHmqvkNuEPZS12hcvRYcd-omoYvBOzKtw@mail.gmail.com","threadId":"53305","inReplyTo":"20200424172823.GK1949@danh.dev","subject":"Re: [PATCH 4/8] cmake: support for testing git with ctest","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-04-24T21:26:42Z","receivedAt":"2020-04-24T21:26:57Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Fri, Apr 24, 2020 at 10:58 PM Danh Doan <congdanhqx@gmail.com> wrote:\n>\n> On 2020-04-24 04:01:33+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> >\n> > This patch provides an alternate way to test git using ctest.\n> > CTest ships with CMake, so there is no additional dependency being\n> > introduced.\n> >\n> > To perform the tests with ctest do this after building:\n> > ctest -j[number of jobs]\n> >\n> > NOTE: -j is optional, the default number of jobs is 1\n> >\n> > Each of the jobs does this:\n> > cd t/ && sh t[something].sh\n> >\n> > The reason for using CTest is that it logs the output of the tests\n> > in a neat way, which can be helpful during diagnosis of failures.\n> >\n> > After the tests have run ctest generates three log files located in\n> > `build-directory`/Testing/Temporary/\n> >\n> > These log files are:\n> >\n> > CTestCostData.txt:\n> > This file contains the time taken to complete each test.\n> >\n> > LastTestsFailed.log:\n> > This log file contains the names of the tests that have failed in the\n> > run.\n> >\n> > LastTest.log:\n> > This log file contains the log of all the tests that have run.\n> > A snippet of the file is given below.\n> >\n> > 10/901 Testing: D:/my/git-master/t/t0009-prio-queue.sh\n> > 10/901 Test: D:/my/git-master/t/t0009-prio-queue.sh\n> > Command: \"sh.exe\" \"D:/my/git-master/t/t0009-prio-queue.sh\"\n> > Directory: D:/my/git-master/t\n> > \"D:/my/git-master/t/t0009-prio-queue.sh\"\n> > Output:\n> > ----------------------------------------------------------\n> > ok 1 - basic ordering\n> > ok 2 - mixed put and get\n> > ok 3 - notice empty queue\n> > ok 4 - stack order\n> > passed all 4 test(s)\n> > 1..4\n> > <end of output>\n> > Test time =   1.11 sec\n> >\n> > NOTE: Testing only works when building in source for now.\n> >\n> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> > ---\n> >  CMakeLists.txt | 142 +++++++++++++++++++++++++++++++++++++++++++++++++\n> >  1 file changed, 142 insertions(+)\n> >\n> > diff --git a/CMakeLists.txt b/CMakeLists.txt\n> > index 25de5b5bc35..141ccefa559 100644\n> > --- a/CMakeLists.txt\n> > +++ b/CMakeLists.txt\n> > @@ -23,6 +23,7 @@ include(CheckIncludeFile)\n> >  include(CheckFunctionExists)\n> >  include(CheckSymbolExists)\n> >  include(CheckStructHasMember)\n> > +include(CTest)\n> >\n> >  find_package(ZLIB REQUIRED)\n> >  find_package(CURL)\n> > @@ -680,3 +681,144 @@ install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/\n> >  if(MSGFMT_EXE)\n> >       install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)\n> >  endif()\n> > +\n> > +\n> > +if(BUILD_TESTING)\n> > +\n> > +#tests-helpers\n> > +add_executable(test-fake-ssh t/helper/test-fake-ssh.c)\n> > +target_link_libraries(test-fake-ssh common-main)\n> > +\n> > +add_executable(test-line-buffer t/helper/test-line-buffer.c)\n> > +target_link_libraries(test-line-buffer common-main vcs-svn)\n> > +\n> > +add_executable(test-svn-fe t/helper/test-svn-fe.c)\n> > +target_link_libraries(test-svn-fe common-main vcs-svn)\n> > +\n> > +set(test_helper_sources\n> > +     t/helper/test-tool.c t/helper/test-advise.c t/helper/test-bloom.c t/helper/test-chmtime.c\n> > +     t/helper/test-config.c t/helper/test-ctype.c t/helper/test-date.c t/helper/test-delta.c\n> > +     t/helper/test-dir-iterator.c t/helper/test-drop-caches.c t/helper/test-dump-cache-tree.c\n> > +     t/helper/test-dump-fsmonitor.c t/helper/test-dump-split-index.c\n> > +     t/helper/test-dump-untracked-cache.c t/helper/test-example-decorate.c\n> > +     t/helper/test-genrandom.c t/helper/test-genzeros.c t/helper/test-hash.c\n> > +     t/helper/test-hashmap.c t/helper/test-hash-speed.c t/helper/test-index-version.c\n> > +     t/helper/test-json-writer.c t/helper/test-lazy-init-name-hash.c\n> > +     t/helper/test-match-trees.c t/helper/test-mergesort.c t/helper/test-mktemp.c\n> > +     t/helper/test-oidmap.c t/helper/test-online-cpus.c t/helper/test-parse-options.c\n> > +     t/helper/test-parse-pathspec-file.c t/helper/test-path-utils.c t/helper/test-pkt-line.c\n> > +     t/helper/test-prio-queue.c t/helper/test-progress.c t/helper/test-reach.c\n> > +     t/helper/test-read-cache.c t/helper/test-read-graph.c t/helper/test-read-midx.c\n> > +     t/helper/test-ref-store.c t/helper/test-regex.c t/helper/test-repository.c\n> > +     t/helper/test-revision-walking.c t/helper/test-run-command.c t/helper/test-scrap-cache-tree.c\n> > +     t/helper/test-serve-v2.c t/helper/test-sha1.c t/helper/test-oid-array.c t/helper/test-sha256.c\n> > +     t/helper/test-sigchain.c t/helper/test-strcmp-offset.c t/helper/test-string-list.c\n> > +     t/helper/test-submodule-config.c t/helper/test-submodule-nested-repo-config.c t/helper/test-subprocess.c\n> > +     t/helper/test-trace2.c t/helper/test-urlmatch-normalization.c t/helper/test-xml-encode.c\n> > +     t/helper/test-wildmatch.c t/helper/test-windows-named-pipe.c t/helper/test-write-cache.c)\n> > +\n> > +add_executable(test-tool ${test_helper_sources})\n> > +target_link_libraries(test-tool common-main)\n> > +\n> > +set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool\n> > +                     PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)\n> > +\n> > +#wrapper scripts\n> > +set(wrapper_scripts\n> > +     git git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)\n> > +\n> > +set(wrapper_test_scripts\n> > +     test-fake-ssh test-line-buffer test-svn-fe test-tool)\n> > +\n> > +\n> > +foreach(script ${wrapper_scripts})\n> > +     file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n> > +     string(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n> > +     string(REPLACE \"@@PROG@@\" \"${script}\" content \"${content}\")\n> > +     file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n> > +endforeach()\n> > +\n> > +foreach(script ${wrapper_test_scripts})\n> > +     file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n> > +     string(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n> > +     string(REPLACE \"@@PROG@@\" \"t/helper/${script}\" content \"${content}\")\n> > +     file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n> > +endforeach()\n> > +\n> > +file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n> > +string(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n> > +string(REPLACE \"@@PROG@@\" \"git-cvsserver\" content \"${content}\")\n> > +file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})\n> > +\n> > +#options for configuring test options\n> > +option(PERL_TESTS \"Perform tests that use perl\" ON)\n> > +option(PYTHON_TESTS \"Perform tests that use python\" ON)\n> > +\n> > +#GIT-BUILD-OPTIONS\n> > +set(TEST_SHELL_PATH ${SHELL_PATH})\n> > +set(DIFF diff)\n> > +set(PYTHON_PATH /usr/bin/python)\n> > +set(TAR tar)\n> > +set(NO_CURL )\n> > +set(NO_EXPAT )\n> > +set(USE_LIBPCRE1 )\n> > +set(USE_LIBPCRE2 )\n>\n> Hm, really?\n>\n>\n\nThese are generated by default on the Makefile also.\n\n> > +set(NO_LIBPCRE1_JIT )\n> > +set(NO_PERL )\n> > +set(NO_PTHREADS )\n> > +set(NO_PYTHON )\n> > +set(PAGER_ENV \"LESS=FRX LV=-c\")\n> > +set(DC_SHA1 YesPlease)\n> > +set(RUNTIME_PREFIX true)\n> > +set(NO_GETTEXT )\n> > +\n> > +if(NOT CURL_FOUND)\n> > +     set(NO_CURL 1)\n> > +endif()\n> > +\n> > +if(NOT EXPAT_FOUND)\n> > +     set(NO_EXPAT 1)\n> > +endif()\n> > +\n> > +if(NOT Intl_FOUND)\n> > +     set(NO_GETTEXT 1)\n> > +endif()\n> > +\n> > +if(NOT PERL_TESTS)\n> > +     set(NO_PERL 1)\n> > +endif()\n> > +\n> > +if(NOT PYTHON_TESTS)\n> > +     set(NO_PYTHON 1)\n> > +endif()\n>\n> I hope we have something like:\n>\n> PYTHON_PATH=/path/to/my/yet/to/release/python/to/check/if/it/works/with/current/git\n>\n> If it's ready, thanks.\n> If it isn't, no, I'm stressed enough by CMake.\n>\n\nYes it can be done.\n\n> > +\n> > +file(WRITE ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"SHELL_PATH='${SHELL_PATH}'\\n\")\n> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"TEST_SHELL_PATH='${TEST_SHELL_PATH}'\\n\")\n> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PERL_PATH='${PERL_PATH}'\\n\")\n> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"DIFF='${DIFF}'\\n\")\n> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PYTHON_PATH='${PYTHON_PATH}'\\n\")\n> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"TAR='${TAR}'\\n\")\n> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_CURL='${NO_CURL}'\\n\")\n> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_EXPAT='${NO_EXPAT}'\\n\")\n> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"USE_LIBPCRE1='${USE_LIBPCRE1}'\\n\")\n> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_LIBPCRE1_JIT='${NO_LIBPCRE1_JIT}'\\n\")\n> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PERL='${NO_PERL}'\\n\")\n> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PTHREADS='${NO_PTHREADS}'\\n\")\n> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\\n\")\n> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PAGER_ENV='${PAGER_ENV}'\\n\")\n> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"DC_SHA1='${DC_SHA1}'\\n\")\n> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"X=''\\n\")\n> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_GETTEXT='${NO_GETTEXT}'\\n\")\n> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"RUNTIME_PREFIX='${RUNTIME_PREFIX}'\\n\")\n> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PYTHON='${NO_PYTHON}'\\n\")\n> > +\n> > +file(GLOB test_scipts \"${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh\")\n>\n> CMake recommends to not use GLOB for this kind of things, themselves, no?\n>\n> > +\n> > +#test\n> > +foreach(tsh ${test_scipts})\n> > +     add_test(NAME ${tsh}\n> > +             COMMAND ${SH_EXE} ${tsh}\n> > +             WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t)\n> > +endforeach()\n> > +\n> > +endif()#BUILD_TESTING\n> > \\ No newline at end of file\n>\n> Please fix your editor!\n>\n> --\n> Danh\n\nThank You,\nSibi Siddharthan\n"},{"id":"396190","messageId":"CAKiG+9V=bJNqrHRy8y8cbjkgzrmhOMMz47+8fgfQARAetx4MFQ@mail.gmail.com","threadId":"53305","inReplyTo":"20200424173433.GL1949@danh.dev","subject":"Re: [PATCH 5/8] cmake: support for testing git when building out of the source tree","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-04-24T21:32:49Z","receivedAt":"2020-04-24T21:33:03Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Fri, Apr 24, 2020 at 11:04 PM Danh Doan <congdanhqx@gmail.com> wrote:\n>\n> On 2020-04-24 04:01:34+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> >\n> > This patch allows git to be tested when performin out of source builds.\n> >\n> > This involves changing GIT_BUILD_DIR in t/test-lib.sh to point to the\n> > build directory. Also some miscellaneous copies from the source directory\n> > to the build directory.\n> > The copies are:\n> > t/chainlint.sed needed by a bunch of test scripts\n> > po/is.po needed by t0204-gettext-rencode-sanity\n> > mergetools/tkdiff needed by t7800-difftool\n> > contrib/completion/git-prompt.sh needed by t9903-bash-prompt\n> > contrib/completion/git-completion.bash needed by t9902-completion\n> > contrib/svn-fe/svnrdump_sim.py needed by t9020-remote-svn\n> >\n> > NOTE: t/test-lib.sh is only modified when tests are run not during\n> > the build or configure.\n> > The trash directory is still srcdir/t\n> >\n> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> > ---\n> >  CMakeLists.txt | 19 +++++++++++++++++++\n> >  1 file changed, 19 insertions(+)\n> >\n> > diff --git a/CMakeLists.txt b/CMakeLists.txt\n> > index 141ccefa559..29a23eb11f7 100644\n> > --- a/CMakeLists.txt\n> > +++ b/CMakeLists.txt\n> > @@ -812,6 +812,25 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_GETTEXT='${NO_GETTEXT}'\\n\"\n> >  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"RUNTIME_PREFIX='${RUNTIME_PREFIX}'\\n\")\n> >  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PYTHON='${NO_PYTHON}'\\n\")\n> >\n> > +#Make the tests work when building out of the source tree\n> > +if(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})\n>\n> IIRC, CMake recommends _NOT_ expand variable inside if()\n> This very inconsistent recommendation of CMake (when should I use\n> ${var} and when should I use var?) is one of reason I hate CMake\n>\n\nI know, I got taken aback at first, but then you get used to it.\n\n> > +     file(RELATIVE_PATH BUILD_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/CMakeCache.txt)\n> > +     string(REPLACE \"/CMakeCache.txt\" \"\" BUILD_DIR_RELATIVE ${BUILD_DIR_RELATIVE})\n>\n> I don't know what is going on here!\n>\n\nWe are trying find the relative path to the build directory from the\nsource directory\nfile(RELATIVE_PATH ...)  requires a file in the to \"whatever\" directory.\nThe one file that is always present in the build directory after a\nCMake configure is CMakeCache.txt, so we use that.\nThen we remove \"CMakeCache.txt\" from the variable \"BUILD_DIR_RELATIVE\"\nto get the actual relative path.\n\n> > +     #Setting the build directory in test-lib.sh before running tests\n> > +     file(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.cmake\n> > +             \"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh GIT_BUILD_DIR_REPL REGEX \\\"GIT_BUILD_DIR=(.*)\\\")\\n\"\n> > +             \"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh content NEWLINE_CONSUME)\\n\"\n> > +             \"string(REPLACE \\\"\\${GIT_BUILD_DIR_REPL}\\\" \\\"GIT_BUILD_DIR=\\\\\\\"$TEST_DIRECTORY\\\\\\\"/../${BUILD_DIR_RELATIVE}\\\" content \\\"\\${content}\\\")\\n\"\n> > +             \"file(WRITE ${CMAKE_SOURCE_DIR}/t/test-lib.sh \\${content})\")\n> > +     #misc copies\n> > +     file(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.sed DESTINATION ${CMAKE_BINARY_DIR}/t/)\n>\n> So, some sed will be used in Windows without POSIX-like system,\n> interesting!\n>\n> > +     file(COPY ${CMAKE_SOURCE_DIR}/po/is.po DESTINATION ${CMAKE_BINARY_DIR}/po/)\n> > +     file(COPY ${CMAKE_SOURCE_DIR}/mergetools/tkdiff DESTINATION ${CMAKE_BINARY_DIR}/mergetools/)\n> > +     file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-prompt.sh DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)\n> > +     file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-completion.bash DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)\n> > +     file(COPY ${CMAKE_SOURCE_DIR}/contrib/svn-fe/svnrdump_sim.py DESTINATION ${CMAKE_BINARY_DIR}/contrib/svn-fe/)\n> > +endif()\n> > +\n> >  file(GLOB test_scipts \"${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh\")\n>\n> Remember cmake won't be re-run if nothing was changed in CMakeList.txt\n> If I only change some code, and I decided the change I make should be\n> tested by a-new-and-independent-test-script.\n> I need to re-run cmake manually! I don't like it, at all.\n>\n\nNo you don't have re-run CMake.\n\n>\n> --\n> Danh\n\nThank You,\nSibi Siddharthan\n"},{"id":"396191","messageId":"CAKiG+9Wr+-ax_2=eK+n0Kt50hafTZd-xwxNf5cG96a-RCFP_jA@mail.gmail.com","threadId":"53305","inReplyTo":"20200424173951.GM1949@danh.dev","subject":"Re: [PATCH 7/8] cmake: support for building git on windows with msvc and clang.","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-04-24T21:35:16Z","receivedAt":"2020-04-24T21:35:30Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Fri, Apr 24, 2020 at 11:09 PM Danh Doan <congdanhqx@gmail.com> wrote:\n>\n> On 2020-04-24 04:01:36+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> >\n> > This patch adds support for Visual Studio and Clang builds\n> >\n> > The minimum required version of CMake is upgraded to 3.15 because\n> > this version offers proper support for Clang builds on Windows.\n> >\n> > Libintl is not searched for when building with Visual Studio or Clang\n> > because there is no binary compatible version available yet.\n> >\n> > NOTE: In the link options invalidcontinue.obj has to be included.\n> > The reason for this is because by default, Windows calls abort()'s\n> > instead of setting errno=EINVAL when invalid arguments are passed to\n> > standard functions.\n> > This commit explains it in detail:\n> > 4b623d80f73528a632576990ca51e34c333d5dd6\n> >\n> > On Windows the default generator is Visual Studio,so for Visual Studio\n> > builds do this:\n> >\n> > cmake `relative-path-to-srcdir`\n> >\n> > NOTE: Visual Studio generator is a multi config generator, which means\n> > that Debug and Release builds can be done on the same build directory.\n> >\n> > For Clang builds do this:\n> >\n> > On bash\n> > CC=Clang cmake `relative-path-to-srcdir` -G Ninja\n> >               -DCMAKE_BUILD_TYPE=[Debug or Release]\n> >\n> > On cmd\n> > set CC=Clang\n> > cmake `relative-path-to-srcdir` -G Ninja\n> >               -DCMAKE_BUILD_TYPE=[Debug or Release]\n> >\n> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> > ---\n> >  CMakeLists.txt | 57 ++++++++++++++++++++++++++++++++++++++++----------\n> >  1 file changed, 46 insertions(+), 11 deletions(-)\n> >\n> > diff --git a/CMakeLists.txt b/CMakeLists.txt\n> > index d9eb1060390..5ad3a2557f7 100644\n> > --- a/CMakeLists.txt\n> > +++ b/CMakeLists.txt\n> > @@ -2,7 +2,7 @@\n> >  #    Copyright (c) 2020 Sibi Siddharthan\n> >  #\n> >\n> > -cmake_minimum_required(VERSION 3.14)\n> > +cmake_minimum_required(VERSION 3.15)\n>\n> 3.14 is a step too far, and, now, we want CMake 3.15?\n>\n> >\n> >  #Parse GIT-VERSION-GEN to get the version\n> >  file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX \"DEF_VER=v(.*)\")\n> > @@ -32,8 +32,11 @@ find_package(ZLIB REQUIRED)\n> >  find_package(CURL)\n> >  find_package(EXPAT)\n> >  find_package(Iconv)\n> > -find_package(Intl)\n> >\n> > +#Don't use libintl on Windows Visual Studio and Clang builds\n> > +if(NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL \"MSVC\" OR CMAKE_C_COMPILER_ID STREQUAL \"Clang\")))\n> > +     find_package(Intl)\n> > +endif()\n> >\n> >  if(NOT Intl_FOUND)\n> >       add_compile_definitions(NO_GETTEXT)\n> > @@ -61,7 +64,7 @@ if(NOT SH_EXE)\n> >       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/\")\n> >  endif()\n> >\n> > -if(WIN32)\n> > +if(WIN32 AND NOT MSVC)#not required for visual studio builds\n> >       find_program(WINDRES_EXE windres)\n> >       if(NOT WINDRES_EXE)\n> >               message(FATAL_ERROR \"Install windres on Windows for resource files\")\n> > @@ -73,6 +76,13 @@ if(NOT MSGFMT_EXE)\n> >       message(WARNING \"Text Translations won't be build\")\n> >  endif()\n> >\n> > +#Force all visual studio outputs to CMAKE_BINARY_DIR\n> > +if(CMAKE_C_COMPILER_ID STREQUAL \"MSVC\")\n> > +     set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})\n> > +     set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})\n> > +     add_compile_options(/MP)\n> > +endif()\n> > +\n> >  #default behaviour\n> >  include_directories(${CMAKE_SOURCE_DIR})\n> >  add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n> > @@ -110,6 +120,10 @@ endif()\n> >\n> >  #Platform Specific\n> >  if(${CMAKE_SYSTEM_NAME} STREQUAL \"Windows\")\n> > +     if(CMAKE_C_COMPILER_ID STREQUAL \"MSVC\" OR CMAKE_C_COMPILER_ID STREQUAL \"Clang\")\n> > +             include_directories(compat/vcbuild/include)\n> > +             add_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)\n>\n> This is fair, I hate those warning, too.\n>\n> Is _CRT_NONSTDC_NO_DEPRECATE implied when _CRT_SECURE_NO_WARNINGS\n> defined? Or otherwise around?\n>\n>\n\nThey both are independent\n\n> --\n> Danh\n\nThank You,\nSibi Siddharthan\n"},{"id":"396192","messageId":"CAKiG+9UNdasm_+zx_UhTvqdbiCDfE0TwFiC3SAO0B=njHbAa0A@mail.gmail.com","threadId":"53305","inReplyTo":"20200424174544.GN1949@danh.dev","subject":"Re: [PATCH 8/8] ci: modification of main.yml to use cmake for vs-build job","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-04-24T21:41:56Z","receivedAt":"2020-04-24T21:42:15Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Fri, Apr 24, 2020 at 11:15 PM Danh Doan <congdanhqx@gmail.com> wrote:\n>\n> On 2020-04-24 04:01:37+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> >\n> > This patch modifies .github/workflows/main.yml to use CMake for\n> > Visual Studio builds.\n> >\n> > Modified the vs-test step to match windows-test step. This speeds\n> > up the vs-test. Calling git-cmd from powershell and then calling git-bash\n> > to perform the tests slows things down(factor of about 6). So git-bash\n> > is directly called from powershell to perform the tests using prove.\n> >\n> > NOTE: Since GitHub keeps the same directory for each job\n> > (with respect to path) absolute paths are used in the bin-wrapper\n> > scripts.\n> >\n> > GitHub has switched to CMake 3.17.1 which changed the behaviour of\n> > FindCURL module. An extra definition (-DCURL_NO_CURL_CMAKE=ON) has been\n> > added to revert to the old behaviour.\n> >\n> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> > ---\n> >  .github/workflows/main.yml | 43 ++++++++++++++++++++++----------------\n> >  1 file changed, 25 insertions(+), 18 deletions(-)\n> >\n> > diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml\n> > index fd4df939b50..94f9a385225 100644\n> > --- a/.github/workflows/main.yml\n> > +++ b/.github/workflows/main.yml\n> > @@ -80,13 +80,6 @@ jobs:\n> >      - name: download git-sdk-64-minimal\n> >        shell: bash\n> >        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 -\n> > -    - name: generate Visual Studio solution\n> > -      shell: powershell\n> > -      run: |\n> > -        & .\\git-sdk-64-minimal\\usr\\bin\\bash.exe -lc @\"\n> > -          make NDEBUG=1 DEVELOPER=1 vcxproj\n> > -        \"@\n> > -        if (!$?) { exit(1) }\n> >      - name: download vcpkg artifacts\n> >        shell: powershell\n> >        run: |\n> > @@ -98,6 +91,13 @@ jobs:\n> >          Remove-Item compat.zip\n> >      - name: add msbuild to PATH\n> >        uses: microsoft/setup-msbuild@v1.0.0\n> > +    - name: generate Visual Studio solution\n> > +      shell: powershell\n> > +      run: |\n> > +        & .\\git-sdk-64-minimal\\usr\\bin\\bash.exe -lc @\"\n> > +          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\n> > +        \"@\n> > +        if (!$?) { exit(1) }\n>\n> If you intended to modified some steps to provide a better script for\n> that step, I believe you should change in that step.\n>\n> If the order of those steps need to be changed, please clarify your\n> reasoning!\n>\n\nPreviously, the Visual Studio solution was generated, then the vcpkg\nartifacts were downloaded.\nWith CMake, as it searched for the libraries during configure the\nvcpkg artifacts are now downloaded before the configure step.\n\n> >      - name: MSBuild\n> >        run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142\n> >      - name: bundle artifact tar\n> > @@ -125,9 +125,9 @@ jobs:\n> >          nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n> >      steps:\n> >      - uses: actions/checkout@v1\n> > -    - name: download git-64-portable\n> > +    - name: download git-sdk-64-minimal\n> >        shell: bash\n> > -      run: a=git-64-portable && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -\n> > +      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 -\n> >      - name: download build artifacts\n> >        uses: actions/download-artifact@v1\n> >        with:\n> > @@ -136,23 +136,30 @@ jobs:\n> >      - name: extract build artifacts\n> >        shell: bash\n> >        run: tar xf artifacts.tar.gz\n> > -    - name: test (parallel)\n> > +    - name: test\n>\n> So the test couldn't be run in parallel anymore?\n> It's a regression!\n> And we don't need the matrix anymore!!!!!\n>\n> I wonder if Dscho's effort is wasted, he tried very hard to make\n> those tests run in parallel.\n> He even tried to re-order the matrix in GfW project to let longest\n> test run first!\n>\n>\n\nOkay, When I removed \"(parallel)\" does not mean that the tests are not\nrun in parallel.\nNow they are run in the same way how windows-test(step) is run.\nThe tests(vs-test) actually completes before than the windows-test in the CI\n\n> >        shell: powershell\n> >        env:\n> >          MSYSTEM: MINGW64\n> >          NO_SVN_TESTS: 1\n> >          GIT_TEST_SKIP_REBASE_P: 1\n> >        run: |\n> > -        & git-64-portable\\git-cmd.exe --command=usr\\bin\\bash.exe -lc @\"\n> > -          # Let Git ignore the SDK and the test-cache\n> > -          printf '%s\\n' /git-64-portable/ /test-cache/ >>.git/info/exclude\n> > +        & .\\git-sdk-64-minimal\\usr\\bin\\bash.exe -lc @\"\n> > +          # Let Git ignore the SDK\n> > +          printf '%s\\n' /git-sdk-64-minimal/ >>.git/info/exclude\n> >\n> > -          cd t &&\n> > -          PATH=\\\"`$PWD/helper:`$PATH\\\" &&\n> > -          test-tool.exe run-command testsuite --jobs=10 -V -x --write-junit-xml \\\n> > -                  `$(test-tool.exe path-utils slice-tests \\\n> > -                          ${{matrix.nr}} 10 t[0-9]*.sh)\n> > +          ci/run-test-slice.sh ${{matrix.nr}} 10\n> >          \"@\n> > +    - name: ci/print-test-failures.sh\n> > +      if: failure()\n> > +      shell: powershell\n> > +      run: |\n> > +        & .\\git-sdk-64-minimal\\usr\\bin\\bash.exe -lc ci/print-test-failures.sh\n>\n> What is changed?\n>\n> --\n> Danh\n\nThank You,\nSibi Siddharthan\n"},{"id":"396193","messageId":"xmqq8sikblv2.fsf@gitster.c.googlers.com","threadId":"53305","inReplyTo":"CAKiG+9V_nZUXf2a689vZ54rG+xTCFMGcJe_7Av-khaxxuijERg@mail.gmail.com","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-04-24T21:43:45Z","receivedAt":"2020-04-24T21:43:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n\n> The goal would be to maintain a CMake build for Git keeping it in sync\n> with the Makefile.\n> The Makefile is not going to be replaced at all. The CMake script for\n> now only supports Linux and Windows.\n> It does not support BSD, Solaris and others, whereas the Makefile does\n> support them.\n\nSo you are doing (1).  I already said that I feel that engineering\nburden to divert resources for CMake support would be unacceptably\nhigh.\n\nWhenever any of our developers need to add source files, Makefile\nconfiguration knobs that people can add to config.mak, etc., you are\nforcing them to figure out where in the CMakefile to add them or\ndevise ways to allow builders who do not use config.mak (because\nthey use CMake) to do similar tweaks.\n\nAny patch that is acceptable to the current project would become\nunacceptable because they lack updates to CMake part, but I suspect\nwe do not have enough people who are so much devoted to give a good\nreview if updates to CMake part are added.  And it is unclear why it\nwould be beneficial to slow our existing developers down by forcing\nthem to become familiar with CMake.\n\nSo..., I am not just \"still not convinced\", but I am even more\nconvinced that we do not want this series, after thinking about it\nlonger.\n\nThanks.\n\n"},{"id":"396194","messageId":"nycvar.QRO.7.76.6.2004242335100.18039@tvgsbejvaqbjf.bet","threadId":"53305","inReplyTo":"20200424174544.GN1949@danh.dev","subject":"Re: [PATCH 8/8] ci: modification of main.yml to use cmake for vs-build job","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-04-24T21:44:22Z","receivedAt":"2020-04-24T21:44:30Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Danh,\n\nOn Sat, 25 Apr 2020, Danh Doan wrote:\n\n> On 2020-04-24 04:01:37+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> >\n> > @@ -98,6 +91,13 @@ jobs:\n> >          Remove-Item compat.zip\n> >      - name: add msbuild to PATH\n> >        uses: microsoft/setup-msbuild@v1.0.0\n> > +    - name: generate Visual Studio solution\n> > +      shell: powershell\n> > +      run: |\n> > +        & .\\git-sdk-64-minimal\\usr\\bin\\bash.exe -lc @\"\n> > +          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\n> > +        \"@\n> > +        if (!$?) { exit(1) }\n>\n> If you intended to modified some steps to provide a better script for\n> that step, I believe you should change in that step.\n>\n> If the order of those steps need to be changed, please clarify your\n> reasoning!\n\nIt is the order that needs to be changed, indeed: The CMake step requires\nthe vcpkg artifacts (i.e. pre-built dependencies like curl), whereas the\nprevious `make vcxproj` did not require them.\n\nAnd yes, that's good material for the commit message!\n\n> >      - name: MSBuild\n> >        run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142\n> >      - name: bundle artifact tar\n> > @@ -125,9 +125,9 @@ jobs:\n> >          nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n> >      steps:\n> >      - uses: actions/checkout@v1\n> > -    - name: download git-64-portable\n> > +    - name: download git-sdk-64-minimal\n> >        shell: bash\n> > -      run: a=git-64-portable && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -\n> > +      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 -\n> >      - name: download build artifacts\n> >        uses: actions/download-artifact@v1\n> >        with:\n> > @@ -136,23 +136,30 @@ jobs:\n> >      - name: extract build artifacts\n> >        shell: bash\n> >        run: tar xf artifacts.tar.gz\n> > -    - name: test (parallel)\n> > +    - name: test\n>\n> So the test couldn't be run in parallel anymore?\n> It's a regression!\n> And we don't need the matrix anymore!!!!!\n>\n> I wonder if Dscho's effort is wasted, he tried very hard to make\n> those tests run in parallel.\n\nNo need to worry, it's still parallel.\n\nThe reason why it looks incorrect is that Sibi used the `windows-test` job\nas an example rather than the `vs-test` one. For that reason, it is the\nfull `git-sdk-64-minimal` rather than the portable Git in which the tests\nare run.\n\nI would prefer to re-revert this again, to use the `(parallel)` and the\n`git-64-portable` again.\n\n> He even tried to re-order the matrix in GfW project to let longest\n> test run first!\n\nI did! And it was quite a bit of manual work because the times are not\nreally obvious from the logs, you have to script something to get at them.\nIn the end, it was not worth the effort, as the overall runtime was only\nminimally faster, and I did not like how the order could become stale and\nless helpful over time.\n\n> >        shell: powershell\n> >        env:\n> >          MSYSTEM: MINGW64\n> >          NO_SVN_TESTS: 1\n> >          GIT_TEST_SKIP_REBASE_P: 1\n> >        run: |\n> > -        & git-64-portable\\git-cmd.exe --command=usr\\bin\\bash.exe -lc @\"\n> > -          # Let Git ignore the SDK and the test-cache\n> > -          printf '%s\\n' /git-64-portable/ /test-cache/ >>.git/info/exclude\n> > +        & .\\git-sdk-64-minimal\\usr\\bin\\bash.exe -lc @\"\n> > +          # Let Git ignore the SDK\n> > +          printf '%s\\n' /git-sdk-64-minimal/ >>.git/info/exclude\n> >\n> > -          cd t &&\n> > -          PATH=\\\"`$PWD/helper:`$PATH\\\" &&\n> > -          test-tool.exe run-command testsuite --jobs=10 -V -x --write-junit-xml \\\n> > -                  `$(test-tool.exe path-utils slice-tests \\\n> > -                          ${{matrix.nr}} 10 t[0-9]*.sh)\n> > +          ci/run-test-slice.sh ${{matrix.nr}} 10\n> >          \"@\n> > +    - name: ci/print-test-failures.sh\n> > +      if: failure()\n> > +      shell: powershell\n> > +      run: |\n> > +        & .\\git-sdk-64-minimal\\usr\\bin\\bash.exe -lc ci/print-test-failures.sh\n>\n> What is changed?\n\nThis also is a consequence of copy/editing the `windows-test` job instead\nof the `vs-test` one: The portable Git does not bring enough stuff to run\n`prove`, therefore we have to \"roll our own runner\" here.\n\nUnless we use the substantially larger `git-sdk-64-minimal`. But the idea\nhere _was_ to test in as similar a fashion to developers on Windows: they\nwould not want to download the full Git for Windows SDK, but run the test\nin the Bash of a regular Git for Windows instead.\n\nIndeed, you could say that in a way, this entire patch series is about\ntrying to make it unnecessary for developers on Windows to download more\nthan 500MB just to start tinkering with the Git source code.\n\nOr maybe the patch series is about more than just that, but that alone\nwould be reason enough to want it. And I think we do want it.\n\nCiao,\nDscho\n"},{"id":"396203","messageId":"20200424225621.GD721@danh.dev","threadId":"53305","inReplyTo":"CAKiG+9VxPkqq-iLCu9pj=jf_4Lgq+05aFb9avfH8dtDtNVzy4w@mail.gmail.com","subject":"Re: [PATCH 1/8] Introduce CMake support for configuring Git on Linux","fromName":"Danh Doan","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-04-24T22:56:21Z","receivedAt":"2020-04-24T22:56:26Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2020-04-25 02:36:12+0530, Sibi Siddharthan <sibisiddharthan.github@gmail.com> wrote:\n> Yes it does,\n> all you have to do is -DZLIB_ROOT=/path/to/zlib/root\n\nOK, I need to learn this syntax\n\n> > > +find_package(EXPAT)\n> > > +find_package(Iconv)\n> > > +find_package(Intl)\n> > > +\n> >\n> > > +if(NOT Intl_FOUND)\n> > > +     add_compile_definitions(NO_GETTEXT)\n> >\n> > find_package(Gettext)?\n> >\n> \n> find_package(Gettext) does not define libintl and libintl.h.\n> If NO_GETTEXT is not defined, it means that libintl.h is present.\n> So, we use find_package(Intl) for libintl\n\nPeople do weird things.\n\nBut, I bet that a lot of people have system that have libintl.h\ninstalled, but they don't install gettext tools. ;-)\n\nAnyway, can I override NO_GETTEXT from command line?\n\nLet's say, I want to bootstrap a new distro?\nIn the boostrap step, I don't want to build any i18n things,\nbecause the bootstrap package will be thrown away and rebuild again.\nI don't want to waste time on building such translation things.\n\n> \n> > > +     if(NOT Iconv_FOUND)\n> > > +             add_compile_definitions(NO_ICONV)\n> > > +     endif()\n> > > +endif()\n> >\n> > ICONV_OMITS_BOM?\n> >\n> \n> Forgot about this, will add it.\n\nThanks, my platform relies on this definition!\n\n> > > +\n> > > +include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})\n> > > +if(CURL_FOUND)\n> > > +     include_directories(SYSTEM ${CURL_INCLUDE_DIRS})\n> > > +endif()\n> > > +if(EXPAT_FOUND)\n> > > +     include_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})\n> > > +endif()\n> > > +if(Iconv_FOUND)\n> > > +     include_directories(SYSTEM ${Iconv_INCLUDE_DIRS})\n> > > +endif()\n> > > +if(Intl_FOUND)\n> > > +     include_directories(SYSTEM ${Intl_INCLUDE_DIRS})\n> > > +endif()\n> > > +\n> > > +find_program(SH_EXE sh)\n> >\n> > We want to find usable sh, not just sh, no?\n> >\n> > It's matter on Solaris, HP-UX\n> >\n> \n> How do I check for this, can you help?\n\nSorry, Please ask someone else, check Makefile to see who fixed build\nfor Solaris and HP-UX.\n\n> Also, the script is not supported on Solaris and HP-UX.\n\nIf Solaris or HP-UX is out of equation,\nI'll just write: SH_EXE=/bin/sh ;-)\n\n\n> \n> > > +\n> > > +#default behaviour\n> > > +include_directories(${CMAKE_SOURCE_DIR})\n> > > +add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n> > > +add_compile_definitions(SHA256_BLK INTERNAL_QSORT RUNTIME_PREFIX)\n> > > +add_compile_definitions(NO_OPENSSL SHA1_DC SHA1DC_NO_STANDARD_INCLUDES\n> > > +                     SHA1DC_INIT_SAFE_HASH_DEFAULT=0\n> > > +                     SHA1DC_CUSTOM_INCLUDE_SHA1_C=\"cache.h\"\n> > > +                     SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"git-compat-util.h\" )\n> > > +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)\n> > > +\n> > > +\n> > > +add_compile_definitions(PAGER_ENV=\"LESS=FRX LV=-c\"\n> > > +                     ETC_GITATTRIBUTES=\"etc/gitattributes\"\n> > > +                     ETC_GITCONFIG=\"etc/gitconfig\"\n> > > +                     GIT_EXEC_PATH=\"libexec/git-core\"\n> > > +                     GIT_LOCALE_PATH=\"share/locale\"\n> > > +                     GIT_MAN_PATH=\"share/man\"\n> > > +                     GIT_INFO_PATH=\"share/info\"\n> > > +                     GIT_HTML_PATH=\"share/doc/git-doc\"\n> > > +                     DEFAULT_HELP_FORMAT=\"html\"\n> > > +                     DEFAULT_GIT_TEMPLATE_DIR=\"share/git-core/templates\"\n> > > +                     GIT_VERSION=\"${PROJECT_VERSION}.GIT\"\n> > > +                     GIT_USER_AGENT=\"git/${PROJECT_VERSION}.GIT\"\n> > > +                     BINDIR=\"bin\"\n> > > +                     GIT_BUILT_FROM_COMMIT=\"\")\n> >\n> > I wish I could verify this.\n> > Have you check this part on a default build system for a Linux distro,\n> > FreeBSD? For things started with \"etc/\"\n> >\n> \n> These are the values I got when I looked at the build logs from the\n> Makefile (make -n) in Linux and Windows.\n> Don't know about FreeBSD\n\nLinux will install configuration to /etc, Windows (by using msys),\nwill also do that.\n\n*BSD port installs git with /usr/local prefix, and install\nconfiguration to /usr/local/etc\n\n> \n> > > +\n> > > +set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n> > > +add_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n> > > +\n> > > +add_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n> >\n> > /proc/self/exe is Linux only, no?\n> >\n> \n> Yes, it is. This first patch only supports Linux build.\n> \n> > > +list(APPEND compat_SOURCES unix-socket.c)\n> > > +\n> > > +#header checks\n> > > +check_include_file(libgen.h HAVE_LIBGEN_H)\n> > > +if(NOT HAVE_LIBGEN_H)\n> > > +     add_compile_definitions(NO_LIBGEN_H)\n> > > +     list(APPEND compat_SOURCES compat/basename.c)\n> > > +endif()\n> > > +\n> > > +check_include_file(sys/sysinfo.h HAVE_SYSINFO)\n> > > +if(HAVE_SYSINFO)\n> > > +     add_compile_definitions(HAVE_SYSINFO)\n> > > +endif()\n> > > +\n> > > +check_c_source_compiles(\"\n> > > +#include <alloca.h>\n> > > +int\n> > > +main ()\n> > > +{\n> > > +char *p = (char *) alloca (2 * sizeof (int));\n> > > +     if (p) return 0;\n> > > +     return 0;\n> >\n> > All code path will return 0?\n> >\n> \n> This check is for a working alloca.h.\n> Some systems define alloca in malloc.h (Windows)\n\nDoes CMake have a macro for check function in which include files?\n\n> \n> > > +}\"\n> > > +HAVE_ALLOCA_H)\n> > > +if(HAVE_ALLOCA_H)\n> > > +     add_compile_definitions(HAVE_ALLOCA_H)\n> > > +endif()\n> > > +\n> > > +\n> > > +if(CURL_FOUND)\n> > > +     set(remote_exes\n> > > +             git-remote-https git-remote-ftp git-remote-ftps)\n> > > +     foreach(s ${remote_exes})\n> > > +             file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git-remote-http ${s})\\n\")\n\nNow, I looked at this again.\nI didn't see the creatation of CreateLinks.cmake anywhere!\n\n> > > +             list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})\n> > > +     endforeach()\n> > > +endif()\n> > > +\n> > > +add_custom_command(OUTPUT ${git_links} ${git_http_links}\n> > > +             COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake\n> > > +             DEPENDS git git-remote-http)\n> > > +add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})\n> > > \\ No newline at end of file\n> >\n> > No new line at end of line always leave a bad taste in my mount!\n> >\n\n-- \nDanh\n"},{"id":"396204","messageId":"20200424230954.GA4071@danh.dev","threadId":"53305","inReplyTo":"CAKiG+9V=bJNqrHRy8y8cbjkgzrmhOMMz47+8fgfQARAetx4MFQ@mail.gmail.com","subject":"Re: [PATCH 5/8] cmake: support for testing git when building out of the source tree","fromName":"Danh Doan","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-04-24T23:09:54Z","receivedAt":"2020-04-24T23:09:59Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2020-04-25 03:02:49+0530, Sibi Siddharthan <sibisiddharthan.github@gmail.com> wrote:\n> > >  file(GLOB test_scipts \"${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh\")\n> >\n> > Remember cmake won't be re-run if nothing was changed in CMakeList.txt\n> > If I only change some code, and I decided the change I make should be\n> > tested by a-new-and-independent-test-script.\n> > I need to re-run cmake manually! I don't like it, at all.\n> >\n> \n> No you don't have re-run CMake.\n\nYes, you have to re-run CMake.\nhttps://cmake.org/cmake/help/v3.14/command/file.html#glob\n\n> Note\n>\n> We do not recommend using GLOB to collect a list of source files\n> from your source tree. If no CMakeLists.txt file changes when\n> a source is added or removed then the generated build system cannot\n> know when to ask CMake to regenerate. The CONFIGURE_DEPENDS flag may\n> not work reliably on all generators, or if a new generator is added\n> in the future that cannot support it, projects using it will be\n> stuck. Even if CONFIGURE_DEPENDS works reliably, there is still\n> a cost to perform the check on every rebuild. \n\n* Run CMake now.\n* Don't touch anything\n* Create new test-script, let's say t9904-just-for-cmake.sh\n\n* Check if it's run or not, I bet the answer is not\n\nAnyway, Junio said NO, I don't need to be a CMake hater here, anymore.\n\n-- \nDanh\n"},{"id":"396229","messageId":"CAKiG+9VZcyjGQLHzT2S70mptKNhHLpwZ9Sd1rto32cN6a-7f_w@mail.gmail.com","threadId":"53305","inReplyTo":"20200424225621.GD721@danh.dev","subject":"Re: [PATCH 1/8] Introduce CMake support for configuring Git on Linux","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-04-25T03:50:36Z","receivedAt":"2020-04-25T03:50:50Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Sat, Apr 25, 2020 at 4:26 AM Danh Doan <congdanhqx@gmail.com> wrote:\n>\n> On 2020-04-25 02:36:12+0530, Sibi Siddharthan <sibisiddharthan.github@gmail.com> wrote:\n> > Yes it does,\n> > all you have to do is -DZLIB_ROOT=/path/to/zlib/root\n>\n> OK, I need to learn this syntax\n>\n> > > > +find_package(EXPAT)\n> > > > +find_package(Iconv)\n> > > > +find_package(Intl)\n> > > > +\n> > >\n> > > > +if(NOT Intl_FOUND)\n> > > > +     add_compile_definitions(NO_GETTEXT)\n> > >\n> > > find_package(Gettext)?\n> > >\n> >\n> > find_package(Gettext) does not define libintl and libintl.h.\n> > If NO_GETTEXT is not defined, it means that libintl.h is present.\n> > So, we use find_package(Intl) for libintl\n>\n> People do weird things.\n>\n> But, I bet that a lot of people have system that have libintl.h\n> installed, but they don't install gettext tools. ;-)\n>\n> Anyway, can I override NO_GETTEXT from command line?\n>\n> Let's say, I want to bootstrap a new distro?\n> In the boostrap step, I don't want to build any i18n things,\n> because the bootstrap package will be thrown away and rebuild again.\n> I don't want to waste time on building such translation things.\n>\n\nSo, you are trying to build two times and configuring it only once. Am I right?\nIf so I don't think you bootstrap with CMake. Will let you know if I\nfigure something out.\n\n> >\n> > > > +     if(NOT Iconv_FOUND)\n> > > > +             add_compile_definitions(NO_ICONV)\n> > > > +     endif()\n> > > > +endif()\n> > >\n> > > ICONV_OMITS_BOM?\n> > >\n> >\n> > Forgot about this, will add it.\n>\n> Thanks, my platform relies on this definition!\n>\n> > > > +\n> > > > +include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})\n> > > > +if(CURL_FOUND)\n> > > > +     include_directories(SYSTEM ${CURL_INCLUDE_DIRS})\n> > > > +endif()\n> > > > +if(EXPAT_FOUND)\n> > > > +     include_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})\n> > > > +endif()\n> > > > +if(Iconv_FOUND)\n> > > > +     include_directories(SYSTEM ${Iconv_INCLUDE_DIRS})\n> > > > +endif()\n> > > > +if(Intl_FOUND)\n> > > > +     include_directories(SYSTEM ${Intl_INCLUDE_DIRS})\n> > > > +endif()\n> > > > +\n> > > > +find_program(SH_EXE sh)\n> > >\n> > > We want to find usable sh, not just sh, no?\n> > >\n> > > It's matter on Solaris, HP-UX\n> > >\n> >\n> > How do I check for this, can you help?\n>\n> Sorry, Please ask someone else, check Makefile to see who fixed build\n> for Solaris and HP-UX.\n>\n> > Also, the script is not supported on Solaris and HP-UX.\n>\n> If Solaris or HP-UX is out of equation,\n> I'll just write: SH_EXE=/bin/sh ;-)\n>\n>\n\nThis is exactly what the current definition does.\n\n> >\n> > > > +\n> > > > +#default behaviour\n> > > > +include_directories(${CMAKE_SOURCE_DIR})\n> > > > +add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n> > > > +add_compile_definitions(SHA256_BLK INTERNAL_QSORT RUNTIME_PREFIX)\n> > > > +add_compile_definitions(NO_OPENSSL SHA1_DC SHA1DC_NO_STANDARD_INCLUDES\n> > > > +                     SHA1DC_INIT_SAFE_HASH_DEFAULT=0\n> > > > +                     SHA1DC_CUSTOM_INCLUDE_SHA1_C=\"cache.h\"\n> > > > +                     SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"git-compat-util.h\" )\n> > > > +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)\n> > > > +\n> > > > +\n> > > > +add_compile_definitions(PAGER_ENV=\"LESS=FRX LV=-c\"\n> > > > +                     ETC_GITATTRIBUTES=\"etc/gitattributes\"\n> > > > +                     ETC_GITCONFIG=\"etc/gitconfig\"\n> > > > +                     GIT_EXEC_PATH=\"libexec/git-core\"\n> > > > +                     GIT_LOCALE_PATH=\"share/locale\"\n> > > > +                     GIT_MAN_PATH=\"share/man\"\n> > > > +                     GIT_INFO_PATH=\"share/info\"\n> > > > +                     GIT_HTML_PATH=\"share/doc/git-doc\"\n> > > > +                     DEFAULT_HELP_FORMAT=\"html\"\n> > > > +                     DEFAULT_GIT_TEMPLATE_DIR=\"share/git-core/templates\"\n> > > > +                     GIT_VERSION=\"${PROJECT_VERSION}.GIT\"\n> > > > +                     GIT_USER_AGENT=\"git/${PROJECT_VERSION}.GIT\"\n> > > > +                     BINDIR=\"bin\"\n> > > > +                     GIT_BUILT_FROM_COMMIT=\"\")\n> > >\n> > > I wish I could verify this.\n> > > Have you check this part on a default build system for a Linux distro,\n> > > FreeBSD? For things started with \"etc/\"\n> > >\n> >\n> > These are the values I got when I looked at the build logs from the\n> > Makefile (make -n) in Linux and Windows.\n> > Don't know about FreeBSD\n>\n> Linux will install configuration to /etc, Windows (by using msys),\n> will also do that.\n>\n> *BSD port installs git with /usr/local prefix, and install\n> configuration to /usr/local/etc\n>\n\nAren't the above definitions relative paths?(With RUNTIME_PREFIX)\nOnce you decide to install, you have INSTALL_PREFIX(similar to\nDESTDIR) with which you\ncan achieve the above.\n\n> >\n> > > > +\n> > > > +set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n> > > > +add_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n> > > > +\n> > > > +add_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n> > >\n> > > /proc/self/exe is Linux only, no?\n> > >\n> >\n> > Yes, it is. This first patch only supports Linux build.\n> >\n> > > > +list(APPEND compat_SOURCES unix-socket.c)\n> > > > +\n> > > > +#header checks\n> > > > +check_include_file(libgen.h HAVE_LIBGEN_H)\n> > > > +if(NOT HAVE_LIBGEN_H)\n> > > > +     add_compile_definitions(NO_LIBGEN_H)\n> > > > +     list(APPEND compat_SOURCES compat/basename.c)\n> > > > +endif()\n> > > > +\n> > > > +check_include_file(sys/sysinfo.h HAVE_SYSINFO)\n> > > > +if(HAVE_SYSINFO)\n> > > > +     add_compile_definitions(HAVE_SYSINFO)\n> > > > +endif()\n> > > > +\n> > > > +check_c_source_compiles(\"\n> > > > +#include <alloca.h>\n> > > > +int\n> > > > +main ()\n> > > > +{\n> > > > +char *p = (char *) alloca (2 * sizeof (int));\n> > > > +     if (p) return 0;\n> > > > +     return 0;\n> > >\n> > > All code path will return 0?\n> > >\n> >\n> > This check is for a working alloca.h.\n> > Some systems define alloca in malloc.h (Windows)\n>\n> Does CMake have a macro for check function in which include files?\n>\n\nThe check functions is something that was used to match the automake behaviour.\nIf you want to check whether a function exists in a particulae header\nfile use check_symbol_exists().\n\n> >\n> > > > +}\"\n> > > > +HAVE_ALLOCA_H)\n> > > > +if(HAVE_ALLOCA_H)\n> > > > +     add_compile_definitions(HAVE_ALLOCA_H)\n> > > > +endif()\n> > > > +\n> > > > +\n> > > > +if(CURL_FOUND)\n> > > > +     set(remote_exes\n> > > > +             git-remote-https git-remote-ftp git-remote-ftps)\n> > > > +     foreach(s ${remote_exes})\n> > > > +             file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git-remote-http ${s})\\n\")\n>\n> Now, I looked at this again.\n> I didn't see the creatation of CreateLinks.cmake anywhere!\n>\n> > > > +             list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})\n> > > > +     endforeach()\n> > > > +endif()\n> > > > +\n> > > > +add_custom_command(OUTPUT ${git_links} ${git_http_links}\n> > > > +             COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake\n> > > > +             DEPENDS git git-remote-http)\n> > > > +add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})\n> > > > \\ No newline at end of file\n> > >\n> > > No new line at end of line always leave a bad taste in my mount!\n> > >\n>\n> --\n> Danh\n\nThank You,\nSibi Siddharthan\n"},{"id":"396230","messageId":"CAKiG+9VELgWxiehkwjREQ6H3L+eTt-Wrs0sPLMAucCLiD3Ooeg@mail.gmail.com","threadId":"53305","inReplyTo":"20200424230954.GA4071@danh.dev","subject":"Re: [PATCH 5/8] cmake: support for testing git when building out of the source tree","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-04-25T03:57:08Z","receivedAt":"2020-04-25T03:57:23Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"If you are adding a new test script you will have re-configure.\nEven in automake you are expected to do this, unless you have a glob\npattern in Makefile.in somewhere.\n\nOn Sat, Apr 25, 2020 at 4:39 AM Danh Doan <congdanhqx@gmail.com> wrote:\n>\n> On 2020-04-25 03:02:49+0530, Sibi Siddharthan <sibisiddharthan.github@gmail.com> wrote:\n> > > >  file(GLOB test_scipts \"${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh\")\n> > >\n> > > Remember cmake won't be re-run if nothing was changed in CMakeList.txt\n> > > If I only change some code, and I decided the change I make should be\n> > > tested by a-new-and-independent-test-script.\n> > > I need to re-run cmake manually! I don't like it, at all.\n> > >\n> >\n> > No you don't have re-run CMake.\n>\n> Yes, you have to re-run CMake.\n> https://cmake.org/cmake/help/v3.14/command/file.html#glob\n>\n> > Note\n> >\n> > We do not recommend using GLOB to collect a list of source files\n> > from your source tree. If no CMakeLists.txt file changes when\n> > a source is added or removed then the generated build system cannot\n> > know when to ask CMake to regenerate. The CONFIGURE_DEPENDS flag may\n> > not work reliably on all generators, or if a new generator is added\n> > in the future that cannot support it, projects using it will be\n> > stuck. Even if CONFIGURE_DEPENDS works reliably, there is still\n> > a cost to perform the check on every rebuild.\n>\n> * Run CMake now.\n> * Don't touch anything\n> * Create new test-script, let's say t9904-just-for-cmake.sh\n>\n> * Check if it's run or not, I bet the answer is not\n>\n\nThe new test script is not added to list of test scripts.\nSo yes, you will have to re-run CMake.\nA reconfigure in CMake is going to take less than 2 seconds, not like\nautomake which can take as long as the initial configure itself.\n\n> Anyway, Junio said NO, I don't need to be a CMake hater here, anymore.\n>\n> --\n> Danh\n\nThank You,\nSibi Siddharthan\n"},{"id":"396231","messageId":"CAKiG+9Xtof8Hj3npsS-M0SnT_dcjtHjP_+avWB4oOHkaMdnSbw@mail.gmail.com","threadId":"53305","inReplyTo":"xmqq8sikblv2.fsf@gitster.c.googlers.com","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-04-25T04:09:55Z","receivedAt":"2020-04-25T04:10:15Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Sat, Apr 25, 2020 at 3:13 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n>\n> > The goal would be to maintain a CMake build for Git keeping it in sync\n> > with the Makefile.\n> > The Makefile is not going to be replaced at all. The CMake script for\n> > now only supports Linux and Windows.\n> > It does not support BSD, Solaris and others, whereas the Makefile does\n> > support them.\n>\n> So you are doing (1).  I already said that I feel that engineering\n> burden to divert resources for CMake support would be unacceptably\n> high.\n>\n> Whenever any of our developers need to add source files, Makefile\n> configuration knobs that people can add to config.mak, etc., you are\n> forcing them to figure out where in the CMakefile to add them or\n> devise ways to allow builders who do not use config.mak (because\n> they use CMake) to do similar tweaks.\n>\n\nAdding source files to the CMakefile is going to just as long as\nadding it to the Makefile,\nanyone can figure this out and this is not going to take much time at all.\n\nAs for the configuration knobs I agree that adding the same to CMake\nis going to a bit longer.\nBut anyone who is hacking Git is going to do it with the Makefile or\n(if accepted)CMake script, but not both while hacking.\nSo they will continue to make progress with the system they feel comfortable in.\nThey will only run into an issue when they try for a PR. Currently the\nCMake script is only used for generating the visual studio solution.\nWe can add a (continue-on-error) to vs-build job to make this process\nless of a hindrance.\nIf people take the time to hack Git, figuring out how to do the\nconfiguration knobs in the CMake script is not going to that much take\ntime\ncompared to the time they spend making Git better.\n\n\n> Any patch that is acceptable to the current project would become\n> unacceptable because they lack updates to CMake part, but I suspect\n> we do not have enough people who are so much devoted to give a good\n> review if updates to CMake part are added.  And it is unclear why it\n> would be beneficial to slow our existing developers down by forcing\n> them to become familiar with CMake.\n>\n> So..., I am not just \"still not convinced\", but I am even more\n> convinced that we do not want this series, after thinking about it\n> longer.\n>\n> Thanks.\n>\n\nThank You,\nSibi Siddharthan\n"},{"id":"396243","messageId":"cb5f658b-f63d-1a67-fd10-be7762930612@iee.email","threadId":"53305","inReplyTo":"CAKiG+9V9N5zV=dxZwVmAaEFYQbswnSNLVqKMx5ti=zaPatZdkg@mail.gmail.com","subject":"Re: [PATCH 6/8] cmake: support for building git on windows with mingw","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.email","sentAt":"2020-04-25T11:37:58Z","receivedAt":"2020-04-25T11:38:01Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"Hi Sibi,\n\nOn 24/04/2020 21:29, Sibi Siddharthan wrote:\n> Hi Philip,\n>\n> On Fri, Apr 24, 2020 at 11:09 PM Philip Oakley <philipoakley@iee.email> wrote:\n>> Hi Sibi,\n>>\n>> On 24/04/2020 05:01, Sibi Siddharthan via GitGitGadget wrote:\n>>> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n>>>\n>>> This patch facilitates building git on Windows with CMake using MinGW\n>>>\n>>> NOTE: The funtions unsetenv and hstrerror are not checked in Windows\n>>> builds.\n>>> Reasons\n>>> NO_UNSETENV is not compatible with Windows builds.\n>>> lines 262-264 compat/mingw.h\n>>>\n>>> compat/mingw.h(line 25) provides a definition of hstrerror which\n>>> conflicts with the definition provided in\n>>> git-compat-util.h(lines 733-736).\n>>>\n>>> To use CMake on Windows with MinGW do this:\n>>> cmake `relative-path-to-srcdir` -G \"MinGW Makefiles\"\n>>>\n>>> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n>>> ---\n>>>  CMakeLists.txt | 120 +++++++++++++++++++++++++++++++++++++++----------\n>>>  1 file changed, 97 insertions(+), 23 deletions(-)\n>>>\n>>> diff --git a/CMakeLists.txt b/CMakeLists.txt\n>>> index 29a23eb11f7..d9eb1060390 100644\n>>> [snip..]\n>>>  find_program(SH_EXE sh)\n>>> +if(NOT SH_EXE)\n>>> +     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/\")\n>> Either the error message or the web page it points to need to coordinate\n>> on the 'sh interpreter' reference to help the script kiddies follow the\n>> thread. At the moment there is no 'interp..' on the gitforwindows web\n>> page. Would someone attempting to use cmake need to use the Download or\n>> the Contribute buttons, or some other route to acquire the missing SH_EXE?\n>>\n> On Windows, if you are using Git Bash, then you don't have a problem.\n> This message was for people trying to Git on Windows without a bash shell.\n>\n> I can rephrase the message saying\n> \"On Windows go to https://gitforwindows.org/ and download the Git\n> installer which ships with a sh interpreter(bash).\"\n>\n> Would you suggest something else?\n\nFilling the message out a little, I'm thinking of:\n\n\"sh: shell interpreter was not found in your path, please install one.\nOn Windows, you can get it as part of 'Git for Windows' install at\nhttps://gitforwindows.org/\"\n\nThe second 'install' could be dropped, but may be needed to fully\nqualify the instructions for some readers.\n\nThe key feature I was checking was the clarity of the 'install' action,\nas opposed to the way sh is integrated within Git for Windows (which is\na whole new topic of conversation for some users!)\n>\n>> (this is also a context line in the next patch)\n>>\n[snip..]\n\n--\nPhilip\n"},{"id":"396244","messageId":"CAKiG+9WCzSa4DGqh+5zxkyvMNp=QV5=pyw3cZXFo3vY8ZWqW6A@mail.gmail.com","threadId":"53305","inReplyTo":"cb5f658b-f63d-1a67-fd10-be7762930612@iee.email","subject":"Re: [PATCH 6/8] cmake: support for building git on windows with mingw","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-04-25T12:09:12Z","receivedAt":"2020-04-25T12:09:27Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"Hi Philip,\n\nOn Sat, Apr 25, 2020 at 5:07 PM Philip Oakley <philipoakley@iee.email> wrote:\n>\n> Hi Sibi,\n>\n> On 24/04/2020 21:29, Sibi Siddharthan wrote:\n> > Hi Philip,\n> >\n> > On Fri, Apr 24, 2020 at 11:09 PM Philip Oakley <philipoakley@iee.email> wrote:\n> >> Hi Sibi,\n> >>\n> >> On 24/04/2020 05:01, Sibi Siddharthan via GitGitGadget wrote:\n> >>> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> >>>\n> >>> This patch facilitates building git on Windows with CMake using MinGW\n> >>>\n> >>> NOTE: The funtions unsetenv and hstrerror are not checked in Windows\n> >>> builds.\n> >>> Reasons\n> >>> NO_UNSETENV is not compatible with Windows builds.\n> >>> lines 262-264 compat/mingw.h\n> >>>\n> >>> compat/mingw.h(line 25) provides a definition of hstrerror which\n> >>> conflicts with the definition provided in\n> >>> git-compat-util.h(lines 733-736).\n> >>>\n> >>> To use CMake on Windows with MinGW do this:\n> >>> cmake `relative-path-to-srcdir` -G \"MinGW Makefiles\"\n> >>>\n> >>> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> >>> ---\n> >>>  CMakeLists.txt | 120 +++++++++++++++++++++++++++++++++++++++----------\n> >>>  1 file changed, 97 insertions(+), 23 deletions(-)\n> >>>\n> >>> diff --git a/CMakeLists.txt b/CMakeLists.txt\n> >>> index 29a23eb11f7..d9eb1060390 100644\n> >>> [snip..]\n> >>>  find_program(SH_EXE sh)\n> >>> +if(NOT SH_EXE)\n> >>> +     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/\")\n> >> Either the error message or the web page it points to need to coordinate\n> >> on the 'sh interpreter' reference to help the script kiddies follow the\n> >> thread. At the moment there is no 'interp..' on the gitforwindows web\n> >> page. Would someone attempting to use cmake need to use the Download or\n> >> the Contribute buttons, or some other route to acquire the missing SH_EXE?\n> >>\n> > On Windows, if you are using Git Bash, then you don't have a problem.\n> > This message was for people trying to Git on Windows without a bash shell.\n> >\n> > I can rephrase the message saying\n> > \"On Windows go to https://gitforwindows.org/ and download the Git\n> > installer which ships with a sh interpreter(bash).\"\n> >\n> > Would you suggest something else?\n>\n> Filling the message out a little, I'm thinking of:\n>\n> \"sh: shell interpreter was not found in your path, please install one.\n> On Windows, you can get it as part of 'Git for Windows' install at\n> https://gitforwindows.org/\"\n>\n> The second 'install' could be dropped, but may be needed to fully\n> qualify the instructions for some readers.\n>\n> The key feature I was checking was the clarity of the 'install' action,\n> as opposed to the way sh is integrated within Git for Windows (which is\n> a whole new topic of conversation for some users!)\n\nSure, We can incorporate this message.\n\n> >\n> >> (this is also a context line in the next patch)\n> >>\n> [snip..]\n>\n> --\n> Philip\n\nThank You,\nSibi Siddharthan\n"},{"id":"396245","messageId":"nycvar.QRO.7.76.6.2004251354390.18039@tvgsbejvaqbjf.bet","threadId":"53305","inReplyTo":"xmqq8sikblv2.fsf@gitster.c.googlers.com","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-04-25T12:24:34Z","receivedAt":"2020-04-25T12:24:41Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Junio,\n\nOn Fri, 24 Apr 2020, Junio C Hamano wrote:\n\n> Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n>\n> > The goal would be to maintain a CMake build for Git keeping it in sync\n> > with the Makefile. The Makefile is not going to be replaced at all.\n> > The CMake script for now only supports Linux and Windows. It does not\n> > support BSD, Solaris and others, whereas the Makefile does support\n> > them.\n>\n> So you are doing (1).  I already said that I feel that engineering\n> burden to divert resources for CMake support would be unacceptably\n> high.\n\nWould your position change if Sibi was interested in maintaining this, and\nhelping with keeping CMake support in shape?\n\nIf you have a look at https://github.com/git-for-windows/git/pull/2580 and\nat https://github.com/gitgitgadget/git/pull/614, you will probably get the\nsame impression as I: in contrast to earlier contributors who just talked\nabout adding CMake support, Sibi went ahead and did it, and then polished\nthe heck out of the patches, was very responsive and active.\n\nI have a pretty good feeling about this.\n\n> Whenever any of our developers need to add source files, Makefile\n> configuration knobs that people can add to config.mak, etc., you are\n> forcing them to figure out where in the CMakefile to add them or devise\n> ways to allow builders who do not use config.mak (because they use\n> CMake) to do similar tweaks.\n\nTo be honest, I don't think that that happens all that often, and quite\nhonestly, I think anybody who has had a look at the Makefile and at\nCMakeLists.txt will have a pretty good idea where new files should go.\n\n> Any patch that is acceptable to the current project would become\n> unacceptable because they lack updates to CMake part, but I suspect\n> we do not have enough people who are so much devoted to give a good\n> review if updates to CMake part are added.  And it is unclear why it\n> would be beneficial to slow our existing developers down by forcing\n> them to become familiar with CMake.\n\nWhen it comes to new Makefile knobs, I do agree that it would place an\nunacceptable burden on contributors if we expected them to add the same\nknob to CMakeLists.txt. But we already don't do that for our autoconf\nsupport, so why would we expect it for CMake?\n\nWhen it comes to adding new, and/or removing, files, I fail to see the\nproblem. It is dead easy to keep the Makefile and CMakeLists.txt in sync\nwhen it comes to lists of files.\n\nAnother thing that strikes me as much more favorable this time as compared\nto earlier attempts at adding CMake support is that we now have pretty\ngood automated builds that will definitely help with keeping CMake support\nup to date.\n\nSo now that I have covered the \"it's not all that bad to maintain this\"\nangle, let's cover the much more important part: \"why would we even bother\nwith this?\". And that's pretty easy to answer for me: first-class Visual\nStudio support.\n\nIt is totally unacceptable to expect a contributor to download three\nquarters of a gigabyte and then let the Git for Windows SDK occupy around\ntwo full gigabytes on disk, just to get going. This is an upfront cost we\ncurrently expect from any developer on Windows, whether someone familiar\nwith Visual Studio or more familiar with the command-line and GCC or not.\n\nAnd guess what? Whenever I try to encourage a developer who uses Git and\nwho is pretty good with C to \"just check out the Git for Windows SDK, run\n`make vcxproj`, then load the generated Visual Studio solution and then\nstart developing\", the odds are really, really, really high that that's\nthe last of it.\n\nThis is frustrating. And not only for me: Why should a contributor fight\nso hard just to get started, when all they want to do is to tinker with\nthe code in order to see whether there is a chance that they can easily\nmake it do what they want?\n\nFor some time now, I have an automated build which auto-generates the\n`vs/master` branch from Git for Windows' `master` branch, which has all of\nthis preconfigured. But it is too hard to find, and it is definitely too\nhard to go from there to contributing the patches back to the Git project,\nso I think that maybe one contributor used that venue in the last years.\nOne. Just one. That's very little return for the effort spent on getting\nVisual Studio support back to functional ever after it was broken with\nVisual Studio 2010's release. And it demonstrates a level of being\nuninviting that I am simply uncomfortable with.\n\nThere's more.\n\nIf you are a developer who feels at home in IDEs, running `make` in the\ncommand-line, and finding out about options in the Makefile and how to\nspecify them on the command-line, is just very awkward. CMake recognizes\nthis, and offers GUIs to configure the builds. So that's nice.\n\nBut there's more.\n\nIt would appear that in recent years, ARM64-based Windows laptops have\nmade great progress. They are affordable, they are fast, and they have\nlong battery life. If I could use and develop Git for Windows on one of\nthese beauties, I would.\n\nBut I can't, because the obstacles to building Git on ARM64 Windows are\njust too high. The mingw-w64 version of GCC \"does not really support\"\nthat. We have literally no ARM64 support whatsoever from MSYS2's side,\ni.e. no Bash, no Perl, no OpenSSH.\n\nAnd then Sibi comes along and offers CMake support for Git.\n\nCMake can target Visual Studio and clang. Both have pretty good support\nfor ARM64 Windows.\n\nSo while this is not a complete solution for the ARM64 Windows problem, it\nis at least the most exciting opportunity in that regard that I have seen\nin _years_.\n\nGiven all these benefits, I would like to believe that the cost is rather\nminimal in comparison.\n\nAnd that's coming from me, who is not a fan of CMake at all.\n\n> So..., I am not just \"still not convinced\", but I am even more\n> convinced that we do not want this series, after thinking about it\n> longer.\n\nOf course, I do hope that I have convinced you above that it might not\nlook all that bleak.\n\nBut even if I haven't, I would like to propose to run with Sibi's patches\nand merge them first to `pu`, and then to `next`, and let that cook for a\nwhile (I will merge them into Git for Windows early so that there is also\nsome support stream from that side).\n\nI know you think that the maintenance cost is too high, but I think it\nmight be more than just manageable. And I don't think that the risk is too\nhigh to give the patches a try, at least inside `next`, for a couple of\nweeks or even months.\n\nIf it turns out that they _do_ add too much of a maintenance burden, big\ndeal: we just drop the patches, and that's that. No hard feelings, we gave\nit a try, a scientific test, if you want, and we now have evidence to back\nup your initial suspicion.\n\nIf it turns out that they _do_ add value _and_ are easy to maintain, then\nthat's good, right? And then, at your leisurely leisure, you can merge\nthem down to `master` and eventually into an official release.\n\nWhat do you think? Doesn't that sound like a good plan?\n\nCiao,\nDscho\n"},{"id":"396249","messageId":"40da111a-77e0-55b1-a6c2-9edc77cf1f3c@iee.email","threadId":"53305","inReplyTo":"CAKiG+9Xtof8Hj3npsS-M0SnT_dcjtHjP_+avWB4oOHkaMdnSbw@mail.gmail.com","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.email","sentAt":"2020-04-25T12:56:15Z","receivedAt":"2020-04-25T12:56:20Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"Hi Sibi,\n\nOn 25/04/2020 05:09, Sibi Siddharthan wrote:\n> On Sat, Apr 25, 2020 at 3:13 AM Junio C Hamano <gitster@pobox.com> wrote:\n>> Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n>>\n>>> The goal would be to maintain a CMake build for Git keeping it in sync\n>>> with the Makefile.\n>>> The Makefile is not going to be replaced at all. The CMake script for\n>>> now only supports Linux and Windows.\n>>> It does not support BSD, Solaris and others, whereas the Makefile does\n>>> support them.\n>> So you are doing (1).  I already said that I feel that engineering\n>> burden to divert resources for CMake support would be unacceptably\n>> high.\n>>\n>> Whenever any of our developers need to add source files, Makefile\n>> configuration knobs that people can add to config.mak, etc., you are\n>> forcing them to figure out where in the CMakefile to add them or\n>> devise ways to allow builders who do not use config.mak (because\n>> they use CMake) to do similar tweaks.\n>>\n> Adding source files to the CMakefile is going to just as long as\n> adding it to the Makefile,\n> anyone can figure this out and this is not going to take much time at all.\nWhile figuring these things out isn't /hard/ it can be tedious and time\nconsuming for those who are not familiar with the particular tool set\n(as evidenced, in my mind, by the poor dev support for Git for Windows\nbecause of the need to understand two operating systems and their\nawkward interactions) - those that are familiar and understand the/their\nwhole tool set are usually the x10 folks.\n>\n> As for the configuration knobs I agree that adding the same to CMake\n> is going to a bit longer.\n> But anyone who is hacking Git is going to do it with the Makefile or\n> (if accepted)CMake script, but not both while hacking.\n> So they will continue to make progress with the system they feel comfortable in.\n> They will only run into an issue when they try for a PR. Currently the\n> CMake script is only used for generating the visual studio solution.\n> We can add a (continue-on-error) to vs-build job to make this process\n> less of a hindrance.\n> If people take the time to hack Git, figuring out how to do the\n> configuration knobs in the CMake script is not going to that much take\n> time\n> compared to the time they spend making Git better.\n>\n>\n>> Any patch that is acceptable to the current project would become\n>> unacceptable because they lack updates to CMake part, but I suspect\n>> we do not have enough people who are so much devoted to give a good\n>> review if updates to CMake part are added.  And it is unclear why it\n>> would be beneficial to slow our existing developers down by forcing\n>> them to become familiar with CMake.\n>>\n>> So..., I am not just \"still not convinced\", but I am even more\n>> convinced that we do not want this series, after thinking about it\n>> longer.\n>>\n>> Thanks.\n>>\n\nIs there a middle way, given that IIUC there is most benefit on the\nWindows side, that on the git.git side the Makefile could contain a\nsuitable comment directing those interested in CMake to the relevant\npart of Git-for-Windows. Is there a part that could hold, and track, the\nmatching changes to the primary Makefile? \n\nAre there tools that track and compare CMake and Make variants, or at\nleast indicate any divergences to help separately maintaining the CMake\nseries?\n> Thank You,\n> Sibi Siddharthan\n--\nPhilip\n"},{"id":"396251","messageId":"nycvar.QRO.7.76.6.2004251523560.18039@tvgsbejvaqbjf.bet","threadId":"53305","inReplyTo":"40da111a-77e0-55b1-a6c2-9edc77cf1f3c@iee.email","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-04-25T13:29:50Z","receivedAt":"2020-04-25T13:29:59Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Philip,\n\nOn Sat, 25 Apr 2020, Philip Oakley wrote:\n\n> On 25/04/2020 05:09, Sibi Siddharthan wrote:\n> > On Sat, Apr 25, 2020 at 3:13 AM Junio C Hamano <gitster@pobox.com> wrote:\n> >> Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n> >>\n> >>> The goal would be to maintain a CMake build for Git keeping it in\n> >>> sync with the Makefile. The Makefile is not going to be replaced at\n> >>> all. The CMake script for now only supports Linux and Windows. It\n> >>> does not support BSD, Solaris and others, whereas the Makefile does\n> >>> support them.\n> >>\n> >> So you are doing (1).  I already said that I feel that engineering\n> >> burden to divert resources for CMake support would be unacceptably\n> >> high.\n> >>\n> >> Whenever any of our developers need to add source files, Makefile\n> >> configuration knobs that people can add to config.mak, etc., you are\n> >> forcing them to figure out where in the CMakefile to add them or\n> >> devise ways to allow builders who do not use config.mak (because they\n> >> use CMake) to do similar tweaks.\n> >\n> > Adding source files to the CMakefile is going to just as long as\n> > adding it to the Makefile, anyone can figure this out and this is not\n> > going to take much time at all.\n>\n> While figuring these things out isn't /hard/ it can be tedious and time\n> consuming for those who are not familiar with the particular tool set\n> (as evidenced, in my mind, by the poor dev support for Git for Windows\n> because of the need to understand two operating systems and their\n> awkward interactions) - those that are familiar and understand the/their\n> whole tool set are usually the x10 folks.\n\nIs it fair to compare the complexities of the differences between what Git\nexpects and what Windows provides to the difference to add files to\nMakefile _and_ CMakeLists.txt?\n\nWhen I add a file to the Makefile, what I do (and imagine that _everybody_\nis doing in that circumstance) is to find an already-existing file that is\nsimilar to the one I want to add. For example, if adding\n`builtin/oakley--helper.c`, I will try to imitate\n`builtin/submodule--helper.c`.\n\nAnd when you do that, you don't really need to understand Makefiles or\nCMake. You find the list(s) and add your file there, paying attention to\nwhether it is maintained alphabetically or append-only.\n\nThat is a _far_ cry from the hoops through which you have to jump to\nunderstand, say, the important background details in order to start\nworking on `compat/mingw.c`.\n\nAt least from my point of view, there is very little analogy between the\nsubject under discussion and what you brought up.\n\nHaving said that...\n\n> > As for the configuration knobs I agree that adding the same to CMake\n> > is going to a bit longer.\n> > But anyone who is hacking Git is going to do it with the Makefile or\n> > (if accepted)CMake script, but not both while hacking.\n> > So they will continue to make progress with the system they feel comfortable in.\n> > They will only run into an issue when they try for a PR. Currently the\n> > CMake script is only used for generating the visual studio solution.\n> > We can add a (continue-on-error) to vs-build job to make this process\n> > less of a hindrance.\n> > If people take the time to hack Git, figuring out how to do the\n> > configuration knobs in the CMake script is not going to that much take\n> > time\n> > compared to the time they spend making Git better.\n> >\n> >\n> >> Any patch that is acceptable to the current project would become\n> >> unacceptable because they lack updates to CMake part, but I suspect\n> >> we do not have enough people who are so much devoted to give a good\n> >> review if updates to CMake part are added.  And it is unclear why it\n> >> would be beneficial to slow our existing developers down by forcing\n> >> them to become familiar with CMake.\n> >>\n> >> So..., I am not just \"still not convinced\", but I am even more\n> >> convinced that we do not want this series, after thinking about it\n> >> longer.\n> >>\n> >> Thanks.\n> >>\n>\n> Is there a middle way, given that IIUC there is most benefit on the\n> Windows side, that on the git.git side the Makefile could contain a\n> suitable comment directing those interested in CMake to the relevant\n> part of Git-for-Windows. Is there a part that could hold, and track, the\n> matching changes to the primary Makefile? \n\nWe already use `GIT-VERSION-GEN` as the authoritative source for the Git\nversion, by parsing the line that contains.\n\nIt would look very similar, at least in my mind, to generate the list of\nsource/script files by parsing the `Makefile`.\n\nSibi, what do you think?\n\nCiao,\nDscho\n"},{"id":"396252","messageId":"nycvar.QRO.7.76.6.2004251530210.18039@tvgsbejvaqbjf.bet","threadId":"53305","inReplyTo":"20200424170540.GH1949@danh.dev","subject":"Re: [PATCH 1/8] Introduce CMake support for configuring Git on Linux","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-04-25T13:34:31Z","receivedAt":"2020-04-25T13:34:35Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Danh,\n\nOn Sat, 25 Apr 2020, Danh Doan wrote:\n\n> Please excuse my hatred for CMake.\n\nI share that distaste. However, is it really productive to bring that up\nhere?\n\nYou know what I also hate? I also hate vulnerabilities, and find it\n_really_ taxing and tiring to work on them. Yet I frequently find myself\nfocusing on security bug fixes. Why? Because it's important.\n\nIn this instance, while there's no love lost on CMake from my side, I do\nsee tremendous benefits in having support for it in Git, in particular in\nsupporting Windows-based developers instead of treating them like\nthird-class citizens.\n\nYou had so many good and helpful comments and suggestions how to improve\nthe CMake patches, maybe we can have more of those?\n\nThank you,\nDscho\n"},{"id":"396255","messageId":"CAKiG+9VMjft14ttqQuZMwewOGFbnbfJ3uXn0vPiJb05A8wdSwg@mail.gmail.com","threadId":"53305","inReplyTo":"nycvar.QRO.7.76.6.2004251523560.18039@tvgsbejvaqbjf.bet","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-04-25T14:12:10Z","receivedAt":"2020-04-25T14:13:01Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"Hi Philip and Dscho\n\nOn Sat, Apr 25, 2020 at 6:59 PM Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n>\n> Hi Philip,\n>\n> On Sat, 25 Apr 2020, Philip Oakley wrote:\n>\n> > On 25/04/2020 05:09, Sibi Siddharthan wrote:\n> > > On Sat, Apr 25, 2020 at 3:13 AM Junio C Hamano <gitster@pobox.com> wrote:\n> > >> Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n> > >>\n> > >>> The goal would be to maintain a CMake build for Git keeping it in\n> > >>> sync with the Makefile. The Makefile is not going to be replaced at\n> > >>> all. The CMake script for now only supports Linux and Windows. It\n> > >>> does not support BSD, Solaris and others, whereas the Makefile does\n> > >>> support them.\n> > >>\n> > >> So you are doing (1).  I already said that I feel that engineering\n> > >> burden to divert resources for CMake support would be unacceptably\n> > >> high.\n> > >>\n> > >> Whenever any of our developers need to add source files, Makefile\n> > >> configuration knobs that people can add to config.mak, etc., you are\n> > >> forcing them to figure out where in the CMakefile to add them or\n> > >> devise ways to allow builders who do not use config.mak (because they\n> > >> use CMake) to do similar tweaks.\n> > >\n> > > Adding source files to the CMakefile is going to just as long as\n> > > adding it to the Makefile, anyone can figure this out and this is not\n> > > going to take much time at all.\n> >\n> > While figuring these things out isn't /hard/ it can be tedious and time\n> > consuming for those who are not familiar with the particular tool set\n> > (as evidenced, in my mind, by the poor dev support for Git for Windows\n> > because of the need to understand two operating systems and their\n> > awkward interactions) - those that are familiar and understand the/their\n> > whole tool set are usually the x10 folks.\n\nOne way of reducing the tediousness is to guide the developers in the\nContribuiting document\nas to where to add the new source files for both the Makefile and CMake script.\n\n>\n> Is it fair to compare the complexities of the differences between what Git\n> expects and what Windows provides to the difference to add files to\n> Makefile _and_ CMakeLists.txt?\n>\n> When I add a file to the Makefile, what I do (and imagine that _everybody_\n> is doing in that circumstance) is to find an already-existing file that is\n> similar to the one I want to add. For example, if adding\n> `builtin/oakley--helper.c`, I will try to imitate\n> `builtin/submodule--helper.c`.\n>\n> And when you do that, you don't really need to understand Makefiles or\n> CMake. You find the list(s) and add your file there, paying attention to\n> whether it is maintained alphabetically or append-only.\n>\n> That is a _far_ cry from the hoops through which you have to jump to\n> understand, say, the important background details in order to start\n> working on `compat/mingw.c`.\n>\n> At least from my point of view, there is very little analogy between the\n> subject under discussion and what you brought up.\n>\n> Having said that...\n>\n> > > As for the configuration knobs I agree that adding the same to CMake\n> > > is going to a bit longer.\n> > > But anyone who is hacking Git is going to do it with the Makefile or\n> > > (if accepted)CMake script, but not both while hacking.\n> > > So they will continue to make progress with the system they feel comfortable in.\n> > > They will only run into an issue when they try for a PR. Currently the\n> > > CMake script is only used for generating the visual studio solution.\n> > > We can add a (continue-on-error) to vs-build job to make this process\n> > > less of a hindrance.\n> > > If people take the time to hack Git, figuring out how to do the\n> > > configuration knobs in the CMake script is not going to that much take\n> > > time\n> > > compared to the time they spend making Git better.\n> > >\n> > >\n> > >> Any patch that is acceptable to the current project would become\n> > >> unacceptable because they lack updates to CMake part, but I suspect\n> > >> we do not have enough people who are so much devoted to give a good\n> > >> review if updates to CMake part are added.  And it is unclear why it\n> > >> would be beneficial to slow our existing developers down by forcing\n> > >> them to become familiar with CMake.\n> > >>\n> > >> So..., I am not just \"still not convinced\", but I am even more\n> > >> convinced that we do not want this series, after thinking about it\n> > >> longer.\n> > >>\n> > >> Thanks.\n> > >>\n> >\n> > Is there a middle way, given that IIUC there is most benefit on the\n> > Windows side, that on the git.git side the Makefile could contain a\n> > suitable comment directing those interested in CMake to the relevant\n> > part of Git-for-Windows. Is there a part that could hold, and track, the\n> > matching changes to the primary Makefile?\n>\n> We already use `GIT-VERSION-GEN` as the authoritative source for the Git\n> version, by parsing the line that contains.\n>\n> It would look very similar, at least in my mind, to generate the list of\n> source/script files by parsing the `Makefile`.\n>\n> Sibi, what do you think?\n>\n\nOne way of doing it is to track if the Makefile is changed in a\ncommit, run a hook\nto see if it contains any new OBJs and match it with the CMake script.\nBut this is too much work, in my opinion.\n\nFor the scripts, things are a bit complicated, suppose people use sed\nand grep to\ndo their logic in the Makefile, we add \"sed\" and \"grep\" dependencies\nto the build process\nThis is not a bad thing, but the same logic can be implemented in\nCMake without \"grep\" and \"sed\".\nAlso, the Makefile script generation logics are path relative, which\nshould be modified in CMake\nto have arbitrary build and source directories.\n\nThe better option is to guide developers how to add their build\nchanges to CMake also. (This is not hard at all)\n\n> Ciao,\n> Dscho\n\nThank You,\nSibi Siddharthan\n"},{"id":"396257","messageId":"nycvar.QRO.7.76.6.2004251624100.18039@tvgsbejvaqbjf.bet","threadId":"53305","inReplyTo":"CAKiG+9VMjft14ttqQuZMwewOGFbnbfJ3uXn0vPiJb05A8wdSwg@mail.gmail.com","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-04-25T14:28:38Z","receivedAt":"2020-04-25T14:28:44Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Sibi,\n\nOn Sat, 25 Apr 2020, Sibi Siddharthan wrote:\n\n> On Sat, Apr 25, 2020 at 6:59 PM Johannes Schindelin\n> <Johannes.Schindelin@gmx.de> wrote:\n>\n> >\n> > We already use `GIT-VERSION-GEN` as the authoritative source for the Git\n> > version, by parsing the line that contains.\n> >\n> > It would look very similar, at least in my mind, to generate the list of\n> > source/script files by parsing the `Makefile`.\n> >\n> > Sibi, what do you think?\n>\n> One way of doing it is to track if the Makefile is changed in a commit,\n> run a hook to see if it contains any new OBJs and match it with the\n> CMake script. But this is too much work, in my opinion.\n\nOh, sorry, I should have clarified: We already parse the\n`DEF_VER=v2.26.GIT` line in `GIT-VERSION-GEN` to determine the Git\nversion.\n\nWe should be able to do the very exact same thing to parse the `SCRIPT_SH`\nlines like\n\n\tSCRIPT_SH += git-bisect.sh\n\nin the `Makefile` to accumulate the list of shell scripts, and likewise\nthe list of object files could be accumulated by parsing the `LIB_OBJS`\nlines like\n\n\tLIB_OBJS += abspath.o\n\n(We would of course need to substitute the `.o` with `.c`, but that should\nbe easy.)\n\nThat way, nobody will ever need to touch the CMakeLists.txt file when they\nadd a new source file to libgit.a.\n\nI was not trying to auto-detect what `sed` invocation changed. Those\nchanges _will_ need manual forward-porting to CMakeLists.txt. Thankfully,\nthose events are really rare.\n\nMakes sense?\n\nCiao,\nDscho\n"},{"id":"396258","messageId":"CAKiG+9XpZjesKs4p_yRvtgEhqwSHDqnjJcNkzqg_AEWr5BeuQg@mail.gmail.com","threadId":"53305","inReplyTo":"nycvar.QRO.7.76.6.2004251624100.18039@tvgsbejvaqbjf.bet","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-04-25T14:38:11Z","receivedAt":"2020-04-25T14:38:26Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"Hi Dscho\n\nOn Sat, Apr 25, 2020 at 7:58 PM Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n>\n> Hi Sibi,\n>\n> On Sat, 25 Apr 2020, Sibi Siddharthan wrote:\n>\n> > On Sat, Apr 25, 2020 at 6:59 PM Johannes Schindelin\n> > <Johannes.Schindelin@gmx.de> wrote:\n> >\n> > >\n> > > We already use `GIT-VERSION-GEN` as the authoritative source for the Git\n> > > version, by parsing the line that contains.\n> > >\n> > > It would look very similar, at least in my mind, to generate the list of\n> > > source/script files by parsing the `Makefile`.\n> > >\n> > > Sibi, what do you think?\n> >\n> > One way of doing it is to track if the Makefile is changed in a commit,\n> > run a hook to see if it contains any new OBJs and match it with the\n> > CMake script. But this is too much work, in my opinion.\n>\n> Oh, sorry, I should have clarified: We already parse the\n> `DEF_VER=v2.26.GIT` line in `GIT-VERSION-GEN` to determine the Git\n> version.\n>\n> We should be able to do the very exact same thing to parse the `SCRIPT_SH`\n> lines like\n>\n>         SCRIPT_SH += git-bisect.sh\n>\n> in the `Makefile` to accumulate the list of shell scripts, and likewise\n> the list of object files could be accumulated by parsing the `LIB_OBJS`\n> lines like\n>\n>         LIB_OBJS += abspath.o\n>\n> (We would of course need to substitute the `.o` with `.c`, but that should\n> be easy.)\n>\n> That way, nobody will ever need to touch the CMakeLists.txt file when they\n> add a new source file to libgit.a.\n>\n\nI understand what you are trying to say, this is not impossible to do but doing\nso will make the CMake script dependent on the Makefile for the sources.\nI am not fan of this approach.\n\nWe should write a separate script (say python) to match each of the sources in\nthe Makefile and the CMake file automatically whenever the changes detected.\nThis excludes the platform specific/compatibility stuff in config.mak.uname.\n\n> I was not trying to auto-detect what `sed` invocation changed. Those\n> changes _will_ need manual forward-porting to CMakeLists.txt. Thankfully,\n> those events are really rare.\n>\n> Makes sense?\n>\n> Ciao,\n> Dscho\n\nThank You,\nSibi Siddharthan\n"},{"id":"396259","messageId":"nycvar.QRO.7.76.6.2004251647520.18039@tvgsbejvaqbjf.bet","threadId":"53305","inReplyTo":"CAKiG+9XpZjesKs4p_yRvtgEhqwSHDqnjJcNkzqg_AEWr5BeuQg@mail.gmail.com","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-04-25T14:49:29Z","receivedAt":"2020-04-25T14:49:37Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Sibi,\n\nOn Sat, 25 Apr 2020, Sibi Siddharthan wrote:\n\n> On Sat, Apr 25, 2020 at 7:58 PM Johannes Schindelin\n> <Johannes.Schindelin@gmx.de> wrote:\n> >\n> > On Sat, 25 Apr 2020, Sibi Siddharthan wrote:\n> >\n> > > On Sat, Apr 25, 2020 at 6:59 PM Johannes Schindelin\n> > > <Johannes.Schindelin@gmx.de> wrote:\n> > >\n> > > >\n> > > > We already use `GIT-VERSION-GEN` as the authoritative source for the Git\n> > > > version, by parsing the line that contains.\n> > > >\n> > > > It would look very similar, at least in my mind, to generate the list of\n> > > > source/script files by parsing the `Makefile`.\n> > > >\n> > > > Sibi, what do you think?\n> > >\n> > > One way of doing it is to track if the Makefile is changed in a commit,\n> > > run a hook to see if it contains any new OBJs and match it with the\n> > > CMake script. But this is too much work, in my opinion.\n> >\n> > Oh, sorry, I should have clarified: We already parse the\n> > `DEF_VER=v2.26.GIT` line in `GIT-VERSION-GEN` to determine the Git\n> > version.\n> >\n> > We should be able to do the very exact same thing to parse the `SCRIPT_SH`\n> > lines like\n> >\n> >         SCRIPT_SH += git-bisect.sh\n> >\n> > in the `Makefile` to accumulate the list of shell scripts, and likewise\n> > the list of object files could be accumulated by parsing the `LIB_OBJS`\n> > lines like\n> >\n> >         LIB_OBJS += abspath.o\n> >\n> > (We would of course need to substitute the `.o` with `.c`, but that should\n> > be easy.)\n> >\n> > That way, nobody will ever need to touch the CMakeLists.txt file when they\n> > add a new source file to libgit.a.\n> >\n>\n> I understand what you are trying to say, this is not impossible to do but doing\n> so will make the CMake script dependent on the Makefile for the sources.\n> I am not fan of this approach.\n>\n> We should write a separate script (say python) to match each of the sources in\n> the Makefile and the CMake file automatically whenever the changes detected.\n> This excludes the platform specific/compatibility stuff in config.mak.uname.\n\nHmm. That is an approach that _I_ don't like. Why duplicate the\ninformation when you don't have to?\n\nI don't see any issue with keeping CMakeLists.txt dependent on Makefile.\nWe could of course extract the lists into a separate file that is sourced\nboth from the Makefile and from CMakeLists.txt, but that would actually\nnot reflect that the Makefile _is_ authoritative. CMakeLists.txt will\nnever be the authoritative source.\n\nCiao,\nDscho\n\n>\n> > I was not trying to auto-detect what `sed` invocation changed. Those\n> > changes _will_ need manual forward-porting to CMakeLists.txt. Thankfully,\n> > those events are really rare.\n> >\n> > Makes sense?\n> >\n> > Ciao,\n> > Dscho\n>\n> Thank You,\n> Sibi Siddharthan\n>\n>\n"},{"id":"396260","messageId":"CAKiG+9XwoD+UzHovS_mW76CPX_Vtt1eTaSM-xaszKWwt6R3ewA@mail.gmail.com","threadId":"53305","inReplyTo":"nycvar.QRO.7.76.6.2004251647520.18039@tvgsbejvaqbjf.bet","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-04-25T14:57:37Z","receivedAt":"2020-04-25T14:57:52Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"Hi Dscho,\n\nI guess this is a pain point having to manage two separate build systems.\nI will modify CMake script to get its sources from the Makefile.\n\nThank You,\nSibi Siddharthan\n\nOn Sat, Apr 25, 2020 at 8:19 PM Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n>\n> Hi Sibi,\n>\n> On Sat, 25 Apr 2020, Sibi Siddharthan wrote:\n>\n> > On Sat, Apr 25, 2020 at 7:58 PM Johannes Schindelin\n> > <Johannes.Schindelin@gmx.de> wrote:\n> > >\n> > > On Sat, 25 Apr 2020, Sibi Siddharthan wrote:\n> > >\n> > > > On Sat, Apr 25, 2020 at 6:59 PM Johannes Schindelin\n> > > > <Johannes.Schindelin@gmx.de> wrote:\n> > > >\n> > > > >\n> > > > > We already use `GIT-VERSION-GEN` as the authoritative source for the Git\n> > > > > version, by parsing the line that contains.\n> > > > >\n> > > > > It would look very similar, at least in my mind, to generate the list of\n> > > > > source/script files by parsing the `Makefile`.\n> > > > >\n> > > > > Sibi, what do you think?\n> > > >\n> > > > One way of doing it is to track if the Makefile is changed in a commit,\n> > > > run a hook to see if it contains any new OBJs and match it with the\n> > > > CMake script. But this is too much work, in my opinion.\n> > >\n> > > Oh, sorry, I should have clarified: We already parse the\n> > > `DEF_VER=v2.26.GIT` line in `GIT-VERSION-GEN` to determine the Git\n> > > version.\n> > >\n> > > We should be able to do the very exact same thing to parse the `SCRIPT_SH`\n> > > lines like\n> > >\n> > >         SCRIPT_SH += git-bisect.sh\n> > >\n> > > in the `Makefile` to accumulate the list of shell scripts, and likewise\n> > > the list of object files could be accumulated by parsing the `LIB_OBJS`\n> > > lines like\n> > >\n> > >         LIB_OBJS += abspath.o\n> > >\n> > > (We would of course need to substitute the `.o` with `.c`, but that should\n> > > be easy.)\n> > >\n> > > That way, nobody will ever need to touch the CMakeLists.txt file when they\n> > > add a new source file to libgit.a.\n> > >\n> >\n> > I understand what you are trying to say, this is not impossible to do but doing\n> > so will make the CMake script dependent on the Makefile for the sources.\n> > I am not fan of this approach.\n> >\n> > We should write a separate script (say python) to match each of the sources in\n> > the Makefile and the CMake file automatically whenever the changes detected.\n> > This excludes the platform specific/compatibility stuff in config.mak.uname.\n>\n> Hmm. That is an approach that _I_ don't like. Why duplicate the\n> information when you don't have to?\n>\n> I don't see any issue with keeping CMakeLists.txt dependent on Makefile.\n> We could of course extract the lists into a separate file that is sourced\n> both from the Makefile and from CMakeLists.txt, but that would actually\n> not reflect that the Makefile _is_ authoritative. CMakeLists.txt will\n> never be the authoritative source.\n>\n> Ciao,\n> Dscho\n>\n> >\n> > > I was not trying to auto-detect what `sed` invocation changed. Those\n> > > changes _will_ need manual forward-porting to CMakeLists.txt. Thankfully,\n> > > those events are really rare.\n> > >\n> > > Makes sense?\n> > >\n> > > Ciao,\n> > > Dscho\n> >\n> > Thank You,\n> > Sibi Siddharthan\n> >\n> >\n"},{"id":"396262","messageId":"20200425170740.GA6421@camp.crustytoothpaste.net","threadId":"53305","inReplyTo":"70ab1f03dd5413256166bf9db47be47b746ea6b1.1587700897.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 1/8] Introduce CMake support for configuring Git on Linux","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-04-25T17:07:40Z","receivedAt":"2020-04-25T17:07:47Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2020-04-24 at 04:01:30, Sibi Siddharthan via GitGitGadget wrote:\n> diff --git a/CMakeLists.txt b/CMakeLists.txt\n> new file mode 100644\n> index 00000000000..73703bd321f\n> --- /dev/null\n> +++ b/CMakeLists.txt\n> @@ -0,0 +1,528 @@\n> +#\n> +#\tCopyright (c) 2020 Sibi Siddharthan\n> +#\n> +\n> +cmake_minimum_required(VERSION 3.14)\n\nI don't plan a full review of this series, but I wanted to point out\nthat this version is newer than what's in Debian 10, so this isn't\npractically buildable on many systems.\n\nIf we wanted to add CMake support, even just for Linux and Windows, I'd\nwant to see it functional on the latest versions of the major distros,\nat the very least.  Ideally it would function using the system packages\non all security-supported versions of the major distros, since our\nMakefile does right now.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"396263","messageId":"02a401d61b28$141b8d00$3c52a700$@nexbridge.com","threadId":"53305","inReplyTo":"20200425170740.GA6421@camp.crustytoothpaste.net","subject":"RE: [PATCH 1/8] Introduce CMake support for configuring Git on Linux","fromName":"Randall S. Becker","fromEmail":"rsbecker@nexbridge.com","sentAt":"2020-04-25T17:36:34Z","receivedAt":"2020-04-25T17:36:49Z","isPatch":true,"sender":{"key":"randall.becker@nexbridge.ca","avatar":"https://avatars.githubusercontent.com/u/28956764?v=4"},"body":"On April 25, 2020 1:08 PM, brian m. carlson Wrote:\n> On 2020-04-24 at 04:01:30, Sibi Siddharthan via GitGitGadget wrote:\n> > diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644\n> > index 00000000000..73703bd321f\n> > --- /dev/null\n> > +++ b/CMakeLists.txt\n> > @@ -0,0 +1,528 @@\n> > +#\n> > +#\tCopyright (c) 2020 Sibi Siddharthan\n> > +#\n> > +\n> > +cmake_minimum_required(VERSION 3.14)\n> \n> I don't plan a full review of this series, but I wanted to point out that this\n> version is newer than what's in Debian 10, so this isn't practically buildable on\n> many systems.\n\nI am unsure about this, but are non-git-foundation copyrights consistent GPL v2? Just asking for curiosity.\n\n"},{"id":"396264","messageId":"318e4641-3e21-ba9a-cca6-246d821812ad@iee.email","threadId":"53305","inReplyTo":"02a401d61b28$141b8d00$3c52a700$@nexbridge.com","subject":"Re: [PATCH 1/8] Introduce CMake support for configuring Git on Linux","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.email","sentAt":"2020-04-25T18:01:01Z","receivedAt":"2020-04-25T18:01:04Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"On 25/04/2020 18:36, Randall S. Becker wrote:\n> On April 25, 2020 1:08 PM, brian m. carlson Wrote:\n>> On 2020-04-24 at 04:01:30, Sibi Siddharthan via GitGitGadget wrote:\n>>> diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644\n>>> index 00000000000..73703bd321f\n>>> --- /dev/null\n>>> +++ b/CMakeLists.txt\n>>> @@ -0,0 +1,528 @@\n>>> +#\n>>> +#\tCopyright (c) 2020 Sibi Siddharthan\n>>> +#\n>>> +\n>>> +cmake_minimum_required(VERSION 3.14)\n>> I don't plan a full review of this series, but I wanted to point out that this\n>> version is newer than what's in Debian 10, so this isn't practically buildable on\n>> many systems.\n> I am unsure about this, but are non-git-foundation copyrights consistent GPL v2? Just asking for curiosity.\n>\ngrep'ing for copyright gave plenty of examples, so it looks OK. Someone\nhad to author it.\n\nPhilip\n\n"},{"id":"396265","messageId":"CAKiG+9X7o1x2CeRv37BXEsUJHPZ2CYb8XzPyKw-E6doNP93Wgw@mail.gmail.com","threadId":"53305","inReplyTo":"20200425170740.GA6421@camp.crustytoothpaste.net","subject":"Re: [PATCH 1/8] Introduce CMake support for configuring Git on Linux","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-04-25T18:11:19Z","receivedAt":"2020-04-25T18:11:33Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"Hi Brian,\n\nOn Sat, Apr 25, 2020 at 10:37 PM brian m. carlson\n<sandals@crustytoothpaste.net> wrote:\n>\n> On 2020-04-24 at 04:01:30, Sibi Siddharthan via GitGitGadget wrote:\n> > diff --git a/CMakeLists.txt b/CMakeLists.txt\n> > new file mode 100644\n> > index 00000000000..73703bd321f\n> > --- /dev/null\n> > +++ b/CMakeLists.txt\n> > @@ -0,0 +1,528 @@\n> > +#\n> > +#    Copyright (c) 2020 Sibi Siddharthan\n> > +#\n> > +\n> > +cmake_minimum_required(VERSION 3.14)\n>\n> I don't plan a full review of this series, but I wanted to point out\n> that this version is newer than what's in Debian 10, so this isn't\n> practically buildable on many systems.\n>\n> If we wanted to add CMake support, even just for Linux and Windows, I'd\n> want to see it functional on the latest versions of the major distros,\n> at the very least.  Ideally it would function using the system packages\n> on all security-supported versions of the major distros, since our\n> Makefile does right now.\n\nI know that version 3.14 is asking a lot, but without this version the\nscript would\nhave a lot platform specific stuff related to how hard links are created.\nWindows -> mklink\nOther systems -> ln\n\nThis is why this version was chosen.\nI would also like to say that this CMake script is not a replacement for\nthe Makefile.\n\n> --\n> brian m. carlson: Houston, Texas, US\n> OpenPGP: https://keybase.io/bk2204\n\nThank You,\nSibi Siddharthan\n"},{"id":"396276","messageId":"20200426004119.otgynhnzvmykitez@danh.dev","threadId":"53305","inReplyTo":"CAKiG+9XwoD+UzHovS_mW76CPX_Vtt1eTaSM-xaszKWwt6R3ewA@mail.gmail.com","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Danh Doan","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-04-26T00:41:19Z","receivedAt":"2020-04-26T00:41:25Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2020-04-25 20:27:37+0530, Sibi Siddharthan <sibisiddharthan.github@gmail.com> wrote:\n> Hi Dscho,\n> \n> I guess this is a pain point having to manage two separate build systems.\n> I will modify CMake script to get its sources from the Makefile.\n> \n> > > I understand what you are trying to say, this is not impossible to do but doing\n> > > so will make the CMake script dependent on the Makefile for the sources.\n> > > I am not fan of this approach.\n> > >\n> > > We should write a separate script (say python) to match each of the sources in\n> > > the Makefile and the CMake file automatically whenever the changes detected.\n> > > This excludes the platform specific/compatibility stuff in config.mak.uname.\n> >\n> > Hmm. That is an approach that _I_ don't like. Why duplicate the\n> > information when you don't have to?\n> >\n> > I don't see any issue with keeping CMakeLists.txt dependent on Makefile.\n> > We could of course extract the lists into a separate file that is sourced\n> > both from the Makefile and from CMakeLists.txt, but that would actually\n> > not reflect that the Makefile _is_ authoritative. CMakeLists.txt will\n> > never be the authoritative source.\n\n(This email is hard to be replied, because Sibi do top-posting.\nAnd, I want to quote both on this).\n\nI'm still not a fan of CMake despite that I need to write it at\nprevious $DAYJOBS.\n\nI would like to keep Makefile as authoritative source of information,\nand to convince other developers, we need to keep Makefile as\nauthoritative source of information. Let's say this way, I dislike it,\nbut if it works for you, that's fine, just don't add more burden for\nexisting people.\n\nRemember that with CMake support, we will never able to use CMake\ngenerated build in-tree because we have an existing Makefile in-tree\n(not a problem since it's expected to be built out-of-tree if CMake is used),\nbut please don't complain if it people accidentally break it.\n./configure doesn't work correctly with `--without-<pkg>` and people\nseems to not interest in my series to respect it, for example.\n\nWhen writing this, I intended to write something to support\nout-of-tree build with current Makefile. Hopefully, it won't be rocket\nscience.\n\nLast but not least, (this point was discussed with Sibi off-list)\nabout our test infrastructure, when we add a new test,\nwe can simply run:\n\n\tmake test\n\nMakefile will pick it up, and run all tests just fine.\n\nCMake's glob only works at CMake configuration time.\nIf there's a new test after CMake was run, and nothing changed in\nCMakeList.txt. The list generated by CMake will still be the same,\nctest wouldn't know that there's a new test.\nPeople need to manually run cmake again to pick it up (or as Sibi\ntold me off-list, that developer is question can run by hand\n\n\tpath/to/git/source/t/t-9999-true.sh\n\nThat's not a problem for the person write that test,\nbut it'll be problem for other people, who will fetch the new source\nto their own repo, and naively run msbuild and ctest.\n\nIt's analogue to this habit in git (me in my previous $DAYJOBS)\n\n\tyes | git add -p\n\nAnyway, get back to the solution (should this series be accepted),\nI think it'll work if we can split:\n\n\tSOURCE_FILES += cmake.c\n\ninto a source-list.mak\n\nThen, cmake will do some magic with `configure_file` or something\nsimilar, IIRC, it's a reduced functionallity of sed.\n\n-- \nDanh\n"},{"id":"396283","messageId":"CAKiG+9VQd3R0DtPnxWq-RHwEAf-_kdpspPX_pAeQhBD8t=H_QQ@mail.gmail.com","threadId":"53305","inReplyTo":"20200426004119.otgynhnzvmykitez@danh.dev","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-04-26T04:30:25Z","receivedAt":"2020-04-26T04:30:42Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Sun, Apr 26, 2020 at 6:11 AM Danh Doan <congdanhqx@gmail.com> wrote:\n>\n> On 2020-04-25 20:27:37+0530, Sibi Siddharthan <sibisiddharthan.github@gmail.com> wrote:\n> > Hi Dscho,\n> >\n> > I guess this is a pain point having to manage two separate build systems.\n> > I will modify CMake script to get its sources from the Makefile.\n> >\n> > > > I understand what you are trying to say, this is not impossible to do but doing\n> > > > so will make the CMake script dependent on the Makefile for the sources.\n> > > > I am not fan of this approach.\n> > > >\n> > > > We should write a separate script (say python) to match each of the sources in\n> > > > the Makefile and the CMake file automatically whenever the changes detected.\n> > > > This excludes the platform specific/compatibility stuff in config.mak.uname.\n> > >\n> > > Hmm. That is an approach that _I_ don't like. Why duplicate the\n> > > information when you don't have to?\n> > >\n> > > I don't see any issue with keeping CMakeLists.txt dependent on Makefile.\n> > > We could of course extract the lists into a separate file that is sourced\n> > > both from the Makefile and from CMakeLists.txt, but that would actually\n> > > not reflect that the Makefile _is_ authoritative. CMakeLists.txt will\n> > > never be the authoritative source.\n>\n> (This email is hard to be replied, because Sibi do top-posting.\n> And, I want to quote both on this).\n>\n> I'm still not a fan of CMake despite that I need to write it at\n> previous $DAYJOBS.\n>\n> I would like to keep Makefile as authoritative source of information,\n> and to convince other developers, we need to keep Makefile as\n> authoritative source of information. Let's say this way, I dislike it,\n> but if it works for you, that's fine, just don't add more burden for\n> existing people.\n>\n> Remember that with CMake support, we will never able to use CMake\n> generated build in-tree because we have an existing Makefile in-tree\n> (not a problem since it's expected to be built out-of-tree if CMake is used),\n> but please don't complain if it people accidentally break it.\n> ./configure doesn't work correctly with `--without-<pkg>` and people\n> seems to not interest in my series to respect it, for example.\n>\n\nTo prevent the CMake script from overwriting the current Makefile,\nI can add a check at the beginning to stop the configure if the build\nis done in source.\n\n> When writing this, I intended to write something to support\n> out-of-tree build with current Makefile. Hopefully, it won't be rocket\n> science.\n>\n> Last but not least, (this point was discussed with Sibi off-list)\n> about our test infrastructure, when we add a new test,\n> we can simply run:\n>\n>         make test\n>\n> Makefile will pick it up, and run all tests just fine.\n>\n> CMake's glob only works at CMake configuration time.\n> If there's a new test after CMake was run, and nothing changed in\n> CMakeList.txt. The list generated by CMake will still be the same,\n> ctest wouldn't know that there's a new test.\n> People need to manually run cmake again to pick it up (or as Sibi\n> told me off-list, that developer is question can run by hand\n>\n>         path/to/git/source/t/t-9999-true.sh\n>\n> That's not a problem for the person write that test,\n> but it'll be problem for other people, who will fetch the new source\n> to their own repo, and naively run msbuild and ctest.\n>\n> It's analogue to this habit in git (me in my previous $DAYJOBS)\n>\n>         yes | git add -p\n>\n> Anyway, get back to the solution (should this series be accepted),\n> I think it'll work if we can split:\n>\n>         SOURCE_FILES += cmake.c\n>\n> into a source-list.mak\n>\n> Then, cmake will do some magic with `configure_file` or something\n> similar, IIRC, it's a reduced functionallity of sed.\n>\n\nMe and Dscho discussed that we will use the Makefile for getting the\nsource list.\nSo we will basically parse the Makefile for the requires sourced to be\nused( in CMake itself).\nSo devs can just maintain the Makefile alone.\nThis approach works for\nSCRIPT_SH\nSCRIPT_LIB\nSCRIPT_PERL\nSCRIPT_PYTHON\nTEST_BUILTINS_OBJS\nLIB_OBJS\nBUILTIN_OBJS\nXDIFF_OBJS\nVCSSVN_OBJS\n\nPROGRAM_OBJS do not work, as a few of them link with curl and expat.\nAs git-bugreport was added recently to the next branch.\nThis should not be major issue I guess.\n\n> --\n> Danh\n\nThank You,\nSibi Siddharthan\n"},{"id":"396371","messageId":"20200427200852.GC1728884@coredump.intra.peff.net","threadId":"53305","inReplyTo":"nycvar.QRO.7.76.6.2004251354390.18039@tvgsbejvaqbjf.bet","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2020-04-27T20:08:52Z","receivedAt":"2020-04-27T20:08:55Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Apr 25, 2020 at 02:24:34PM +0200, Johannes Schindelin wrote:\n\n> > > The goal would be to maintain a CMake build for Git keeping it in sync\n> > > with the Makefile. The Makefile is not going to be replaced at all.\n> > > The CMake script for now only supports Linux and Windows. It does not\n> > > support BSD, Solaris and others, whereas the Makefile does support\n> > > them.\n> >\n> > So you are doing (1).  I already said that I feel that engineering\n> > burden to divert resources for CMake support would be unacceptably\n> > high.\n> \n> Would your position change if Sibi was interested in maintaining this, and\n> helping with keeping CMake support in shape?\n\nI have mixed feelings.\n\nImagine we say that the Makefile is the official build mechanism and\nthat cmake support is a second-class citizen. I.e., somebody is willing\nto be the maintainer of that feature and port over changes for people\nwho want to use cmake. That removes the issue of developers spending\ntime dealing with a new make tool that they don't care about (and might\nnot even have, or might not be available for their platform).\n\nThat's basically what we do with autoconf. But I haven't been all that\npleased with the results. The autoconf code is frequently out-of-date or\njust plain wrong (e.g., the recent inet_ntop issues) and a frequent\nresponse to questions on the list is \"have you tried just building\nwithout autoconf\". I'm not sure if we are doing users a disservice to\npretend that we have maintained autoconf support.\n\nOn the other hand, if it is helping people avoid turning Makefile knobs\nmanually, we'd never hear complaints if it Just Works for some folks. So\nmaybe autoconf is a necessary evil (evil from the perspective of\ndevelopers, not users) that does pull its own weight.\n\nGetting back to cmake: I can plausibly believe it's in the same boat. I\ndon't have any interest in Visual Studio, but I can believe that it's an\nimportant convenience for some people / platforms, and that cmake is the\nbest way to get there.\n\nSo if you are proposing to declare this as an experiment which will be\nmaintained independently, and we can see how often it becomes a problem\nand how many people it helps, that makes more sense to me.\n\nSkimming the patches, I do wish I didn't see so much repetition with the\nexisting Makefile. I know that some of the logic will just have to be\nported manually, but surely we could be pulling things like the list of\nlibgit_SOURCES from the Makefile as the single source of truth?\n\n> > Any patch that is acceptable to the current project would become\n> > unacceptable because they lack updates to CMake part, but I suspect\n> > we do not have enough people who are so much devoted to give a good\n> > review if updates to CMake part are added.  And it is unclear why it\n> > would be beneficial to slow our existing developers down by forcing\n> > them to become familiar with CMake.\n> \n> When it comes to new Makefile knobs, I do agree that it would place an\n> unacceptable burden on contributors if we expected them to add the same\n> knob to CMakeLists.txt. But we already don't do that for our autoconf\n> support, so why would we expect it for CMake?\n\nMy concern here would be that the various knobs and behaviors are going\nto fall out of date, and nobody will notice. Because there aren't many\ncmake users, and because some of the logic is subtle (e.g., if it picked\nthe wrong sha1-implementation default, who would notice?). But again, if\nwe're willing to say \"cmake support is an experiment\" and let the\nmaintenance burden fall to people who are interested, then we can at\nleast have some data on how it works in practice.\n\n> When it comes to adding new, and/or removing, files, I fail to see the\n> problem. It is dead easy to keep the Makefile and CMakeLists.txt in sync\n> when it comes to lists of files.\n\nIt's _conceptually_ dead easy, but now there's a new tool and a new step\npeople have to know about. Automated builds let you know when there's a\nproblem, but somebody still has to fix it. I'd hope that basic stuff\nlike file lists could be written so that there's no need to fix at all:\nthey'd just pull from the same source as the Makefile.\n\n> But even if I haven't, I would like to propose to run with Sibi's patches\n> and merge them first to `pu`, and then to `next`, and let that cook for a\n> while (I will merge them into Git for Windows early so that there is also\n> some support stream from that side).\n> \n> I know you think that the maintenance cost is too high, but I think it\n> might be more than just manageable. And I don't think that the risk is too\n> high to give the patches a try, at least inside `next`, for a couple of\n> weeks or even months.\n> \n> If it turns out that they _do_ add too much of a maintenance burden, big\n> deal: we just drop the patches, and that's that. No hard feelings, we gave\n> it a try, a scientific test, if you want, and we now have evidence to back\n> up your initial suspicion.\n> \n> If it turns out that they _do_ add value _and_ are easy to maintain, then\n> that's good, right? And then, at your leisurely leisure, you can merge\n> them down to `master` and eventually into an official release.\n> \n> What do you think? Doesn't that sound like a good plan?\n\nI think what I'm suggesting is not all that different from this, except\nthat I'd suspect \"next\" would not get enough exposure. So in my mind\nmerging to master is not so much \"hooray, we now have visual studio\nsupport\" but rather the first step in getting data. But we'd have to be\nvery clear about how the project regards the cmake support: it's there\nfor now, you're encouraged to play with it, but don't be upset if it\nneeds some coaxing to behave like the normal Makefile or if it goes away\nin the future.\n\n-Peff\n"},{"id":"396372","messageId":"20200427201228.GD1728884@coredump.intra.peff.net","threadId":"53305","inReplyTo":"20200427200852.GC1728884@coredump.intra.peff.net","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2020-04-27T20:12:28Z","receivedAt":"2020-04-27T20:12:31Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Apr 27, 2020 at 04:08:52PM -0400, Jeff King wrote:\n\n> Skimming the patches, I do wish I didn't see so much repetition with the\n> existing Makefile. I know that some of the logic will just have to be\n> ported manually, but surely we could be pulling things like the list of\n> libgit_SOURCES from the Makefile as the single source of truth?\n\nThinking I surely couldn't be the only one to think of this, I dug\nfurther into some of the sub-threads. And indeed, it seems like you are\non the same page here.\n\nIMHO it is worth making the cmake file depend as much as possible on\nwhat's in the Makefile.\n\n-Peff\n"},{"id":"396393","messageId":"xmqqlfmg7hn7.fsf@gitster.c.googlers.com","threadId":"53305","inReplyTo":"20200427200852.GC1728884@coredump.intra.peff.net","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-04-27T21:17:32Z","receivedAt":"2020-04-27T21:17:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> I think what I'm suggesting is not all that different from this, except\n> that I'd suspect \"next\" would not get enough exposure. So in my mind\n> merging to master is not so much \"hooray, we now have visual studio\n> support\" but rather the first step in getting data. But we'd have to be\n> very clear about how the project regards the cmake support: it's there\n> for now, you're encouraged to play with it, but don't be upset if it\n> needs some coaxing to behave like the normal Makefile or if it goes away\n> in the future.\n\nI think you said almost everything I would have said.  \n\nIf we were to adopt it as an experiment, hoping to gain exposure,\nnothing above 'master' (or tagged releases) won't work.  And once a\nthing is in 'master', users will ignore the \"this is merely an\nexperiment\" warning and expect it to be fully functional and usable.\n\nGiven the observation in the thread that it would take a fairly\nrecent version to benefit platform-agnostic usability features, I\ndid not get an impression that it is ready to be anywhere near that,\nnot even ready for 'next'.  It is *not* like \"Sibi's patches were\nbad but they can become ready with further polishing\".  The\nimpression I got was that the large part of why it is not ready is\nbecause it needs time for larger set of distros to adopt more recent\nversions of cmake.\n\nAnd I somehow think that rewriting Sibi's patches to lose the parts\nthat takes advantage of more recent cmake (abstracting \"mklink\" vs\n\"ln\" out was mentioned as an example---there may be a lot more) is\ngoing in a wrong direction.  The world will eventually catch up, and\nGit does not need cmake immediately.  Using the more recent features\nwhile waiting for the right time would be a more sensible approach\nthan aiming for an outdated version.\n\nSo, perhaps we'll try again in 3 years, perhaps, to consider if it\nmakes sense to add the cmake support to _my_ tree.\n\nBut in the meantime, those who are interested in building Git with\ncmake do not have to wait, doing nothing, I would imagine.  I wonder\nif they can work on a separate project (let's call it git-on-cmake)\nwhose sole purpose is to develop and polish CMakeLists.txt, waiting\nfor an advanced enough version of cmake becomes commonplace.  Then,\nanybody who are interested and has recent cmake can subtree-merge\ngit-on-cmake project into their own clone of our project somewhere,\nand help developing git-on-cmake further.\n\nThen we'll meet again in 3 years and see if the world got new enough\n;-)\n"},{"id":"396397","messageId":"20200427235604.226e9561@naga.burning-in.hell","threadId":"53305","inReplyTo":"xmqqlfmg7hn7.fsf@gitster.c.googlers.com","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Michal Suchánek","fromEmail":"msuchanek@suse.de","sentAt":"2020-04-27T21:56:04Z","receivedAt":"2020-04-27T21:56:08Z","isPatch":true,"sender":{"key":"msuchanek@suse.de","avatar":"https://avatars.githubusercontent.com/u/787652?v=4"},"body":"On Mon, 27 Apr 2020 14:17:32 -0700\nJunio C Hamano <gitster@pobox.com> wrote:\n\n> Jeff King <peff@peff.net> writes:\n> \n> > I think what I'm suggesting is not all that different from this, except\n> > that I'd suspect \"next\" would not get enough exposure. So in my mind\n> > merging to master is not so much \"hooray, we now have visual studio\n> > support\" but rather the first step in getting data. But we'd have to be\n> > very clear about how the project regards the cmake support: it's there\n> > for now, you're encouraged to play with it, but don't be upset if it\n> > needs some coaxing to behave like the normal Makefile or if it goes away\n> > in the future.  \n> \n> I think you said almost everything I would have said.  \n> \n> If we were to adopt it as an experiment, hoping to gain exposure,\n> nothing above 'master' (or tagged releases) won't work.  And once a\n> thing is in 'master', users will ignore the \"this is merely an\n> experiment\" warning and expect it to be fully functional and usable.\n> \n> Given the observation in the thread that it would take a fairly\n> recent version to benefit platform-agnostic usability features, I\n> did not get an impression that it is ready to be anywhere near that,\n> not even ready for 'next'.  It is *not* like \"Sibi's patches were\n> bad but they can become ready with further polishing\".  The\n> impression I got was that the large part of why it is not ready is\n> because it needs time for larger set of distros to adopt more recent\n> versions of cmake.\n> \nWhy do you need distros to adopt more recent versions of cmake?\n\nThe cmake support is mainly for VS and you can install current version\nof cmake with VS, there is no distro there. It can also work on\ndistros with recent cmake but that's not really the goal so it's not a\nproblem if many distros don't work.\n\nThanks\n\nMichal\n"},{"id":"396399","messageId":"20200427220955.GA1747507@coredump.intra.peff.net","threadId":"53305","inReplyTo":"xmqqlfmg7hn7.fsf@gitster.c.googlers.com","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2020-04-27T22:09:55Z","receivedAt":"2020-04-27T22:09:57Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Apr 27, 2020 at 02:17:32PM -0700, Junio C Hamano wrote:\n\n> If we were to adopt it as an experiment, hoping to gain exposure,\n> nothing above 'master' (or tagged releases) won't work.  And once a\n> thing is in 'master', users will ignore the \"this is merely an\n> experiment\" warning and expect it to be fully functional and usable.\n\nYeah, that is a problem. I wonder if the state would be more obvious if\nit lived in contrib/. We already have contrib/buildsystems,\nwhich seems like an earlier attempt at this exact problem?\n\n> But in the meantime, those who are interested in building Git with\n> cmake do not have to wait, doing nothing, I would imagine.  I wonder\n> if they can work on a separate project (let's call it git-on-cmake)\n> whose sole purpose is to develop and polish CMakeLists.txt, waiting\n> for an advanced enough version of cmake becomes commonplace.  Then,\n> anybody who are interested and has recent cmake can subtree-merge\n> git-on-cmake project into their own clone of our project somewhere,\n> and help developing git-on-cmake further.\n\nI think there's actually a good reason to have it in your tree: people\nuse your tree as the basis to build (and submit!) changes.\n\nI noticed the same thing with trying to play with CI changes. As a\ncontributor, yes I _can_ make my CI changes, and then base my branches\non that. But it gets rather awkward juggling branches that contain some\nchanges that should go upstream, and some which should not. And quite a\nbit more difficult if people want to use tools like GitGitGadget to just\ntarget a PR against git.git and send it to the mailing list.\n\nIf it lived in contrib/ that might strike a good balance between making\nit available for people to experiment with, but not having people\nconfuse it for the official build system.\n\n-Peff\n"},{"id":"396401","messageId":"CABPp-BE4qBquBwHp6QH31WNcQ-jUMrC+SqCbnBWKtCxdhoWRCQ@mail.gmail.com","threadId":"53305","inReplyTo":"20200427220955.GA1747507@coredump.intra.peff.net","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2020-04-27T22:23:22Z","receivedAt":"2020-04-27T22:23:36Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"On Mon, Apr 27, 2020 at 3:12 PM Jeff King <peff@peff.net> wrote:\n>\n> On Mon, Apr 27, 2020 at 02:17:32PM -0700, Junio C Hamano wrote:\n>\n> > If we were to adopt it as an experiment, hoping to gain exposure,\n> > nothing above 'master' (or tagged releases) won't work.  And once a\n> > thing is in 'master', users will ignore the \"this is merely an\n> > experiment\" warning and expect it to be fully functional and usable.\n>\n> Yeah, that is a problem. I wonder if the state would be more obvious if\n> it lived in contrib/. We already have contrib/buildsystems,\n> which seems like an earlier attempt at this exact problem?\n>\n> > But in the meantime, those who are interested in building Git with\n> > cmake do not have to wait, doing nothing, I would imagine.  I wonder\n> > if they can work on a separate project (let's call it git-on-cmake)\n> > whose sole purpose is to develop and polish CMakeLists.txt, waiting\n> > for an advanced enough version of cmake becomes commonplace.  Then,\n> > anybody who are interested and has recent cmake can subtree-merge\n> > git-on-cmake project into their own clone of our project somewhere,\n> > and help developing git-on-cmake further.\n>\n> I think there's actually a good reason to have it in your tree: people\n> use your tree as the basis to build (and submit!) changes.\n>\n> I noticed the same thing with trying to play with CI changes. As a\n> contributor, yes I _can_ make my CI changes, and then base my branches\n> on that. But it gets rather awkward juggling branches that contain some\n> changes that should go upstream, and some which should not. And quite a\n> bit more difficult if people want to use tools like GitGitGadget to just\n> target a PR against git.git and send it to the mailing list.\n>\n> If it lived in contrib/ that might strike a good balance between making\n> it available for people to experiment with, but not having people\n> confuse it for the official build system.\n\nMaybe we could move configure.ac and config.mak.in into contrib as well?\n"},{"id":"396402","messageId":"xmqq4kt47c5k.fsf@gitster.c.googlers.com","threadId":"53305","inReplyTo":"CABPp-BE4qBquBwHp6QH31WNcQ-jUMrC+SqCbnBWKtCxdhoWRCQ@mail.gmail.com","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-04-27T23:16:07Z","receivedAt":"2020-04-27T23:16:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Elijah Newren <newren@gmail.com> writes:\n\n>> If it lived in contrib/ that might strike a good balance between making\n>> it available for people to experiment with, but not having people\n>> confuse it for the official build system.\n\nIf we declare cmake support is only for VS and throw it into\nsomewhere like contrib/buildsystems, that may be good enough.\n\n> Maybe we could move configure.ac and config.mak.in into contrib as well?\n\nPerhaps.\n"},{"id":"396435","messageId":"20200428053602.GA2376380@coredump.intra.peff.net","threadId":"53305","inReplyTo":"CABPp-BE4qBquBwHp6QH31WNcQ-jUMrC+SqCbnBWKtCxdhoWRCQ@mail.gmail.com","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2020-04-28T05:36:02Z","receivedAt":"2020-04-28T05:36:06Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Apr 27, 2020 at 03:23:22PM -0700, Elijah Newren wrote:\n\n> > If it lived in contrib/ that might strike a good balance between making\n> > it available for people to experiment with, but not having people\n> > confuse it for the official build system.\n> \n> Maybe we could move configure.ac and config.mak.in into contrib as well?\n\nMaybe. I have a feeling that most folks who use autoconf do it from the\ntarballs, which have the generated ./configure anyway.\n\n-Peff\n"},{"id":"396460","messageId":"20200428135222.GB31366@danh.dev","threadId":"53305","inReplyTo":"20200427201228.GD1728884@coredump.intra.peff.net","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Danh Doan","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-04-28T13:52:37Z","receivedAt":"2020-04-28T13:52:41Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2020-04-27 16:12:28-0400, Jeff King <peff@peff.net> wrote:\n> On Mon, Apr 27, 2020 at 04:08:52PM -0400, Jeff King wrote:\n> \n> > Skimming the patches, I do wish I didn't see so much repetition with the\n> > existing Makefile. I know that some of the logic will just have to be\n> > ported manually, but surely we could be pulling things like the list of\n> > libgit_SOURCES from the Makefile as the single source of truth?\n> \n> Thinking I surely couldn't be the only one to think of this, I dug\n> further into some of the sub-threads. And indeed, it seems like you are\n> on the same page here.\n> \n> IMHO it is worth making the cmake file depend as much as possible on\n> what's in the Makefile.\n\nPlease correct me if I were wrong (I recall this from my memory\nwithout checking anything).\n\nThe worst thing about CMake is we can't override (Make's) variable\nin Makefile generated by CMake.\n\nI've made some comment in Sibi's patch about some make's variable,\nbecause Sibi naively translates them from current Makefile.\nNamely, the location of some system configuration files, $(libexecdir)\nand build conditional macro.\n\nWith current Makefile, we can just:\n\n\tmake VAR=VALUE target\n\nor:\n\techo \"VAR=VALUE\" >> config.mak\n\tmake target\n\nWith cmake, we need to define all of them as CMake options (this will\nbrings along a big burden), whenever we need to change any options,\nwe need to (assume that cmake generates Makefile):\n\n\tcmake -DVAR=VALUE path/to/src/dir\n\tmake target\n\nHow many make variables that we need to define in CMakeList.txt,\nI don't know.\n\n-- \nDanh\n"},{"id":"396506","messageId":"20200428210750.GE4000@coredump.intra.peff.net","threadId":"53305","inReplyTo":"20200428135222.GB31366@danh.dev","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2020-04-28T21:07:50Z","receivedAt":"2020-04-28T21:07:53Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Apr 28, 2020 at 08:52:37PM +0700, Danh Doan wrote:\n\n> On 2020-04-27 16:12:28-0400, Jeff King <peff@peff.net> wrote:\n> > On Mon, Apr 27, 2020 at 04:08:52PM -0400, Jeff King wrote:\n> > \n> > > Skimming the patches, I do wish I didn't see so much repetition with the\n> > > existing Makefile. I know that some of the logic will just have to be\n> > > ported manually, but surely we could be pulling things like the list of\n> > > libgit_SOURCES from the Makefile as the single source of truth?\n> > \n> > Thinking I surely couldn't be the only one to think of this, I dug\n> > further into some of the sub-threads. And indeed, it seems like you are\n> > on the same page here.\n> > \n> > IMHO it is worth making the cmake file depend as much as possible on\n> > what's in the Makefile.\n> \n> Please correct me if I were wrong (I recall this from my memory\n> without checking anything).\n> \n> The worst thing about CMake is we can't override (Make's) variable\n> in Makefile generated by CMake.\n\nI really don't know enough about cmake to say one way or the other. I\ncan well believe there are parts of the Makefile that will need to be\nmanually translated, and that it may not ever hit full parity.\n\nBut as long as it just a tool for people using Visual Studio, and if\nthey are happier being able to use that tool, even with a few\ndeficiencies, then it may still be worth doing.\n\n-Peff\n"},{"id":"396529","messageId":"CAKiG+9U2Eg5yvT4XjgpMUXu4OV-8JF9Hp_ou_P6twxfqJ1tEYA@mail.gmail.com","threadId":"53305","inReplyTo":"20200428210750.GE4000@coredump.intra.peff.net","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-04-29T08:42:43Z","receivedAt":"2020-04-29T08:42:57Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"Adding the CMake script to contrib/buildsystem is a good option.\nIs there any changes (apart from the CMakeLists.txt critique and) that\nI have to do on my part?\n\nThank You,\nSibi Siddharthan\n\nOn Wed, Apr 29, 2020 at 2:37 AM Jeff King <peff@peff.net> wrote:\n>\n> On Tue, Apr 28, 2020 at 08:52:37PM +0700, Danh Doan wrote:\n>\n> > On 2020-04-27 16:12:28-0400, Jeff King <peff@peff.net> wrote:\n> > > On Mon, Apr 27, 2020 at 04:08:52PM -0400, Jeff King wrote:\n> > >\n> > > > Skimming the patches, I do wish I didn't see so much repetition with the\n> > > > existing Makefile. I know that some of the logic will just have to be\n> > > > ported manually, but surely we could be pulling things like the list of\n> > > > libgit_SOURCES from the Makefile as the single source of truth?\n> > >\n> > > Thinking I surely couldn't be the only one to think of this, I dug\n> > > further into some of the sub-threads. And indeed, it seems like you are\n> > > on the same page here.\n> > >\n> > > IMHO it is worth making the cmake file depend as much as possible on\n> > > what's in the Makefile.\n> >\n> > Please correct me if I were wrong (I recall this from my memory\n> > without checking anything).\n> >\n> > The worst thing about CMake is we can't override (Make's) variable\n> > in Makefile generated by CMake.\n>\n> I really don't know enough about cmake to say one way or the other. I\n> can well believe there are parts of the Makefile that will need to be\n> manually translated, and that it may not ever hit full parity.\n>\n> But as long as it just a tool for people using Visual Studio, and if\n> they are happier being able to use that tool, even with a few\n> deficiencies, then it may still be worth doing.\n>\n> -Peff\n"},{"id":"396779","messageId":"nycvar.QRO.7.76.6.2005012130010.18039@tvgsbejvaqbjf.bet","threadId":"53305","inReplyTo":"CAKiG+9U2Eg5yvT4XjgpMUXu4OV-8JF9Hp_ou_P6twxfqJ1tEYA@mail.gmail.com","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-05-01T19:32:23Z","receivedAt":"2020-05-01T19:32:40Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Sibi,\n\n[please avoid top-posting on this list, but do reply inline instead, that\nis much preferred.]\n\nOn Wed, 29 Apr 2020, Sibi Siddharthan wrote:\n\n> Adding the CMake script to contrib/buildsystem is a good option.\n\nI'd actually prefer it to live in a different subdirectory: what is in\ncontrib/buildsystem/ uses the technique of running `make` in a dry-run\nmode, parsing the output, and then generating project files. But that is\nnot what CMakeLists.txt is about.\n\nHow about contrib/cmake/?\n\n> Is there any changes (apart from the CMakeLists.txt critique and) that\n> I have to do on my part?\n\nNo, I think that's it!\n\nThanks,\nDscho\n\n>\n> Thank You,\n> Sibi Siddharthan\n>\n> On Wed, Apr 29, 2020 at 2:37 AM Jeff King <peff@peff.net> wrote:\n> >\n> > On Tue, Apr 28, 2020 at 08:52:37PM +0700, Danh Doan wrote:\n> >\n> > > On 2020-04-27 16:12:28-0400, Jeff King <peff@peff.net> wrote:\n> > > > On Mon, Apr 27, 2020 at 04:08:52PM -0400, Jeff King wrote:\n> > > >\n> > > > > Skimming the patches, I do wish I didn't see so much repetition with the\n> > > > > existing Makefile. I know that some of the logic will just have to be\n> > > > > ported manually, but surely we could be pulling things like the list of\n> > > > > libgit_SOURCES from the Makefile as the single source of truth?\n> > > >\n> > > > Thinking I surely couldn't be the only one to think of this, I dug\n> > > > further into some of the sub-threads. And indeed, it seems like you are\n> > > > on the same page here.\n> > > >\n> > > > IMHO it is worth making the cmake file depend as much as possible on\n> > > > what's in the Makefile.\n> > >\n> > > Please correct me if I were wrong (I recall this from my memory\n> > > without checking anything).\n> > >\n> > > The worst thing about CMake is we can't override (Make's) variable\n> > > in Makefile generated by CMake.\n> >\n> > I really don't know enough about cmake to say one way or the other. I\n> > can well believe there are parts of the Makefile that will need to be\n> > manually translated, and that it may not ever hit full parity.\n> >\n> > But as long as it just a tool for people using Visual Studio, and if\n> > they are happier being able to use that tool, even with a few\n> > deficiencies, then it may still be worth doing.\n> >\n> > -Peff\n>\n"},{"id":"396822","messageId":"20200502132144.GB3143@danh.dev","threadId":"53305","inReplyTo":"CAKiG+9U2Eg5yvT4XjgpMUXu4OV-8JF9Hp_ou_P6twxfqJ1tEYA@mail.gmail.com","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Danh Doan","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-05-02T13:21:44Z","receivedAt":"2020-05-02T13:21:49Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"Hi Sibi,\n\nOn 2020-04-29 14:12:43+0530, Sibi Siddharthan <sibisiddharthan.github@gmail.com> wrote:\n> > > Please correct me if I were wrong (I recall this from my memory\n> > > without checking anything).\n> > >\n> > > The worst thing about CMake is we can't override (Make's) variable\n> > > in Makefile generated by CMake.\n> >\n> > I really don't know enough about cmake to say one way or the other. I\n> > can well believe there are parts of the Makefile that will need to be\n> > manually translated, and that it may not ever hit full parity.\n> >\n> > But as long as it just a tool for people using Visual Studio, and if\n> > they are happier being able to use that tool, even with a few\n> > deficiencies, then it may still be worth doing.\n> Adding the CMake script to contrib/buildsystem is a good option.\n> Is there any changes (apart from the CMakeLists.txt critique and) that\n> I have to do on my part?\n\n(Sorry for this late reply, it's holiday over here).\n\nIt's long time since last time I worked with CMake, but I have some\nsuggestion, maybe it was written in my previous comment, maybe not.\n\n- If we could find anything in CMake that equivalent with `sysconfdir`\n  in autotools, please use it for configuration files instead of\n  relative to `CMAKE_INSTALL_PREFIX`\n- I'll change (this and alikes)\n  \tfind_program(SH_PATH, \"sh\")\n  with:\n  \toption(SHELL_PATH \"path to POSIX compliance shell\" \"/bin/sh\")\n  in order to support Solaris people, should they want to try CMake\n- I'll wrap the incompatible option of gettext under uname check\n- and remove ${} around variable in `if`\n\n-- \nDanh\n"},{"id":"396826","messageId":"CAKiG+9UvnLtF7eS9FsPLyRR4ZPNSnakZwyYy3dO7WoAnRpvoMA@mail.gmail.com","threadId":"53305","inReplyTo":"nycvar.QRO.7.76.6.2005012130010.18039@tvgsbejvaqbjf.bet","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-05-02T14:31:39Z","receivedAt":"2020-05-02T14:31:55Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Sat, May 2, 2020 at 1:02 AM Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n>\n> Hi Sibi,\n>\n> [please avoid top-posting on this list, but do reply inline instead, that\n> is much preferred.]\n>\n> On Wed, 29 Apr 2020, Sibi Siddharthan wrote:\n>\n> > Adding the CMake script to contrib/buildsystem is a good option.\n>\n> I'd actually prefer it to live in a different subdirectory: what is in\n> contrib/buildsystem/ uses the technique of running `make` in a dry-run\n> mode, parsing the output, and then generating project files. But that is\n> not what CMakeLists.txt is about.\n>\n> How about contrib/cmake/?\n>\n\nThe CMakeLists.txt will be non-functional if it in any other directory except\nthe root source directory. To help users we can,\nadd some instructions in INSTALL on how to use the script.\nOR\ncreate a dummy CMakeLists.txt in the root directory which just\nsays\n`message(\"Copy and Replace the CMakeLists from `whatever-folder` to here\")`\nalong with some instructions if necessary. This is what LLVM does for autoconf.\n\nThank You,\nSibi Siddharthan\n\n> > Is there any changes (apart from the CMakeLists.txt critique and) that\n> > I have to do on my part?\n>\n> No, I think that's it!\n>\n> Thanks,\n> Dscho\n>\n> >\n> > Thank You,\n> > Sibi Siddharthan\n> >\n> > On Wed, Apr 29, 2020 at 2:37 AM Jeff King <peff@peff.net> wrote:\n> > >\n> > > On Tue, Apr 28, 2020 at 08:52:37PM +0700, Danh Doan wrote:\n> > >\n> > > > On 2020-04-27 16:12:28-0400, Jeff King <peff@peff.net> wrote:\n> > > > > On Mon, Apr 27, 2020 at 04:08:52PM -0400, Jeff King wrote:\n> > > > >\n> > > > > > Skimming the patches, I do wish I didn't see so much repetition with the\n> > > > > > existing Makefile. I know that some of the logic will just have to be\n> > > > > > ported manually, but surely we could be pulling things like the list of\n> > > > > > libgit_SOURCES from the Makefile as the single source of truth?\n> > > > >\n> > > > > Thinking I surely couldn't be the only one to think of this, I dug\n> > > > > further into some of the sub-threads. And indeed, it seems like you are\n> > > > > on the same page here.\n> > > > >\n> > > > > IMHO it is worth making the cmake file depend as much as possible on\n> > > > > what's in the Makefile.\n> > > >\n> > > > Please correct me if I were wrong (I recall this from my memory\n> > > > without checking anything).\n> > > >\n> > > > The worst thing about CMake is we can't override (Make's) variable\n> > > > in Makefile generated by CMake.\n> > >\n> > > I really don't know enough about cmake to say one way or the other. I\n> > > can well believe there are parts of the Makefile that will need to be\n> > > manually translated, and that it may not ever hit full parity.\n> > >\n> > > But as long as it just a tool for people using Visual Studio, and if\n> > > they are happier being able to use that tool, even with a few\n> > > deficiencies, then it may still be worth doing.\n> > >\n> > > -Peff\n> >\n"},{"id":"396827","messageId":"CAKiG+9WNkM-9hfp83xz_xv0s3LQaiyG0voMFKoxvMwFKt4YoZQ@mail.gmail.com","threadId":"53305","inReplyTo":"20200502132144.GB3143@danh.dev","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-05-02T14:50:50Z","receivedAt":"2020-05-02T14:51:05Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Sat, May 2, 2020 at 6:51 PM Danh Doan <congdanhqx@gmail.com> wrote:\n>\n> Hi Sibi,\n>\n> On 2020-04-29 14:12:43+0530, Sibi Siddharthan <sibisiddharthan.github@gmail.com> wrote:\n> > > > Please correct me if I were wrong (I recall this from my memory\n> > > > without checking anything).\n> > > >\n> > > > The worst thing about CMake is we can't override (Make's) variable\n> > > > in Makefile generated by CMake.\n> > >\n> > > I really don't know enough about cmake to say one way or the other. I\n> > > can well believe there are parts of the Makefile that will need to be\n> > > manually translated, and that it may not ever hit full parity.\n> > >\n> > > But as long as it just a tool for people using Visual Studio, and if\n> > > they are happier being able to use that tool, even with a few\n> > > deficiencies, then it may still be worth doing.\n> > Adding the CMake script to contrib/buildsystem is a good option.\n> > Is there any changes (apart from the CMakeLists.txt critique and) that\n> > I have to do on my part?\n>\n> (Sorry for this late reply, it's holiday over here).\n>\n> It's long time since last time I worked with CMake, but I have some\n> suggestion, maybe it was written in my previous comment, maybe not.\n>\n> - If we could find anything in CMake that equivalent with `sysconfdir`\n>   in autotools, please use it for configuration files instead of\n>   relative to `CMAKE_INSTALL_PREFIX`\n\nThe module GNUInstallDirs does what you ask.\n\n> - I'll change (this and alikes)\n>         find_program(SH_PATH, \"sh\")\n>   with:\n>         option(SHELL_PATH \"path to POSIX compliance shell\" \"/bin/sh\")\n>   in order to support Solaris people, should they want to try CMake\n> - I'll wrap the incompatible option of gettext under uname check\n> - and remove ${} around variable in `if`\n>\n\nThe thing with options in cmake is the values it takes are boolean only.\nTo do what you want I think you have to do something along the lines of this.\nif(NOT DEFINED SHELL_PATH)\nset(SHELL_PATH  <default value> CACHE STRING \"path to POSIX compliance shell\")\nendif()\n\nThen if you want to change this value, edit this value in CMakeCache.txt.\n\nThank You,\nSibi Siddharthan\n\n> --\n> Danh\n"},{"id":"396828","messageId":"04eb01d62092$3865fb90$a931f2b0$@nexbridge.com","threadId":"53305","inReplyTo":"CAKiG+9UvnLtF7eS9FsPLyRR4ZPNSnakZwyYy3dO7WoAnRpvoMA@mail.gmail.com","subject":"RE: [PATCH 0/8] CMake build system for git","fromName":"Randall S. Becker","fromEmail":"rsbecker@nexbridge.com","sentAt":"2020-05-02T14:58:57Z","receivedAt":"2020-05-02T14:59:18Z","isPatch":true,"sender":{"key":"randall.becker@nexbridge.ca","avatar":"https://avatars.githubusercontent.com/u/28956764?v=4"},"body":"On May 2, 2020 10:32 AM, Sibi Siddharthan Wrote:\n> On Sat, May 2, 2020 at 1:02 AM Johannes Schindelin\n> <Johannes.Schindelin@gmx.de> wrote:\n> > On Wed, 29 Apr 2020, Sibi Siddharthan wrote:\n> >\n> > > Adding the CMake script to contrib/buildsystem is a good option.\n> >\n> > I'd actually prefer it to live in a different subdirectory: what is in\n> > contrib/buildsystem/ uses the technique of running `make` in a dry-run\n> > mode, parsing the output, and then generating project files. But that\n> > is not what CMakeLists.txt is about.\n> >\n> > How about contrib/cmake/?\n> >\n> \n> The CMakeLists.txt will be non-functional if it in any other directory except\n> the root source directory. To help users we can, add some instructions in\n> INSTALL on how to use the script.\n> OR\n> create a dummy CMakeLists.txt in the root directory which just says\n> `message(\"Copy and Replace the CMakeLists from `whatever-folder` to\n> here\")` along with some instructions if necessary. This is what LLVM does for\n> autoconf.\n> > > Is there any changes (apart from the CMakeLists.txt critique and)\n> > > that I have to do on my part?\n> >\n> > No, I think that's it!\n> >\n> > Thanks,\n> > Dscho\n> >\n> > >\n> > > Thank You,\n> > > Sibi Siddharthan\n> > >\n> > > On Wed, Apr 29, 2020 at 2:37 AM Jeff King <peff@peff.net> wrote:\n> > > >\n> > > > On Tue, Apr 28, 2020 at 08:52:37PM +0700, Danh Doan wrote:\n> > > >\n> > > > > On 2020-04-27 16:12:28-0400, Jeff King <peff@peff.net> wrote:\n> > > > > > On Mon, Apr 27, 2020 at 04:08:52PM -0400, Jeff King wrote:\n> > > > > >\n> > > > > > > Skimming the patches, I do wish I didn't see so much\n> > > > > > > repetition with the existing Makefile. I know that some of\n> > > > > > > the logic will just have to be ported manually, but surely\n> > > > > > > we could be pulling things like the list of libgit_SOURCES from the\n> Makefile as the single source of truth?\n> > > > > >\n> > > > > > Thinking I surely couldn't be the only one to think of this, I\n> > > > > > dug further into some of the sub-threads. And indeed, it seems\n> > > > > > like you are on the same page here.\n> > > > > >\n> > > > > > IMHO it is worth making the cmake file depend as much as\n> > > > > > possible on what's in the Makefile.\n> > > > >\n> > > > > Please correct me if I were wrong (I recall this from my memory\n> > > > > without checking anything).\n> > > > >\n> > > > > The worst thing about CMake is we can't override (Make's)\n> > > > > variable in Makefile generated by CMake.\n> > > >\n> > > > I really don't know enough about cmake to say one way or the\n> > > > other. I can well believe there are parts of the Makefile that\n> > > > will need to be manually translated, and that it may not ever hit full\n> parity.\n> > > >\n> > > > But as long as it just a tool for people using Visual Studio, and\n> > > > if they are happier being able to use that tool, even with a few\n> > > > deficiencies, then it may still be worth doing.\n> > > >\n> > > > -Peff\n> > >\n\nJust 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).\n\nRegards,\nRandall\n\n-- Brief whoami:\n NonStop developer since approximately 211288444200000000\n UNIX developer since approximately 421664400\n-- In my real life, I talk too much.\n\n\n\n"},{"id":"396829","messageId":"20200502150200.GA26423@danh.dev","threadId":"53305","inReplyTo":"CAKiG+9WNkM-9hfp83xz_xv0s3LQaiyG0voMFKoxvMwFKt4YoZQ@mail.gmail.com","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Danh Doan","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-05-02T15:02:00Z","receivedAt":"2020-05-02T15:02:04Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2020-05-02 20:20:50+0530, Sibi Siddharthan <sibisiddharthan.github@gmail.com> wrote:\n> On Sat, May 2, 2020 at 6:51 PM Danh Doan <congdanhqx@gmail.com> wrote:\n> The thing with options in cmake is the values it takes are boolean only.\n> To do what you want I think you have to do something along the lines of this.\n> if(NOT DEFINED SHELL_PATH)\n> set(SHELL_PATH  <default value> CACHE STRING \"path to POSIX compliance shell\")\n> endif()\n> \n> Then if you want to change this value, edit this value in CMakeCache.txt.\n\nAh, this is what I mean, I think it's better to use this (without\nif_not_define)\n\n\tset(SHELL_PATH  \"/bin/sh\" CACHE PATH \"path to POSIX compliance shell\")\n\nThen, we can use this:\n\n\tcmake -DSHELL_PATH=/path/to/good/sh ...\n\n-- \nDanh\n"},{"id":"396831","messageId":"CAKiG+9Xk5vgNxYZ7kNsUhgv0oopY-057VexUK=iE6dX6GKPrqA@mail.gmail.com","threadId":"53305","inReplyTo":"20200502150200.GA26423@danh.dev","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-05-02T15:16:12Z","receivedAt":"2020-05-02T15:16:26Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Sat, May 2, 2020 at 8:32 PM Danh Doan <congdanhqx@gmail.com> wrote:\n>\n> On 2020-05-02 20:20:50+0530, Sibi Siddharthan <sibisiddharthan.github@gmail.com> wrote:\n> > On Sat, May 2, 2020 at 6:51 PM Danh Doan <congdanhqx@gmail.com> wrote:\n> > The thing with options in cmake is the values it takes are boolean only.\n> > To do what you want I think you have to do something along the lines of this.\n> > if(NOT DEFINED SHELL_PATH)\n> > set(SHELL_PATH  <default value> CACHE STRING \"path to POSIX compliance shell\")\n> > endif()\n> >\n> > Then if you want to change this value, edit this value in CMakeCache.txt.\n>\n> Ah, this is what I mean, I think it's better to use this (without\n> if_not_define)\n>\n>         set(SHELL_PATH  \"/bin/sh\" CACHE PATH \"path to POSIX compliance shell\")\n>\n> Then, we can use this:\n>\n>         cmake -DSHELL_PATH=/path/to/good/sh ...\n>\n\nIf you CACHE the variable, you have to do this\n cmake -USHELL_PATH -DSHELL_PATH=/path/to/good/sh\n\nI know it is bad.\nOtherwise you can modify the cache entry directly in CMakeCache.txt.\n\nThank You,\nSibi Siddharthan\n\n> --\n> Danh\n"},{"id":"396833","messageId":"xmqq4ksyl4mz.fsf@gitster.c.googlers.com","threadId":"53305","inReplyTo":"CAKiG+9UvnLtF7eS9FsPLyRR4ZPNSnakZwyYy3dO7WoAnRpvoMA@mail.gmail.com","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-02T15:48:20Z","receivedAt":"2020-05-02T15:48:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n\n>> How about contrib/cmake/?\n>>\n>\n> The CMakeLists.txt will be non-functional if it in any other directory except\n> the root source directory. To help users we can,\n> add some instructions in INSTALL on how to use the script.\n> OR\n> create a dummy CMakeLists.txt in the root directory which just\n> says\n> `message(\"Copy and Replace the CMakeLists from `whatever-folder` to here\")`\n> along with some instructions if necessary. This is what LLVM does for autoconf.\n\nIsn't there a corresponding feature to make's \"-f\" option to specify\nwhich file to read instructions from?\n\nAs you say, an extra instruction in INSTALL file to tell users to\ncopy from contrib/cmake may workable, though it is unsatisfactory.\nBut the other one will not simply work.  If we need to have a new\nfile with string \"CMake\" in its name at the top-level *anyway*, we\nshould have the real thing to reduce one step from those who want to\nuse it.  Those who do not want to see \"CMake\" at the toplevel are\nalready harmed either way, if is a dummy or if it is the real thing.\n\nThanks.\n"},{"id":"396872","messageId":"CAKiG+9Vvwz_ajhJ1KPVWtq25UaGtJOH57eXTA=cgm5qzoZCfGw@mail.gmail.com","threadId":"53305","inReplyTo":"xmqq4ksyl4mz.fsf@gitster.c.googlers.com","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-05-03T15:33:29Z","receivedAt":"2020-05-03T15:33:43Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Sat, May 2, 2020 at 9:18 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n>\n> >> How about contrib/cmake/?\n> >>\n> >\n> > The CMakeLists.txt will be non-functional if it in any other directory except\n> > the root source directory. To help users we can,\n> > add some instructions in INSTALL on how to use the script.\n> > OR\n> > create a dummy CMakeLists.txt in the root directory which just\n> > says\n> > `message(\"Copy and Replace the CMakeLists from `whatever-folder` to here\")`\n> > along with some instructions if necessary. This is what LLVM does for autoconf.\n>\n> Isn't there a corresponding feature to make's \"-f\" option to specify\n> which file to read instructions from?\n\nSadly, CMake expects CMakeLists.txt only, nothing else.\n\n>\n> As you say, an extra instruction in INSTALL file to tell users to\n> copy from contrib/cmake may workable, though it is unsatisfactory.\n> But the other one will not simply work.  If we need to have a new\n> file with string \"CMake\" in its name at the top-level *anyway*, we\n> should have the real thing to reduce one step from those who want to\n> use it.  Those who do not want to see \"CMake\" at the toplevel are\n> already harmed either way, if is a dummy or if it is the real thing.\n\nIn your opinion, what would be the best way to communicate with users, there is\nan optional CMake build system for git?\n\nThank You,\nSibi Siddharthan\n\n>\n> Thanks.\n"},{"id":"396877","messageId":"xmqqsgghhr32.fsf@gitster.c.googlers.com","threadId":"53305","inReplyTo":"CAKiG+9Vvwz_ajhJ1KPVWtq25UaGtJOH57eXTA=cgm5qzoZCfGw@mail.gmail.com","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-03T17:21:37Z","receivedAt":"2020-05-03T17:21:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n\n>> As you say, an extra instruction in INSTALL file to tell users to\n>> copy from contrib/cmake may workable, though it is unsatisfactory.\n>> But the other one will not simply work.  If we need to have a new\n>> file with string \"CMake\" in its name at the top-level *anyway*, we\n>> should have the real thing to reduce one step from those who want to\n>> use it.  Those who do not want to see \"CMake\" at the toplevel are\n>> already harmed either way, if is a dummy or if it is the real thing.\n>\n> In your opinion, what would be the best way to communicate with users, there is\n> an optional CMake build system for git?\n\nYou do not want to hear my opinion, as my priorities would be\ndifferent from yours ;-)\n\nGiven that we all agreed that the only reason we contemplate use of\nCMake in our project is strictly to help Windows build, i.e. due to\nthe same reason why we have contrib/buildsystems/, it is not one of\nmy goals to communicate with general users about optional CMake\nsupport in the first place.  It has lower priority than keeping the\nproject tree and the project history less cluttered.\n\nSo my first preference would be an instruction somewhere in install\nor readme that tells those who want to build for windows to copy\nfrom (or perhaps update cmake to offer the \"-f\" option and tell it\nto read from) contrib/cmake/CMakeLists.txt to the toplevel before\ndoing anything [*1*].\n\nIf there are many people who want to help the cmake effort, however,\nshipping a real CMakeLists.txt at the top-level of the tree, with\nall the instructions at the beginning of *that* file, would be an\neasier way for them to discover and polish.  It would also be my\npreference but only under the \"if there are many people\" condition.\n\nThanks.\n\n\n[Footnote]\n\n*1* It probably is too error prone to tell people who do the real\n    work to \"copy\", as they are prone to modify the copy and forget\n    updating the source.  So the instruction may tell them to create\n    a symlink at the toplevel that points to the real file in the\n    contrib/cmake/ directory, or if the filesystem does not support\n    symbolic links (which is very likely given the target audience\n    of this are all on Windows), tell them copy a small skeleton\n    file that is also shipped in contrib/cmake/ directory to the\n    top-level.  That skeleton file would \"include\" the real thing\n    that lives in contrib/cmake/ directory (I am assuming that\n    CMakeLists.txt can include other CMakeLists.txt file here).\n\n"},{"id":"396879","messageId":"689741588534833@mail.yandex.ru","threadId":"53305","inReplyTo":"xmqqsgghhr32.fsf@gitster.c.googlers.com","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Konstantin Tokarev","fromEmail":"annulen@yandex.ru","sentAt":"2020-05-03T19:42:01Z","receivedAt":"2020-05-03T19:42:08Z","isPatch":true,"sender":{"key":"annulen@yandex.ru","avatar":null},"body":"\n\n03.05.2020, 20:21, \"Junio C Hamano\" <gitster@pobox.com>:\n> Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n>\n>>>  As you say, an extra instruction in INSTALL file to tell users to\n>>>  copy from contrib/cmake may workable, though it is unsatisfactory.\n>>>  But the other one will not simply work. If we need to have a new\n>>>  file with string \"CMake\" in its name at the top-level *anyway*, we\n>>>  should have the real thing to reduce one step from those who want to\n>>>  use it. Those who do not want to see \"CMake\" at the toplevel are\n>>>  already harmed either way, if is a dummy or if it is the real thing.\n>>\n>>  In your opinion, what would be the best way to communicate with users, there is\n>>  an optional CMake build system for git?\n>\n> You do not want to hear my opinion, as my priorities would be\n> different from yours ;-)\n>\n> Given that we all agreed that the only reason we contemplate use of\n> CMake in our project is strictly to help Windows build, i.e. due to\n> the same reason why we have contrib/buildsystems/, it is not one of\n> my goals to communicate with general users about optional CMake\n> support in the first place. It has lower priority than keeping the\n> project tree and the project history less cluttered.\n>\n> So my first preference would be an instruction somewhere in install\n> or readme that tells those who want to build for windows to copy\n> from (or perhaps update cmake to offer the \"-f\" option and tell it\n> to read from) contrib/cmake/CMakeLists.txt to the toplevel before\n> doing anything [*1*].\n\nFWIW, CMakeLists.txt doesn't have to be in the root of source tree in\norder to work. It can perfectly work from contrib/cmake after necessary\nchanges in relative paths.\n\n>\n> If there are many people who want to help the cmake effort, however,\n> shipping a real CMakeLists.txt at the top-level of the tree, with\n> all the instructions at the beginning of *that* file, would be an\n> easier way for them to discover and polish. It would also be my\n> preference but only under the \"if there are many people\" condition.\n>\n> Thanks.\n>\n> [Footnote]\n>\n> *1* It probably is too error prone to tell people who do the real\n>     work to \"copy\", as they are prone to modify the copy and forget\n>     updating the source. So the instruction may tell them to create\n>     a symlink at the toplevel that points to the real file in the\n>     contrib/cmake/ directory, or if the filesystem does not support\n>     symbolic links (which is very likely given the target audience\n>     of this are all on Windows), tell them copy a small skeleton\n>     file that is also shipped in contrib/cmake/ directory to the\n>     top-level. That skeleton file would \"include\" the real thing\n>     that lives in contrib/cmake/ directory (I am assuming that\n>     CMakeLists.txt can include other CMakeLists.txt file here).\n\n-- \nRegards,\nKonstantin\n\n"},{"id":"396880","messageId":"xmqqo8r4iyr4.fsf@gitster.c.googlers.com","threadId":"53305","inReplyTo":"689741588534833@mail.yandex.ru","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-03T19:50:39Z","receivedAt":"2020-05-03T19:51:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Konstantin Tokarev <annulen@yandex.ru> writes:\n\n> FWIW, CMakeLists.txt doesn't have to be in the root of source tree in\n> order to work. It can perfectly work from contrib/cmake after necessary\n> changes in relative paths.\n\nThat's great to know---perhaps you can work with Sibi to help\nwhipping the CMakeLists.txt into shape, placing it in contrib/cmake/\ndirectory?\n\nWhen that is in place, my answer to Sibi's question, i.e. \"what is\nthe best way to tell users they can use CMake for their Windows\nbuild?\" would be \"the same way as we advertise contrib/buildsystems\nand/or compat/vcbuild to them\", I think.\n\nThanks.\n"},{"id":"396993","messageId":"nycvar.QRO.7.76.6.2005041630150.56@tvgsbejvaqbjf.bet","threadId":"53305","inReplyTo":"689741588534833@mail.yandex.ru","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-05-04T14:31:06Z","receivedAt":"2020-05-04T21:32:13Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Konst,\n\nOn Sun, 3 May 2020, Konstantin Tokarev wrote:\n\n>\n>\n> 03.05.2020, 20:21, \"Junio C Hamano\" <gitster@pobox.com>:\n> > Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n> >\n> >>>  As you say, an extra instruction in INSTALL file to tell users to\n> >>>  copy from contrib/cmake may workable, though it is unsatisfactory.\n> >>>  But the other one will not simply work. If we need to have a new\n> >>>  file with string \"CMake\" in its name at the top-level *anyway*, we\n> >>>  should have the real thing to reduce one step from those who want to\n> >>>  use it. Those who do not want to see \"CMake\" at the toplevel are\n> >>>  already harmed either way, if is a dummy or if it is the real thing.\n> >>\n> >>  In your opinion, what would be the best way to communicate with users, there is\n> >>  an optional CMake build system for git?\n> >\n> > You do not want to hear my opinion, as my priorities would be\n> > different from yours ;-)\n> >\n> > Given that we all agreed that the only reason we contemplate use of\n> > CMake in our project is strictly to help Windows build, i.e. due to\n> > the same reason why we have contrib/buildsystems/, it is not one of\n> > my goals to communicate with general users about optional CMake\n> > support in the first place. It has lower priority than keeping the\n> > project tree and the project history less cluttered.\n> >\n> > So my first preference would be an instruction somewhere in install\n> > or readme that tells those who want to build for windows to copy\n> > from (or perhaps update cmake to offer the \"-f\" option and tell it\n> > to read from) contrib/cmake/CMakeLists.txt to the toplevel before\n> > doing anything [*1*].\n>\n> FWIW, CMakeLists.txt doesn't have to be in the root of source tree in\n> order to work. It can perfectly work from contrib/cmake after necessary\n> changes in relative paths.\n\nWould you have an example handy, or a link to an article describing this?\n\nCiao,\nJohannes\n"},{"id":"396998","messageId":"848941588629532@mail.yandex.ru","threadId":"53305","inReplyTo":"nycvar.QRO.7.76.6.2005041630150.56@tvgsbejvaqbjf.bet","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Konstantin Tokarev","fromEmail":"annulen@yandex.ru","sentAt":"2020-05-04T21:59:49Z","receivedAt":"2020-05-04T21:59:54Z","isPatch":true,"sender":{"key":"annulen@yandex.ru","avatar":null},"body":"\n\n05.05.2020, 00:32, \"Johannes Schindelin\" <johannes.schindelin@gmx.de>:\n> Hi Konst,\n>\n> On Sun, 3 May 2020, Konstantin Tokarev wrote:\n>\n>>  03.05.2020, 20:21, \"Junio C Hamano\" <gitster@pobox.com>:\n>>  > Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n>>  >\n>>  >>>  As you say, an extra instruction in INSTALL file to tell users to\n>>  >>>  copy from contrib/cmake may workable, though it is unsatisfactory.\n>>  >>>  But the other one will not simply work. If we need to have a new\n>>  >>>  file with string \"CMake\" in its name at the top-level *anyway*, we\n>>  >>>  should have the real thing to reduce one step from those who want to\n>>  >>>  use it. Those who do not want to see \"CMake\" at the toplevel are\n>>  >>>  already harmed either way, if is a dummy or if it is the real thing.\n>>  >>\n>>  >>  In your opinion, what would be the best way to communicate with users, there is\n>>  >>  an optional CMake build system for git?\n>>  >\n>>  > You do not want to hear my opinion, as my priorities would be\n>>  > different from yours ;-)\n>>  >\n>>  > Given that we all agreed that the only reason we contemplate use of\n>>  > CMake in our project is strictly to help Windows build, i.e. due to\n>>  > the same reason why we have contrib/buildsystems/, it is not one of\n>>  > my goals to communicate with general users about optional CMake\n>>  > support in the first place. It has lower priority than keeping the\n>>  > project tree and the project history less cluttered.\n>>  >\n>>  > So my first preference would be an instruction somewhere in install\n>>  > or readme that tells those who want to build for windows to copy\n>>  > from (or perhaps update cmake to offer the \"-f\" option and tell it\n>>  > to read from) contrib/cmake/CMakeLists.txt to the toplevel before\n>>  > doing anything [*1*].\n>>\n>>  FWIW, CMakeLists.txt doesn't have to be in the root of source tree in\n>>  order to work. It can perfectly work from contrib/cmake after necessary\n>>  changes in relative paths.\n>\n> Would you have an example handy, or a link to an article describing this?\n\nIt's so trivial that I'm not sure what such an article would have to describe.\n\nhttps://github.com/annulen/cmake-example\n\n-- \nRegards,\nKonstantin\n\n"},{"id":"397046","messageId":"CAKiG+9Xu+eeET1Y3hFJTSpofxBCWEvwjyaY0cjFbKptzYLACNw@mail.gmail.com","threadId":"53305","inReplyTo":"848941588629532@mail.yandex.ru","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-05-05T04:16:09Z","receivedAt":"2020-05-05T04:16:23Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Tue, May 5, 2020 at 3:29 AM Konstantin Tokarev <annulen@yandex.ru> wrote:\n>\n>\n>\n> 05.05.2020, 00:32, \"Johannes Schindelin\" <johannes.schindelin@gmx.de>:\n> > Hi Konst,\n> >\n> > On Sun, 3 May 2020, Konstantin Tokarev wrote:\n> >\n> >>  03.05.2020, 20:21, \"Junio C Hamano\" <gitster@pobox.com>:\n> >>  > Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n> >>  >\n> >>  >>>  As you say, an extra instruction in INSTALL file to tell users to\n> >>  >>>  copy from contrib/cmake may workable, though it is unsatisfactory.\n> >>  >>>  But the other one will not simply work. If we need to have a new\n> >>  >>>  file with string \"CMake\" in its name at the top-level *anyway*, we\n> >>  >>>  should have the real thing to reduce one step from those who want to\n> >>  >>>  use it. Those who do not want to see \"CMake\" at the toplevel are\n> >>  >>>  already harmed either way, if is a dummy or if it is the real thing.\n> >>  >>\n> >>  >>  In your opinion, what would be the best way to communicate with users, there is\n> >>  >>  an optional CMake build system for git?\n> >>  >\n> >>  > You do not want to hear my opinion, as my priorities would be\n> >>  > different from yours ;-)\n> >>  >\n> >>  > Given that we all agreed that the only reason we contemplate use of\n> >>  > CMake in our project is strictly to help Windows build, i.e. due to\n> >>  > the same reason why we have contrib/buildsystems/, it is not one of\n> >>  > my goals to communicate with general users about optional CMake\n> >>  > support in the first place. It has lower priority than keeping the\n> >>  > project tree and the project history less cluttered.\n> >>  >\n> >>  > So my first preference would be an instruction somewhere in install\n> >>  > or readme that tells those who want to build for windows to copy\n> >>  > from (or perhaps update cmake to offer the \"-f\" option and tell it\n> >>  > to read from) contrib/cmake/CMakeLists.txt to the toplevel before\n> >>  > doing anything [*1*].\n> >>\n> >>  FWIW, CMakeLists.txt doesn't have to be in the root of source tree in\n> >>  order to work. It can perfectly work from contrib/cmake after necessary\n> >>  changes in relative paths.\n> >\n> > Would you have an example handy, or a link to an article describing this?\n>\n> It's so trivial that I'm not sure what such an article would have to describe.\n>\n> https://github.com/annulen/cmake-example\n>\n\nYes, this is trivial, but doing so is bad practice in general and\ndifficult to maintain.\nWon't it be better just to copy the CMakeLists.txt to the root\ndirectory for configuring.\n\nThank You,\nSibi Siddharthan\n\n> --\n> Regards,\n> Konstantin\n>\n"},{"id":"397054","messageId":"xmqqwo5qc3ec.fsf@gitster.c.googlers.com","threadId":"53305","inReplyTo":"CAKiG+9Xu+eeET1Y3hFJTSpofxBCWEvwjyaY0cjFbKptzYLACNw@mail.gmail.com","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-05T06:16:43Z","receivedAt":"2020-05-05T06:16:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n\n> Yes, this is trivial, but doing so is bad practice in general and\n> difficult to maintain.\n\nCan you substantiate \"bad\" and \"difficult\" in the above sentence?\n\nThey are so subjective words and sounds more of your \"opinion\" than\ngenerally accepted \"fact\".\n\n> Won't it be better just to copy the CMakeLists.txt to the root\n> directory for configuring.\n\nI do not know it is better or not compared to using directly from a\nsubdirectory.  But it is easy to see that it is a bad practice to\nkeep the source of truth in contrib/cmake/CMakeLists.txt and use it\nby copying it to the top of the working tree.  \n\nThe reason would be obvious once you imagine what happens when those\nwho are helping to improve CMake support find that they need to make\nchanges.  It is too easy to edit the one they copied to the top of\nthe working tree until they manage to get it working, and then\nforget to copy it back to contrib/cmake/ before committing the\nchange [*1*].\n\nCompared to that, the way Konstantin showed, which is just to be at\nthe top of the working tree and run the cmake command with a single\nargument, which is the path to the CMakeList.txt file, looked quite\nsimple and straight-forward to an untrained eye that hsan't seen a\nreal use of CMake.  But there must be reasons, coming from lessons\nlearned by using CMake with a CMakeList.txt file in a subdirectory\nand suffering the consequences of doing so, that makes you say it is\na bad practice and difficult to maintain.  It needs to be spelled\nout to help those who do not know CMake understand.\n\nThanks.\n\n\n[Footnote]\n\n*1* Creating a symlink CMakeLists.txt at the top of the working tree\nthat points into contrib/cmake/CMakeLists.txt (and it needs to be\ndone only once) would avoid such a problem, but if your filesystem\ndoes not let you use a symlink, copying a skeletal CMakeLists.txt\nthat nobody is expected to modify to the top of the working tree\nmight be an acceptable workaround.  The sole purpose of that\nskeletal CMakeLists.txt at the top of the working tree would be to\ninclude the \"real\" thing in contrib/cmake/ directory (I am assuming\nthat CMake is capable of including a CMakeLists.txt file that exists\nelsewhere in another CMakeLists.txt file).\n\nWith either of these arrangements, it is much less likely for the\nuser to accidentally edit a \"wrong\" copy and forgets to update the\nreal thing---the real thing stored in contrib/cmake will be the only\none that would be edited.\n"},{"id":"397110","messageId":"CAKiG+9WzQdFa1qM4dKUu8O7k+Q8JGsDMGQg-2GRJr=AJye6wJg@mail.gmail.com","threadId":"53305","inReplyTo":"xmqqwo5qc3ec.fsf@gitster.c.googlers.com","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-05-05T16:23:01Z","receivedAt":"2020-05-05T16:23:16Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"Hi there,\n\nI have made the following changes as suggested:\n1) The CMake script works from contrib/cmake now.\n2) The CMake script parses the Makefile for\nSCRIPT_SH\nSCRIPT_PERL\nTEST_BUILTINS_OBJS\nLIB_OBJS\nBUILTIN_OBJS\nXDIFF_OBJS\nVCSSVN_OBJS\n3) Philip suggested to change the error message if sh/bash was not\nfound on windows.\n4) CMake now tests for ICONV_OMITS_BOM, NO_ST_BLOCKS_IN_STRUCT_STAT.\n\nRegarding the commits, since 1,2,4 are additions to the script, is it\nacceptable for those changes to be staged in the next commits?\nRegarding the workflow file(main.yml), I modified the vs-build and\ntest steps, should I drop the commit or should I keep the changes(a\nmodification is further needed if CMake is going to be used for\nvs-build)\n\nThank You,\nSibi Siddharthan\n"},{"id":"397124","messageId":"xmqqk11qb61j.fsf@gitster.c.googlers.com","threadId":"53305","inReplyTo":"CAKiG+9WzQdFa1qM4dKUu8O7k+Q8JGsDMGQg-2GRJr=AJye6wJg@mail.gmail.com","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-05T18:17:12Z","receivedAt":"2020-05-05T18:17:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n\n> I have made the following changes as suggested:\n> 1) The CMake script works from contrib/cmake now.\n> 2) The CMake script parses the Makefile for\n> SCRIPT_SH\n> SCRIPT_PERL\n> TEST_BUILTINS_OBJS\n> LIB_OBJS\n> BUILTIN_OBJS\n> XDIFF_OBJS\n> VCSSVN_OBJS\n> 3) Philip suggested to change the error message if sh/bash was not\n> found on windows.\n> 4) CMake now tests for ICONV_OMITS_BOM, NO_ST_BLOCKS_IN_STRUCT_STAT.\n>\n> Regarding the commits, since 1,2,4 are additions to the script, is it\n> acceptable for those changes to be staged in the next commits?\n\nI am not sure what you exactly mean by \"to be staged in the next\ncommits\".  But as a new topic (from the point of view of the general\npublic), please avoid adding a known-broken one in patch 1 and then\nfollowing up with a series of \"oops, that was wrong and here is to\nfix the breakage\" patches.\n\nOn the other hand, if the final contents added by the resulting\ntopic is easier to explain and review if built incrementally in\nlogical steps, please do so.  In other words, a series of follow up\n\"now we have basics there, teach the machinery to do this, too\"\npatches is perfectly fine, as opposed to \"oops, that was wrong and\nhere is to fix\".\n\n> Regarding the workflow file(main.yml), I modified the vs-build and\n> test steps, should I drop the commit or should I keep the changes(a\n> modification is further needed if CMake is going to be used for\n> vs-build)\n\nIt sounds like an integral part of the end result we would want to\nget out of this series, so if that is the case, I do not see a\nreason to exclude it.\n\nThanks.\n"},{"id":"397227","messageId":"CAKiG+9WE08ikv9uzDg30w2w=+chRQs9te8hKbVg2WG0p964RZw@mail.gmail.com","threadId":"53305","inReplyTo":"xmqqk11qb61j.fsf@gitster.c.googlers.com","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-05-06T18:43:25Z","receivedAt":"2020-05-06T18:43:40Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Tue, May 5, 2020 at 11:47 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n>\n> > I have made the following changes as suggested:\n> > 1) The CMake script works from contrib/cmake now.\n> > 2) The CMake script parses the Makefile for\n> > SCRIPT_SH\n> > SCRIPT_PERL\n> > TEST_BUILTINS_OBJS\n> > LIB_OBJS\n> > BUILTIN_OBJS\n> > XDIFF_OBJS\n> > VCSSVN_OBJS\n> > 3) Philip suggested to change the error message if sh/bash was not\n> > found on windows.\n> > 4) CMake now tests for ICONV_OMITS_BOM, NO_ST_BLOCKS_IN_STRUCT_STAT.\n> >\n> > Regarding the commits, since 1,2,4 are additions to the script, is it\n> > acceptable for those changes to be staged in the next commits?\n>\n> I am not sure what you exactly mean by \"to be staged in the next\n> commits\".  But as a new topic (from the point of view of the general\n> public), please avoid adding a known-broken one in patch 1 and then\n> following up with a series of \"oops, that was wrong and here is to\n> fix the breakage\" patches.\n>\n> On the other hand, if the final contents added by the resulting\n> topic is easier to explain and review if built incrementally in\n> logical steps, please do so.  In other words, a series of follow up\n> \"now we have basics there, teach the machinery to do this, too\"\n> patches is perfectly fine, as opposed to \"oops, that was wrong and\n> here is to fix\".\n>\n\n2 and 4 are additions to the capability of the script, which means\nthey have to be added\nas separate commits (between 7/8 and 8/8).\n\n3 is clearly an edit (fixup 6/8)\n\nI am confused for 1 though.\nI think it would be better to add it as a new commit (between 7/8 and 8/8).\nIs this acceptable?\n\nThank You,\nSibi Siddharthan\n\n\n> > Regarding the workflow file(main.yml), I modified the vs-build and\n> > test steps, should I drop the commit or should I keep the changes(a\n> > modification is further needed if CMake is going to be used for\n> > vs-build)\n>\n> It sounds like an integral part of the end result we would want to\n> get out of this series, so if that is the case, I do not see a\n> reason to exclude it.\n>\n> Thanks.\n"},{"id":"397238","messageId":"nycvar.QRO.7.76.6.2005062326350.56@tvgsbejvaqbjf.bet","threadId":"53305","inReplyTo":"CAKiG+9WzQdFa1qM4dKUu8O7k+Q8JGsDMGQg-2GRJr=AJye6wJg@mail.gmail.com","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-05-06T21:27:18Z","receivedAt":"2020-05-06T21:27:34Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Sibi,\n\nOn Tue, 5 May 2020, Sibi Siddharthan wrote:\n\n> Hi there,\n>\n> I have made the following changes as suggested:\n> 1) The CMake script works from contrib/cmake now.\n> 2) The CMake script parses the Makefile for\n> SCRIPT_SH\n> SCRIPT_PERL\n> TEST_BUILTINS_OBJS\n> LIB_OBJS\n> BUILTIN_OBJS\n> XDIFF_OBJS\n> VCSSVN_OBJS\n> 3) Philip suggested to change the error message if sh/bash was not\n> found on windows.\n> 4) CMake now tests for ICONV_OMITS_BOM, NO_ST_BLOCKS_IN_STRUCT_STAT.\n>\n> Regarding the commits, since 1,2,4 are additions to the script, is it\n> acceptable for those changes to be staged in the next commits?\n> Regarding the workflow file(main.yml), I modified the vs-build and\n> test steps, should I drop the commit or should I keep the changes(a\n> modification is further needed if CMake is going to be used for\n> vs-build)\n\nYes, I think it will be crucial to use CMake for vs-build, to keep the\nCMake support functional.\n\nCiao,\nDscho\n"},{"id":"397285","messageId":"20200507114848.GA32465@danh.dev","threadId":"53305","inReplyTo":"CAKiG+9WE08ikv9uzDg30w2w=+chRQs9te8hKbVg2WG0p964RZw@mail.gmail.com","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-05-07T11:48:48Z","receivedAt":"2020-05-07T11:48:53Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2020-05-07 00:13:25+0530, Sibi Siddharthan <sibisiddharthan.github@gmail.com> wrote:\n> On Tue, May 5, 2020 at 11:47 PM Junio C Hamano <gitster@pobox.com> wrote:\n> >\n> > Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n> >\n> > > I have made the following changes as suggested:\n> > > 1) The CMake script works from contrib/cmake now.\n> I am confused for 1 though.\n> I think it would be better to add it as a new commit (between 7/8 and 8/8).\n> Is this acceptable?\n\nPlease make CMake works from contrib/cmake from the first patch in the\nseries.\n\n-- \nDanh\n"},{"id":"397352","messageId":"nycvar.QRO.7.76.6.2005072253000.56@tvgsbejvaqbjf.bet","threadId":"53305","inReplyTo":"848941588629532@mail.yandex.ru","subject":"Re: [PATCH 0/8] CMake build system for git","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-05-07T20:54:11Z","receivedAt":"2020-05-07T20:54:26Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Konst,\n\nOn Tue, 5 May 2020, Konstantin Tokarev wrote:\n\n> 05.05.2020, 00:32, \"Johannes Schindelin\" <johannes.schindelin@gmx.de>:\n> > Hi Konst,\n> >\n> > On Sun, 3 May 2020, Konstantin Tokarev wrote:\n> >\n> >>  03.05.2020, 20:21, \"Junio C Hamano\" <gitster@pobox.com>:\n> >>  > Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n> >>  >\n> >>  >>>  As you say, an extra instruction in INSTALL file to tell users to\n> >>  >>>  copy from contrib/cmake may workable, though it is unsatisfactory.\n> >>  >>>  But the other one will not simply work. If we need to have a new\n> >>  >>>  file with string \"CMake\" in its name at the top-level *anyway*, we\n> >>  >>>  should have the real thing to reduce one step from those who want to\n> >>  >>>  use it. Those who do not want to see \"CMake\" at the toplevel are\n> >>  >>>  already harmed either way, if is a dummy or if it is the real thing.\n> >>  >>\n> >>  >>  In your opinion, what would be the best way to communicate with users, there is\n> >>  >>  an optional CMake build system for git?\n> >>  >\n> >>  > You do not want to hear my opinion, as my priorities would be\n> >>  > different from yours ;-)\n> >>  >\n> >>  > Given that we all agreed that the only reason we contemplate use of\n> >>  > CMake in our project is strictly to help Windows build, i.e. due to\n> >>  > the same reason why we have contrib/buildsystems/, it is not one of\n> >>  > my goals to communicate with general users about optional CMake\n> >>  > support in the first place. It has lower priority than keeping the\n> >>  > project tree and the project history less cluttered.\n> >>  >\n> >>  > So my first preference would be an instruction somewhere in install\n> >>  > or readme that tells those who want to build for windows to copy\n> >>  > from (or perhaps update cmake to offer the \"-f\" option and tell it\n> >>  > to read from) contrib/cmake/CMakeLists.txt to the toplevel before\n> >>  > doing anything [*1*].\n> >>\n> >>  FWIW, CMakeLists.txt doesn't have to be in the root of source tree in\n> >>  order to work. It can perfectly work from contrib/cmake after necessary\n> >>  changes in relative paths.\n> >\n> > Would you have an example handy, or a link to an article describing this?\n>\n> It's so trivial that I'm not sure what such an article would have to describe.\n>\n> https://github.com/annulen/cmake-example\n\nIt is trivial all right, but I had hoped for a more elegant solution along\nthe lines of `set_top_level_directory(../..)` or some such. I mistook your\nmail for having an elegant version of this, and I was curious.\n\nCiao,\nJohannes\n\n> --\n> Regards,\n> Konstantin\n>\n>\n"},{"id":"397604","messageId":"pull.614.v2.git.1589302254.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.git.1587700897.gitgitgadget@gmail.com","subject":"[PATCH v2 00/11] CMake build system for git","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-05-12T16:50:43Z","receivedAt":"2020-05-12T16:51:02Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"This is an attempt to build Git using CMake. CMake is cross-platform build\ngenerator which works well on a variety of platforms(primarily Linux and\nWindows). Using CMake we can check whether certain headers exist, certain\nfunctions exist, the required libraries are present and configure the build\naccordingly. Using CMake we can also build and test Git out of source,\nresulting in a clean source tree.\n\nTested platforms\n\nUbuntu 18.04 GCC 7.4 Clang 8.0.1\n\nWindows MinGW GCC 9.2 Clang 9 Visual Studio 2015,2017,2019\n\nChanges:\n\n1) The CMake script has been relocated to contrib/buildsystems 2) The CMake\nscript parses the Makefile for the sources. 3) Philip suggested to change\nthe error message if sh/bash was not found on windows. 4) CMake now tests\nfor ICONV_OMITS_BOM, NO_ST_BLOCKS_IN_STRUCT_STAT\n\nSibi Siddharthan (11):\n  Introduce CMake support for configuring Git on Linux\n  cmake: generate the shell/perl/python scripts and templates,\n    translations\n  cmake: installation support for git\n  cmake: support for testing git with ctest\n  cmake: support for testing git when building out of the source tree\n  cmake: support for building git on windows with mingw\n  cmake: support for building git on windows with msvc and clang.\n  cmake: added checks for struct stat and libiconv\n  cmake: relocated script file contrib/buildsystems\n  cmake: parse the makefile for the sources.\n  ci: modification of main.yml to use cmake for vs-build job\n\n .github/workflows/main.yml          |  46 +-\n contrib/buildsystems/CMakeLists.txt | 945 ++++++++++++++++++++++++++++\n 2 files changed, 971 insertions(+), 20 deletions(-)\n create mode 100644 contrib/buildsystems/CMakeLists.txt\n\n\nbase-commit: 744177e7f7fd407c26e9e4aa3b19696859010c48\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-614%2FSibiSiddharthan%2Fgit-og-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-614/SibiSiddharthan/git-og-v2\nPull-Request: https://github.com/gitgitgadget/git/pull/614\n\nRange-diff vs v1:\n\n  1:  70ab1f03dd5 =  1:  70ab1f03dd5 Introduce CMake support for configuring Git on Linux\n  2:  ca242cf5bda =  2:  ca242cf5bda cmake: generate the shell/perl/python scripts and templates, translations\n  3:  10390063a39 !  3:  b2974432d77 cmake: installation support for git\n     @@ Commit message\n      \n          Then run `make install`\n      \n     +    Changes:\n     +    Removed a comment regarding the installation of gitk.\n     +\n          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n      \n       ## CMakeLists.txt ##\n     @@ CMakeLists.txt: if(MSGFMT_EXE)\n      +#install\n      +install(TARGETS git git-shell\n      +\tRUNTIME DESTINATION bin)\n     -+install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver  #${CMAKE_SOURCE_DIR}/gitk-git/gitk check\n     ++install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver\n      +\tDESTINATION bin)\n      +\n      +list(REMOVE_ITEM PROGRAMS_BUILT git git-shell)\n  4:  35a3554df3e !  4:  2bd8870fb96 cmake: support for testing git with ctest\n     @@ Commit message\n      \n          NOTE: Testing only works when building in source for now.\n      \n     +    Changes:\n     +    Renamed the variable test_helper_sources to test-tool_SOURCES\n     +    to be consistent with the naming of source variables.\n     +\n          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n      \n       ## CMakeLists.txt ##\n     @@ CMakeLists.txt: install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION\n      +add_executable(test-svn-fe t/helper/test-svn-fe.c)\n      +target_link_libraries(test-svn-fe common-main vcs-svn)\n      +\n     -+set(test_helper_sources\n     ++set(test-tool_SOURCES\n      +\tt/helper/test-tool.c t/helper/test-advise.c t/helper/test-bloom.c t/helper/test-chmtime.c\n      +\tt/helper/test-config.c t/helper/test-ctype.c t/helper/test-date.c t/helper/test-delta.c\n      +\tt/helper/test-dir-iterator.c t/helper/test-drop-caches.c t/helper/test-dump-cache-tree.c\n     @@ CMakeLists.txt: install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION\n      +\tt/helper/test-trace2.c t/helper/test-urlmatch-normalization.c t/helper/test-xml-encode.c\n      +\tt/helper/test-wildmatch.c t/helper/test-windows-named-pipe.c t/helper/test-write-cache.c)\n      +\n     -+add_executable(test-tool ${test_helper_sources})\n     ++add_executable(test-tool ${test-tool_SOURCES})\n      +target_link_libraries(test-tool common-main)\n      +\n      +set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool\n  5:  166b78f7175 =  5:  096f6311ad5 cmake: support for testing git when building out of the source tree\n  6:  d6c630028bf !  6:  00cae10bbb7 cmake: support for building git on windows with mingw\n     @@ Commit message\n          To use CMake on Windows with MinGW do this:\n          cmake `relative-path-to-srcdir` -G \"MinGW Makefiles\"\n      \n     +    Changes:\n     +    Changed the error message when sh.exe is not found on Windows as\n     +    suggested by Philip Oakley <philipoakley@iee.email>\n     +\n          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n      \n       ## CMakeLists.txt ##\n     @@ CMakeLists.txt: if(Intl_FOUND)\n       \n       find_program(SH_EXE sh)\n      +if(NOT SH_EXE)\n     -+\tmessage(FATAL_ERROR \"sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/\")\n     ++\tmessage(FATAL_ERROR \"sh: shell interpreter was not found in your path, please install one.\"\n     ++\t\t\t\"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n      +endif()\n      +\n      +if(WIN32)\n  7:  0577d7bf0a8 !  7:  af6c606881d cmake: support for building git on windows with msvc and clang.\n     @@ CMakeLists.txt: find_package(ZLIB REQUIRED)\n       if(NOT Intl_FOUND)\n       \tadd_compile_definitions(NO_GETTEXT)\n      @@ CMakeLists.txt: if(NOT SH_EXE)\n     - \tmessage(FATAL_ERROR \"sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/\")\n     + \t\t\t\"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n       endif()\n       \n      -if(WIN32)\n  -:  ----------- >  8:  f496cd7d8aa cmake: added checks for struct stat and libiconv\n  -:  ----------- >  9:  9c674372fb5 cmake: relocated script file contrib/buildsystems\n  -:  ----------- > 10:  b0a321a714a cmake: parse the makefile for the sources.\n  8:  f0294be3f11 ! 11:  fa1b8032906 ci: modification of main.yml to use cmake for vs-build job\n     @@ Commit message\n          FindCURL module. An extra definition (-DCURL_NO_CURL_CMAKE=ON) has been\n          added to revert to the old behaviour.\n      \n     +    Edit(Explanation for the reordering of build steps):\n     +    In the configuration phase CMake looks for the required libraries for\n     +    building git (eg zlib,libiconv). So we extract the libraries before we\n     +    configure.\n     +\n     +    Changes:\n     +    The CMake script has been relocated to contib/buildsystems, so point\n     +    to the CMakeLists.txt in the invocation commands.\n     +\n     +    The generation command now uses the absolute paths for the generation\n     +    step.\n     +\n     +    To check for ICONV_OMITS_BOM libiconv.dll needs to be in the working\n     +    directory of script or path. So we copy the dlls before we configure.\n     +\n          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n      \n       ## .github/workflows/main.yml ##\n     @@ .github/workflows/main.yml: jobs:\n               Remove-Item compat.zip\n           - name: add msbuild to PATH\n             uses: microsoft/setup-msbuild@v1.0.0\n     -+    - name: generate Visual Studio solution\n     ++    - name: copy dlls to root\n      +      shell: powershell\n      +      run: |\n     -+        & .\\git-sdk-64-minimal\\usr\\bin\\bash.exe -lc @\"\n     -+          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\n     -+        \"@\n     ++        & compat\\vcbuild\\vcpkg_copy_dlls.bat release\n      +        if (!$?) { exit(1) }\n     ++    - name: generate Visual Studio solution\n     ++      shell: bash\n     ++      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\n           - name: MSBuild\n             run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142\n           - name: bundle artifact tar\n     +@@ .github/workflows/main.yml: jobs:\n     +         MSVC: 1\n     +         VCPKG_ROOT: ${{github.workspace}}\\compat\\vcbuild\\vcpkg\n     +       run: |\n     +-        & compat\\vcbuild\\vcpkg_copy_dlls.bat release\n     +-        if (!$?) { exit(1) }\n     +         & git-sdk-64-minimal\\usr\\bin\\bash.exe -lc @\"\n     +           mkdir -p artifacts &&\n     +           eval \\\"`$(make -n artifacts-tar INCLUDE_DLLS_IN_ARTIFACTS=YesPlease ARTIFACTS_DIRECTORY=artifacts 2>&1 | grep ^tar)\\\"\n      @@ .github/workflows/main.yml: jobs:\n               nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n           steps:\n\n-- \ngitgitgadget\n"},{"id":"397607","messageId":"ca242cf5bda74aafca6c169ad53ce33a62761027.1589302254.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v2.git.1589302254.gitgitgadget@gmail.com","subject":"[PATCH v2 02/11] cmake: generate the shell/perl/python scripts and templates, translations","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-05-12T16:50:45Z","receivedAt":"2020-05-12T16:51:03Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThis patch implements the placeholder substitution to generate, say,\n`git-request-pull` from `git-request-pull.sh`.\n\nThe shell/perl/python scripts and template are generated using CMake\n(very similar to what sed does).\n\nThe text translations are only build if `msgfmt` is found in your path.\n\nNOTE: The scripts and templates are generated during configuration.\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n CMakeLists.txt | 107 ++++++++++++++++++++++++++++++++++++++++++++++++-\n 1 file changed, 106 insertions(+), 1 deletion(-)\n\ndiff --git a/CMakeLists.txt b/CMakeLists.txt\nindex 73703bd321f..788b53be873 100644\n--- a/CMakeLists.txt\n+++ b/CMakeLists.txt\n@@ -51,6 +51,11 @@ endif()\n \n find_program(SH_EXE sh)\n \n+find_program(MSGFMT_EXE msgfmt)\n+if(NOT MSGFMT_EXE)\n+\tmessage(WARNING \"Text Translations won't be build\")\n+endif()\n+\n #default behaviour\n include_directories(${CMAKE_SOURCE_DIR})\n add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n@@ -525,4 +530,104 @@ endif()\n add_custom_command(OUTPUT ${git_links} ${git_http_links}\n \t\tCOMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake\n \t\tDEPENDS git git-remote-http)\n-add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})\n\\ No newline at end of file\n+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})\n+\n+\n+#creating required scripts\n+set(SHELL_PATH /bin/sh)\n+set(PERL_PATH /usr/bin/perl)\n+set(LOCALEDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)\n+set(GITWEBDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)\n+set(INSTLIBDIR ${FALLBACK_RUNTIME_PREFIX}/share/perl5)\n+\n+#shell scripts\n+set(git_shell_scripts\n+\tgit-bisect git-difftool--helper git-filter-branch\n+\tgit-merge-octopus git-merge-one-file git-merge-resolve\n+\tgit-mergetool git-quiltimport\n+\tgit-request-pull git-submodule git-web--browse\n+\tgit-mergetool--lib git-parse-remote git-rebase--preserve-merges\n+\tgit-sh-setup git-sh-i18n git-instaweb)\n+\n+foreach(script ${git_shell_scripts})\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/${script}.sh content NEWLINE_CONSUME)\n+\tstring(REPLACE \"@SHELL_PATH@\" \"${SHELL_PATH}\" content \"${content}\")\n+\tstring(REPLACE \"@@DIFF@@\" \"diff\" content \"${content}\")\n+\tstring(REPLACE \"@LOCALEDIR@\" \"${LOCALEDIR}\" content \"${content}\")\n+\tstring(REPLACE \"@GITWEBDIR@\" \"${GITWEBDIR}\" content \"${content}\")\n+\tstring(REPLACE \"@@NO_CURL@@\" \"\" content \"${content}\")\n+\tstring(REPLACE \"@@USE_GETTEXT_SCHEME@@\" \"\" content \"${content}\")\n+\tstring(REPLACE \"# @@BROKEN_PATH_FIX@@\" \"\" content \"${content}\")\n+\tstring(REPLACE \"@@PERL@@\" \"${PERL_PATH}\" content \"${content}\")\n+\tstring(REPLACE \"@@SANE_TEXT_GREP@@\" \"-a\" content \"${content}\")\n+\tstring(REPLACE \"@@PAGER_ENV@@\" \"LESS=FRX LV=-c\" content \"${content}\")\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})\n+endforeach()\n+\n+#perl scripts\n+set(git_perl_scripts\n+\tgit-add--interactive git-archimport git-cvsexportcommit\n+\tgit-cvsimport git-cvsserver git-send-email git-svn)\n+\n+#create perl header\n+file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )\n+string(REPLACE \"@@PATHSEP@@\" \":\" perl_header \"${perl_header}\")\n+string(REPLACE \"@@INSTLIBDIR@@\" \"${INSTLIBDIR}\" perl_header \"${perl_header}\")\n+\n+foreach(script ${git_perl_scripts})\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/${script}.perl content NEWLINE_CONSUME)\n+\tstring(REPLACE \"#!/usr/bin/perl\" \"#!/usr/bin/perl\\n${perl_header}\\n\" content \"${content}\")\n+\tstring(REPLACE \"@@GIT_VERSION@@\" \"${PROJECT_VERSION}\" content \"${content}\")\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})\n+endforeach()\n+\n+#python script\n+file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)\n+string(REPLACE \"#!/usr/bin/env python\" \"#!/usr/bin/python\" content \"${content}\")\n+file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})\n+\n+#perl modules\n+file(GLOB_RECURSE perl_modules \"${CMAKE_SOURCE_DIR}/perl/*.pm\")\n+\n+foreach(pm ${perl_modules})\n+\tstring(REPLACE \"${CMAKE_SOURCE_DIR}/perl/\" \"\" file_path ${pm})\n+\tfile(STRINGS ${pm} content NEWLINE_CONSUME)\n+\tstring(REPLACE \"@@LOCALEDIR@@\" \"${LOCALEDIR}\" content \"${content}\")\n+\tstring(REPLACE \"@@NO_PERL_CPAN_FALLBACKS@@\" \"\" content \"${content}\")\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})\n+#test-lib.sh requires perl/build/lib to be the build directory of perl modules\n+endforeach()\n+\n+\n+#templates\n+file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches\n+set(hooks_templates\n+\tapplypatch-msg.sample pre-applypatch.sample pre-push.sample\n+\tcommit-msg.sample pre-commit.sample pre-rebase.sample\n+\tfsmonitor-watchman.sample pre-merge-commit.sample pre-receive.sample\n+\tpost-update.sample prepare-commit-msg.sample update.sample)\n+\n+#templates have @.*@ replacement so use configure_file instead\n+#hooks\n+foreach(tm ${hooks_templates})\n+\tconfigure_file(${CMAKE_SOURCE_DIR}/templates/hooks--${tm} ${CMAKE_BINARY_DIR}/templates/blt/hooks/${tm} @ONLY)\n+endforeach()\n+\n+#info\n+configure_file(${CMAKE_SOURCE_DIR}/templates/info--exclude ${CMAKE_BINARY_DIR}/templates/blt/info/exclude @ONLY)\n+\n+#this\n+configure_file(${CMAKE_SOURCE_DIR}/templates/this--description ${CMAKE_BINARY_DIR}/templates/blt/description @ONLY)\n+\n+\n+#translations\n+if(MSGFMT_EXE)\n+\tset(po_files bg  ca  de  el  es  fr  is  it  ko  pt_PT  ru  sv  tr  vi  zh_CN  zh_TW)\n+\tforeach(po ${po_files})\n+\t\tfile(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES)\n+\t\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo\n+\t\t\t\tCOMMAND ${MSGFMT_EXE} --check --statistics -o ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo ${CMAKE_SOURCE_DIR}/po/${po}.po)\n+\t\tlist(APPEND po_gen ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo)\n+\tendforeach()\n+\tadd_custom_target(po-gen ALL DEPENDS ${po_gen})\n+endif()\n-- \ngitgitgadget\n\n"},{"id":"397606","messageId":"70ab1f03dd5413256166bf9db47be47b746ea6b1.1589302254.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v2.git.1589302254.gitgitgadget@gmail.com","subject":"[PATCH v2 01/11] Introduce CMake support for configuring Git on Linux","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-05-12T16:50:44Z","receivedAt":"2020-05-12T16:51:04Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nAt the moment, the recommended way to configure Git's builds is to\nsimply run `make`. If that does not work, the recommended strategy is to\nlook at the top of the `Makefile` to see whether any \"Makefile knob\" has\nto be turned on/off, e.g. `make NO_OPENSSL=YesPlease`.\n\nAlternatively, Git also has an `autoconf` setup which allows configuring\nbuilds via `./configure [<option>...]`.\n\nBoth of these options are fine if the developer works on Unix or Linux.\nBut on Windows, we have to jump through hoops to configure a build\n(read: we force the user to install a full Git for Windows SDK, which\noccupies around two gigabytes (!) on disk and downloads about three\nquarters of a gigabyte worth of Git objects).\n\nTo make this a little less awkward, the Git for Windows project offers\nthe `vs/master` branch which has a full Visual Studio solution generated\nand committed. This branch can therefore be used to tinker with Git in\nVisual Studio _without_ having to download the full Git for Windows SDK.\nUnfortunatly, that branch is auto-generated from Git for Windows'\n`master`. If a developer wants to tinker, say, with `pu`, they are out\nof luck.\n\nCMake was invented to make this sort of problem go away, by providing a\nmore standardized, cross-platform way to configure builds.\n\nWith a working support CMake, developers on Windows need only install\nCMake, configure their build, load the generated Visual Studio solution\nand immediately start modifying the code and build their own version of\nGit. Likewise, developers on other platforms can use the convenient GUI\ntools provided by CMake to configure their build.\n\nSo let's start building CMake support for Git.\n\nThis is only the first step, and to make it easier to review, it only\nallows for configuring builds on the platform that is easiest to\nconfigure for: Linux.\n\nThe CMake script checks whether the headers are present(eg. libgen.h),\nwhether the functions are present(eg. memmem), whether the funtions work\nproperly (eg. snprintf) and generate the required compile definitions\nfor the platform. The script also searches for the required libraries,\nif it fails to find the required libraries the respective executables\nwon't be built.(eg. If libcurl is not found then git-remote-http won't\nbe built). This will help building Git easier.\n\nWith a CMake script an out of source build of git is possible resulting\nin a clean source tree.\n\nNote: earlier endeavors on the Git mailing list to introduce CMake ended\nup in dead water. The primary reason for that was that reviewers\n_expected_ CMake support to fall out of maintenance, unless the\ncontributor would promise to keep an eye on keeping CMake support up to\ndate. However, in the meantime, support for automated testing has been\nintroduced in Git's source code, and a later patch will modify the\n(still experimental) GitHub workflow to continually verify that CMake\nsupport is still complete. That will make maintenance reasonably easy.\n\nNote: this patch asks for the minimum version v3.14 of CMake (which is\nnot all that old as of time of writing) because that is the first\nversion to offer a platform-independent way to generate hardlinks as\npart of the build. This is needed to generate all those hardlinks for\nthe built-in commands of Git.\n\nInstructions to run CMake:\n\ncmake `relative-path-to-srcdir` -DCMAKE_BUILD_TYPE=Release\n\nPossible build configurations(-DCMAKE_BUILD_TYPE) with corresponding\ncompiler flags\nDebug : -g\nRelease: -O3\nRelWithDebInfo : -O2 -g\nMinSizeRel : -Os\nempty(default) :\n\nNOTE: -DCMAKE_BUILD_TYPE is optional\n\nThis process generates a Makefile.\nThen run `make` to build Git.\n\nNOTE: By default CMake uses Makefile as the build tool on Linux, to use\nanother tool say `ninja` add this to the command line when configuring.\n`-G Ninja`\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n CMakeLists.txt | 528 +++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 528 insertions(+)\n create mode 100644 CMakeLists.txt\n\ndiff --git a/CMakeLists.txt b/CMakeLists.txt\nnew file mode 100644\nindex 00000000000..73703bd321f\n--- /dev/null\n+++ b/CMakeLists.txt\n@@ -0,0 +1,528 @@\n+#\n+#\tCopyright (c) 2020 Sibi Siddharthan\n+#\n+\n+cmake_minimum_required(VERSION 3.14)\n+\n+#Parse GIT-VERSION-GEN to get the version\n+file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX \"DEF_VER=v(.*)\")\n+string(REPLACE \"DEF_VER=v\" \"\" git_version ${git_version})\n+string(REPLACE \".GIT\" \".0\" git_version ${git_version})#for building from a snapshot\n+\n+project(git\n+\tVERSION ${git_version}\n+\tLANGUAGES C)\n+\n+\n+include(CheckTypeSize)\n+include(CheckCSourceRuns)\n+include(CheckCSourceCompiles)\n+include(CheckIncludeFile)\n+include(CheckFunctionExists)\n+include(CheckSymbolExists)\n+include(CheckStructHasMember)\n+\n+find_package(ZLIB REQUIRED)\n+find_package(CURL)\n+find_package(EXPAT)\n+find_package(Iconv)\n+find_package(Intl)\n+\n+if(NOT Intl_FOUND)\n+\tadd_compile_definitions(NO_GETTEXT)\n+\tif(NOT Iconv_FOUND)\n+\t\tadd_compile_definitions(NO_ICONV)\n+\tendif()\n+endif()\n+\n+include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})\n+if(CURL_FOUND)\n+\tinclude_directories(SYSTEM ${CURL_INCLUDE_DIRS})\n+endif()\n+if(EXPAT_FOUND)\n+\tinclude_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})\n+endif()\n+if(Iconv_FOUND)\n+\tinclude_directories(SYSTEM ${Iconv_INCLUDE_DIRS})\n+endif()\n+if(Intl_FOUND)\n+\tinclude_directories(SYSTEM ${Intl_INCLUDE_DIRS})\n+endif()\n+\n+find_program(SH_EXE sh)\n+\n+#default behaviour\n+include_directories(${CMAKE_SOURCE_DIR})\n+add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n+add_compile_definitions(SHA256_BLK INTERNAL_QSORT RUNTIME_PREFIX)\n+add_compile_definitions(NO_OPENSSL SHA1_DC SHA1DC_NO_STANDARD_INCLUDES\n+\t\t\tSHA1DC_INIT_SAFE_HASH_DEFAULT=0\n+\t\t\tSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"cache.h\"\n+\t\t\tSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"git-compat-util.h\" )\n+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)\n+\n+\n+add_compile_definitions(PAGER_ENV=\"LESS=FRX LV=-c\"\n+\t\t\tETC_GITATTRIBUTES=\"etc/gitattributes\"\n+\t\t\tETC_GITCONFIG=\"etc/gitconfig\"\n+\t\t\tGIT_EXEC_PATH=\"libexec/git-core\"\n+\t\t\tGIT_LOCALE_PATH=\"share/locale\"\n+\t\t\tGIT_MAN_PATH=\"share/man\"\n+\t\t\tGIT_INFO_PATH=\"share/info\"\n+\t\t\tGIT_HTML_PATH=\"share/doc/git-doc\"\n+\t\t\tDEFAULT_HELP_FORMAT=\"html\"\n+\t\t\tDEFAULT_GIT_TEMPLATE_DIR=\"share/git-core/templates\"\n+\t\t\tGIT_VERSION=\"${PROJECT_VERSION}.GIT\"\n+\t\t\tGIT_USER_AGENT=\"git/${PROJECT_VERSION}.GIT\"\n+\t\t\tBINDIR=\"bin\"\n+\t\t\tGIT_BUILT_FROM_COMMIT=\"\")\n+\n+set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n+add_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n+\n+add_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n+list(APPEND compat_SOURCES unix-socket.c)\n+\n+#header checks\n+check_include_file(libgen.h HAVE_LIBGEN_H)\n+if(NOT HAVE_LIBGEN_H)\n+\tadd_compile_definitions(NO_LIBGEN_H)\n+\tlist(APPEND compat_SOURCES compat/basename.c)\n+endif()\n+\n+check_include_file(sys/sysinfo.h HAVE_SYSINFO)\n+if(HAVE_SYSINFO)\n+\tadd_compile_definitions(HAVE_SYSINFO)\n+endif()\n+\n+check_c_source_compiles(\"\n+#include <alloca.h>\n+int\n+main ()\n+{\n+char *p = (char *) alloca (2 * sizeof (int));\n+\tif (p) return 0;\n+\treturn 0;\n+}\"\n+HAVE_ALLOCA_H)\n+if(HAVE_ALLOCA_H)\n+\tadd_compile_definitions(HAVE_ALLOCA_H)\n+endif()\n+\n+check_include_file(strings.h HAVE_STRINGS_H)\n+if(HAVE_STRINGS_H)\n+\tadd_compile_definitions(HAVE_STRINGS_H)\n+endif()\n+\n+check_include_file(sys/select.h HAVE_SYS_SELECT_H)\n+if(NOT HAVE_SYS_SELECT_H)\n+\tadd_compile_definitions(NO_SYS_SELECT_H)\n+endif()\n+\n+check_include_file(sys/poll.h HAVE_SYS_POLL_H)\n+if(NOT HAVE_SYS_POLL_H)\n+\tadd_compile_definitions(NO_SYS_POLL_H)\n+endif()\n+\n+check_include_file(poll.h HAVE_POLL_H)\n+if(NOT HAVE_POLL_H)\n+\tadd_compile_definitions(NO_POLL_H)\n+endif()\n+\n+check_include_file(inttypes.h HAVE_INTTYPES_H)\n+if(NOT HAVE_INTTYPES_H)\n+\tadd_compile_definitions(NO_INTTYPES_H)\n+endif()\n+\n+check_include_file(paths.h HAVE_PATHS_H)\n+if(HAVE_PATHS_H)\n+\tadd_compile_definitions(HAVE_PATHS_H)\n+endif()\n+\n+#function checks\n+set(function_checks\n+\tstrcasestr memmem strlcpy strtoimax strtoumax strtoull\n+\tsetenv  mkdtemp poll pread  memmem unsetenv hstrerror)\n+\n+foreach(f ${function_checks})\n+\tstring(TOUPPER ${f} uf)\n+\tcheck_function_exists(${f} HAVE_${uf})\n+\tif(NOT HAVE_${uf})\n+\t\tadd_compile_definitions(NO_${uf})\n+\tendif()\n+endforeach()\n+\n+if(NOT HAVE_POLL_H OR NOT HAVE_SYS_POLL_H OR NOT HAVE_POLL)\n+\tinclude_directories(compat/poll)\n+\tadd_compile_definitions(NO_POLL)\n+\tlist(APPEND compat_SOURCES compat/poll/poll.c)\n+endif()\n+\n+if(NOT HAVE_STRCASESTR)\n+\tlist(APPEND compat_SOURCES compat/strcasestr.c)\n+endif()\n+\n+if(NOT HAVE_STRLCPY)\n+\tlist(APPEND compat_SOURCES compat/strlcpy.c)\n+endif()\n+\n+if(NOT HAVE_STRTOUMAX)\n+\tlist(APPEND compat_SOURCES compat/strtoumax.c compat/strtoimax.c)\n+endif()\n+\n+if(NOT HAVE_SETENV)\n+\tlist(APPEND compat_SOURCES compat/setenv.c)\n+endif()\n+\n+if(NOT HAVE_MKDTEMP)\n+\tlist(APPEND compat_SOURCES compat/mkdtemp.c)\n+endif()\n+\n+if(NOT HAVE_PREAD)\n+\tlist(APPEND compat_SOURCES compat/pread.c)\n+endif()\n+\n+if(NOT HAVE_MEMMEM)\n+\tlist(APPEND compat_SOURCES compat/memmem.c)\n+endif()\n+\n+if(NOT WIN32)\n+\tif(NOT HAVE_UNSETENV)\n+\t\tlist(APPEND compat_SOURCES compat/unsetenv.c)\n+\tendif()\n+\n+\tif(NOT HAVE_HSTRERROR)\n+\t\tlist(APPEND compat_SOURCES compat/hstrerror.c)\n+\tendif()\n+endif()\n+\n+check_function_exists(getdelim HAVE_GETDELIM)\n+if(HAVE_GETDELIM)\n+\tadd_compile_definitions(HAVE_GETDELIM)\n+endif()\n+\n+check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)\n+check_symbol_exists(CLOCK_MONOTONIC \"time.h\" HAVE_CLOCK_MONOTONIC)\n+if(HAVE_CLOCK_GETTIME)\n+\tadd_compile_definitions(HAVE_CLOCK_GETTIME)\n+endif()\n+if(HAVE_CLOCK_MONOTONIC)\n+\tadd_compile_definitions(HAVE_CLOCK_MONOTONIC)\n+endif()\n+\n+\n+#compile checks\n+check_c_source_runs(\"\n+#include<stdio.h>\n+#include<stdarg.h>\n+#include<string.h>\n+#include<stdlib.h>\n+int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)\n+{\n+\tint ret;\n+\tva_list ap;\n+\n+\tva_start(ap, format);\n+\tret = vsnprintf(str, maxsize, format, ap);\n+\tva_end(ap);\n+\treturn ret;\n+}\n+\n+int\n+main ()\n+{\n+\tchar buf[6];\n+\tif (test_vsnprintf(buf, 3, \\\"%s\\\", \\\"12345\\\") != 5\n+\t\t|| strcmp(buf, \\\"12\\\")) return 1;\n+\tif (snprintf(buf, 3, \\\"%s\\\", \\\"12345\\\") != 5\n+\t\t|| strcmp(buf, \\\"12\\\")) return 1;\n+\n+\treturn 0;\n+}\"\n+SNPRINTF_OK)\n+if(NOT SNPRINTF_OK)\n+\tadd_compile_definitions(SNPRINTF_RETURNS_BOGUS)\n+\tlist(APPEND compat_SOURCES compat/snprintf.c)\n+endif()\n+\n+check_c_source_runs(\"\n+#include<stdio.h>\n+int\n+main ()\n+{\n+\tFILE *f = fopen(\\\".\\\", \\\"r\\\");\n+\treturn f != NULL;\n+\n+\treturn 0;\n+}\"\n+FREAD_READS_DIRECTORIES_NO)\n+if(NOT FREAD_READS_DIRECTORIES_NO)\n+\tadd_compile_definitions(FREAD_READS_DIRECTORIES)\n+\tlist(APPEND compat_SOURCES compat/fopen.c)\n+endif()\n+\n+check_c_source_compiles(\"\n+#include <regex.h>\n+#ifndef REG_STARTEND\n+#error oops we dont have it\n+#endif\n+int main(){return 0;}\"\n+HAVE_REGEX)\n+if(NOT HAVE_REGEX)\n+\tinclude_directories(compat/regex )\n+\tlist(APPEND compat_SOURCES compat/regex/regex.c )\n+\tadd_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)\n+endif()\n+\n+\n+check_c_source_compiles(\"\n+#include <stddef.h>\n+#include <sys/types.h>\n+#include <sys/sysctl.h>\n+\n+int\n+main ()\n+{\n+\tint val, mib[2];\n+\tsize_t len;\n+\n+\tmib[0] = CTL_HW;\n+\tmib[1] = 1;\n+\tlen = sizeof(val);\n+\treturn sysctl(mib, 2, &val, &len, NULL, 0) ? 1 : 0;\n+\n+\treturn 0;\n+}\"\n+HAVE_BSD_SYSCTL)\n+if(HAVE_BSD_SYSCTL)\n+\tadd_compile_definitions(HAVE_BSD_SYSCTL)\n+endif()\n+\n+#programs\n+set(PROGRAMS_BUILT\n+\tgit git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst\n+\tgit-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)\n+\n+if(NOT CURL_FOUND)\n+\tlist(APPEND excluded_progs git-http-fetch git-http-push)\n+\tadd_compile_definitions(NO_CURL)\n+\tmessage(WARNING \"git-http-push and git-http-fetch will not be built\")\n+else()\n+\tlist(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)\n+\tif(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)\n+\t\tadd_compile_definitions(USE_CURL_FOR_IMAP_SEND)\n+\tendif()\n+endif()\n+\n+if(NOT EXPAT_FOUND)\n+\tlist(APPEND excluded_progs git-http-push)\n+\tadd_compile_definitions(NO_EXPAT)\n+else()\n+\tlist(APPEND PROGRAMS_BUILT git-http-push)\n+\tif(EXPAT_VERSION_STRING VERSION_LESS_EQUAL 1.2)\n+\t\tadd_compile_definitions(EXPAT_NEEDS_XMLPARSE_H)\n+\tendif()\n+endif()\n+\n+list(REMOVE_DUPLICATES excluded_progs)\n+list(REMOVE_DUPLICATES PROGRAMS_BUILT)\n+\n+\n+foreach(p ${excluded_progs})\n+\tlist(APPEND EXCLUSION_PROGS --exclude-program ${p} )\n+endforeach()\n+\n+#for comparing null values\n+list(APPEND EXCLUSION_PROGS empty)\n+set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING \"Programs not built\" FORCE)\n+\n+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)\n+\tlist(REMOVE_ITEM EXCLUSION_PROGS empty)\n+\tmessage(\"Generating command-list.h\")\n+\texecute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt\n+\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n+\t\t\tOUTPUT_FILE ${CMAKE_SOURCE_DIR}/command-list.h)\n+endif()\n+\n+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/config-list.h)\n+\tmessage(\"Generating config-list.h\")\n+\texecute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh\n+\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n+\t\t\tOUTPUT_FILE ${CMAKE_SOURCE_DIR}/config-list.h)\n+endif()\n+\n+\n+#build\n+set(libgit_SOURCES\n+\tabspath.c add-interactive.c add-patch.c advice.c alias.c\n+\talloc.c apply.c archive.c archive-tar.c archive-zip.c argv-array.c\n+\tattr.c base85.c bisect.c blame.c blob.c bloom.c branch.c bulk-checkin.c\n+\tbundle.c cache-tree.c chdir-notify.c checkout.c color.c column.c\n+\tcombine-diff.c commit.c commit-graph.c commit-reach.c compat/obstack.c\n+\tcompat/terminal.c config.c connect.c connected.c convert.c copy.c credential.c\n+\tcsum-file.c ctype.c date.c decorate.c delta-islands.c diffcore-break.c\n+\tdiffcore-delta.c diffcore-order.c diffcore-pickaxe.c diffcore-rename.c\n+\tdiff-delta.c diff-lib.c diff-no-index.c diff.c dir.c dir-iterator.c editor.c\n+\tentry.c environment.c ewah/bitmap.c ewah/ewah_bitmap.c ewah/ewah_io.c\n+\tewah/ewah_rlw.c exec-cmd.c fetch-negotiator.c fetch-pack.c fmt-merge-msg.c fsck.c fsmonitor.c\n+\tgettext.c gpg-interface.c graph.c grep.c hashmap.c linear-assignment.c help.c hex.c\n+\tident.c interdiff.c json-writer.c kwset.c levenshtein.c line-log.c line-range.c list-objects.c\n+\tlist-objects-filter.c list-objects-filter-options.c ll-merge.c lockfile.c\n+\tlog-tree.c ls-refs.c mailinfo.c mailmap.c match-trees.c mem-pool.c merge.c merge-blobs.c\n+\tmerge-recursive.c mergesort.c midx.c name-hash.c negotiator/default.c\n+\tnegotiator/skipping.c notes.c notes-cache.c notes-merge.c notes-utils.c object.c oidmap.c\n+\toidset.c oid-array.c packfile.c pack-bitmap.c pack-bitmap-write.c pack-check.c pack-objects.c\n+\tpack-revindex.c pack-write.c pager.c parse-options.c parse-options-cb.c patch-delta.c\n+\tpatch-ids.c path.c pathspec.c pkt-line.c preload-index.c pretty.c prio-queue.c progress.c\n+\tpromisor-remote.c prompt.c protocol.c prune-packed.c quote.c range-diff.c reachable.c read-cache.c rebase.c\n+\trebase-interactive.c reflog-walk.c refs.c refs/files-backend.c refs/iterator.c\n+\trefs/packed-backend.c refs/ref-cache.c refspec.c ref-filter.c remote.c replace-object.c\n+\trepo-settings.c repository.c rerere.c reset.c resolve-undo.c revision.c run-command.c\n+\tsend-pack.c sequencer.c serve.c server-info.c setup.c sha1-lookup.c\n+\tsha1-file.c sha1-name.c shallow.c sideband.c sigchain.c split-index.c\n+\tstable-qsort.c strbuf.c streaming.c string-list.c submodule.c submodule-config.c\n+\tsub-process.c symlinks.c tag.c tempfile.c thread-utils.c tmp-objdir.c\n+\ttrace.c trace2.c trace2/tr2_cfg.c trace2/tr2_cmd_name.c trace2/tr2_dst.c\n+\ttrace2/tr2_sid.c trace2/tr2_sysenv.c trace2/tr2_tbuf.c trace2/tr2_tgt_event.c\n+\ttrace2/tr2_tgt_normal.c trace2/tr2_tgt_perf.c trace2/tr2_tls.c trailer.c transport.c\n+\ttransport-helper.c tree-diff.c tree.c tree-walk.c unpack-trees.c upload-pack.c url.c\n+\turlmatch.c usage.c userdiff.c utf8.c varint.c version.c versioncmp.c walker.c wildmatch.c\n+\tworktree.c wrapper.c write-or-die.c ws.c wt-status.c xdiff-interface.c\n+\tzlib.c)\n+\n+add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})\n+\n+set(libxdiff_SOURCES\n+\txdiff/xdiffi.c xdiff/xprepare.c xdiff/xutils.c xdiff/xemit.c\n+\txdiff/xmerge.c xdiff/xpatience.c xdiff/xhistogram.c)\n+add_library(xdiff STATIC ${libxdiff_SOURCES})\n+\n+set(libvcs-svn_SOURCES\n+\tvcs-svn/line_buffer.c vcs-svn/sliding_window.c vcs-svn/fast_export.c\n+\tvcs-svn/svndiff.c vcs-svn/svndump.c)\n+add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})\n+\n+#link all required libraries to common-main\n+add_library(common-main OBJECT common-main.c)\n+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)\n+if(Intl_FOUND)\n+\ttarget_link_libraries(common-main ${Intl_LIBRARIES})\n+endif()\n+if(Iconv_FOUND)\n+\ttarget_link_libraries(common-main ${Iconv_LIBRARIES})\n+endif()\n+\n+\n+set(git_SOURCES\n+\tbuiltin/add.c builtin/am.c builtin/annotate.c builtin/apply.c\n+\tbuiltin/archive.c builtin/bisect--helper.c builtin/blame.c\n+\tbuiltin/branch.c builtin/bundle.c builtin/cat-file.c builtin/check-attr.c\n+\tbuiltin/check-ignore.c builtin/check-mailmap.c builtin/check-ref-format.c\n+\tbuiltin/checkout-index.c builtin/checkout.c builtin/clean.c\n+\tbuiltin/clone.c builtin/column.c builtin/commit-tree.c\n+\tbuiltin/commit.c builtin/commit-graph.c builtin/config.c\n+\tbuiltin/count-objects.c builtin/credential.c builtin/describe.c\n+\tbuiltin/diff-files.c builtin/diff-index.c builtin/diff-tree.c\n+\tbuiltin/diff.c builtin/difftool.c builtin/env--helper.c\n+\tbuiltin/fast-export.c builtin/fetch-pack.c builtin/fetch.c builtin/fmt-merge-msg.c\n+\tbuiltin/for-each-ref.c builtin/fsck.c builtin/gc.c\n+\tbuiltin/get-tar-commit-id.c builtin/grep.c builtin/hash-object.c\n+\tbuiltin/help.c builtin/index-pack.c builtin/init-db.c\n+\tbuiltin/interpret-trailers.c builtin/log.c builtin/ls-files.c\n+\tbuiltin/ls-remote.c builtin/ls-tree.c builtin/mailinfo.c builtin/mailsplit.c\n+\tbuiltin/merge.c builtin/merge-base.c builtin/merge-file.c builtin/merge-index.c\n+\tbuiltin/merge-ours.c builtin/merge-recursive.c builtin/merge-tree.c\n+\tbuiltin/mktag.c builtin/mktree.c builtin/multi-pack-index.c builtin/mv.c\n+\tbuiltin/name-rev.c builtin/notes.c builtin/pack-objects.c builtin/pack-redundant.c\n+\tbuiltin/pack-refs.c builtin/patch-id.c builtin/prune-packed.c builtin/prune.c\n+\tbuiltin/pull.c builtin/push.c builtin/range-diff.c builtin/read-tree.c\n+\tbuiltin/rebase.c builtin/receive-pack.c builtin/reflog.c builtin/remote.c\n+\tbuiltin/remote-ext.c builtin/remote-fd.c builtin/repack.c builtin/replace.c\n+\tbuiltin/rerere.c builtin/reset.c builtin/rev-list.c builtin/rev-parse.c\n+\tbuiltin/revert.c builtin/rm.c builtin/send-pack.c builtin/shortlog.c\n+\tbuiltin/show-branch.c builtin/show-index.c builtin/show-ref.c\n+\tbuiltin/sparse-checkout.c builtin/stash.c builtin/stripspace.c\n+\tbuiltin/submodule--helper.c builtin/symbolic-ref.c builtin/tag.c\n+\tbuiltin/unpack-file.c builtin/unpack-objects.c builtin/update-index.c\n+\tbuiltin/update-ref.c builtin/update-server-info.c builtin/upload-archive.c\n+\tbuiltin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c\n+\tbuiltin/verify-tag.c builtin/worktree.c builtin/write-tree.c)\n+\n+add_executable(git git.c ${git_SOURCES})\n+target_link_libraries(git common-main )\n+\n+add_executable(git-bugreport bugreport.c)\n+target_link_libraries(git-bugreport common-main)\n+\n+add_executable(git-credential-store credential-store.c)\n+target_link_libraries(git-credential-store common-main)\n+\n+add_executable(git-daemon daemon.c)\n+target_link_libraries(git-daemon common-main)\n+\n+add_executable(git-fast-import fast-import.c)\n+target_link_libraries(git-fast-import common-main)\n+\n+add_executable(git-http-backend http-backend.c)\n+target_link_libraries(git-http-backend common-main)\n+\n+add_executable(git-sh-i18n--envsubst sh-i18n--envsubst.c)\n+target_link_libraries(git-sh-i18n--envsubst common-main)\n+\n+add_executable(git-shell shell.c)\n+target_link_libraries(git-shell common-main)\n+\n+if(CURL_FOUND)\n+\tadd_library(http_obj OBJECT http.c)\n+\n+\tadd_executable(git-imap-send imap-send.c)\n+\ttarget_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})\n+\n+\tadd_executable(git-http-fetch http-walker.c http-fetch.c)\n+\ttarget_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})\n+\n+\tadd_executable(git-remote-http http-walker.c remote-curl.c)\n+\ttarget_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )\n+\n+\tif(EXPAT_FOUND)\n+\t\tadd_executable(git-http-push http-push.c)\n+\t\ttarget_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})\n+\tendif()\n+endif()\n+\n+add_executable(git-remote-testsvn remote-testsvn.c)\n+target_link_libraries(git-remote-testsvn common-main vcs-svn)\n+\n+add_executable(git-credential-cache credential-cache.c)\n+target_link_libraries(git-credential-cache common-main)\n+\n+add_executable(git-credential-cache--daemon credential-cache--daemon.c)\n+target_link_libraries(git-credential-cache--daemon common-main)\n+\n+\n+set(git_builtin_extra\n+\tcherry cherry-pick format-patch fsck-objects\n+\tinit merge-subtree restore show\n+\tstage status switch whatchanged)\n+\n+#Creating hardlinks\n+foreach(s ${git_SOURCES} ${git_builtin_extra})\n+\tstring(REPLACE \"builtin/\" \"\" s ${s})\n+\tstring(REPLACE \".c\" \"\" s ${s})\n+\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git git-${s})\\n\")\n+\tlist(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})\n+endforeach()\n+\n+if(CURL_FOUND)\n+\tset(remote_exes\n+\t\tgit-remote-https git-remote-ftp git-remote-ftps)\n+\tforeach(s ${remote_exes})\n+\t\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git-remote-http ${s})\\n\")\n+\t\tlist(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})\n+\tendforeach()\n+endif()\n+\n+add_custom_command(OUTPUT ${git_links} ${git_http_links}\n+\t\tCOMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake\n+\t\tDEPENDS git git-remote-http)\n+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})\n\\ No newline at end of file\n-- \ngitgitgadget\n\n"},{"id":"397605","messageId":"096f6311ad505130b5d92ab24845c9536a79bbab.1589302254.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v2.git.1589302254.gitgitgadget@gmail.com","subject":"[PATCH v2 05/11] cmake: support for testing git when building out of the source tree","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-05-12T16:50:48Z","receivedAt":"2020-05-12T16:51:05Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThis patch allows git to be tested when performin out of source builds.\n\nThis involves changing GIT_BUILD_DIR in t/test-lib.sh to point to the\nbuild directory. Also some miscellaneous copies from the source directory\nto the build directory.\nThe copies are:\nt/chainlint.sed needed by a bunch of test scripts\npo/is.po needed by t0204-gettext-rencode-sanity\nmergetools/tkdiff needed by t7800-difftool\ncontrib/completion/git-prompt.sh needed by t9903-bash-prompt\ncontrib/completion/git-completion.bash needed by t9902-completion\ncontrib/svn-fe/svnrdump_sim.py needed by t9020-remote-svn\n\nNOTE: t/test-lib.sh is only modified when tests are run not during\nthe build or configure.\nThe trash directory is still srcdir/t\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n CMakeLists.txt | 19 +++++++++++++++++++\n 1 file changed, 19 insertions(+)\n\ndiff --git a/CMakeLists.txt b/CMakeLists.txt\nindex 05fbb05c6ad..47d3f3c2866 100644\n--- a/CMakeLists.txt\n+++ b/CMakeLists.txt\n@@ -812,6 +812,25 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_GETTEXT='${NO_GETTEXT}'\\n\"\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"RUNTIME_PREFIX='${RUNTIME_PREFIX}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PYTHON='${NO_PYTHON}'\\n\")\n \n+#Make the tests work when building out of the source tree\n+if(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})\n+\tfile(RELATIVE_PATH BUILD_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/CMakeCache.txt)\n+\tstring(REPLACE \"/CMakeCache.txt\" \"\" BUILD_DIR_RELATIVE ${BUILD_DIR_RELATIVE})\n+\t#Setting the build directory in test-lib.sh before running tests\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.cmake\n+\t\t\"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh GIT_BUILD_DIR_REPL REGEX \\\"GIT_BUILD_DIR=(.*)\\\")\\n\"\n+\t\t\"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh content NEWLINE_CONSUME)\\n\"\n+\t\t\"string(REPLACE \\\"\\${GIT_BUILD_DIR_REPL}\\\" \\\"GIT_BUILD_DIR=\\\\\\\"$TEST_DIRECTORY\\\\\\\"/../${BUILD_DIR_RELATIVE}\\\" content \\\"\\${content}\\\")\\n\"\n+\t\t\"file(WRITE ${CMAKE_SOURCE_DIR}/t/test-lib.sh \\${content})\")\n+\t#misc copies\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.sed DESTINATION ${CMAKE_BINARY_DIR}/t/)\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/po/is.po DESTINATION ${CMAKE_BINARY_DIR}/po/)\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/mergetools/tkdiff DESTINATION ${CMAKE_BINARY_DIR}/mergetools/)\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-prompt.sh DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-completion.bash DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/contrib/svn-fe/svnrdump_sim.py DESTINATION ${CMAKE_BINARY_DIR}/contrib/svn-fe/)\n+endif()\n+\n file(GLOB test_scipts \"${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh\")\n \n #test\n-- \ngitgitgadget\n\n"},{"id":"397608","messageId":"b2974432d771e735e69a8724a59fb25da88f0bf9.1589302254.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v2.git.1589302254.gitgitgadget@gmail.com","subject":"[PATCH v2 03/11] cmake: installation support for git","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-05-12T16:50:46Z","receivedAt":"2020-05-12T16:51:07Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThis patch provides the facility to install the built binaries and\nscripts.\n\nThis is very similar to `make install`.\nBy default the destination directory(DESTDIR) is /usr/local/ on Linux\nTo set a custom installation path do this:\ncmake `relative-path-to-srcdir`\n\t-DCMAKE_INSTALL_PREFIX=`preferred-install-path`\n\nThen run `make install`\n\nChanges:\nRemoved a comment regarding the installation of gitk.\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n CMakeLists.txt | 49 +++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 49 insertions(+)\n\ndiff --git a/CMakeLists.txt b/CMakeLists.txt\nindex 788b53be873..1e9f2fe8ff6 100644\n--- a/CMakeLists.txt\n+++ b/CMakeLists.txt\n@@ -13,6 +13,8 @@ project(git\n \tVERSION ${git_version}\n \tLANGUAGES C)\n \n+#TODO gitk git-gui gitweb\n+#TODO Add pcre support\n \n include(CheckTypeSize)\n include(CheckCSourceRuns)\n@@ -631,3 +633,50 @@ if(MSGFMT_EXE)\n \tendforeach()\n \tadd_custom_target(po-gen ALL DEPENDS ${po_gen})\n endif()\n+\n+\n+#to help with the install\n+list(TRANSFORM git_shell_scripts PREPEND \"${CMAKE_BINARY_DIR}/\")\n+list(TRANSFORM git_perl_scripts PREPEND \"${CMAKE_BINARY_DIR}/\")\n+\n+#install\n+install(TARGETS git git-shell\n+\tRUNTIME DESTINATION bin)\n+install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver\n+\tDESTINATION bin)\n+\n+list(REMOVE_ITEM PROGRAMS_BUILT git git-shell)\n+install(TARGETS ${PROGRAMS_BUILT}\n+\tRUNTIME DESTINATION libexec/git-core)\n+\n+set(bin_links\n+\tgit-receive-pack git-upload-archive git-upload-pack)\n+\n+foreach(b ${bin_links})\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})\")\n+endforeach()\n+\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)\")\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)\")\n+\n+foreach(b ${git_links})\n+\tstring(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n+\tinstall(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n+endforeach()\n+\n+foreach(b ${git_http_links})\n+\tstring(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n+\tinstall(CODE \"file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n+endforeach()\n+\n+install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4\n+\tDESTINATION libexec/git-core)\n+\n+install(DIRECTORY mergetools DESTINATION libexec/git-core)\n+install(DIRECTORY ${CMAKE_BINARY_DIR}/perl/build/lib/ DESTINATION share/perl5\n+\tFILES_MATCHING PATTERN \"*.pm\")\n+install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/templates)\n+\n+if(MSGFMT_EXE)\n+\tinstall(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)\n+endif()\n-- \ngitgitgadget\n\n"},{"id":"397609","messageId":"00cae10bbb7870b27202642d6e1e284a97a3c5b7.1589302254.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v2.git.1589302254.gitgitgadget@gmail.com","subject":"[PATCH v2 06/11] cmake: support for building git on windows with mingw","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-05-12T16:50:49Z","receivedAt":"2020-05-12T16:51:08Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThis patch facilitates building git on Windows with CMake using MinGW\n\nNOTE: The funtions unsetenv and hstrerror are not checked in Windows\nbuilds.\nReasons\nNO_UNSETENV is not compatible with Windows builds.\nlines 262-264 compat/mingw.h\n\ncompat/mingw.h(line 25) provides a definition of hstrerror which\nconflicts with the definition provided in\ngit-compat-util.h(lines 733-736).\n\nTo use CMake on Windows with MinGW do this:\ncmake `relative-path-to-srcdir` -G \"MinGW Makefiles\"\n\nChanges:\nChanged the error message when sh.exe is not found on Windows as\nsuggested by Philip Oakley <philipoakley@iee.email>\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n CMakeLists.txt | 121 +++++++++++++++++++++++++++++++++++++++----------\n 1 file changed, 98 insertions(+), 23 deletions(-)\n\ndiff --git a/CMakeLists.txt b/CMakeLists.txt\nindex 47d3f3c2866..9625e41886f 100644\n--- a/CMakeLists.txt\n+++ b/CMakeLists.txt\n@@ -13,9 +13,12 @@ project(git\n \tVERSION ${git_version}\n \tLANGUAGES C)\n \n+\n #TODO gitk git-gui gitweb\n+#TODO Enable NLS on windows natively\n #TODO Add pcre support\n \n+\n include(CheckTypeSize)\n include(CheckCSourceRuns)\n include(CheckCSourceCompiles)\n@@ -31,6 +34,7 @@ find_package(EXPAT)\n find_package(Iconv)\n find_package(Intl)\n \n+\n if(NOT Intl_FOUND)\n \tadd_compile_definitions(NO_GETTEXT)\n \tif(NOT Iconv_FOUND)\n@@ -53,6 +57,17 @@ if(Intl_FOUND)\n endif()\n \n find_program(SH_EXE sh)\n+if(NOT SH_EXE)\n+\tmessage(FATAL_ERROR \"sh: shell interpreter was not found in your path, please install one.\"\n+\t\t\t\"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n+endif()\n+\n+if(WIN32)\n+\tfind_program(WINDRES_EXE windres)\n+\tif(NOT WINDRES_EXE)\n+\t\tmessage(FATAL_ERROR \"Install windres on Windows for resource files\")\n+\tendif()\n+endif()\n \n find_program(MSGFMT_EXE msgfmt)\n if(NOT MSGFMT_EXE)\n@@ -85,11 +100,39 @@ add_compile_definitions(PAGER_ENV=\"LESS=FRX LV=-c\"\n \t\t\tBINDIR=\"bin\"\n \t\t\tGIT_BUILT_FROM_COMMIT=\"\")\n \n-set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n-add_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n+if(WIN32)\n+\tset(FALLBACK_RUNTIME_PREFIX /mingw64)\n+\tadd_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n+else()\n+\tset(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n+\tadd_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n+endif()\n \n-add_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n-list(APPEND compat_SOURCES unix-socket.c)\n+\n+#Platform Specific\n+if(${CMAKE_SYSTEM_NAME} STREQUAL \"Windows\")\n+\tinclude_directories(compat/win32)\n+\tadd_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32\n+\t\t\t\t_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=\".exe\"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT\n+\t\t\t\tNOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0 NO_ST_BLOCKS_IN_STRUCT_STAT\n+\t\t\t\tUSE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP\n+\t\t\t\tUNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)\n+\tlist(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c\n+\t\tcompat/win32/pthread.c compat/win32mmap.c compat/win32/syslog.c\n+\t\tcompat/win32/trace2_win32_process_info.c compat/win32/dirent.c\n+\t\tcompat/nedmalloc/nedmalloc.c compat/strdup.c)\n+\tset(NO_UNIX_SOCKETS 1)\n+\n+elseif(${CMAKE_SYSTEM_NAME} STREQUAL \"Linux\")\n+\tadd_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n+\tlist(APPEND compat_SOURCES unix-socket.c)\n+endif()\n+\n+if(WIN32)\n+\tset(EXE_EXTENSION .exe)\n+else()\n+\tset(EXE_EXTENSION)\n+endif()\n \n #header checks\n check_include_file(libgen.h HAVE_LIBGEN_H)\n@@ -150,7 +193,12 @@ endif()\n #function checks\n set(function_checks\n \tstrcasestr memmem strlcpy strtoimax strtoumax strtoull\n-\tsetenv  mkdtemp poll pread  memmem unsetenv hstrerror)\n+\tsetenv  mkdtemp poll pread  memmem)\n+\n+#unsetenv,hstrerror are incompatible with windows build\n+if(NOT WIN32)\n+\tlist(APPEND function_checks unsetenv hstrerror)\n+endif()\n \n foreach(f ${function_checks})\n \tstring(TOUPPER ${f} uf)\n@@ -309,7 +357,13 @@ endif()\n #programs\n set(PROGRAMS_BUILT\n \tgit git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst\n-\tgit-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)\n+\tgit-shell git-remote-testsvn)\n+\n+if(NO_UNIX_SOCKETS)\n+\tlist(APPEND excluded_progs git-credential-cache git-credential-cache--daemon)\n+else()\n+\tlist(APPEND PROGRAMS_BUILT git-credential-cache git-credential-cache--daemon)\n+endif()\n \n if(NOT CURL_FOUND)\n \tlist(APPEND excluded_progs git-http-fetch git-http-push)\n@@ -410,15 +464,34 @@ set(libvcs-svn_SOURCES\n \tvcs-svn/svndiff.c vcs-svn/svndump.c)\n add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})\n \n+#add git.rc for gcc\n+if(WIN32)\n+\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n+\t\t\tCOMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}\n+\t\t\t\t-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION=\"\\\\\\\"${PROJECT_VERSION}.GIT\\\\\\\"\"\n+\t\t\t\t-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res\n+\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n+\t\t\tVERBATIM)\n+\tadd_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)\n+endif()\n+\n #link all required libraries to common-main\n add_library(common-main OBJECT common-main.c)\n-target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)\n+\n+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})\n if(Intl_FOUND)\n \ttarget_link_libraries(common-main ${Intl_LIBRARIES})\n endif()\n if(Iconv_FOUND)\n \ttarget_link_libraries(common-main ${Iconv_LIBRARIES})\n endif()\n+if(WIN32)\n+\ttarget_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)\n+\tadd_dependencies(common-main git-rc)\n+\ttarget_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)\n+elseif(UNIX)\n+\ttarget_link_libraries(common-main pthread rt)\n+endif()\n \n \n set(git_SOURCES\n@@ -501,11 +574,13 @@ endif()\n add_executable(git-remote-testsvn remote-testsvn.c)\n target_link_libraries(git-remote-testsvn common-main vcs-svn)\n \n-add_executable(git-credential-cache credential-cache.c)\n-target_link_libraries(git-credential-cache common-main)\n+if(NOT NO_UNIX_SOCKETS)\n+\tadd_executable(git-credential-cache credential-cache.c)\n+\ttarget_link_libraries(git-credential-cache common-main)\n \n-add_executable(git-credential-cache--daemon credential-cache--daemon.c)\n-target_link_libraries(git-credential-cache--daemon common-main)\n+\tadd_executable(git-credential-cache--daemon credential-cache--daemon.c)\n+\ttarget_link_libraries(git-credential-cache--daemon common-main)\n+endif()\n \n \n set(git_builtin_extra\n@@ -517,16 +592,16 @@ set(git_builtin_extra\n foreach(s ${git_SOURCES} ${git_builtin_extra})\n \tstring(REPLACE \"builtin/\" \"\" s ${s})\n \tstring(REPLACE \".c\" \"\" s ${s})\n-\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git git-${s})\\n\")\n-\tlist(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})\n+\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git${EXE_EXTENSION} git-${s}${EXE_EXTENSION})\\n\")\n+\tlist(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s}${EXE_EXTENSION})\n endforeach()\n \n if(CURL_FOUND)\n \tset(remote_exes\n \t\tgit-remote-https git-remote-ftp git-remote-ftps)\n \tforeach(s ${remote_exes})\n-\t\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git-remote-http ${s})\\n\")\n-\t\tlist(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})\n+\t\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git-remote-http${EXE_EXTENSION} ${s}${EXE_EXTENSION})\\n\")\n+\t\tlist(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s}${EXE_EXTENSION})\n \tendforeach()\n endif()\n \n@@ -654,20 +729,20 @@ set(bin_links\n \tgit-receive-pack git-upload-archive git-upload-pack)\n \n foreach(b ${bin_links})\n-install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})\")\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/bin/${b}${EXE_EXTENSION})\")\n endforeach()\n \n-install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)\")\n-install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)\")\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git${EXE_EXTENSION})\")\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell${EXE_EXTENSION})\")\n \n foreach(b ${git_links})\n \tstring(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n-\tinstall(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n+\tinstall(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})\")\n endforeach()\n \n foreach(b ${git_http_links})\n \tstring(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n-\tinstall(CODE \"file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n+\tinstall(CODE \"file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})\")\n endforeach()\n \n install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4\n@@ -734,14 +809,14 @@ set(wrapper_test_scripts\n foreach(script ${wrapper_scripts})\n \tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n \tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n-\tstring(REPLACE \"@@PROG@@\" \"${script}\" content \"${content}\")\n+\tstring(REPLACE \"@@PROG@@\" \"${script}${EXE_EXTENSION}\" content \"${content}\")\n \tfile(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n endforeach()\n \n foreach(script ${wrapper_test_scripts})\n \tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n \tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n-\tstring(REPLACE \"@@PROG@@\" \"t/helper/${script}\" content \"${content}\")\n+\tstring(REPLACE \"@@PROG@@\" \"t/helper/${script}${EXE_EXTENSION}\" content \"${content}\")\n \tfile(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n endforeach()\n \n@@ -807,7 +882,7 @@ 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\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PAGER_ENV='${PAGER_ENV}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"DC_SHA1='${DC_SHA1}'\\n\")\n-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"X=''\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"X='${EXE_EXTENSION}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_GETTEXT='${NO_GETTEXT}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"RUNTIME_PREFIX='${RUNTIME_PREFIX}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PYTHON='${NO_PYTHON}'\\n\")\n-- \ngitgitgadget\n\n"},{"id":"397610","messageId":"2bd8870fb96a5c032108c84db2f8a79c69053644.1589302254.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v2.git.1589302254.gitgitgadget@gmail.com","subject":"[PATCH v2 04/11] cmake: support for testing git with ctest","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-05-12T16:50:47Z","receivedAt":"2020-05-12T16:51:09Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThis patch provides an alternate way to test git using ctest.\nCTest ships with CMake, so there is no additional dependency being\nintroduced.\n\nTo perform the tests with ctest do this after building:\nctest -j[number of jobs]\n\nNOTE: -j is optional, the default number of jobs is 1\n\nEach of the jobs does this:\ncd t/ && sh t[something].sh\n\nThe reason for using CTest is that it logs the output of the tests\nin a neat way, which can be helpful during diagnosis of failures.\n\nAfter the tests have run ctest generates three log files located in\n`build-directory`/Testing/Temporary/\n\nThese log files are:\n\nCTestCostData.txt:\nThis file contains the time taken to complete each test.\n\nLastTestsFailed.log:\nThis log file contains the names of the tests that have failed in the\nrun.\n\nLastTest.log:\nThis log file contains the log of all the tests that have run.\nA snippet of the file is given below.\n\n10/901 Testing: D:/my/git-master/t/t0009-prio-queue.sh\n10/901 Test: D:/my/git-master/t/t0009-prio-queue.sh\nCommand: \"sh.exe\" \"D:/my/git-master/t/t0009-prio-queue.sh\"\nDirectory: D:/my/git-master/t\n\"D:/my/git-master/t/t0009-prio-queue.sh\"\nOutput:\n----------------------------------------------------------\nok 1 - basic ordering\nok 2 - mixed put and get\nok 3 - notice empty queue\nok 4 - stack order\npassed all 4 test(s)\n1..4\n<end of output>\nTest time =   1.11 sec\n\nNOTE: Testing only works when building in source for now.\n\nChanges:\nRenamed the variable test_helper_sources to test-tool_SOURCES\nto be consistent with the naming of source variables.\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n CMakeLists.txt | 142 +++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 142 insertions(+)\n\ndiff --git a/CMakeLists.txt b/CMakeLists.txt\nindex 1e9f2fe8ff6..05fbb05c6ad 100644\n--- a/CMakeLists.txt\n+++ b/CMakeLists.txt\n@@ -23,6 +23,7 @@ include(CheckIncludeFile)\n include(CheckFunctionExists)\n include(CheckSymbolExists)\n include(CheckStructHasMember)\n+include(CTest)\n \n find_package(ZLIB REQUIRED)\n find_package(CURL)\n@@ -680,3 +681,144 @@ install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/\n if(MSGFMT_EXE)\n \tinstall(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)\n endif()\n+\n+\n+if(BUILD_TESTING)\n+\n+#tests-helpers\n+add_executable(test-fake-ssh t/helper/test-fake-ssh.c)\n+target_link_libraries(test-fake-ssh common-main)\n+\n+add_executable(test-line-buffer t/helper/test-line-buffer.c)\n+target_link_libraries(test-line-buffer common-main vcs-svn)\n+\n+add_executable(test-svn-fe t/helper/test-svn-fe.c)\n+target_link_libraries(test-svn-fe common-main vcs-svn)\n+\n+set(test-tool_SOURCES\n+\tt/helper/test-tool.c t/helper/test-advise.c t/helper/test-bloom.c t/helper/test-chmtime.c\n+\tt/helper/test-config.c t/helper/test-ctype.c t/helper/test-date.c t/helper/test-delta.c\n+\tt/helper/test-dir-iterator.c t/helper/test-drop-caches.c t/helper/test-dump-cache-tree.c\n+\tt/helper/test-dump-fsmonitor.c t/helper/test-dump-split-index.c\n+\tt/helper/test-dump-untracked-cache.c t/helper/test-example-decorate.c\n+\tt/helper/test-genrandom.c t/helper/test-genzeros.c t/helper/test-hash.c\n+\tt/helper/test-hashmap.c t/helper/test-hash-speed.c t/helper/test-index-version.c\n+\tt/helper/test-json-writer.c t/helper/test-lazy-init-name-hash.c\n+\tt/helper/test-match-trees.c t/helper/test-mergesort.c t/helper/test-mktemp.c\n+\tt/helper/test-oidmap.c t/helper/test-online-cpus.c t/helper/test-parse-options.c\n+\tt/helper/test-parse-pathspec-file.c t/helper/test-path-utils.c t/helper/test-pkt-line.c\n+\tt/helper/test-prio-queue.c t/helper/test-progress.c t/helper/test-reach.c\n+\tt/helper/test-read-cache.c t/helper/test-read-graph.c t/helper/test-read-midx.c\n+\tt/helper/test-ref-store.c t/helper/test-regex.c t/helper/test-repository.c\n+\tt/helper/test-revision-walking.c t/helper/test-run-command.c t/helper/test-scrap-cache-tree.c\n+\tt/helper/test-serve-v2.c t/helper/test-sha1.c t/helper/test-oid-array.c t/helper/test-sha256.c\n+\tt/helper/test-sigchain.c t/helper/test-strcmp-offset.c t/helper/test-string-list.c\n+\tt/helper/test-submodule-config.c t/helper/test-submodule-nested-repo-config.c t/helper/test-subprocess.c\n+\tt/helper/test-trace2.c t/helper/test-urlmatch-normalization.c t/helper/test-xml-encode.c\n+\tt/helper/test-wildmatch.c t/helper/test-windows-named-pipe.c t/helper/test-write-cache.c)\n+\n+add_executable(test-tool ${test-tool_SOURCES})\n+target_link_libraries(test-tool common-main)\n+\n+set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool\n+\t\t\tPROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)\n+\n+#wrapper scripts\n+set(wrapper_scripts\n+\tgit git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)\n+\n+set(wrapper_test_scripts\n+\ttest-fake-ssh test-line-buffer test-svn-fe test-tool)\n+\n+\n+foreach(script ${wrapper_scripts})\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n+\tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n+\tstring(REPLACE \"@@PROG@@\" \"${script}\" content \"${content}\")\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n+endforeach()\n+\n+foreach(script ${wrapper_test_scripts})\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n+\tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n+\tstring(REPLACE \"@@PROG@@\" \"t/helper/${script}\" content \"${content}\")\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n+endforeach()\n+\n+file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n+string(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n+string(REPLACE \"@@PROG@@\" \"git-cvsserver\" content \"${content}\")\n+file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})\n+\n+#options for configuring test options\n+option(PERL_TESTS \"Perform tests that use perl\" ON)\n+option(PYTHON_TESTS \"Perform tests that use python\" ON)\n+\n+#GIT-BUILD-OPTIONS\n+set(TEST_SHELL_PATH ${SHELL_PATH})\n+set(DIFF diff)\n+set(PYTHON_PATH /usr/bin/python)\n+set(TAR tar)\n+set(NO_CURL )\n+set(NO_EXPAT )\n+set(USE_LIBPCRE1 )\n+set(USE_LIBPCRE2 )\n+set(NO_LIBPCRE1_JIT )\n+set(NO_PERL )\n+set(NO_PTHREADS )\n+set(NO_PYTHON )\n+set(PAGER_ENV \"LESS=FRX LV=-c\")\n+set(DC_SHA1 YesPlease)\n+set(RUNTIME_PREFIX true)\n+set(NO_GETTEXT )\n+\n+if(NOT CURL_FOUND)\n+\tset(NO_CURL 1)\n+endif()\n+\n+if(NOT EXPAT_FOUND)\n+\tset(NO_EXPAT 1)\n+endif()\n+\n+if(NOT Intl_FOUND)\n+\tset(NO_GETTEXT 1)\n+endif()\n+\n+if(NOT PERL_TESTS)\n+\tset(NO_PERL 1)\n+endif()\n+\n+if(NOT PYTHON_TESTS)\n+\tset(NO_PYTHON 1)\n+endif()\n+\n+file(WRITE ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"SHELL_PATH='${SHELL_PATH}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"TEST_SHELL_PATH='${TEST_SHELL_PATH}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PERL_PATH='${PERL_PATH}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"DIFF='${DIFF}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PYTHON_PATH='${PYTHON_PATH}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"TAR='${TAR}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_CURL='${NO_CURL}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_EXPAT='${NO_EXPAT}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"USE_LIBPCRE1='${USE_LIBPCRE1}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_LIBPCRE1_JIT='${NO_LIBPCRE1_JIT}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PERL='${NO_PERL}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PTHREADS='${NO_PTHREADS}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PAGER_ENV='${PAGER_ENV}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"DC_SHA1='${DC_SHA1}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"X=''\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_GETTEXT='${NO_GETTEXT}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"RUNTIME_PREFIX='${RUNTIME_PREFIX}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PYTHON='${NO_PYTHON}'\\n\")\n+\n+file(GLOB test_scipts \"${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh\")\n+\n+#test\n+foreach(tsh ${test_scipts})\n+\tadd_test(NAME ${tsh}\n+\t\tCOMMAND ${SH_EXE} ${tsh}\n+\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t)\n+endforeach()\n+\n+endif()#BUILD_TESTING\n\\ No newline at end of file\n-- \ngitgitgadget\n\n"},{"id":"397612","messageId":"af6c606881d73cac2cf10f165327462e75efb9d8.1589302254.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v2.git.1589302254.gitgitgadget@gmail.com","subject":"[PATCH v2 07/11] cmake: support for building git on windows with msvc and clang.","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-05-12T16:50:50Z","receivedAt":"2020-05-12T16:51:11Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThis patch adds support for Visual Studio and Clang builds\n\nThe minimum required version of CMake is upgraded to 3.15 because\nthis version offers proper support for Clang builds on Windows.\n\nLibintl is not searched for when building with Visual Studio or Clang\nbecause there is no binary compatible version available yet.\n\nNOTE: In the link options invalidcontinue.obj has to be included.\nThe reason for this is because by default, Windows calls abort()'s\ninstead of setting errno=EINVAL when invalid arguments are passed to\nstandard functions.\nThis commit explains it in detail:\n4b623d80f73528a632576990ca51e34c333d5dd6\n\nOn Windows the default generator is Visual Studio,so for Visual Studio\nbuilds do this:\n\ncmake `relative-path-to-srcdir`\n\nNOTE: Visual Studio generator is a multi config generator, which means\nthat Debug and Release builds can be done on the same build directory.\n\nFor Clang builds do this:\n\nOn bash\nCC=Clang cmake `relative-path-to-srcdir` -G Ninja\n\t\t-DCMAKE_BUILD_TYPE=[Debug or Release]\n\nOn cmd\nset CC=Clang\ncmake `relative-path-to-srcdir` -G Ninja\n\t\t-DCMAKE_BUILD_TYPE=[Debug or Release]\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n CMakeLists.txt | 57 ++++++++++++++++++++++++++++++++++++++++----------\n 1 file changed, 46 insertions(+), 11 deletions(-)\n\ndiff --git a/CMakeLists.txt b/CMakeLists.txt\nindex 9625e41886f..4353080b708 100644\n--- a/CMakeLists.txt\n+++ b/CMakeLists.txt\n@@ -2,7 +2,7 @@\n #\tCopyright (c) 2020 Sibi Siddharthan\n #\n \n-cmake_minimum_required(VERSION 3.14)\n+cmake_minimum_required(VERSION 3.15)\n \n #Parse GIT-VERSION-GEN to get the version\n file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX \"DEF_VER=v(.*)\")\n@@ -32,8 +32,11 @@ find_package(ZLIB REQUIRED)\n find_package(CURL)\n find_package(EXPAT)\n find_package(Iconv)\n-find_package(Intl)\n \n+#Don't use libintl on Windows Visual Studio and Clang builds\n+if(NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL \"MSVC\" OR CMAKE_C_COMPILER_ID STREQUAL \"Clang\")))\n+\tfind_package(Intl)\n+endif()\n \n if(NOT Intl_FOUND)\n \tadd_compile_definitions(NO_GETTEXT)\n@@ -62,7 +65,7 @@ if(NOT SH_EXE)\n \t\t\t\"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n endif()\n \n-if(WIN32)\n+if(WIN32 AND NOT MSVC)#not required for visual studio builds\n \tfind_program(WINDRES_EXE windres)\n \tif(NOT WINDRES_EXE)\n \t\tmessage(FATAL_ERROR \"Install windres on Windows for resource files\")\n@@ -74,6 +77,13 @@ if(NOT MSGFMT_EXE)\n \tmessage(WARNING \"Text Translations won't be build\")\n endif()\n \n+#Force all visual studio outputs to CMAKE_BINARY_DIR\n+if(CMAKE_C_COMPILER_ID STREQUAL \"MSVC\")\n+\tset(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})\n+\tset(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})\n+\tadd_compile_options(/MP)\n+endif()\n+\n #default behaviour\n include_directories(${CMAKE_SOURCE_DIR})\n add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n@@ -111,6 +121,10 @@ endif()\n \n #Platform Specific\n if(${CMAKE_SYSTEM_NAME} STREQUAL \"Windows\")\n+\tif(CMAKE_C_COMPILER_ID STREQUAL \"MSVC\" OR CMAKE_C_COMPILER_ID STREQUAL \"Clang\")\n+\t\tinclude_directories(compat/vcbuild/include)\n+\t\tadd_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)\n+\tendif()\n \tinclude_directories(compat/win32)\n \tadd_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32\n \t\t\t\t_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=\".exe\"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT\n@@ -464,14 +478,22 @@ set(libvcs-svn_SOURCES\n \tvcs-svn/svndiff.c vcs-svn/svndump.c)\n add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})\n \n-#add git.rc for gcc\n if(WIN32)\n-\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n-\t\t\tCOMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}\n-\t\t\t\t-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION=\"\\\\\\\"${PROJECT_VERSION}.GIT\\\\\\\"\"\n-\t\t\t\t-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res\n-\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n-\t\t\tVERBATIM)\n+\tif(NOT MSVC)#use windres when compiling with gcc and clang\n+\t\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n+\t\t\t\tCOMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}\n+\t\t\t\t\t-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION=\"\\\\\\\"${PROJECT_VERSION}.GIT\\\\\\\"\"\n+\t\t\t\t\t-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res\n+\t\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n+\t\t\t\tVERBATIM)\n+\telse()#MSVC use rc\n+\t\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n+\t\t\t\tCOMMAND ${CMAKE_RC_COMPILER} /d MAJOR=${PROJECT_VERSION_MAJOR} /d MINOR=${PROJECT_VERSION_MINOR}\n+\t\t\t\t\t/d MICRO=${PROJECT_VERSION_PATCH} /d PATCHLEVEL=0 /d GIT_VERSION=\"${PROJECT_VERSION}.GIT\"\n+\t\t\t\t\t/fo ${CMAKE_BINARY_DIR}/git.res ${CMAKE_SOURCE_DIR}/git.rc\n+\t\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n+\t\t\t\tVERBATIM)\n+\tendif()\n \tadd_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)\n endif()\n \n@@ -488,7 +510,13 @@ endif()\n if(WIN32)\n \ttarget_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)\n \tadd_dependencies(common-main git-rc)\n-\ttarget_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)\n+\tif(CMAKE_C_COMPILER_ID STREQUAL \"GNU\")\n+\t\ttarget_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)\n+\telseif(CMAKE_C_COMPILER_ID STREQUAL \"Clang\")\n+\t\ttarget_link_options(common-main PUBLIC -municode -Wl,-nxcompat -Wl,-dynamicbase -Wl,-entry:wmainCRTStartup -Wl,invalidcontinue.obj)\n+\telseif(CMAKE_C_COMPILER_ID STREQUAL \"MSVC\")\n+\t\ttarget_link_options(common-main PUBLIC /IGNORE:4217 /IGNORE:4049 /NOLOGO /ENTRY:wmainCRTStartup /SUBSYSTEM:CONSOLE invalidcontinue.obj)\n+\tendif()\n elseif(UNIX)\n \ttarget_link_libraries(common-main pthread rt)\n endif()\n@@ -798,6 +826,13 @@ target_link_libraries(test-tool common-main)\n set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool\n \t\t\tPROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)\n \n+if(MSVC)\n+\tset_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool\n+\t\t\t\tPROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/t/helper)\n+\tset_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool\n+\t\t\t\tPROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/helper)\n+endif()\n+\n #wrapper scripts\n set(wrapper_scripts\n \tgit git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)\n-- \ngitgitgadget\n\n"},{"id":"397615","messageId":"f496cd7d8aa12047db7f6c0212fbcb2497469785.1589302255.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v2.git.1589302254.gitgitgadget@gmail.com","subject":"[PATCH v2 08/11] cmake: added checks for struct stat and libiconv","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-05-12T16:50:51Z","receivedAt":"2020-05-12T16:51:12Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThe CMake script now checks whether st_blocks is a member of struct stat\nand set the compile definition NO_ST_BLOCKS_IN_STRUCT_STAT accordingly.\n\nThe check for whether ICONV_OMITS_BOM is also added as requested by Danh.\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n CMakeLists.txt | 59 ++++++++++++++++++++++++++++++++++++++++++++++++--\n 1 file changed, 57 insertions(+), 2 deletions(-)\n\ndiff --git a/CMakeLists.txt b/CMakeLists.txt\nindex 4353080b708..975791c8b89 100644\n--- a/CMakeLists.txt\n+++ b/CMakeLists.txt\n@@ -22,6 +22,7 @@ project(git\n include(CheckTypeSize)\n include(CheckCSourceRuns)\n include(CheckCSourceCompiles)\n+include(CheckCSourceRuns)\n include(CheckIncludeFile)\n include(CheckFunctionExists)\n include(CheckSymbolExists)\n@@ -128,7 +129,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL \"Windows\")\n \tinclude_directories(compat/win32)\n \tadd_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32\n \t\t\t\t_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=\".exe\"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT\n-\t\t\t\tNOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0 NO_ST_BLOCKS_IN_STRUCT_STAT\n+\t\t\t\tNOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0\n \t\t\t\tUSE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP\n \t\t\t\tUNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)\n \tlist(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c\n@@ -280,6 +281,11 @@ if(HAVE_CLOCK_MONOTONIC)\n \tadd_compile_definitions(HAVE_CLOCK_MONOTONIC)\n endif()\n \n+#check for st_blocks in struct stat\n+check_struct_has_member(\"struct stat\" st_blocks \"sys/stat.h\" STRUCT_STAT_HAS_ST_BLOCKS)\n+if(NOT STRUCT_STAT_HAS_ST_BLOCKS)\n+\tadd_compile_definitions(NO_ST_BLOCKS_IN_STRUCT_STAT)\n+endif()\n \n #compile checks\n check_c_source_runs(\"\n@@ -344,7 +350,6 @@ if(NOT HAVE_REGEX)\n \tadd_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)\n endif()\n \n-\n check_c_source_compiles(\"\n #include <stddef.h>\n #include <sys/types.h>\n@@ -368,6 +373,56 @@ if(HAVE_BSD_SYSCTL)\n \tadd_compile_definitions(HAVE_BSD_SYSCTL)\n endif()\n \n+set(CMAKE_REQUIRED_LIBRARIES ${Iconv_LIBRARIES})\n+set(CMAKE_REQUIRED_INCLUDES ${Iconv_INCLUDE_DIRS})\n+\n+check_c_source_compiles(\"\n+#include <iconv.h>\n+\n+extern size_t iconv(iconv_t cd,\n+\t\tchar **inbuf, size_t *inbytesleft,\n+\t\tchar **outbuf, size_t *outbytesleft);\n+\n+int main(){return 0;}\"\n+HAVE_NEW_ICONV)\n+if(HAVE_NEW_ICONV)\n+\tset(HAVE_OLD_ICONV 0)\n+else()\n+\tset(HAVE_OLD_ICONV 1)\n+endif()\n+\n+check_c_source_runs(\"\n+#include <iconv.h>\n+#if ${HAVE_OLD_ICONV}\n+typedef const char *iconv_ibp;\n+#else\n+typedef char *iconv_ibp;\n+#endif\n+\n+int main()\n+{\n+\tint v;\n+\ticonv_t conv;\n+\tchar in[] = \\\"a\\\"; iconv_ibp pin = in;\n+\tchar out[20] = \\\"\\\"; char *pout = out;\n+\tsize_t isz = sizeof in;\n+\tsize_t osz = sizeof out;\n+\n+\tconv = iconv_open(\\\"UTF-16\\\", \\\"UTF-8\\\");\n+\ticonv(conv, &pin, &isz, &pout, &osz);\n+\ticonv_close(conv);\n+\tv = (unsigned char)(out[0]) + (unsigned char)(out[1]);\n+\treturn v != 0xfe + 0xff;\n+}\"\n+ICONV_DOESNOT_OMIT_BOM)\n+if(NOT ICONV_DOESNOT_OMIT_BOM)\n+\tadd_compile_definitions(ICONV_OMITS_BOM)\n+endif()\n+\n+unset(CMAKE_REQUIRED_LIBRARIES)\n+unset(CMAKE_REQUIRED_INCLUDES)\n+\n+\n #programs\n set(PROGRAMS_BUILT\n \tgit git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst\n-- \ngitgitgadget\n\n"},{"id":"397611","messageId":"fa1b8032906c6042a0e5851f803ec0427922a1a5.1589302255.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v2.git.1589302254.gitgitgadget@gmail.com","subject":"[PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-05-12T16:50:54Z","receivedAt":"2020-05-12T16:51:14Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThis patch modifies .github/workflows/main.yml to use CMake for\nVisual Studio builds.\n\nModified the vs-test step to match windows-test step. This speeds\nup the vs-test. Calling git-cmd from powershell and then calling git-bash\nto perform the tests slows things down(factor of about 6). So git-bash\nis directly called from powershell to perform the tests using prove.\n\nNOTE: Since GitHub keeps the same directory for each job\n(with respect to path) absolute paths are used in the bin-wrapper\nscripts.\n\nGitHub has switched to CMake 3.17.1 which changed the behaviour of\nFindCURL module. An extra definition (-DCURL_NO_CURL_CMAKE=ON) has been\nadded to revert to the old behaviour.\n\nEdit(Explanation for the reordering of build steps):\nIn the configuration phase CMake looks for the required libraries for\nbuilding git (eg zlib,libiconv). So we extract the libraries before we\nconfigure.\n\nChanges:\nThe CMake script has been relocated to contib/buildsystems, so point\nto the CMakeLists.txt in the invocation commands.\n\nThe generation command now uses the absolute paths for the generation\nstep.\n\nTo check for ICONV_OMITS_BOM libiconv.dll needs to be in the working\ndirectory of script or path. So we copy the dlls before we configure.\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n .github/workflows/main.yml | 46 +++++++++++++++++++++-----------------\n 1 file changed, 26 insertions(+), 20 deletions(-)\n\ndiff --git a/.github/workflows/main.yml b/.github/workflows/main.yml\nindex fd4df939b50..7a65cc0764f 100644\n--- a/.github/workflows/main.yml\n+++ b/.github/workflows/main.yml\n@@ -80,13 +80,6 @@ jobs:\n     - name: download git-sdk-64-minimal\n       shell: bash\n       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 -\n-    - name: generate Visual Studio solution\n-      shell: powershell\n-      run: |\n-        & .\\git-sdk-64-minimal\\usr\\bin\\bash.exe -lc @\"\n-          make NDEBUG=1 DEVELOPER=1 vcxproj\n-        \"@\n-        if (!$?) { exit(1) }\n     - name: download vcpkg artifacts\n       shell: powershell\n       run: |\n@@ -98,6 +91,14 @@ jobs:\n         Remove-Item compat.zip\n     - name: add msbuild to PATH\n       uses: microsoft/setup-msbuild@v1.0.0\n+    - name: copy dlls to root\n+      shell: powershell\n+      run: |\n+        & compat\\vcbuild\\vcpkg_copy_dlls.bat release\n+        if (!$?) { exit(1) }\n+    - name: generate Visual Studio solution\n+      shell: bash\n+      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\n     - name: MSBuild\n       run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142\n     - name: bundle artifact tar\n@@ -106,8 +107,6 @@ jobs:\n         MSVC: 1\n         VCPKG_ROOT: ${{github.workspace}}\\compat\\vcbuild\\vcpkg\n       run: |\n-        & compat\\vcbuild\\vcpkg_copy_dlls.bat release\n-        if (!$?) { exit(1) }\n         & git-sdk-64-minimal\\usr\\bin\\bash.exe -lc @\"\n           mkdir -p artifacts &&\n           eval \\\"`$(make -n artifacts-tar INCLUDE_DLLS_IN_ARTIFACTS=YesPlease ARTIFACTS_DIRECTORY=artifacts 2>&1 | grep ^tar)\\\"\n@@ -125,9 +124,9 @@ jobs:\n         nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n     steps:\n     - uses: actions/checkout@v1\n-    - name: download git-64-portable\n+    - name: download git-sdk-64-minimal\n       shell: bash\n-      run: a=git-64-portable && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -\n+      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 -\n     - name: download build artifacts\n       uses: actions/download-artifact@v1\n       with:\n@@ -136,23 +135,30 @@ jobs:\n     - name: extract build artifacts\n       shell: bash\n       run: tar xf artifacts.tar.gz\n-    - name: test (parallel)\n+    - name: test\n       shell: powershell\n       env:\n         MSYSTEM: MINGW64\n         NO_SVN_TESTS: 1\n         GIT_TEST_SKIP_REBASE_P: 1\n       run: |\n-        & git-64-portable\\git-cmd.exe --command=usr\\bin\\bash.exe -lc @\"\n-          # Let Git ignore the SDK and the test-cache\n-          printf '%s\\n' /git-64-portable/ /test-cache/ >>.git/info/exclude\n+        & .\\git-sdk-64-minimal\\usr\\bin\\bash.exe -lc @\"\n+          # Let Git ignore the SDK\n+          printf '%s\\n' /git-sdk-64-minimal/ >>.git/info/exclude\n \n-          cd t &&\n-          PATH=\\\"`$PWD/helper:`$PATH\\\" &&\n-          test-tool.exe run-command testsuite --jobs=10 -V -x --write-junit-xml \\\n-                  `$(test-tool.exe path-utils slice-tests \\\n-                          ${{matrix.nr}} 10 t[0-9]*.sh)\n+          ci/run-test-slice.sh ${{matrix.nr}} 10\n         \"@\n+    - name: ci/print-test-failures.sh\n+      if: failure()\n+      shell: powershell\n+      run: |\n+        & .\\git-sdk-64-minimal\\usr\\bin\\bash.exe -lc ci/print-test-failures.sh\n+    - name: Upload failed tests' directories\n+      if: failure() && env.FAILED_TEST_ARTIFACTS != ''\n+      uses: actions/upload-artifact@v1\n+      with:\n+        name: failed-tests-windows\n+        path: ${{env.FAILED_TEST_ARTIFACTS}}\n   regular:\n     strategy:\n       matrix:\n-- \ngitgitgadget\n"},{"id":"397614","messageId":"b0a321a714a766962456e2a9e8dd7d2be349e34d.1589302255.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v2.git.1589302254.gitgitgadget@gmail.com","subject":"[PATCH v2 10/11] cmake: parse the makefile for the sources.","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-05-12T16:50:53Z","receivedAt":"2020-05-12T16:51:14Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThe CMake script parses the Makefile for:\nSCRIPT_SH\nSCRIPT_PERL\nTEST_BUILTINS_OBJS\nLIB_OBJS\nBUILTIN_OBJS\nXDIFF_OBJS\nVCSSVN_OBJS\n\nBy doing this we avoid duplication of text between the Makefile and\nthe CMake script.\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n contrib/buildsystems/CMakeLists.txt | 137 ++++++----------------------\n 1 file changed, 30 insertions(+), 107 deletions(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex e0ce069dc2a..4592ce614cf 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -21,6 +21,25 @@ project(git\n #TODO Enable NLS on windows natively\n #TODO Add pcre support\n \n+#macros for parsing the Makefile for sources and scripts\n+macro(parse_makefile_for_sources list_var regex)\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX \"^${regex} \\\\+=(.*)\")\n+\tstring(REPLACE \"${regex} +=\" \"\" ${list_var} ${${list_var}})\n+\tstring(REPLACE \"$(COMPAT_OBJS)\" \"\" ${list_var} ${${list_var}}) #remove \"$(COMPAT_OBJS)\" This is only for libgit.\n+\tstring(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces\n+\tstring(REPLACE \".o\" \".c;\" ${list_var} ${${list_var}}) #change .o to .c, ; is for converting the string into a list\n+\tlist(TRANSFORM ${list_var} STRIP) #remove trailing/leading whitespaces for each element in list\n+\tlist(REMOVE_ITEM ${list_var} \"\") #remove empty list elements\n+endmacro()\n+\n+macro(parse_makefile_for_scripts list_var regex lang)\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX \"^${regex} \\\\+=(.*)\")\n+\tstring(REPLACE \"${regex} +=\" \"\" ${list_var} ${${list_var}})\n+\tstring(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces\n+\tstring(REPLACE \" \" \";\" ${list_var} ${${list_var}}) #convert string to a list\n+\tlist(TRANSFORM ${list_var} REPLACE \"${lang}\" \"\") #do the replacement\n+endmacro()\n+\n \n include(CheckTypeSize)\n include(CheckCSourceRuns)\n@@ -489,57 +508,18 @@ include_directories(${CMAKE_BINARY_DIR})\n \n \n #build\n-set(libgit_SOURCES\n-\tabspath.c add-interactive.c add-patch.c advice.c alias.c\n-\talloc.c apply.c archive.c archive-tar.c archive-zip.c argv-array.c\n-\tattr.c base85.c bisect.c blame.c blob.c bloom.c branch.c bulk-checkin.c\n-\tbundle.c cache-tree.c chdir-notify.c checkout.c color.c column.c\n-\tcombine-diff.c commit.c commit-graph.c commit-reach.c compat/obstack.c\n-\tcompat/terminal.c config.c connect.c connected.c convert.c copy.c credential.c\n-\tcsum-file.c ctype.c date.c decorate.c delta-islands.c diffcore-break.c\n-\tdiffcore-delta.c diffcore-order.c diffcore-pickaxe.c diffcore-rename.c\n-\tdiff-delta.c diff-lib.c diff-no-index.c diff.c dir.c dir-iterator.c editor.c\n-\tentry.c environment.c ewah/bitmap.c ewah/ewah_bitmap.c ewah/ewah_io.c\n-\tewah/ewah_rlw.c exec-cmd.c fetch-negotiator.c fetch-pack.c fmt-merge-msg.c fsck.c fsmonitor.c\n-\tgettext.c gpg-interface.c graph.c grep.c hashmap.c linear-assignment.c help.c hex.c\n-\tident.c interdiff.c json-writer.c kwset.c levenshtein.c line-log.c line-range.c list-objects.c\n-\tlist-objects-filter.c list-objects-filter-options.c ll-merge.c lockfile.c\n-\tlog-tree.c ls-refs.c mailinfo.c mailmap.c match-trees.c mem-pool.c merge.c merge-blobs.c\n-\tmerge-recursive.c mergesort.c midx.c name-hash.c negotiator/default.c\n-\tnegotiator/skipping.c notes.c notes-cache.c notes-merge.c notes-utils.c object.c oidmap.c\n-\toidset.c oid-array.c packfile.c pack-bitmap.c pack-bitmap-write.c pack-check.c pack-objects.c\n-\tpack-revindex.c pack-write.c pager.c parse-options.c parse-options-cb.c patch-delta.c\n-\tpatch-ids.c path.c pathspec.c pkt-line.c preload-index.c pretty.c prio-queue.c progress.c\n-\tpromisor-remote.c prompt.c protocol.c prune-packed.c quote.c range-diff.c reachable.c read-cache.c rebase.c\n-\trebase-interactive.c reflog-walk.c refs.c refs/files-backend.c refs/iterator.c\n-\trefs/packed-backend.c refs/ref-cache.c refspec.c ref-filter.c remote.c replace-object.c\n-\trepo-settings.c repository.c rerere.c reset.c resolve-undo.c revision.c run-command.c\n-\tsend-pack.c sequencer.c serve.c server-info.c setup.c sha1-lookup.c\n-\tsha1-file.c sha1-name.c shallow.c sideband.c sigchain.c split-index.c\n-\tstable-qsort.c strbuf.c streaming.c string-list.c submodule.c submodule-config.c\n-\tsub-process.c symlinks.c tag.c tempfile.c thread-utils.c tmp-objdir.c\n-\ttrace.c trace2.c trace2/tr2_cfg.c trace2/tr2_cmd_name.c trace2/tr2_dst.c\n-\ttrace2/tr2_sid.c trace2/tr2_sysenv.c trace2/tr2_tbuf.c trace2/tr2_tgt_event.c\n-\ttrace2/tr2_tgt_normal.c trace2/tr2_tgt_perf.c trace2/tr2_tls.c trailer.c transport.c\n-\ttransport-helper.c tree-diff.c tree.c tree-walk.c unpack-trees.c upload-pack.c url.c\n-\turlmatch.c usage.c userdiff.c utf8.c varint.c version.c versioncmp.c walker.c wildmatch.c\n-\tworktree.c wrapper.c write-or-die.c ws.c wt-status.c xdiff-interface.c\n-\tzlib.c)\n+parse_makefile_for_sources(libgit_SOURCES \"LIB_OBJS\")\n \n list(TRANSFORM libgit_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n list(TRANSFORM compat_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})\n \n-set(libxdiff_SOURCES\n-\txdiff/xdiffi.c xdiff/xprepare.c xdiff/xutils.c xdiff/xemit.c\n-\txdiff/xmerge.c xdiff/xpatience.c xdiff/xhistogram.c)\n+parse_makefile_for_sources(libxdiff_SOURCES \"XDIFF_OBJS\")\n \n list(TRANSFORM libxdiff_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n add_library(xdiff STATIC ${libxdiff_SOURCES})\n \n-set(libvcs-svn_SOURCES\n-\tvcs-svn/line_buffer.c vcs-svn/sliding_window.c vcs-svn/fast_export.c\n-\tvcs-svn/svndiff.c vcs-svn/svndump.c)\n+parse_makefile_for_sources(libvcs-svn_SOURCES \"VCSSVN_OBJS\")\n \n list(TRANSFORM libvcs-svn_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})\n@@ -588,40 +568,7 @@ elseif(UNIX)\n endif()\n \n \n-set(git_SOURCES\n-\tbuiltin/add.c builtin/am.c builtin/annotate.c builtin/apply.c\n-\tbuiltin/archive.c builtin/bisect--helper.c builtin/blame.c\n-\tbuiltin/branch.c builtin/bundle.c builtin/cat-file.c builtin/check-attr.c\n-\tbuiltin/check-ignore.c builtin/check-mailmap.c builtin/check-ref-format.c\n-\tbuiltin/checkout-index.c builtin/checkout.c builtin/clean.c\n-\tbuiltin/clone.c builtin/column.c builtin/commit-tree.c\n-\tbuiltin/commit.c builtin/commit-graph.c builtin/config.c\n-\tbuiltin/count-objects.c builtin/credential.c builtin/describe.c\n-\tbuiltin/diff-files.c builtin/diff-index.c builtin/diff-tree.c\n-\tbuiltin/diff.c builtin/difftool.c builtin/env--helper.c\n-\tbuiltin/fast-export.c builtin/fetch-pack.c builtin/fetch.c builtin/fmt-merge-msg.c\n-\tbuiltin/for-each-ref.c builtin/fsck.c builtin/gc.c\n-\tbuiltin/get-tar-commit-id.c builtin/grep.c builtin/hash-object.c\n-\tbuiltin/help.c builtin/index-pack.c builtin/init-db.c\n-\tbuiltin/interpret-trailers.c builtin/log.c builtin/ls-files.c\n-\tbuiltin/ls-remote.c builtin/ls-tree.c builtin/mailinfo.c builtin/mailsplit.c\n-\tbuiltin/merge.c builtin/merge-base.c builtin/merge-file.c builtin/merge-index.c\n-\tbuiltin/merge-ours.c builtin/merge-recursive.c builtin/merge-tree.c\n-\tbuiltin/mktag.c builtin/mktree.c builtin/multi-pack-index.c builtin/mv.c\n-\tbuiltin/name-rev.c builtin/notes.c builtin/pack-objects.c builtin/pack-redundant.c\n-\tbuiltin/pack-refs.c builtin/patch-id.c builtin/prune-packed.c builtin/prune.c\n-\tbuiltin/pull.c builtin/push.c builtin/range-diff.c builtin/read-tree.c\n-\tbuiltin/rebase.c builtin/receive-pack.c builtin/reflog.c builtin/remote.c\n-\tbuiltin/remote-ext.c builtin/remote-fd.c builtin/repack.c builtin/replace.c\n-\tbuiltin/rerere.c builtin/reset.c builtin/rev-list.c builtin/rev-parse.c\n-\tbuiltin/revert.c builtin/rm.c builtin/send-pack.c builtin/shortlog.c\n-\tbuiltin/show-branch.c builtin/show-index.c builtin/show-ref.c\n-\tbuiltin/sparse-checkout.c builtin/stash.c builtin/stripspace.c\n-\tbuiltin/submodule--helper.c builtin/symbolic-ref.c builtin/tag.c\n-\tbuiltin/unpack-file.c builtin/unpack-objects.c builtin/update-index.c\n-\tbuiltin/update-ref.c builtin/update-server-info.c builtin/upload-archive.c\n-\tbuiltin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c\n-\tbuiltin/verify-tag.c builtin/worktree.c builtin/write-tree.c)\n+parse_makefile_for_sources(git_SOURCES \"BUILTIN_OBJS\")\n \n list(TRANSFORM git_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n add_executable(git ${CMAKE_SOURCE_DIR}/git.c ${git_SOURCES})\n@@ -714,11 +661,9 @@ set(GITWEBDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)\n set(INSTLIBDIR ${FALLBACK_RUNTIME_PREFIX}/share/perl5)\n \n #shell scripts\n+parse_makefile_for_scripts(git_sh_scripts \"SCRIPT_SH\" \".sh\")\n set(git_shell_scripts\n-\tgit-bisect git-difftool--helper git-filter-branch\n-\tgit-merge-octopus git-merge-one-file git-merge-resolve\n-\tgit-mergetool git-quiltimport\n-\tgit-request-pull git-submodule git-web--browse\n+\t${git_sh_scripts}\n \tgit-mergetool--lib git-parse-remote git-rebase--preserve-merges\n \tgit-sh-setup git-sh-i18n git-instaweb)\n \n@@ -738,9 +683,7 @@ foreach(script ${git_shell_scripts})\n endforeach()\n \n #perl scripts\n-set(git_perl_scripts\n-\tgit-add--interactive git-archimport git-cvsexportcommit\n-\tgit-cvsimport git-cvsserver git-send-email git-svn)\n+parse_makefile_for_scripts(git_perl_scripts \"SCRIPT_PERL\" \".perl\")\n \n #create perl header\n file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )\n@@ -865,30 +808,10 @@ target_link_libraries(test-line-buffer common-main vcs-svn)\n add_executable(test-svn-fe ${CMAKE_SOURCE_DIR}/t/helper/test-svn-fe.c)\n target_link_libraries(test-svn-fe common-main vcs-svn)\n \n-set(test-tool_SOURCES\n-\tt/helper/test-tool.c t/helper/test-advise.c t/helper/test-bloom.c t/helper/test-chmtime.c\n-\tt/helper/test-config.c t/helper/test-ctype.c t/helper/test-date.c t/helper/test-delta.c\n-\tt/helper/test-dir-iterator.c t/helper/test-drop-caches.c t/helper/test-dump-cache-tree.c\n-\tt/helper/test-dump-fsmonitor.c t/helper/test-dump-split-index.c\n-\tt/helper/test-dump-untracked-cache.c t/helper/test-example-decorate.c\n-\tt/helper/test-genrandom.c t/helper/test-genzeros.c t/helper/test-hash.c\n-\tt/helper/test-hashmap.c t/helper/test-hash-speed.c t/helper/test-index-version.c\n-\tt/helper/test-json-writer.c t/helper/test-lazy-init-name-hash.c\n-\tt/helper/test-match-trees.c t/helper/test-mergesort.c t/helper/test-mktemp.c\n-\tt/helper/test-oidmap.c t/helper/test-online-cpus.c t/helper/test-parse-options.c\n-\tt/helper/test-parse-pathspec-file.c t/helper/test-path-utils.c t/helper/test-pkt-line.c\n-\tt/helper/test-prio-queue.c t/helper/test-progress.c t/helper/test-reach.c\n-\tt/helper/test-read-cache.c t/helper/test-read-graph.c t/helper/test-read-midx.c\n-\tt/helper/test-ref-store.c t/helper/test-regex.c t/helper/test-repository.c\n-\tt/helper/test-revision-walking.c t/helper/test-run-command.c t/helper/test-scrap-cache-tree.c\n-\tt/helper/test-serve-v2.c t/helper/test-sha1.c t/helper/test-oid-array.c t/helper/test-sha256.c\n-\tt/helper/test-sigchain.c t/helper/test-strcmp-offset.c t/helper/test-string-list.c\n-\tt/helper/test-submodule-config.c t/helper/test-submodule-nested-repo-config.c t/helper/test-subprocess.c\n-\tt/helper/test-trace2.c t/helper/test-urlmatch-normalization.c t/helper/test-xml-encode.c\n-\tt/helper/test-wildmatch.c t/helper/test-windows-named-pipe.c t/helper/test-write-cache.c)\n-\n-list(TRANSFORM test-tool_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n-add_executable(test-tool ${test-tool_SOURCES})\n+parse_makefile_for_sources(test-tool_SOURCES \"TEST_BUILTINS_OBJS\")\n+\n+list(TRANSFORM test-tool_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/t/helper/\")\n+add_executable(test-tool ${CMAKE_SOURCE_DIR}/t/helper/test-tool.c ${test-tool_SOURCES})\n target_link_libraries(test-tool common-main)\n \n set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool\n-- \ngitgitgadget\n\n"},{"id":"397613","messageId":"9c674372fb58aa42e339c0a96c432283c4b0a894.1589302255.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v2.git.1589302254.gitgitgadget@gmail.com","subject":"[PATCH v2 09/11] cmake: relocated script file contrib/buildsystems","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-05-12T16:50:52Z","receivedAt":"2020-05-12T16:51:18Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThe CMake script has been relocated to contrib/buildsystems.\nThe changes made to the script involves pointing to correct location\nof the source files.\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n .../buildsystems/CMakeLists.txt               | 76 +++++++++++--------\n 1 file changed, 45 insertions(+), 31 deletions(-)\n rename CMakeLists.txt => contrib/buildsystems/CMakeLists.txt (92%)\n\ndiff --git a/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nsimilarity index 92%\nrename from CMakeLists.txt\nrename to contrib/buildsystems/CMakeLists.txt\nindex 975791c8b89..e0ce069dc2a 100644\n--- a/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -4,6 +4,9 @@\n \n cmake_minimum_required(VERSION 3.15)\n \n+#set the source directory to root of git\n+set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n+\n #Parse GIT-VERSION-GEN to get the version\n file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX \"DEF_VER=v(.*)\")\n string(REPLACE \"DEF_VER=v\" \"\" git_version ${git_version})\n@@ -123,10 +126,10 @@ endif()\n #Platform Specific\n if(${CMAKE_SYSTEM_NAME} STREQUAL \"Windows\")\n \tif(CMAKE_C_COMPILER_ID STREQUAL \"MSVC\" OR CMAKE_C_COMPILER_ID STREQUAL \"Clang\")\n-\t\tinclude_directories(compat/vcbuild/include)\n+\t\tinclude_directories(${CMAKE_SOURCE_DIR}/compat/vcbuild/include)\n \t\tadd_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)\n \tendif()\n-\tinclude_directories(compat/win32)\n+\tinclude_directories(${CMAKE_SOURCE_DIR}/compat/win32)\n \tadd_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32\n \t\t\t\t_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=\".exe\"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT\n \t\t\t\tNOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0\n@@ -224,7 +227,7 @@ foreach(f ${function_checks})\n endforeach()\n \n if(NOT HAVE_POLL_H OR NOT HAVE_SYS_POLL_H OR NOT HAVE_POLL)\n-\tinclude_directories(compat/poll)\n+\tinclude_directories(${CMAKE_SOURCE_DIR}/compat/poll)\n \tadd_compile_definitions(NO_POLL)\n \tlist(APPEND compat_SOURCES compat/poll/poll.c)\n endif()\n@@ -345,7 +348,7 @@ check_c_source_compiles(\"\n int main(){return 0;}\"\n HAVE_REGEX)\n if(NOT HAVE_REGEX)\n-\tinclude_directories(compat/regex )\n+\tinclude_directories(${CMAKE_SOURCE_DIR}/compat/regex)\n \tlist(APPEND compat_SOURCES compat/regex/regex.c )\n \tadd_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)\n endif()\n@@ -467,21 +470,23 @@ endforeach()\n list(APPEND EXCLUSION_PROGS empty)\n set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING \"Programs not built\" FORCE)\n \n-if(NOT EXISTS ${CMAKE_SOURCE_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)\n+if(NOT EXISTS ${CMAKE_BINARY_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)\n \tlist(REMOVE_ITEM EXCLUSION_PROGS empty)\n \tmessage(\"Generating command-list.h\")\n \texecute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt\n \t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n-\t\t\tOUTPUT_FILE ${CMAKE_SOURCE_DIR}/command-list.h)\n+\t\t\tOUTPUT_FILE ${CMAKE_BINARY_DIR}/command-list.h)\n endif()\n \n-if(NOT EXISTS ${CMAKE_SOURCE_DIR}/config-list.h)\n+if(NOT EXISTS ${CMAKE_BINARY_DIR}/config-list.h)\n \tmessage(\"Generating config-list.h\")\n \texecute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh\n \t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n-\t\t\tOUTPUT_FILE ${CMAKE_SOURCE_DIR}/config-list.h)\n+\t\t\tOUTPUT_FILE ${CMAKE_BINARY_DIR}/config-list.h)\n endif()\n \n+include_directories(${CMAKE_BINARY_DIR})\n+\n \n #build\n set(libgit_SOURCES\n@@ -521,16 +526,22 @@ set(libgit_SOURCES\n \tworktree.c wrapper.c write-or-die.c ws.c wt-status.c xdiff-interface.c\n \tzlib.c)\n \n+list(TRANSFORM libgit_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n+list(TRANSFORM compat_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})\n \n set(libxdiff_SOURCES\n \txdiff/xdiffi.c xdiff/xprepare.c xdiff/xutils.c xdiff/xemit.c\n \txdiff/xmerge.c xdiff/xpatience.c xdiff/xhistogram.c)\n+\n+list(TRANSFORM libxdiff_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n add_library(xdiff STATIC ${libxdiff_SOURCES})\n \n set(libvcs-svn_SOURCES\n \tvcs-svn/line_buffer.c vcs-svn/sliding_window.c vcs-svn/fast_export.c\n \tvcs-svn/svndiff.c vcs-svn/svndump.c)\n+\n+list(TRANSFORM libvcs-svn_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})\n \n if(WIN32)\n@@ -553,7 +564,7 @@ if(WIN32)\n endif()\n \n #link all required libraries to common-main\n-add_library(common-main OBJECT common-main.c)\n+add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)\n \n target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})\n if(Intl_FOUND)\n@@ -612,56 +623,57 @@ set(git_SOURCES\n \tbuiltin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c\n \tbuiltin/verify-tag.c builtin/worktree.c builtin/write-tree.c)\n \n-add_executable(git git.c ${git_SOURCES})\n+list(TRANSFORM git_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n+add_executable(git ${CMAKE_SOURCE_DIR}/git.c ${git_SOURCES})\n target_link_libraries(git common-main )\n \n-add_executable(git-bugreport bugreport.c)\n+add_executable(git-bugreport ${CMAKE_SOURCE_DIR}/bugreport.c)\n target_link_libraries(git-bugreport common-main)\n \n-add_executable(git-credential-store credential-store.c)\n+add_executable(git-credential-store ${CMAKE_SOURCE_DIR}/credential-store.c)\n target_link_libraries(git-credential-store common-main)\n \n-add_executable(git-daemon daemon.c)\n+add_executable(git-daemon ${CMAKE_SOURCE_DIR}/daemon.c)\n target_link_libraries(git-daemon common-main)\n \n-add_executable(git-fast-import fast-import.c)\n+add_executable(git-fast-import ${CMAKE_SOURCE_DIR}/fast-import.c)\n target_link_libraries(git-fast-import common-main)\n \n-add_executable(git-http-backend http-backend.c)\n+add_executable(git-http-backend ${CMAKE_SOURCE_DIR}/http-backend.c)\n target_link_libraries(git-http-backend common-main)\n \n-add_executable(git-sh-i18n--envsubst sh-i18n--envsubst.c)\n+add_executable(git-sh-i18n--envsubst ${CMAKE_SOURCE_DIR}/sh-i18n--envsubst.c)\n target_link_libraries(git-sh-i18n--envsubst common-main)\n \n-add_executable(git-shell shell.c)\n+add_executable(git-shell ${CMAKE_SOURCE_DIR}/shell.c)\n target_link_libraries(git-shell common-main)\n \n if(CURL_FOUND)\n-\tadd_library(http_obj OBJECT http.c)\n+\tadd_library(http_obj OBJECT ${CMAKE_SOURCE_DIR}/http.c)\n \n-\tadd_executable(git-imap-send imap-send.c)\n+\tadd_executable(git-imap-send ${CMAKE_SOURCE_DIR}/imap-send.c)\n \ttarget_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})\n \n-\tadd_executable(git-http-fetch http-walker.c http-fetch.c)\n+\tadd_executable(git-http-fetch ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/http-fetch.c)\n \ttarget_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})\n \n-\tadd_executable(git-remote-http http-walker.c remote-curl.c)\n+\tadd_executable(git-remote-http ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/remote-curl.c)\n \ttarget_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )\n \n \tif(EXPAT_FOUND)\n-\t\tadd_executable(git-http-push http-push.c)\n+\t\tadd_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)\n \t\ttarget_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})\n \tendif()\n endif()\n \n-add_executable(git-remote-testsvn remote-testsvn.c)\n+add_executable(git-remote-testsvn ${CMAKE_SOURCE_DIR}/remote-testsvn.c)\n target_link_libraries(git-remote-testsvn common-main vcs-svn)\n \n if(NOT NO_UNIX_SOCKETS)\n-\tadd_executable(git-credential-cache credential-cache.c)\n+\tadd_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)\n \ttarget_link_libraries(git-credential-cache common-main)\n \n-\tadd_executable(git-credential-cache--daemon credential-cache--daemon.c)\n+\tadd_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)\n \ttarget_link_libraries(git-credential-cache--daemon common-main)\n endif()\n \n@@ -673,7 +685,7 @@ set(git_builtin_extra\n \n #Creating hardlinks\n foreach(s ${git_SOURCES} ${git_builtin_extra})\n-\tstring(REPLACE \"builtin/\" \"\" s ${s})\n+\tstring(REPLACE \"${CMAKE_SOURCE_DIR}/builtin/\" \"\" s ${s})\n \tstring(REPLACE \".c\" \"\" s ${s})\n \tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git${EXE_EXTENSION} git-${s}${EXE_EXTENSION})\\n\")\n \tlist(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s}${EXE_EXTENSION})\n@@ -831,7 +843,7 @@ endforeach()\n install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4\n \tDESTINATION libexec/git-core)\n \n-install(DIRECTORY mergetools DESTINATION libexec/git-core)\n+install(DIRECTORY ${CMAKE_SOURCE_DIR}/mergetools DESTINATION libexec/git-core)\n install(DIRECTORY ${CMAKE_BINARY_DIR}/perl/build/lib/ DESTINATION share/perl5\n \tFILES_MATCHING PATTERN \"*.pm\")\n install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/templates)\n@@ -844,13 +856,13 @@ endif()\n if(BUILD_TESTING)\n \n #tests-helpers\n-add_executable(test-fake-ssh t/helper/test-fake-ssh.c)\n+add_executable(test-fake-ssh ${CMAKE_SOURCE_DIR}/t/helper/test-fake-ssh.c)\n target_link_libraries(test-fake-ssh common-main)\n \n-add_executable(test-line-buffer t/helper/test-line-buffer.c)\n+add_executable(test-line-buffer ${CMAKE_SOURCE_DIR}/t/helper/test-line-buffer.c)\n target_link_libraries(test-line-buffer common-main vcs-svn)\n \n-add_executable(test-svn-fe t/helper/test-svn-fe.c)\n+add_executable(test-svn-fe ${CMAKE_SOURCE_DIR}/t/helper/test-svn-fe.c)\n target_link_libraries(test-svn-fe common-main vcs-svn)\n \n set(test-tool_SOURCES\n@@ -875,6 +887,7 @@ set(test-tool_SOURCES\n \tt/helper/test-trace2.c t/helper/test-urlmatch-normalization.c t/helper/test-xml-encode.c\n \tt/helper/test-wildmatch.c t/helper/test-windows-named-pipe.c t/helper/test-write-cache.c)\n \n+list(TRANSFORM test-tool_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n add_executable(test-tool ${test-tool_SOURCES})\n target_link_libraries(test-tool common-main)\n \n@@ -978,7 +991,8 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"RUNTIME_PREFIX='${RUNTIME_PRE\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PYTHON='${NO_PYTHON}'\\n\")\n \n #Make the tests work when building out of the source tree\n-if(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})\n+get_filename_component(CACHE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../CMakeCache.txt ABSOLUTE)\n+if(NOT ${CMAKE_BINARY_DIR}/CMakeCache.txt STREQUAL ${CACHE_PATH})\n \tfile(RELATIVE_PATH BUILD_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/CMakeCache.txt)\n \tstring(REPLACE \"/CMakeCache.txt\" \"\" BUILD_DIR_RELATIVE ${BUILD_DIR_RELATIVE})\n \t#Setting the build directory in test-lib.sh before running tests\n-- \ngitgitgadget\n\n"},{"id":"397627","messageId":"xmqqo8qsc1it.fsf@gitster.c.googlers.com","threadId":"53305","inReplyTo":"70ab1f03dd5413256166bf9db47be47b746ea6b1.1589302254.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 01/11] Introduce CMake support for configuring Git on Linux","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-12T20:59:54Z","receivedAt":"2020-05-12T21:00:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Sibi Siddharthan via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> To make this a little less awkward, the Git for Windows project offers\n> the `vs/master` branch which has a full Visual Studio solution generated\n> and committed. This branch can therefore be used to tinker with Git in\n> Visual Studio _without_ having to download the full Git for Windows SDK.\n> Unfortunatly, that branch is auto-generated from Git for Windows'\n> `master`. If a developer wants to tinker, say, with `pu`, they are out\n> of luck.\n\n'pu' or 'next' are not to be built upon, so this is not a good line\nof reasoning to complain that generating only for 'master' is bad.\n\n> CMake was invented to make this sort of problem go away, by providing a\n> more standardized, cross-platform way to configure builds.\n\nI think everything above this point (including Makefile, autoconf\netc.) can be replaced with a single sentence\n\n\tThe build infrastructure for Git is written around being\n\table to run make, which is not supported natively on\n\tWindows.\n\nwithout anything else.  That will flow naturally to\n\n\tAdd a build script that uses CMake to help developers on\n\tWindows to build git.\n\nand then you can continue the current state, like this paragraph.\n\n> This is only the first step, and to make it easier to review, it only\n> allows for configuring builds on the platform that is easiest to\n> configure for: Linux.\n>\n> The CMake script checks whether the headers are present(eg. libgen.h),\n> whether the functions are present(eg. memmem), whether the funtions work\n> properly (eg. snprintf) and generate the required compile definitions\n> for the platform. The script also searches for the required libraries,\n> if it fails to find the required libraries the respective executables\n> won't be built.(eg. If libcurl is not found then git-remote-http won't\n> be built). This will help building Git easier.\n>\n> With a CMake script an out of source build of git is possible resulting\n> in a clean source tree.\n\n\n> Note: earlier endeavors on the Git mailing list to introduce CMake ended\n> up in dead water. The primary reason for that was that reviewers\n> _expected_ CMake support to fall out of maintenance, unless the\n> contributor would promise to keep an eye on keeping CMake support up to\n> date. However, in the meantime, support for automated testing has been\n> introduced in Git's source code, and a later patch will modify the\n> (still experimental) GitHub workflow to continually verify that CMake\n> support is still complete. That will make maintenance reasonably easy.\n\nI am not sure this belongs to the log message.\n\n> Note: this patch asks for the minimum version v3.14 of CMake (which is\n> not all that old as of time of writing) because that is the first\n> version to offer a platform-independent way to generate hardlinks as\n> part of the build. This is needed to generate all those hardlinks for\n> the built-in commands of Git.\n\nThis does, but I do not think hardlinks are not required for our\nbuild.  On Unix filesystems, it is not just possible but convenient\nto use, and that is the only reason why we use hardlinks.\n\nIf hardlinks are possible but inconvenient to use on Windows, you\nshouldn't force your target audience to use it.\n\n> Instructions to run CMake:\n>\n> cmake `relative-path-to-srcdir` -DCMAKE_BUILD_TYPE=Release\n>\n> Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding\n> compiler flags\n> Debug : -g\n> Release: -O3\n> RelWithDebInfo : -O2 -g\n> MinSizeRel : -Os\n> empty(default) :\n>\n> NOTE: -DCMAKE_BUILD_TYPE is optional\n>\n> This process generates a Makefile.\n> Then run `make` to build Git.\n>\n> NOTE: By default CMake uses Makefile as the build tool on Linux, to use\n> another tool say `ninja` add this to the command line when configuring.\n> `-G Ninja`\n\nI find it curious that from the instruction, the most important\nplatform, the primary reason why we are reviewing this patch, is\nmissing.  Don't Windows folks need to be told how to run CMake to\nbuild?\n\nIn any case, all of the above \"Instructions\" should go at the top\npart of CMakeLists.txt in a comment, and not in the log message.\n\"git log\" output is not an easy way for your target audience to\nlearn how to use what the commit adds.  Think what they need to do\nwhen they discover there is CMakeLists.txt in our tree in three\nmonths.  Don't force them to run \"git blame\" to find this commit\nthat added the support.\n\n> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> ---\n>  CMakeLists.txt | 528 +++++++++++++++++++++++++++++++++++++++++++++++++\n>  1 file changed, 528 insertions(+)\n>  create mode 100644 CMakeLists.txt\n>\n> diff --git a/CMakeLists.txt b/CMakeLists.txt\n> new file mode 100644\n> index 00000000000..73703bd321f\n> --- /dev/null\n> +++ b/CMakeLists.txt\n> @@ -0,0 +1,528 @@\n> +#\n> +#\tCopyright (c) 2020 Sibi Siddharthan\n> +#\n> +\n> +cmake_minimum_required(VERSION 3.14)\n> +\n> +#Parse GIT-VERSION-GEN to get the version\n> +file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX \"DEF_VER=v(.*)\")\n> +string(REPLACE \"DEF_VER=v\" \"\" git_version ${git_version})\n> +string(REPLACE \".GIT\" \".0\" git_version ${git_version})#for building from a snapshot\n\nHmph, I'd really prefer to see the logic in GIT-VERSION-GEN not\nbypassed like this.  People know they can create a text file 'version'\nand record the version name they desire in it and expect GIT-VERSION-GEN\nto pick it up, for example.\n\nLater in this file, you seem to depend on the shell to do things\nlike generating config-list.h file, so I'd rather see the same\ntechnique used here a well.\n\n> +set(libgit_SOURCES\n> +\tabspath.c add-interactive.c add-patch.c advice.c alias.c\n> +...\n> +\tzlib.c)\n\nHmph.\n\n> +set(git_SOURCES\n> +\tbuiltin/add.c builtin/am.c builtin/annotate.c builtin/apply.c\n> +\tbuiltin/archive.c builtin/bisect--helper.c builtin/blame.c\n> +\tbuiltin/branch.c builtin/bundle.c builtin/cat-file.c builtin/check-attr.c\n> +\tbuiltin/check-ignore.c builtin/check-mailmap.c builtin/check-ref-format.c\n> +\tbuiltin/checkout-index.c builtin/checkout.c builtin/clean.c\n> +\tbuiltin/clone.c builtin/column.c builtin/commit-tree.c\n> +\tbuiltin/commit.c builtin/commit-graph.c builtin/config.c\n> +\tbuiltin/count-objects.c builtin/credential.c builtin/describe.c\n> +\tbuiltin/diff-files.c builtin/diff-index.c builtin/diff-tree.c\n> +\tbuiltin/diff.c builtin/difftool.c builtin/env--helper.c\n> +\tbuiltin/fast-export.c builtin/fetch-pack.c builtin/fetch.c builtin/fmt-merge-msg.c\n> +\tbuiltin/for-each-ref.c builtin/fsck.c builtin/gc.c\n> +\tbuiltin/get-tar-commit-id.c builtin/grep.c builtin/hash-object.c\n> +\tbuiltin/help.c builtin/index-pack.c builtin/init-db.c\n> +\tbuiltin/interpret-trailers.c builtin/log.c builtin/ls-files.c\n> +\tbuiltin/ls-remote.c builtin/ls-tree.c builtin/mailinfo.c builtin/mailsplit.c\n> +\tbuiltin/merge.c builtin/merge-base.c builtin/merge-file.c builtin/merge-index.c\n> +\tbuiltin/merge-ours.c builtin/merge-recursive.c builtin/merge-tree.c\n> +\tbuiltin/mktag.c builtin/mktree.c builtin/multi-pack-index.c builtin/mv.c\n> +\tbuiltin/name-rev.c builtin/notes.c builtin/pack-objects.c builtin/pack-redundant.c\n> +\tbuiltin/pack-refs.c builtin/patch-id.c builtin/prune-packed.c builtin/prune.c\n> +\tbuiltin/pull.c builtin/push.c builtin/range-diff.c builtin/read-tree.c\n> +\tbuiltin/rebase.c builtin/receive-pack.c builtin/reflog.c builtin/remote.c\n> +\tbuiltin/remote-ext.c builtin/remote-fd.c builtin/repack.c builtin/replace.c\n> +\tbuiltin/rerere.c builtin/reset.c builtin/rev-list.c builtin/rev-parse.c\n> +\tbuiltin/revert.c builtin/rm.c builtin/send-pack.c builtin/shortlog.c\n> +\tbuiltin/show-branch.c builtin/show-index.c builtin/show-ref.c\n> +\tbuiltin/sparse-checkout.c builtin/stash.c builtin/stripspace.c\n> +\tbuiltin/submodule--helper.c builtin/symbolic-ref.c builtin/tag.c\n> +\tbuiltin/unpack-file.c builtin/unpack-objects.c builtin/update-index.c\n> +\tbuiltin/update-ref.c builtin/update-server-info.c builtin/upload-archive.c\n> +\tbuiltin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c\n> +\tbuiltin/verify-tag.c builtin/worktree.c builtin/write-tree.c)\n\nCan't we do a bit better here?  \n\nPerhaps grab this out of our Makefile?  The same command applies to\nhuge lists of sources we have seen.\n\nOr do the equivalent of $(wildcard builtin/*.c) if CMake has such a\nfeature?\n\n> ...\n> \\ No newline at end of file\n\nDouble check and make sure you have a text file without an incomplete\nline at the end.\n\nThanks.\n"},{"id":"397628","messageId":"xmqqk11gc1d5.fsf@gitster.c.googlers.com","threadId":"53305","inReplyTo":"b0a321a714a766962456e2a9e8dd7d2be349e34d.1589302255.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 10/11] cmake: parse the makefile for the sources.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-12T21:03:18Z","receivedAt":"2020-05-12T21:03:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Sibi Siddharthan via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n>\n> The CMake script parses the Makefile for:\n> SCRIPT_SH\n> SCRIPT_PERL\n> TEST_BUILTINS_OBJS\n> LIB_OBJS\n> BUILTIN_OBJS\n> XDIFF_OBJS\n> VCSSVN_OBJS\n>\n> By doing this we avoid duplication of text between the Makefile and\n> the CMake script.\n\nThanks, this makes perfect sense, but it probably should have been\ndone from the very beginning, without copying the huge list manually\nin the step [01/11].\n\nHow robust is the \"parser\"?  Do we need to leave an instruction to\nMakefile writers to conform to certain style to help CMake users as\nan additional comment in the Makefile, or is any reasonable textual\ndrift still accepted?\n\n"},{"id":"397629","messageId":"xmqqftc4c123.fsf@gitster.c.googlers.com","threadId":"53305","inReplyTo":"9c674372fb58aa42e339c0a96c432283c4b0a894.1589302255.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 09/11] cmake: relocated script file contrib/buildsystems","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-12T21:09:56Z","receivedAt":"2020-05-12T21:10:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Sibi Siddharthan via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n>\n> The CMake script has been relocated to contrib/buildsystems.\n> The changes made to the script involves pointing to correct location\n> of the source files.\n\nThis does match what the list agreed to do.  Why isn't this done as\npart of [01/11]?  If there is no technical reason not to, I'd\nstrongly prefer to see it done from the very beginning.  The same\ncomment applies to the next step.\n\nThanks.\n\n> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> ---\n>  .../buildsystems/CMakeLists.txt               | 76 +++++++++++--------\n>  1 file changed, 45 insertions(+), 31 deletions(-)\n>  rename CMakeLists.txt => contrib/buildsystems/CMakeLists.txt (92%)\n"},{"id":"397630","messageId":"xmqqblmsc0r1.fsf@gitster.c.googlers.com","threadId":"53305","inReplyTo":"f496cd7d8aa12047db7f6c0212fbcb2497469785.1589302255.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 08/11] cmake: added checks for struct stat and libiconv","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-12T21:16:34Z","receivedAt":"2020-05-12T21:16:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Sibi Siddharthan via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> Subject: Re: [PATCH v2 08/11] cmake: added checks for struct stat and libiconv\n\ns/added/add/; give a command to the codebase to \"be like so\", or a\ncommand to whoever is typing changes to the editor to \"make this\nhappen\".\n\n> The CMake script now checks whether st_blocks is a member of struct stat\n> and set the compile definition NO_ST_BLOCKS_IN_STRUCT_STAT accordingly.\n\n\tTeach the CMake script to check ...\n\n> diff --git a/CMakeLists.txt b/CMakeLists.txt\n> index 4353080b708..975791c8b89 100644\n> --- a/CMakeLists.txt\n> +++ b/CMakeLists.txt\n> @@ -22,6 +22,7 @@ project(git\n>  include(CheckTypeSize)\n>  include(CheckCSourceRuns)\n>  include(CheckCSourceCompiles)\n> +include(CheckCSourceRuns)\n> ...\n> +#check for st_blocks in struct stat\n> +check_struct_has_member(\"struct stat\" st_blocks \"sys/stat.h\" STRUCT_STAT_HAS_ST_BLOCKS)\n> +if(NOT STRUCT_STAT_HAS_ST_BLOCKS)\n> +\tadd_compile_definitions(NO_ST_BLOCKS_IN_STRUCT_STAT)\n> +endif()\n\nAll of these compatibility stuff makes sense, but how do we decide\nwhere to draw the line between the checks we saw added in [01/11]\nand the checks added here?  It feels pretty arbitrary to me and if\nthat is the case, perhaps we want to move all the \"add checks\" to a\ncommit separate from [01/11] (whose primary purpose is to add the\nbasic rules without these build tweaks in the file at the final\nplace)?\n\n"},{"id":"397631","messageId":"xmqq7dxgc0mc.fsf@gitster.c.googlers.com","threadId":"53305","inReplyTo":"ca242cf5bda74aafca6c169ad53ce33a62761027.1589302254.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 02/11] cmake: generate the shell/perl/python scripts and templates, translations","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-12T21:19:23Z","receivedAt":"2020-05-12T21:19:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Sibi Siddharthan via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n>\n> This patch implements the placeholder substitution to generate, say,\n> `git-request-pull` from `git-request-pull.sh`.\n>\n> The shell/perl/python scripts and template are generated using CMake\n> (very similar to what sed does).\n\nWe do not say \"This patch does X\" or \"I do Y in this patch\".\nperhaps.\n\n\tImplement the placeholder substitution to generate scripted\n\tPorcelain commands, e.g. git-request-pull out of\n\tgit-request-pull.sh\n\n\tGenerate scripts and templates using CMake, instead of using\n\tsed like the build procedure in the Makefile does.\n\n"},{"id":"397632","messageId":"xmqq3684c096.fsf@gitster.c.googlers.com","threadId":"53305","inReplyTo":"fa1b8032906c6042a0e5851f803ec0427922a1a5.1589302255.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-12T21:27:17Z","receivedAt":"2020-05-12T21:27:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Sibi Siddharthan via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> Subject: Re: [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job\n\nYay!\n\n> This patch modifies .github/workflows/main.yml to use CMake for\n> Visual Studio builds.\n> Modified the vs-test step to match windows-test step. This speeds\n\n\tTeach .github/workflows/main.yml to use Cmake for VS builds.\n\tModify vs-test step to match windows-test step to speed up\n\tthe vs-test.\n\n> Changes:\n> The CMake script has been relocated to contib/buildsystems, so point\n> to the CMakeLists.txt in the invocation commands.\n\nThis does not belong to the log message for this (or any for that\nmatter) commit, no?  Up to this point, nothing in main.yml used\nCMake script from anywhere, and \"has been relocated\" is irrelevant.\n\nAnd if we add CMake script to contrib/buildsystems/ from the\nbeginning in [01/11], there won't be any \"relocation\" the readers of\nthe log message of this step need to know about.\n\n> The generation command now uses the absolute paths for the generation\n> step.\n\n\"now uses\"?  Is that something the readers of the log message of\nthis step need to know about, or is it \"in contrast to an earlier\nattempt to add CMake script\"?  If the latter, it only confuses the\nreaders of our history, as most of them will not even know about an\nearlier attempt.\n\nThanks.\n"},{"id":"397747","messageId":"CAKiG+9VXk1vdMM1amQK6pnHcn9H_93-3fkqgK4nwKf=GtrDGyg@mail.gmail.com","threadId":"53305","inReplyTo":"xmqq3684c096.fsf@gitster.c.googlers.com","subject":"Re: [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-05-13T19:45:08Z","receivedAt":"2020-05-13T19:45:19Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Wed, May 13, 2020 at 2:57 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> \"Sibi Siddharthan via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>\n> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> > Subject: Re: [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job\n>\n> Yay!\n>\n> > This patch modifies .github/workflows/main.yml to use CMake for\n> > Visual Studio builds.\n> > Modified the vs-test step to match windows-test step. This speeds\n>\n>         Teach .github/workflows/main.yml to use Cmake for VS builds.\n>         Modify vs-test step to match windows-test step to speed up\n>         the vs-test.\n>\n> > Changes:\n> > The CMake script has been relocated to contib/buildsystems, so point\n> > to the CMakeLists.txt in the invocation commands.\n>\n> This does not belong to the log message for this (or any for that\n> matter) commit, no?  Up to this point, nothing in main.yml used\n> CMake script from anywhere, and \"has been relocated\" is irrelevant.\n>\n\nWill remove this.\n\n> And if we add CMake script to contrib/buildsystems/ from the\n> beginning in [01/11], there won't be any \"relocation\" the readers of\n> the log message of this step need to know about.\n>\n> > The generation command now uses the absolute paths for the generation\n> > step.\n>\n> \"now uses\"?  Is that something the readers of the log message of\n> this step need to know about, or is it \"in contrast to an earlier\n> attempt to add CMake script\"?  If the latter, it only confuses the\n> readers of our history, as most of them will not even know about an\n> earlier attempt.\n\nWill also remove this.\n\n>\n> Thanks.\n\nThank You,\nSibi Siddharthan\n"},{"id":"397753","messageId":"CAKiG+9Uc8Kc1F3wN7AoLkBR8Uk1up5sZXpgUperhQO6NVmBRxw@mail.gmail.com","threadId":"53305","inReplyTo":"xmqqk11gc1d5.fsf@gitster.c.googlers.com","subject":"Re: [PATCH v2 10/11] cmake: parse the makefile for the sources.","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-05-13T19:57:50Z","receivedAt":"2020-05-13T19:58:01Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Wed, May 13, 2020 at 2:33 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> \"Sibi Siddharthan via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>\n> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> >\n> > The CMake script parses the Makefile for:\n> > SCRIPT_SH\n> > SCRIPT_PERL\n> > TEST_BUILTINS_OBJS\n> > LIB_OBJS\n> > BUILTIN_OBJS\n> > XDIFF_OBJS\n> > VCSSVN_OBJS\n> >\n> > By doing this we avoid duplication of text between the Makefile and\n> > the CMake script.\n>\n> Thanks, this makes perfect sense, but it probably should have been\n> done from the very beginning, without copying the huge list manually\n> in the step [01/11].\n>\n> How robust is the \"parser\"?  Do we need to leave an instruction to\n> Makefile writers to conform to certain style to help CMake users as\n> an additional comment in the Makefile, or is any reasonable textual\n> drift still accepted?\n>\n\nThe parser just uses a regex capture like this \"SCRIPT_SH += (.*)\".\nIf the current source/script definition in the Makefile is continued\nthings will be fine.\n\nOn a side note, why are we using SCRIPT_SH and SCRIPT_LIB separately?\nCan't we combine them into one? If we can then I can also add it to\nthe list above.\n\nThank You,\nSibi Siddharthan\n"},{"id":"397756","messageId":"CAKiG+9VrKsckfnJiaf1xMYnOtJ6wvnbtZv4-3sz6H7h3aZH3Cg@mail.gmail.com","threadId":"53305","inReplyTo":"xmqqblmsc0r1.fsf@gitster.c.googlers.com","subject":"Re: [PATCH v2 08/11] cmake: added checks for struct stat and libiconv","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-05-13T20:05:57Z","receivedAt":"2020-05-13T20:06:10Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Wed, May 13, 2020 at 2:46 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> \"Sibi Siddharthan via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>\n> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> > Subject: Re: [PATCH v2 08/11] cmake: added checks for struct stat and libiconv\n>\n> s/added/add/; give a command to the codebase to \"be like so\", or a\n> command to whoever is typing changes to the editor to \"make this\n> happen\".\n>\n> > The CMake script now checks whether st_blocks is a member of struct stat\n> > and set the compile definition NO_ST_BLOCKS_IN_STRUCT_STAT accordingly.\n>\n>         Teach the CMake script to check ...\n>\n> > diff --git a/CMakeLists.txt b/CMakeLists.txt\n> > index 4353080b708..975791c8b89 100644\n> > --- a/CMakeLists.txt\n> > +++ b/CMakeLists.txt\n> > @@ -22,6 +22,7 @@ project(git\n> >  include(CheckTypeSize)\n> >  include(CheckCSourceRuns)\n> >  include(CheckCSourceCompiles)\n> > +include(CheckCSourceRuns)\n> > ...\n> > +#check for st_blocks in struct stat\n> > +check_struct_has_member(\"struct stat\" st_blocks \"sys/stat.h\" STRUCT_STAT_HAS_ST_BLOCKS)\n> > +if(NOT STRUCT_STAT_HAS_ST_BLOCKS)\n> > +     add_compile_definitions(NO_ST_BLOCKS_IN_STRUCT_STAT)\n> > +endif()\n>\n> All of these compatibility stuff makes sense, but how do we decide\n> where to draw the line between the checks we saw added in [01/11]\n> and the checks added here?  It feels pretty arbitrary to me and if\n> that is the case, perhaps we want to move all the \"add checks\" to a\n> commit separate from [01/11] (whose primary purpose is to add the\n> basic rules without these build tweaks in the file at the final\n> place)?\n>\n\nThe checks are added on a \"demand\" based the target platform.\nIn the future, if apple support is needed, we need to add ST_TIMESPEC checks.\n\nThank You,\nSibi Siddharthan\n"},{"id":"397757","messageId":"CAKiG+9W+ba1ZFqKb=ADGQy146gNB7zQVOADGUqBZ4ULQM7XX9w@mail.gmail.com","threadId":"53305","inReplyTo":"xmqq7dxgc0mc.fsf@gitster.c.googlers.com","subject":"Re: [PATCH v2 02/11] cmake: generate the shell/perl/python scripts and templates, translations","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-05-13T20:07:13Z","receivedAt":"2020-05-13T20:07:25Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Wed, May 13, 2020 at 2:49 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> \"Sibi Siddharthan via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>\n> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> >\n> > This patch implements the placeholder substitution to generate, say,\n> > `git-request-pull` from `git-request-pull.sh`.\n> >\n> > The shell/perl/python scripts and template are generated using CMake\n> > (very similar to what sed does).\n>\n> We do not say \"This patch does X\" or \"I do Y in this patch\".\n> perhaps.\n>\n>         Implement the placeholder substitution to generate scripted\n>         Porcelain commands, e.g. git-request-pull out of\n>         git-request-pull.sh\n>\n>         Generate scripts and templates using CMake, instead of using\n>         sed like the build procedure in the Makefile does.\n>\n\nWill reword.\n\nThank You,\nSibi Siddharthan\n"},{"id":"397759","messageId":"CAKiG+9U04p9KbjrAc-g=yS-O_h8Jd8zvPoUjKG1L=-OybSUgrQ@mail.gmail.com","threadId":"53305","inReplyTo":"xmqqftc4c123.fsf@gitster.c.googlers.com","subject":"Re: [PATCH v2 09/11] cmake: relocated script file contrib/buildsystems","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-05-13T20:08:15Z","receivedAt":"2020-05-13T20:08:28Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Wed, May 13, 2020 at 2:40 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> \"Sibi Siddharthan via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>\n> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> >\n> > The CMake script has been relocated to contrib/buildsystems.\n> > The changes made to the script involves pointing to correct location\n> > of the source files.\n>\n> This does match what the list agreed to do.  Why isn't this done as\n> part of [01/11]?  If there is no technical reason not to, I'd\n> strongly prefer to see it done from the very beginning.  The same\n> comment applies to the next step.\n\nOkay\n\n>\n> Thanks.\n>\n> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> > ---\n> >  .../buildsystems/CMakeLists.txt               | 76 +++++++++++--------\n> >  1 file changed, 45 insertions(+), 31 deletions(-)\n> >  rename CMakeLists.txt => contrib/buildsystems/CMakeLists.txt (92%)\n"},{"id":"397764","messageId":"CAKiG+9U_KCSD=Y4dTAbBRvBxnmpHL2Gw6jPZ7Pv_ZnR3Y6yB6g@mail.gmail.com","threadId":"53305","inReplyTo":"xmqqo8qsc1it.fsf@gitster.c.googlers.com","subject":"Re: [PATCH v2 01/11] Introduce CMake support for configuring Git on Linux","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-05-13T20:21:59Z","receivedAt":"2020-05-13T20:22:11Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Wed, May 13, 2020 at 2:29 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> \"Sibi Siddharthan via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>\n> > To make this a little less awkward, the Git for Windows project offers\n> > the `vs/master` branch which has a full Visual Studio solution generated\n> > and committed. This branch can therefore be used to tinker with Git in\n> > Visual Studio _without_ having to download the full Git for Windows SDK.\n> > Unfortunatly, that branch is auto-generated from Git for Windows'\n> > `master`. If a developer wants to tinker, say, with `pu`, they are out\n> > of luck.\n>\n> 'pu' or 'next' are not to be built upon, so this is not a good line\n> of reasoning to complain that generating only for 'master' is bad.\n>\n> > CMake was invented to make this sort of problem go away, by providing a\n> > more standardized, cross-platform way to configure builds.\n>\n> I think everything above this point (including Makefile, autoconf\n> etc.) can be replaced with a single sentence\n>\n>         The build infrastructure for Git is written around being\n>         able to run make, which is not supported natively on\n>         Windows.\n>\n> without anything else.  That will flow naturally to\n>\n>         Add a build script that uses CMake to help developers on\n>         Windows to build git.\n>\n> and then you can continue the current state, like this paragraph.\n>\n> > This is only the first step, and to make it easier to review, it only\n> > allows for configuring builds on the platform that is easiest to\n> > configure for: Linux.\n> >\n> > The CMake script checks whether the headers are present(eg. libgen.h),\n> > whether the functions are present(eg. memmem), whether the funtions work\n> > properly (eg. snprintf) and generate the required compile definitions\n> > for the platform. The script also searches for the required libraries,\n> > if it fails to find the required libraries the respective executables\n> > won't be built.(eg. If libcurl is not found then git-remote-http won't\n> > be built). This will help building Git easier.\n> >\n> > With a CMake script an out of source build of git is possible resulting\n> > in a clean source tree.\n>\n>\n> > Note: earlier endeavors on the Git mailing list to introduce CMake ended\n> > up in dead water. The primary reason for that was that reviewers\n> > _expected_ CMake support to fall out of maintenance, unless the\n> > contributor would promise to keep an eye on keeping CMake support up to\n> > date. However, in the meantime, support for automated testing has been\n> > introduced in Git's source code, and a later patch will modify the\n> > (still experimental) GitHub workflow to continually verify that CMake\n> > support is still complete. That will make maintenance reasonably easy.\n>\n> I am not sure this belongs to the log message.\n>\n\nWill remove it.\n\n> > Note: this patch asks for the minimum version v3.14 of CMake (which is\n> > not all that old as of time of writing) because that is the first\n> > version to offer a platform-independent way to generate hardlinks as\n> > part of the build. This is needed to generate all those hardlinks for\n> > the built-in commands of Git.\n>\n> This does, but I do not think hardlinks are not required for our\n> build.  On Unix filesystems, it is not just possible but convenient\n> to use, and that is the only reason why we use hardlinks.\n>\n> If hardlinks are possible but inconvenient to use on Windows, you\n> shouldn't force your target audience to use it.\n\nAnother alternative is to use verbatim copies, but this increases the\nsize of the generated build artifacts considerably.\nHardlinks are not inconvenient on Windows, CMake 3.14 gives a cross\nplatform way of generating them.\n\n>\n> > Instructions to run CMake:\n> >\n> > cmake `relative-path-to-srcdir` -DCMAKE_BUILD_TYPE=Release\n> >\n> > Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding\n> > compiler flags\n> > Debug : -g\n> > Release: -O3\n> > RelWithDebInfo : -O2 -g\n> > MinSizeRel : -Os\n> > empty(default) :\n> >\n> > NOTE: -DCMAKE_BUILD_TYPE is optional\n> >\n> > This process generates a Makefile.\n> > Then run `make` to build Git.\n> >\n> > NOTE: By default CMake uses Makefile as the build tool on Linux, to use\n> > another tool say `ninja` add this to the command line when configuring.\n> > `-G Ninja`\n>\n> I find it curious that from the instruction, the most important\n> platform, the primary reason why we are reviewing this patch, is\n> missing.  Don't Windows folks need to be told how to run CMake to\n> build?\n\nThe instructions are the same for any platform. Just like ./configure.\n\n>\n> In any case, all of the above \"Instructions\" should go at the top\n> part of CMakeLists.txt in a comment, and not in the log message.\n> \"git log\" output is not an easy way for your target audience to\n> learn how to use what the commit adds.  Think what they need to do\n> when they discover there is CMakeLists.txt in our tree in three\n> months.  Don't force them to run \"git blame\" to find this commit\n> that added the support.\n\nOkay, will add some instructions on top of the script.\n\n>\n> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> > ---\n> >  CMakeLists.txt | 528 +++++++++++++++++++++++++++++++++++++++++++++++++\n> >  1 file changed, 528 insertions(+)\n> >  create mode 100644 CMakeLists.txt\n> >\n> > diff --git a/CMakeLists.txt b/CMakeLists.txt\n> > new file mode 100644\n> > index 00000000000..73703bd321f\n> > --- /dev/null\n> > +++ b/CMakeLists.txt\n> > @@ -0,0 +1,528 @@\n> > +#\n> > +#    Copyright (c) 2020 Sibi Siddharthan\n> > +#\n> > +\n> > +cmake_minimum_required(VERSION 3.14)\n> > +\n> > +#Parse GIT-VERSION-GEN to get the version\n> > +file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX \"DEF_VER=v(.*)\")\n> > +string(REPLACE \"DEF_VER=v\" \"\" git_version ${git_version})\n> > +string(REPLACE \".GIT\" \".0\" git_version ${git_version})#for building from a snapshot\n>\n> Hmph, I'd really prefer to see the logic in GIT-VERSION-GEN not\n> bypassed like this.  People know they can create a text file 'version'\n> and record the version name they desire in it and expect GIT-VERSION-GEN\n> to pick it up, for example.\n>\n> Later in this file, you seem to depend on the shell to do things\n> like generating config-list.h file, so I'd rather see the same\n> technique used here a well.\n>\n> > +set(libgit_SOURCES\n> > +     abspath.c add-interactive.c add-patch.c advice.c alias.c\n> > +...\n> > +     zlib.c)\n>\n> Hmph.\n>\n> > +set(git_SOURCES\n> > +     builtin/add.c builtin/am.c builtin/annotate.c builtin/apply.c\n> > +     builtin/archive.c builtin/bisect--helper.c builtin/blame.c\n> > +     builtin/branch.c builtin/bundle.c builtin/cat-file.c builtin/check-attr.c\n> > +     builtin/check-ignore.c builtin/check-mailmap.c builtin/check-ref-format.c\n> > +     builtin/checkout-index.c builtin/checkout.c builtin/clean.c\n> > +     builtin/clone.c builtin/column.c builtin/commit-tree.c\n> > +     builtin/commit.c builtin/commit-graph.c builtin/config.c\n> > +     builtin/count-objects.c builtin/credential.c builtin/describe.c\n> > +     builtin/diff-files.c builtin/diff-index.c builtin/diff-tree.c\n> > +     builtin/diff.c builtin/difftool.c builtin/env--helper.c\n> > +     builtin/fast-export.c builtin/fetch-pack.c builtin/fetch.c builtin/fmt-merge-msg.c\n> > +     builtin/for-each-ref.c builtin/fsck.c builtin/gc.c\n> > +     builtin/get-tar-commit-id.c builtin/grep.c builtin/hash-object.c\n> > +     builtin/help.c builtin/index-pack.c builtin/init-db.c\n> > +     builtin/interpret-trailers.c builtin/log.c builtin/ls-files.c\n> > +     builtin/ls-remote.c builtin/ls-tree.c builtin/mailinfo.c builtin/mailsplit.c\n> > +     builtin/merge.c builtin/merge-base.c builtin/merge-file.c builtin/merge-index.c\n> > +     builtin/merge-ours.c builtin/merge-recursive.c builtin/merge-tree.c\n> > +     builtin/mktag.c builtin/mktree.c builtin/multi-pack-index.c builtin/mv.c\n> > +     builtin/name-rev.c builtin/notes.c builtin/pack-objects.c builtin/pack-redundant.c\n> > +     builtin/pack-refs.c builtin/patch-id.c builtin/prune-packed.c builtin/prune.c\n> > +     builtin/pull.c builtin/push.c builtin/range-diff.c builtin/read-tree.c\n> > +     builtin/rebase.c builtin/receive-pack.c builtin/reflog.c builtin/remote.c\n> > +     builtin/remote-ext.c builtin/remote-fd.c builtin/repack.c builtin/replace.c\n> > +     builtin/rerere.c builtin/reset.c builtin/rev-list.c builtin/rev-parse.c\n> > +     builtin/revert.c builtin/rm.c builtin/send-pack.c builtin/shortlog.c\n> > +     builtin/show-branch.c builtin/show-index.c builtin/show-ref.c\n> > +     builtin/sparse-checkout.c builtin/stash.c builtin/stripspace.c\n> > +     builtin/submodule--helper.c builtin/symbolic-ref.c builtin/tag.c\n> > +     builtin/unpack-file.c builtin/unpack-objects.c builtin/update-index.c\n> > +     builtin/update-ref.c builtin/update-server-info.c builtin/upload-archive.c\n> > +     builtin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c\n> > +     builtin/verify-tag.c builtin/worktree.c builtin/write-tree.c)\n>\n> Can't we do a bit better here?\n>\n> Perhaps grab this out of our Makefile?  The same command applies to\n> huge lists of sources we have seen.\n>\n> Or do the equivalent of $(wildcard builtin/*.c) if CMake has such a\n> feature?\n>\n\nWe do have that.\n\n> > ...\n> > \\ No newline at end of file\n>\n> Double check and make sure you have a text file without an incomplete\n> line at the end.\n>\n> Thanks.\n\nThank You,\nSibi Siddharthan\n"},{"id":"397765","messageId":"xmqq1rnntwi8.fsf@gitster.c.googlers.com","threadId":"53305","inReplyTo":"CAKiG+9Uc8Kc1F3wN7AoLkBR8Uk1up5sZXpgUperhQO6NVmBRxw@mail.gmail.com","subject":"Re: [PATCH v2 10/11] cmake: parse the makefile for the sources.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-13T20:23:11Z","receivedAt":"2020-05-13T20:23:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n\n> On a side note, why are we using SCRIPT_SH and SCRIPT_LIB separately?\n\nI think _SH are commands to be installed as executable, while _LIB\nare to be dot-included and installed as non-executable.  \n\nThere may be other differences; they (i.e. what the Makefile uses\nthese lists for, how the elements on these lists are treated, etc.)\nare something you need to know before you can reimplement the logic\nof building and installing used by the current system in a different\nbuild system.\n\nThanks.\n"},{"id":"397801","messageId":"xmqqd077qnqc.fsf@gitster.c.googlers.com","threadId":"53305","inReplyTo":"CAKiG+9VrKsckfnJiaf1xMYnOtJ6wvnbtZv4-3sz6H7h3aZH3Cg@mail.gmail.com","subject":"Re: [PATCH v2 08/11] cmake: added checks for struct stat and libiconv","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-14T02:00:59Z","receivedAt":"2020-05-14T02:01:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n\n>> All of these compatibility stuff makes sense, but how do we decide\n>> where to draw the line between the checks we saw added in [01/11]\n>> and the checks added here?  It feels pretty arbitrary to me and if\n>> that is the case, perhaps we want to move all the \"add checks\" to a\n>> commit separate from [01/11] (whose primary purpose is to add the\n>> basic rules without these build tweaks in the file at the final\n>> place)?\n>>\n>\n> The checks are added on a \"demand\" based the target platform.\n> In the future, if apple support is needed, we need to add ST_TIMESPEC checks.\n\nWell, let's ask a related question then.\n\nGiven that the primary reason why the project may be interested in\nadding cmake-based build system is because of its support for\nWindows build, how much smaller would this 11-patch series can\nbecome if we discard support for any platforms other than Windows?\nLet's say we add support for other platforms only after the series\nproves capable to build on/for Windows by going through the usual\n\"queued in 'pu', merged to 'next' and then down to 'master'\" route\nand appears in a tagged release.  Would it reduce the time we need\nto spend before seeing a cmake-based build for Windows by doing so?\n"},{"id":"397807","messageId":"20200514152559.GA1939@danh.dev","threadId":"53305","inReplyTo":"00cae10bbb7870b27202642d6e1e284a97a3c5b7.1589302254.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 06/11] cmake: support for building git on windows with mingw","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-05-14T15:25:59Z","receivedAt":"2020-05-14T15:26:04Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"Hi Sibi,\n\nOn 2020-05-12 16:50:49+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> diff --git a/CMakeLists.txt b/CMakeLists.txt\n> index 47d3f3c2866..9625e41886f 100644\n> --- a/CMakeLists.txt\n> +++ b/CMakeLists.txt\n> @@ -13,9 +13,12 @@ project(git\n>  \tVERSION ${git_version}\n>  \tLANGUAGES C)\n>  \n> +\n\nThis newline maybe left from debugging. (and other new newline below).\n\n> +#Platform Specific\n> +if(${CMAKE_SYSTEM_NAME} STREQUAL \"Windows\")\n\nPlease drop ${} around CMAKE_SYSTEM_NAME, here (and other if)\nOr user may accidental messed up.\n------------8<----------------\n$ cat CMakeLists.txt\nproject(test)\nmessage(\"This is ${CMAKE_SYSTEM_NAME}\")\nif (${CMAKE_SYSTEM_NAME} STREQUAL \"Windows\")\n\tmessage(\"Yes, STREQUAL Windows\")\nendif()\n$ cmake . -DLinux=Windows\nThis is Linux\nYes, STREQUAL Windows\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /tmp\n---------------->8--------------\n\n\n-- \nDanh\n"},{"id":"397808","messageId":"20200514153140.GB1939@danh.dev","threadId":"53305","inReplyTo":"f496cd7d8aa12047db7f6c0212fbcb2497469785.1589302255.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 08/11] cmake: added checks for struct stat and libiconv","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-05-14T15:31:40Z","receivedAt":"2020-05-14T15:31:45Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2020-05-12 16:50:51+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> \n> The CMake script now checks whether st_blocks is a member of struct stat\n> and set the compile definition NO_ST_BLOCKS_IN_STRUCT_STAT accordingly.\n> \n> The check for whether ICONV_OMITS_BOM is also added as requested by Danh.\n\nPlease don't write my name in the commit message like this.\nThis maybe rephased to:\n\t\n\tWhile we're as it, add the check for ICONV_OMITS_BOM.\n\n> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> ---\n>  CMakeLists.txt | 59 ++++++++++++++++++++++++++++++++++++++++++++++++--\n>  1 file changed, 57 insertions(+), 2 deletions(-)\n> \n> diff --git a/CMakeLists.txt b/CMakeLists.txt\n> index 4353080b708..975791c8b89 100644\n> --- a/CMakeLists.txt\n> +++ b/CMakeLists.txt\n> @@ -22,6 +22,7 @@ project(git\n>  include(CheckTypeSize)\n>  include(CheckCSourceRuns)\n>  include(CheckCSourceCompiles)\n> +include(CheckCSourceRuns)\n>  include(CheckIncludeFile)\n>  include(CheckFunctionExists)\n>  include(CheckSymbolExists)\n> @@ -128,7 +129,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL \"Windows\")\n>  \tinclude_directories(compat/win32)\n>  \tadd_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32\n>  \t\t\t\t_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=\".exe\"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT\n> -\t\t\t\tNOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0 NO_ST_BLOCKS_IN_STRUCT_STAT\n> +\t\t\t\tNOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0\n>  \t\t\t\tUSE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP\n>  \t\t\t\tUNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)\n>  \tlist(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c\n> @@ -280,6 +281,11 @@ if(HAVE_CLOCK_MONOTONIC)\n>  \tadd_compile_definitions(HAVE_CLOCK_MONOTONIC)\n>  endif()\n>  \n> +#check for st_blocks in struct stat\n> +check_struct_has_member(\"struct stat\" st_blocks \"sys/stat.h\" STRUCT_STAT_HAS_ST_BLOCKS)\n> +if(NOT STRUCT_STAT_HAS_ST_BLOCKS)\n> +\tadd_compile_definitions(NO_ST_BLOCKS_IN_STRUCT_STAT)\n> +endif()\n>  \n>  #compile checks\n>  check_c_source_runs(\"\n> @@ -344,7 +350,6 @@ if(NOT HAVE_REGEX)\n>  \tadd_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)\n>  endif()\n>  \n> -\n>  check_c_source_compiles(\"\n>  #include <stddef.h>\n>  #include <sys/types.h>\n> @@ -368,6 +373,56 @@ if(HAVE_BSD_SYSCTL)\n>  \tadd_compile_definitions(HAVE_BSD_SYSCTL)\n>  endif()\n>  \n> +set(CMAKE_REQUIRED_LIBRARIES ${Iconv_LIBRARIES})\n> +set(CMAKE_REQUIRED_INCLUDES ${Iconv_INCLUDE_DIRS})\n> +\n> +check_c_source_compiles(\"\n> +#include <iconv.h>\n> +\n> +extern size_t iconv(iconv_t cd,\n> +\t\tchar **inbuf, size_t *inbytesleft,\n> +\t\tchar **outbuf, size_t *outbytesleft);\n> +\n> +int main(){return 0;}\"\n> +HAVE_NEW_ICONV)\n> +if(HAVE_NEW_ICONV)\n> +\tset(HAVE_OLD_ICONV 0)\n> +else()\n> +\tset(HAVE_OLD_ICONV 1)\n> +endif()\n> +\n> +check_c_source_runs(\"\n> +#include <iconv.h>\n> +#if ${HAVE_OLD_ICONV}\n> +typedef const char *iconv_ibp;\n> +#else\n> +typedef char *iconv_ibp;\n> +#endif\n> +\n> +int main()\n> +{\n> +\tint v;\n> +\ticonv_t conv;\n> +\tchar in[] = \\\"a\\\"; iconv_ibp pin = in;\n> +\tchar out[20] = \\\"\\\"; char *pout = out;\n> +\tsize_t isz = sizeof in;\n> +\tsize_t osz = sizeof out;\n> +\n> +\tconv = iconv_open(\\\"UTF-16\\\", \\\"UTF-8\\\");\n> +\ticonv(conv, &pin, &isz, &pout, &osz);\n> +\ticonv_close(conv);\n> +\tv = (unsigned char)(out[0]) + (unsigned char)(out[1]);\n> +\treturn v != 0xfe + 0xff;\n> +}\"\n\nI think the closing double-quote should be placed in a newline,\nin order to make sure the source file ended with newline,\nold C standard requires final newline.\n\n\n-- \nDanh\n"},{"id":"397817","messageId":"CAKiG+9Uozz0q_Jk2dPhrh7nKCoObeJWZ-zyX5cr0Zc4Q_0YVsA@mail.gmail.com","threadId":"53305","inReplyTo":"20200514152559.GA1939@danh.dev","subject":"Re: [PATCH v2 06/11] cmake: support for building git on windows with mingw","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-05-14T18:27:14Z","receivedAt":"2020-05-14T18:27:27Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Thu, May 14, 2020 at 8:56 PM Đoàn Trần Công Danh\n<congdanhqx@gmail.com> wrote:\n>\n> Hi Sibi,\n>\n> On 2020-05-12 16:50:49+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> > diff --git a/CMakeLists.txt b/CMakeLists.txt\n> > index 47d3f3c2866..9625e41886f 100644\n> > --- a/CMakeLists.txt\n> > +++ b/CMakeLists.txt\n> > @@ -13,9 +13,12 @@ project(git\n> >       VERSION ${git_version}\n> >       LANGUAGES C)\n> >\n> > +\n>\n> This newline maybe left from debugging. (and other new newline below).\n>\n> > +#Platform Specific\n> > +if(${CMAKE_SYSTEM_NAME} STREQUAL \"Windows\")\n>\n> Please drop ${} around CMAKE_SYSTEM_NAME, here (and other if)\n> Or user may accidental messed up.\n> ------------8<----------------\n> $ cat CMakeLists.txt\n> project(test)\n> message(\"This is ${CMAKE_SYSTEM_NAME}\")\n> if (${CMAKE_SYSTEM_NAME} STREQUAL \"Windows\")\n>         message(\"Yes, STREQUAL Windows\")\n> endif()\n> $ cmake . -DLinux=Windows\n> This is Linux\n> Yes, STREQUAL Windows\n> -- Configuring done\n> -- Generating done\n> -- Build files have been written to: /tmp\n> ---------------->8--------------\n>\n\nThanks for pointing it out, will fix it ASAP.\n\nThank You,\nSibi Siddharthan\n\n\n>\n> --\n> Danh\n"},{"id":"397818","messageId":"CAKiG+9Xu2OMnj9JghEbzD358ZdcR6vw5XdswAqimrZWWXLHvJA@mail.gmail.com","threadId":"53305","inReplyTo":"20200514153140.GB1939@danh.dev","subject":"Re: [PATCH v2 08/11] cmake: added checks for struct stat and libiconv","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-05-14T18:31:20Z","receivedAt":"2020-05-14T18:31:35Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Thu, May 14, 2020 at 9:01 PM Đoàn Trần Công Danh\n<congdanhqx@gmail.com> wrote:\n>\n> On 2020-05-12 16:50:51+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> >\n> > The CMake script now checks whether st_blocks is a member of struct stat\n> > and set the compile definition NO_ST_BLOCKS_IN_STRUCT_STAT accordingly.\n> >\n> > The check for whether ICONV_OMITS_BOM is also added as requested by Danh.\n>\n> Please don't write my name in the commit message like this.\n> This maybe rephased to:\n>\n>         While we're as it, add the check for ICONV_OMITS_BOM.\n\nSure, will remove your name from the message.\nI added it because gitgitgadget PR bot suggested it as a good practice.\n\n>\n> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> > ---\n> >  CMakeLists.txt | 59 ++++++++++++++++++++++++++++++++++++++++++++++++--\n> >  1 file changed, 57 insertions(+), 2 deletions(-)\n> >\n> > diff --git a/CMakeLists.txt b/CMakeLists.txt\n> > index 4353080b708..975791c8b89 100644\n> > --- a/CMakeLists.txt\n> > +++ b/CMakeLists.txt\n> > @@ -22,6 +22,7 @@ project(git\n> >  include(CheckTypeSize)\n> >  include(CheckCSourceRuns)\n> >  include(CheckCSourceCompiles)\n> > +include(CheckCSourceRuns)\n> >  include(CheckIncludeFile)\n> >  include(CheckFunctionExists)\n> >  include(CheckSymbolExists)\n> > @@ -128,7 +129,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL \"Windows\")\n> >       include_directories(compat/win32)\n> >       add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32\n> >                               _CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=\".exe\"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT\n> > -                             NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0 NO_ST_BLOCKS_IN_STRUCT_STAT\n> > +                             NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0\n> >                               USE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP\n> >                               UNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)\n> >       list(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c\n> > @@ -280,6 +281,11 @@ if(HAVE_CLOCK_MONOTONIC)\n> >       add_compile_definitions(HAVE_CLOCK_MONOTONIC)\n> >  endif()\n> >\n> > +#check for st_blocks in struct stat\n> > +check_struct_has_member(\"struct stat\" st_blocks \"sys/stat.h\" STRUCT_STAT_HAS_ST_BLOCKS)\n> > +if(NOT STRUCT_STAT_HAS_ST_BLOCKS)\n> > +     add_compile_definitions(NO_ST_BLOCKS_IN_STRUCT_STAT)\n> > +endif()\n> >\n> >  #compile checks\n> >  check_c_source_runs(\"\n> > @@ -344,7 +350,6 @@ if(NOT HAVE_REGEX)\n> >       add_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)\n> >  endif()\n> >\n> > -\n> >  check_c_source_compiles(\"\n> >  #include <stddef.h>\n> >  #include <sys/types.h>\n> > @@ -368,6 +373,56 @@ if(HAVE_BSD_SYSCTL)\n> >       add_compile_definitions(HAVE_BSD_SYSCTL)\n> >  endif()\n> >\n> > +set(CMAKE_REQUIRED_LIBRARIES ${Iconv_LIBRARIES})\n> > +set(CMAKE_REQUIRED_INCLUDES ${Iconv_INCLUDE_DIRS})\n> > +\n> > +check_c_source_compiles(\"\n> > +#include <iconv.h>\n> > +\n> > +extern size_t iconv(iconv_t cd,\n> > +             char **inbuf, size_t *inbytesleft,\n> > +             char **outbuf, size_t *outbytesleft);\n> > +\n> > +int main(){return 0;}\"\n> > +HAVE_NEW_ICONV)\n> > +if(HAVE_NEW_ICONV)\n> > +     set(HAVE_OLD_ICONV 0)\n> > +else()\n> > +     set(HAVE_OLD_ICONV 1)\n> > +endif()\n> > +\n> > +check_c_source_runs(\"\n> > +#include <iconv.h>\n> > +#if ${HAVE_OLD_ICONV}\n> > +typedef const char *iconv_ibp;\n> > +#else\n> > +typedef char *iconv_ibp;\n> > +#endif\n> > +\n> > +int main()\n> > +{\n> > +     int v;\n> > +     iconv_t conv;\n> > +     char in[] = \\\"a\\\"; iconv_ibp pin = in;\n> > +     char out[20] = \\\"\\\"; char *pout = out;\n> > +     size_t isz = sizeof in;\n> > +     size_t osz = sizeof out;\n> > +\n> > +     conv = iconv_open(\\\"UTF-16\\\", \\\"UTF-8\\\");\n> > +     iconv(conv, &pin, &isz, &pout, &osz);\n> > +     iconv_close(conv);\n> > +     v = (unsigned char)(out[0]) + (unsigned char)(out[1]);\n> > +     return v != 0xfe + 0xff;\n> > +}\"\n>\n> I think the closing double-quote should be placed in a newline,\n> in order to make sure the source file ended with newline,\n> old C standard requires final newline.\n>\n\nOkay\n\nThank You,\nSibi Siddharthan\n\n>\n> --\n> Danh\n"},{"id":"398504","messageId":"CAKiG+9Uz4YG=Hq9PRN8EhFF_agXNUPRnYjetY=ZNVRE6_VDAew@mail.gmail.com","threadId":"53305","inReplyTo":"CAKiG+9VXk1vdMM1amQK6pnHcn9H_93-3fkqgK4nwKf=GtrDGyg@mail.gmail.com","subject":"Re: [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-05-25T19:16:10Z","receivedAt":"2020-05-25T19:16:23Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"Hi Junio,\n\nI have finished the changes you have asked for.\n1) Relocating the CMake script to contrib/buildsystems from patch 01/xx.\n2) Parse the Makefile for sources from patch 01/xx.\n3) Reworded the commit messages you pointed out.\n4) Rebased the ST_BLOCKS_IN_STRUCT_STAT and ICONV_OMITS_BOM to patch\n01/xx to make the review process easier.\n\nNo new features will be introduced in the script, to make the review\nprocess easier.\n\nI have looked at the GIT-VERSION-GEN script and the logic it uses to\ndetermine the version of git.\nThe logic is a bit complicated to be implemented in a  CMake script,\nso I am skipping it for now.\n\nAny other changes I should make before I submit PATCH v3?\n\nThank You,\nSibi Siddharthan\n"},{"id":"398550","messageId":"xmqqzh9vok90.fsf@gitster.c.googlers.com","threadId":"53305","inReplyTo":"CAKiG+9Uz4YG=Hq9PRN8EhFF_agXNUPRnYjetY=ZNVRE6_VDAew@mail.gmail.com","subject":"Re: [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-25T20:03:07Z","receivedAt":"2020-05-25T20:03:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n\n> 1) Relocating the CMake script to contrib/buildsystems from patch 01/xx.\n> 2) Parse the Makefile for sources from patch 01/xx.\n> 3) Reworded the commit messages you pointed out.\n> 4) Rebased the ST_BLOCKS_IN_STRUCT_STAT and ICONV_OMITS_BOM to patch\n> 01/xx to make the review process easier.\n> ...\n> No new features will be introduced in the script, to make the review\n> process easier.\n\nYou did not answer <xmqqd077qnqc.fsf@gitster.c.googlers.com>,\nso I have to guess.\n\nI am guessing that your answer would be that if we keep this series\nconcentrate only on Windows support from the beginning and do not\nadd support for any other platform at all, the scope and necessary\neffort to bring the patches in reviewable shape would be reduced\ndramatically.  And if that is the case, that would be great.\n\nIn other words, I'd prefer not just \"no new features\", but \"with\nmuch less features, now we do not even add support for Linux or\nmacOS to the initial patch series\".\n\nBut because I haven't heard the question answered, I cannot tell if\nthat level of simplification is possible and if that is already what\nyou did in (silent) response to my questions.\n\n> I have looked at the GIT-VERSION-GEN script and the logic it uses to\n> determine the version of git.\n> The logic is a bit complicated to be implemented in a  CMake script,\n> so I am skipping it for now.\n\nRegarding the generation of GIT-VERSION-FILE, I asked you why you\nneed to hand-parse, instead of running the script itself, which is\nthe way you generate the config-list.h file in the same patch, which\nis done with execute_process() to run generate-cmdlist.sh.\n\nYou did not answer the question, either, so I have to guess.\n\nI am guessing that it was an oversight that you did not update the\nprocedure to handle GIT-VERSION-FILE because you wrote the \"let's\nstring-find in the GIT-VERSION-GEN script\" approach way before you\nwrote the other parts of the CMake thing, and with the experience\nand hindsight of having written command-list-h support, you now\nrealize that running the script to ensure that you get the result\nconsistent with folks who use Makefile would be much better.  After\nall, the logic being more complex than your CMake support can\nexpress shouldn't be an issue, if you just let the logic execute\nitself, no?\n\nBut that is also merely my guess, so...\n\n> Any other changes I should make before I submit PATCH v3?\n\n... at this point, it is too early for me to answer that question.\n"},{"id":"398552","messageId":"CAKiG+9UXa_1tfJ49gXGQCKTK5hqmVSAV2SqEc4iZCT54i18h6Q@mail.gmail.com","threadId":"53305","inReplyTo":"xmqqzh9vok90.fsf@gitster.c.googlers.com","subject":"Re: [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-05-25T20:56:10Z","receivedAt":"2020-05-25T20:56:24Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Tue, May 26, 2020 at 1:33 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n>\n> > 1) Relocating the CMake script to contrib/buildsystems from patch 01/xx.\n> > 2) Parse the Makefile for sources from patch 01/xx.\n> > 3) Reworded the commit messages you pointed out.\n> > 4) Rebased the ST_BLOCKS_IN_STRUCT_STAT and ICONV_OMITS_BOM to patch\n> > 01/xx to make the review process easier.\n> > ...\n> > No new features will be introduced in the script, to make the review\n> > process easier.\n>\n> You did not answer <xmqqd077qnqc.fsf@gitster.c.googlers.com>,\n> so I have to guess.\n\nSorry, was going to reply to that, but forgot about it along the way.\n\nAs for my reply to that for windows only support we do not need\na few of the checks namely:\n1) HAVE_BSD_SYSCTL\n2) ICONV_OMITS_BOM (because we are using GNU libiconv 1.16)\n\nThe functions checks (check_function_exists) is needed.\nA few of the header checks are unnecessary(paths.h sys/sysinfo.h).\n\nThe difference in build between Linux platforms and Windows would\nbe 8-15 lines of code atmost . I see no point in the extra Linux stuff to be\na burden for the reviewers.\n\nThere is another way of just copying the configurations in config.mak.uname,\nbut this hurts the purpose of configuring in the first place.\n\n>\n> I am guessing that your answer would be that if we keep this series\n> concentrate only on Windows support from the beginning and do not\n> add support for any other platform at all, the scope and necessary\n> effort to bring the patches in reviewable shape would be reduced\n> dramatically.  And if that is the case, that would be great.\n>\n> In other words, I'd prefer not just \"no new features\", but \"with\n> much less features, now we do not even add support for Linux or\n> macOS to the initial patch series\".\n\nmacOS support is ways off, needs quite a bit of work.\n\nIn terms of Linux support apart from the function, header checks there\nis nothing special\nimplemented here.\n\n>\n> But because I haven't heard the question answered, I cannot tell if\n> that level of simplification is possible and if that is already what\n> you did in (silent) response to my questions.\n>\n> > I have looked at the GIT-VERSION-GEN script and the logic it uses to\n> > determine the version of git.\n> > The logic is a bit complicated to be implemented in a  CMake script,\n> > so I am skipping it for now.\n>\n> Regarding the generation of GIT-VERSION-FILE, I asked you why you\n> need to hand-parse, instead of running the script itself, which is\n> the way you generate the config-list.h file in the same patch, which\n> is done with execute_process() to run generate-cmdlist.sh.\n>\n> You did not answer the question, either, so I have to guess.\n>\n> I am guessing that it was an oversight that you did not update the\n> procedure to handle GIT-VERSION-FILE because you wrote the \"let's\n> string-find in the GIT-VERSION-GEN script\" approach way before you\n> wrote the other parts of the CMake thing, and with the experience\n> and hindsight of having written command-list-h support, you now\n> realize that running the script to ensure that you get the result\n> consistent with folks who use Makefile would be much better.  After\n> all, the logic being more complex than your CMake support can\n> express shouldn't be an issue, if you just let the logic execute\n> itself, no?\n>\n\nYes, fair point.\n\nHave executed GIT-VERSION-GEN, then parsed the GIT-VERSION-FILE for\nversion info.\nAdded it to the list of changes.\n\n> But that is also merely my guess, so...\n>\n> > Any other changes I should make before I submit PATCH v3?\n>\n> ... at this point, it is too early for me to answer that question.\n\nThank You,\nSibi Siddharthan\n"},{"id":"398575","messageId":"nycvar.QRO.7.76.6.2005252338090.56@tvgsbejvaqbjf.bet","threadId":"53305","inReplyTo":"CAKiG+9UXa_1tfJ49gXGQCKTK5hqmVSAV2SqEc4iZCT54i18h6Q@mail.gmail.com","subject":"Re: [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-05-25T21:40:43Z","receivedAt":"2020-05-26T11:57:36Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Sibi,\n\nOn Tue, 26 May 2020, Sibi Siddharthan wrote:\n\n> The difference in build between Linux platforms and Windows would be\n> 8-15 lines of code atmost . I see no point in the extra Linux stuff to\n> be a burden for the reviewers.\n\nI agree that this does not constitute a big burden.\n\nLinux support in the CMake system _might_ come in real handy in certain\ncircumstances. For example, if I understand correctly cppcheck uses the\nCMake configuration to figure out which source files to analyze, and with\nwhich #define's.\n\nSo there might be some previously-underappreciated benefit to having a\nCMake configuration that works on Linux, even if it is not the recommended\nway to build Git on Linux.\n\nThank you for your incredible work on the CMake front,\nDscho\n"},{"id":"398880","messageId":"09c972de52b35b14a4c6f44b10c3dfc1732b2c7a.1590759624.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v3.git.1590759624.gitgitgadget@gmail.com","subject":"[PATCH v3 1/8] Introduce CMake support for configuring Git","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-05-29T13:40:17Z","receivedAt":"2020-05-29T13:40:31Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nAt the moment, the recommended way to configure Git's builds is to\nsimply run `make`. If that does not work, the recommended strategy is to\nlook at the top of the `Makefile` to see whether any \"Makefile knob\" has\nto be turned on/off, e.g. `make NO_OPENSSL=YesPlease`.\n\nAlternatively, Git also has an `autoconf` setup which allows configuring\nbuilds via `./configure [<option>...]`.\n\nBoth of these options are fine if the developer works on Unix or Linux.\nBut on Windows, we have to jump through hoops to configure a build\n(read: we force the user to install a full Git for Windows SDK, which\noccupies around two gigabytes (!) on disk and downloads about three\nquarters of a gigabyte worth of Git objects).\n\nThe build infrastructure for Git is written around being able to run\nmake, which is not supported natively on Windows.\nTo help Windows developers a CMake build script is introduced here.\n\nWith a working support CMake, developers on Windows need only install\nCMake, configure their build, load the generated Visual Studio solution\nand immediately start modifying the code and build their own version of\nGit. Likewise, developers on other platforms can use the convenient GUI\ntools provided by CMake to configure their build.\n\nSo let's start building CMake support for Git.\n\nThis is only the first step, and to make it easier to review, it only\nallows for configuring builds on the platform that is easiest to\nconfigure for: Linux.\n\nThe CMake script checks whether the headers are present(eg. libgen.h),\nwhether the functions are present(eg. memmem), whether the funtions work\nproperly (eg. snprintf) and generate the required compile definitions\nfor the platform. The script also searches for the required libraries,\nif it fails to find the required libraries the respective executables\nwon't be built.(eg. If libcurl is not found then git-remote-http won't\nbe built). This will help building Git easier.\n\nWith a CMake script an out of source build of git is possible resulting\nin a clean source tree.\n\nNote: this patch asks for the minimum version v3.14 of CMake (which is\nnot all that old as of time of writing) because that is the first\nversion to offer a platform-independent way to generate hardlinks as\npart of the build. This is needed to generate all those hardlinks for\nthe built-in commands of Git.\n\nChanges\nThe CMake script parses the Makefile for:\nLIB_OBJS\nBUILTIN_OBJS\nXDIFF_OBJS\nVCSSVN_OBJS\nTEST_BUILTINS_OBJS\n\nBy doing this we avoid duplication of text between the Makefile and\nthe CMake script.\n\nThe CMake script has been relocated to contrib/buildsystems.\n\nThe CMake script uses GIT-VERSION-GEN to determine the version of Git\nbeing built.\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n contrib/buildsystems/CMakeLists.txt | 575 ++++++++++++++++++++++++++++\n 1 file changed, 575 insertions(+)\n create mode 100644 contrib/buildsystems/CMakeLists.txt\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nnew file mode 100644\nindex 00000000000..8e2b27f44a6\n--- /dev/null\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -0,0 +1,575 @@\n+#\n+#\tCopyright (c) 2020 Sibi Siddharthan\n+#\n+\n+#[[\n+\n+Instructions to run CMake:\n+\n+cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release\n+\n+Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding\n+compiler flags\n+Debug : -g\n+Release: -O3\n+RelWithDebInfo : -O2 -g\n+MinSizeRel : -Os\n+empty(default) :\n+\n+NOTE: -DCMAKE_BUILD_TYPE is optional. For multi-config generators like Visual Studio\n+this option is ignored\n+\n+This process generates a Makefile(Linux) , Visual Studio solution(Windows) by default.\n+Run `make` to build Git on Linux.\n+Open git.sln on Windows and build Git.\n+\n+NOTE: By default CMake uses Makefile as the build tool on Linux and Visual Studio in Windows,\n+to use another tool say `ninja` add this to the command line when configuring.\n+`-G Ninja`\n+\n+]]\n+cmake_minimum_required(VERSION 3.14)\n+\n+#set the source directory to root of git\n+set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n+\n+find_program(SH_EXE sh)\n+\n+#Create GIT-VERSION-FILE using GIT-VERSION-GEN\n+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)\n+\tmessage(\"Generating GIT-VERSION-FILE\")\n+\texecute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN\n+\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR})\n+endif()\n+\n+#Parse GIT-VERSION-FILE to get the version\n+file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE git_version REGEX \"GIT_VERSION = (.*)\")\n+string(REPLACE \"GIT_VERSION = \" \"\" git_version ${git_version})\n+string(FIND ${git_version} \"GIT\" location)\n+if(location EQUAL -1)\n+\tstring(REGEX MATCH \"[0-9]*\\\\.[0-9]*\\\\.[0-9]*\" git_version ${git_version})\n+else()\n+\tstring(REGEX MATCH \"[0-9]*\\\\.[0-9]*\" git_version ${git_version})\n+\tstring(APPEND git_version \".0\") #for building from a snapshot\n+endif()\n+\n+project(git\n+\tVERSION ${git_version}\n+\tLANGUAGES C)\n+\n+\n+#macros for parsing the Makefile for sources\n+macro(parse_makefile_for_sources list_var regex)\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX \"^${regex} \\\\+=(.*)\")\n+\tstring(REPLACE \"${regex} +=\" \"\" ${list_var} ${${list_var}})\n+\tstring(REPLACE \"$(COMPAT_OBJS)\" \"\" ${list_var} ${${list_var}}) #remove \"$(COMPAT_OBJS)\" This is only for libgit.\n+\tstring(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces\n+\tstring(REPLACE \".o\" \".c;\" ${list_var} ${${list_var}}) #change .o to .c, ; is for converting the string into a list\n+\tlist(TRANSFORM ${list_var} STRIP) #remove trailing/leading whitespaces for each element in list\n+\tlist(REMOVE_ITEM ${list_var} \"\") #remove empty list elements\n+endmacro()\n+\n+include(CheckTypeSize)\n+include(CheckCSourceRuns)\n+include(CheckCSourceCompiles)\n+include(CheckIncludeFile)\n+include(CheckFunctionExists)\n+include(CheckSymbolExists)\n+include(CheckStructHasMember)\n+\n+find_package(ZLIB REQUIRED)\n+find_package(CURL)\n+find_package(EXPAT)\n+find_package(Iconv)\n+find_package(Intl)\n+\n+if(NOT Intl_FOUND)\n+\tadd_compile_definitions(NO_GETTEXT)\n+\tif(NOT Iconv_FOUND)\n+\t\tadd_compile_definitions(NO_ICONV)\n+\tendif()\n+endif()\n+\n+include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})\n+if(CURL_FOUND)\n+\tinclude_directories(SYSTEM ${CURL_INCLUDE_DIRS})\n+endif()\n+if(EXPAT_FOUND)\n+\tinclude_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})\n+endif()\n+if(Iconv_FOUND)\n+\tinclude_directories(SYSTEM ${Iconv_INCLUDE_DIRS})\n+endif()\n+if(Intl_FOUND)\n+\tinclude_directories(SYSTEM ${Intl_INCLUDE_DIRS})\n+endif()\n+\n+#default behaviour\n+include_directories(${CMAKE_SOURCE_DIR})\n+add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n+add_compile_definitions(SHA256_BLK INTERNAL_QSORT RUNTIME_PREFIX)\n+add_compile_definitions(NO_OPENSSL SHA1_DC SHA1DC_NO_STANDARD_INCLUDES\n+\t\t\tSHA1DC_INIT_SAFE_HASH_DEFAULT=0\n+\t\t\tSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"cache.h\"\n+\t\t\tSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"git-compat-util.h\" )\n+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)\n+\n+\n+add_compile_definitions(PAGER_ENV=\"LESS=FRX LV=-c\"\n+\t\t\tETC_GITATTRIBUTES=\"etc/gitattributes\"\n+\t\t\tETC_GITCONFIG=\"etc/gitconfig\"\n+\t\t\tGIT_EXEC_PATH=\"libexec/git-core\"\n+\t\t\tGIT_LOCALE_PATH=\"share/locale\"\n+\t\t\tGIT_MAN_PATH=\"share/man\"\n+\t\t\tGIT_INFO_PATH=\"share/info\"\n+\t\t\tGIT_HTML_PATH=\"share/doc/git-doc\"\n+\t\t\tDEFAULT_HELP_FORMAT=\"html\"\n+\t\t\tDEFAULT_GIT_TEMPLATE_DIR=\"share/git-core/templates\"\n+\t\t\tGIT_VERSION=\"${PROJECT_VERSION}.GIT\"\n+\t\t\tGIT_USER_AGENT=\"git/${PROJECT_VERSION}.GIT\"\n+\t\t\tBINDIR=\"bin\"\n+\t\t\tGIT_BUILT_FROM_COMMIT=\"\")\n+\n+set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n+add_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n+\n+add_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n+list(APPEND compat_SOURCES unix-socket.c)\n+\n+#header checks\n+check_include_file(libgen.h HAVE_LIBGEN_H)\n+if(NOT HAVE_LIBGEN_H)\n+\tadd_compile_definitions(NO_LIBGEN_H)\n+\tlist(APPEND compat_SOURCES compat/basename.c)\n+endif()\n+\n+check_include_file(sys/sysinfo.h HAVE_SYSINFO)\n+if(HAVE_SYSINFO)\n+\tadd_compile_definitions(HAVE_SYSINFO)\n+endif()\n+\n+check_c_source_compiles(\"\n+#include <alloca.h>\n+int\n+main ()\n+{\n+char *p = (char *) alloca (2 * sizeof (int));\n+\tif (p) return 0;\n+\treturn 0;\n+}\"\n+HAVE_ALLOCA_H)\n+if(HAVE_ALLOCA_H)\n+\tadd_compile_definitions(HAVE_ALLOCA_H)\n+endif()\n+\n+check_include_file(strings.h HAVE_STRINGS_H)\n+if(HAVE_STRINGS_H)\n+\tadd_compile_definitions(HAVE_STRINGS_H)\n+endif()\n+\n+check_include_file(sys/select.h HAVE_SYS_SELECT_H)\n+if(NOT HAVE_SYS_SELECT_H)\n+\tadd_compile_definitions(NO_SYS_SELECT_H)\n+endif()\n+\n+check_include_file(sys/poll.h HAVE_SYS_POLL_H)\n+if(NOT HAVE_SYS_POLL_H)\n+\tadd_compile_definitions(NO_SYS_POLL_H)\n+endif()\n+\n+check_include_file(poll.h HAVE_POLL_H)\n+if(NOT HAVE_POLL_H)\n+\tadd_compile_definitions(NO_POLL_H)\n+endif()\n+\n+check_include_file(inttypes.h HAVE_INTTYPES_H)\n+if(NOT HAVE_INTTYPES_H)\n+\tadd_compile_definitions(NO_INTTYPES_H)\n+endif()\n+\n+check_include_file(paths.h HAVE_PATHS_H)\n+if(HAVE_PATHS_H)\n+\tadd_compile_definitions(HAVE_PATHS_H)\n+endif()\n+\n+#function checks\n+set(function_checks\n+\tstrcasestr memmem strlcpy strtoimax strtoumax strtoull\n+\tsetenv mkdtemp poll pread memmem unsetenv hstrerror)\n+\n+foreach(f ${function_checks})\n+\tstring(TOUPPER ${f} uf)\n+\tcheck_function_exists(${f} HAVE_${uf})\n+\tif(NOT HAVE_${uf})\n+\t\tadd_compile_definitions(NO_${uf})\n+\tendif()\n+endforeach()\n+\n+if(NOT HAVE_POLL_H OR NOT HAVE_SYS_POLL_H OR NOT HAVE_POLL)\n+\tinclude_directories(${CMAKE_SOURCE_DIR}/compat/poll)\n+\tadd_compile_definitions(NO_POLL)\n+\tlist(APPEND compat_SOURCES compat/poll/poll.c)\n+endif()\n+\n+if(NOT HAVE_STRCASESTR)\n+\tlist(APPEND compat_SOURCES compat/strcasestr.c)\n+endif()\n+\n+if(NOT HAVE_STRLCPY)\n+\tlist(APPEND compat_SOURCES compat/strlcpy.c)\n+endif()\n+\n+if(NOT HAVE_STRTOUMAX)\n+\tlist(APPEND compat_SOURCES compat/strtoumax.c compat/strtoimax.c)\n+endif()\n+\n+if(NOT HAVE_SETENV)\n+\tlist(APPEND compat_SOURCES compat/setenv.c)\n+endif()\n+\n+if(NOT HAVE_MKDTEMP)\n+\tlist(APPEND compat_SOURCES compat/mkdtemp.c)\n+endif()\n+\n+if(NOT HAVE_PREAD)\n+\tlist(APPEND compat_SOURCES compat/pread.c)\n+endif()\n+\n+if(NOT HAVE_MEMMEM)\n+\tlist(APPEND compat_SOURCES compat/memmem.c)\n+endif()\n+\n+if(NOT WIN32)\n+\tif(NOT HAVE_UNSETENV)\n+\t\tlist(APPEND compat_SOURCES compat/unsetenv.c)\n+\tendif()\n+\n+\tif(NOT HAVE_HSTRERROR)\n+\t\tlist(APPEND compat_SOURCES compat/hstrerror.c)\n+\tendif()\n+endif()\n+\n+check_function_exists(getdelim HAVE_GETDELIM)\n+if(HAVE_GETDELIM)\n+\tadd_compile_definitions(HAVE_GETDELIM)\n+endif()\n+\n+check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)\n+check_symbol_exists(CLOCK_MONOTONIC \"time.h\" HAVE_CLOCK_MONOTONIC)\n+if(HAVE_CLOCK_GETTIME)\n+\tadd_compile_definitions(HAVE_CLOCK_GETTIME)\n+endif()\n+if(HAVE_CLOCK_MONOTONIC)\n+\tadd_compile_definitions(HAVE_CLOCK_MONOTONIC)\n+endif()\n+\n+#check for st_blocks in struct stat\n+check_struct_has_member(\"struct stat\" st_blocks \"sys/stat.h\" STRUCT_STAT_HAS_ST_BLOCKS)\n+if(NOT STRUCT_STAT_HAS_ST_BLOCKS)\n+\tadd_compile_definitions(NO_ST_BLOCKS_IN_STRUCT_STAT)\n+endif()\n+\n+#compile checks\n+check_c_source_runs(\"\n+#include<stdio.h>\n+#include<stdarg.h>\n+#include<string.h>\n+#include<stdlib.h>\n+int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)\n+{\n+\tint ret;\n+\tva_list ap;\n+\n+\tva_start(ap, format);\n+\tret = vsnprintf(str, maxsize, format, ap);\n+\tva_end(ap);\n+\treturn ret;\n+}\n+\n+int\n+main ()\n+{\n+\tchar buf[6];\n+\tif (test_vsnprintf(buf, 3, \\\"%s\\\", \\\"12345\\\") != 5\n+\t\t|| strcmp(buf, \\\"12\\\")) return 1;\n+\tif (snprintf(buf, 3, \\\"%s\\\", \\\"12345\\\") != 5\n+\t\t|| strcmp(buf, \\\"12\\\")) return 1;\n+\n+\treturn 0;\n+}\"\n+SNPRINTF_OK)\n+if(NOT SNPRINTF_OK)\n+\tadd_compile_definitions(SNPRINTF_RETURNS_BOGUS)\n+\tlist(APPEND compat_SOURCES compat/snprintf.c)\n+endif()\n+\n+check_c_source_runs(\"\n+#include<stdio.h>\n+int\n+main ()\n+{\n+\tFILE *f = fopen(\\\".\\\", \\\"r\\\");\n+\treturn f != NULL;\n+\n+\treturn 0;\n+}\"\n+FREAD_READS_DIRECTORIES_NO)\n+if(NOT FREAD_READS_DIRECTORIES_NO)\n+\tadd_compile_definitions(FREAD_READS_DIRECTORIES)\n+\tlist(APPEND compat_SOURCES compat/fopen.c)\n+endif()\n+\n+check_c_source_compiles(\"\n+#include <regex.h>\n+#ifndef REG_STARTEND\n+#error oops we dont have it\n+#endif\n+int main(){return 0;}\"\n+HAVE_REGEX)\n+if(NOT HAVE_REGEX)\n+\tinclude_directories(${CMAKE_SOURCE_DIR}/compat/regex)\n+\tlist(APPEND compat_SOURCES compat/regex/regex.c )\n+\tadd_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)\n+endif()\n+\n+\n+check_c_source_compiles(\"\n+#include <stddef.h>\n+#include <sys/types.h>\n+#include <sys/sysctl.h>\n+\n+int\n+main ()\n+{\n+\tint val, mib[2];\n+\tsize_t len;\n+\n+\tmib[0] = CTL_HW;\n+\tmib[1] = 1;\n+\tlen = sizeof(val);\n+\treturn sysctl(mib, 2, &val, &len, NULL, 0) ? 1 : 0;\n+\n+\treturn 0;\n+}\"\n+HAVE_BSD_SYSCTL)\n+if(HAVE_BSD_SYSCTL)\n+\tadd_compile_definitions(HAVE_BSD_SYSCTL)\n+endif()\n+\n+set(CMAKE_REQUIRED_LIBRARIES ${Iconv_LIBRARIES})\n+set(CMAKE_REQUIRED_INCLUDES ${Iconv_INCLUDE_DIRS})\n+\n+check_c_source_compiles(\"\n+#include <iconv.h>\n+\n+extern size_t iconv(iconv_t cd,\n+\t\tchar **inbuf, size_t *inbytesleft,\n+\t\tchar **outbuf, size_t *outbytesleft);\n+\n+int main(){return 0;}\"\n+HAVE_NEW_ICONV)\n+if(HAVE_NEW_ICONV)\n+\tset(HAVE_OLD_ICONV 0)\n+else()\n+\tset(HAVE_OLD_ICONV 1)\n+endif()\n+\n+check_c_source_runs(\"\n+#include <iconv.h>\n+#if ${HAVE_OLD_ICONV}\n+typedef const char *iconv_ibp;\n+#else\n+typedef char *iconv_ibp;\n+#endif\n+\n+int main()\n+{\n+\tint v;\n+\ticonv_t conv;\n+\tchar in[] = \\\"a\\\"; iconv_ibp pin = in;\n+\tchar out[20] = \\\"\\\"; char *pout = out;\n+\tsize_t isz = sizeof in;\n+\tsize_t osz = sizeof out;\n+\n+\tconv = iconv_open(\\\"UTF-16\\\", \\\"UTF-8\\\");\n+\ticonv(conv, &pin, &isz, &pout, &osz);\n+\ticonv_close(conv);\n+\tv = (unsigned char)(out[0]) + (unsigned char)(out[1]);\n+\treturn v != 0xfe + 0xff;\n+}\"\n+ICONV_DOESNOT_OMIT_BOM)\n+if(NOT ICONV_DOESNOT_OMIT_BOM)\n+\tadd_compile_definitions(ICONV_OMITS_BOM)\n+endif()\n+\n+unset(CMAKE_REQUIRED_LIBRARIES)\n+unset(CMAKE_REQUIRED_INCLUDES)\n+\n+\n+#programs\n+set(PROGRAMS_BUILT\n+\tgit git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst\n+\tgit-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)\n+\n+if(NOT CURL_FOUND)\n+\tlist(APPEND excluded_progs git-http-fetch git-http-push)\n+\tadd_compile_definitions(NO_CURL)\n+\tmessage(WARNING \"git-http-push and git-http-fetch will not be built\")\n+else()\n+\tlist(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)\n+\tif(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)\n+\t\tadd_compile_definitions(USE_CURL_FOR_IMAP_SEND)\n+\tendif()\n+endif()\n+\n+if(NOT EXPAT_FOUND)\n+\tlist(APPEND excluded_progs git-http-push)\n+\tadd_compile_definitions(NO_EXPAT)\n+else()\n+\tlist(APPEND PROGRAMS_BUILT git-http-push)\n+\tif(EXPAT_VERSION_STRING VERSION_LESS_EQUAL 1.2)\n+\t\tadd_compile_definitions(EXPAT_NEEDS_XMLPARSE_H)\n+\tendif()\n+endif()\n+\n+list(REMOVE_DUPLICATES excluded_progs)\n+list(REMOVE_DUPLICATES PROGRAMS_BUILT)\n+\n+\n+foreach(p ${excluded_progs})\n+\tlist(APPEND EXCLUSION_PROGS --exclude-program ${p} )\n+endforeach()\n+\n+#for comparing null values\n+list(APPEND EXCLUSION_PROGS empty)\n+set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING \"Programs not built\" FORCE)\n+\n+if(NOT EXISTS ${CMAKE_BINARY_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)\n+\tlist(REMOVE_ITEM EXCLUSION_PROGS empty)\n+\tmessage(\"Generating command-list.h\")\n+\texecute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt\n+\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n+\t\t\tOUTPUT_FILE ${CMAKE_BINARY_DIR}/command-list.h)\n+endif()\n+\n+if(NOT EXISTS ${CMAKE_BINARY_DIR}/config-list.h)\n+\tmessage(\"Generating config-list.h\")\n+\texecute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh\n+\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n+\t\t\tOUTPUT_FILE ${CMAKE_BINARY_DIR}/config-list.h)\n+endif()\n+\n+include_directories(${CMAKE_BINARY_DIR})\n+\n+#build\n+#libgit\n+parse_makefile_for_sources(libgit_SOURCES \"LIB_OBJS\")\n+\n+list(TRANSFORM libgit_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n+list(TRANSFORM compat_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n+add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})\n+\n+#libxdiff\n+parse_makefile_for_sources(libxdiff_SOURCES \"XDIFF_OBJS\")\n+\n+list(TRANSFORM libxdiff_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n+add_library(xdiff STATIC ${libxdiff_SOURCES})\n+\n+#libvcs-svn\n+parse_makefile_for_sources(libvcs-svn_SOURCES \"VCSSVN_OBJS\")\n+\n+list(TRANSFORM libvcs-svn_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n+add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})\n+\n+#link all required libraries to common-main\n+add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)\n+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)\n+if(Intl_FOUND)\n+\ttarget_link_libraries(common-main ${Intl_LIBRARIES})\n+endif()\n+if(Iconv_FOUND)\n+\ttarget_link_libraries(common-main ${Iconv_LIBRARIES})\n+endif()\n+\n+#git\n+parse_makefile_for_sources(git_SOURCES \"BUILTIN_OBJS\")\n+\n+list(TRANSFORM git_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n+add_executable(git ${CMAKE_SOURCE_DIR}/git.c ${git_SOURCES})\n+target_link_libraries(git common-main)\n+\n+add_executable(git-bugreport ${CMAKE_SOURCE_DIR}/bugreport.c)\n+target_link_libraries(git-bugreport common-main)\n+\n+add_executable(git-credential-store ${CMAKE_SOURCE_DIR}/credential-store.c)\n+target_link_libraries(git-credential-store common-main)\n+\n+add_executable(git-daemon ${CMAKE_SOURCE_DIR}/daemon.c)\n+target_link_libraries(git-daemon common-main)\n+\n+add_executable(git-fast-import ${CMAKE_SOURCE_DIR}/fast-import.c)\n+target_link_libraries(git-fast-import common-main)\n+\n+add_executable(git-http-backend ${CMAKE_SOURCE_DIR}/http-backend.c)\n+target_link_libraries(git-http-backend common-main)\n+\n+add_executable(git-sh-i18n--envsubst ${CMAKE_SOURCE_DIR}/sh-i18n--envsubst.c)\n+target_link_libraries(git-sh-i18n--envsubst common-main)\n+\n+add_executable(git-shell ${CMAKE_SOURCE_DIR}/shell.c)\n+target_link_libraries(git-shell common-main)\n+\n+if(CURL_FOUND)\n+\tadd_library(http_obj OBJECT ${CMAKE_SOURCE_DIR}/http.c)\n+\n+\tadd_executable(git-imap-send ${CMAKE_SOURCE_DIR}/imap-send.c)\n+\ttarget_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})\n+\n+\tadd_executable(git-http-fetch ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/http-fetch.c)\n+\ttarget_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})\n+\n+\tadd_executable(git-remote-http ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/remote-curl.c)\n+\ttarget_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )\n+\n+\tif(EXPAT_FOUND)\n+\t\tadd_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)\n+\t\ttarget_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})\n+\tendif()\n+endif()\n+\n+add_executable(git-remote-testsvn ${CMAKE_SOURCE_DIR}/remote-testsvn.c)\n+target_link_libraries(git-remote-testsvn common-main vcs-svn)\n+\n+add_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)\n+target_link_libraries(git-credential-cache common-main)\n+\n+add_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)\n+target_link_libraries(git-credential-cache--daemon common-main)\n+\n+\n+set(git_builtin_extra\n+\tcherry cherry-pick format-patch fsck-objects\n+\tinit merge-subtree restore show\n+\tstage status switch whatchanged)\n+\n+#Creating hardlinks\n+foreach(s ${git_SOURCES} ${git_builtin_extra})\n+\tstring(REPLACE \"${CMAKE_SOURCE_DIR}/builtin/\" \"\" s ${s})\n+\tstring(REPLACE \".c\" \"\" s ${s})\n+\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git git-${s})\\n\")\n+\tlist(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})\n+endforeach()\n+\n+if(CURL_FOUND)\n+\tset(remote_exes\n+\t\tgit-remote-https git-remote-ftp git-remote-ftps)\n+\tforeach(s ${remote_exes})\n+\t\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git-remote-http ${s})\\n\")\n+\t\tlist(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})\n+\tendforeach()\n+endif()\n+\n+add_custom_command(OUTPUT ${git_links} ${git_http_links}\n+\t\tCOMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake\n+\t\tDEPENDS git git-remote-http)\n+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})\n-- \ngitgitgadget\n\n"},{"id":"398881","messageId":"6ec73d3e967f41fe145e092e542235e3bf1b9869.1590759624.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v3.git.1590759624.gitgitgadget@gmail.com","subject":"[PATCH v3 3/8] cmake: installation support for git","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-05-29T13:40:19Z","receivedAt":"2020-05-29T13:40:32Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nInstall the built binaries and scripts using CMake\n\nThis is very similar to `make install`.\nBy default the destination directory(DESTDIR) is /usr/local/ on Linux\nTo set a custom installation path do this:\ncmake `relative-path-to-srcdir`\n\t-DCMAKE_INSTALL_PREFIX=`preferred-install-path`\n\nThen run `make install`\n\nChanges:\nRemoved a comment regarding the installation of gitk.\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n contrib/buildsystems/CMakeLists.txt | 49 +++++++++++++++++++++++++++++\n 1 file changed, 49 insertions(+)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 11c909d23e3..0cde1a02cbc 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -57,6 +57,8 @@ project(git\n \tVERSION ${git_version}\n \tLANGUAGES C)\n \n+#TODO gitk git-gui gitweb\n+#TODO Add pcre support\n \n #macros for parsing the Makefile for sources and scripts\n macro(parse_makefile_for_sources list_var regex)\n@@ -682,3 +684,50 @@ if(MSGFMT_EXE)\n \tendforeach()\n \tadd_custom_target(po-gen ALL DEPENDS ${po_gen})\n endif()\n+\n+\n+#to help with the install\n+list(TRANSFORM git_shell_scripts PREPEND \"${CMAKE_BINARY_DIR}/\")\n+list(TRANSFORM git_perl_scripts PREPEND \"${CMAKE_BINARY_DIR}/\")\n+\n+#install\n+install(TARGETS git git-shell\n+\tRUNTIME DESTINATION bin)\n+install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver\n+\tDESTINATION bin)\n+\n+list(REMOVE_ITEM PROGRAMS_BUILT git git-shell)\n+install(TARGETS ${PROGRAMS_BUILT}\n+\tRUNTIME DESTINATION libexec/git-core)\n+\n+set(bin_links\n+\tgit-receive-pack git-upload-archive git-upload-pack)\n+\n+foreach(b ${bin_links})\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})\")\n+endforeach()\n+\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)\")\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)\")\n+\n+foreach(b ${git_links})\n+\tstring(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n+\tinstall(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n+endforeach()\n+\n+foreach(b ${git_http_links})\n+\tstring(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n+\tinstall(CODE \"file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n+endforeach()\n+\n+install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4\n+\tDESTINATION libexec/git-core)\n+\n+install(DIRECTORY ${CMAKE_SOURCE_DIR}/mergetools DESTINATION libexec/git-core)\n+install(DIRECTORY ${CMAKE_BINARY_DIR}/perl/build/lib/ DESTINATION share/perl5\n+\tFILES_MATCHING PATTERN \"*.pm\")\n+install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/templates)\n+\n+if(MSGFMT_EXE)\n+\tinstall(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)\n+endif()\n-- \ngitgitgadget\n\n"},{"id":"398885","messageId":"f19794fdbc09cc3c57392dc522920f7b01691d88.1590759624.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v3.git.1590759624.gitgitgadget@gmail.com","subject":"[PATCH v3 2/8] cmake: generate the shell/perl/python scripts and templates, translations","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-05-29T13:40:18Z","receivedAt":"2020-05-29T13:40:33Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nImplement the placeholder substitution to generate scripted\nPorcelain commands, e.g. git-request-pull out of\ngit-request-pull.sh\n\nGenerate shell/perl/python scripts and template using CMake instead of\nusing sed like the build procedure in the Makefile does.\n\nThe text translations are only build if `msgfmt` is found in your path.\n\nNOTE: The scripts and templates are generated during configuration.\n\nChanges\nThe CMake script parses the Makefile for:\nSCRIPT_SH\nSCRIPT_PERL\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n contrib/buildsystems/CMakeLists.txt | 111 +++++++++++++++++++++++++++-\n 1 file changed, 110 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 8e2b27f44a6..11c909d23e3 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -58,7 +58,7 @@ project(git\n \tLANGUAGES C)\n \n \n-#macros for parsing the Makefile for sources\n+#macros for parsing the Makefile for sources and scripts\n macro(parse_makefile_for_sources list_var regex)\n \tfile(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX \"^${regex} \\\\+=(.*)\")\n \tstring(REPLACE \"${regex} +=\" \"\" ${list_var} ${${list_var}})\n@@ -69,6 +69,14 @@ macro(parse_makefile_for_sources list_var regex)\n \tlist(REMOVE_ITEM ${list_var} \"\") #remove empty list elements\n endmacro()\n \n+macro(parse_makefile_for_scripts list_var regex lang)\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX \"^${regex} \\\\+=(.*)\")\n+\tstring(REPLACE \"${regex} +=\" \"\" ${list_var} ${${list_var}})\n+\tstring(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces\n+\tstring(REPLACE \" \" \";\" ${list_var} ${${list_var}}) #convert string to a list\n+\tlist(TRANSFORM ${list_var} REPLACE \"${lang}\" \"\") #do the replacement\n+endmacro()\n+\n include(CheckTypeSize)\n include(CheckCSourceRuns)\n include(CheckCSourceCompiles)\n@@ -104,6 +112,11 @@ if(Intl_FOUND)\n \tinclude_directories(SYSTEM ${Intl_INCLUDE_DIRS})\n endif()\n \n+find_program(MSGFMT_EXE msgfmt)\n+if(NOT MSGFMT_EXE)\n+\tmessage(WARNING \"Text Translations won't be build\")\n+endif()\n+\n #default behaviour\n include_directories(${CMAKE_SOURCE_DIR})\n add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n@@ -573,3 +586,99 @@ add_custom_command(OUTPUT ${git_links} ${git_http_links}\n \t\tCOMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake\n \t\tDEPENDS git git-remote-http)\n add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})\n+\n+\n+#creating required scripts\n+set(SHELL_PATH /bin/sh)\n+set(PERL_PATH /usr/bin/perl)\n+set(LOCALEDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)\n+set(GITWEBDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)\n+set(INSTLIBDIR ${FALLBACK_RUNTIME_PREFIX}/share/perl5)\n+\n+#shell scripts\n+parse_makefile_for_scripts(git_sh_scripts \"SCRIPT_SH\" \".sh\")\n+set(git_shell_scripts\n+\t${git_sh_scripts}\n+\tgit-mergetool--lib git-parse-remote git-rebase--preserve-merges\n+\tgit-sh-setup git-sh-i18n git-instaweb)\n+\n+foreach(script ${git_shell_scripts})\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/${script}.sh content NEWLINE_CONSUME)\n+\tstring(REPLACE \"@SHELL_PATH@\" \"${SHELL_PATH}\" content \"${content}\")\n+\tstring(REPLACE \"@@DIFF@@\" \"diff\" content \"${content}\")\n+\tstring(REPLACE \"@LOCALEDIR@\" \"${LOCALEDIR}\" content \"${content}\")\n+\tstring(REPLACE \"@GITWEBDIR@\" \"${GITWEBDIR}\" content \"${content}\")\n+\tstring(REPLACE \"@@NO_CURL@@\" \"\" content \"${content}\")\n+\tstring(REPLACE \"@@USE_GETTEXT_SCHEME@@\" \"\" content \"${content}\")\n+\tstring(REPLACE \"# @@BROKEN_PATH_FIX@@\" \"\" content \"${content}\")\n+\tstring(REPLACE \"@@PERL@@\" \"${PERL_PATH}\" content \"${content}\")\n+\tstring(REPLACE \"@@SANE_TEXT_GREP@@\" \"-a\" content \"${content}\")\n+\tstring(REPLACE \"@@PAGER_ENV@@\" \"LESS=FRX LV=-c\" content \"${content}\")\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})\n+endforeach()\n+\n+#perl scripts\n+parse_makefile_for_scripts(git_perl_scripts \"SCRIPT_PERL\" \".perl\")\n+\n+#create perl header\n+file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )\n+string(REPLACE \"@@PATHSEP@@\" \":\" perl_header \"${perl_header}\")\n+string(REPLACE \"@@INSTLIBDIR@@\" \"${INSTLIBDIR}\" perl_header \"${perl_header}\")\n+\n+foreach(script ${git_perl_scripts})\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/${script}.perl content NEWLINE_CONSUME)\n+\tstring(REPLACE \"#!/usr/bin/perl\" \"#!/usr/bin/perl\\n${perl_header}\\n\" content \"${content}\")\n+\tstring(REPLACE \"@@GIT_VERSION@@\" \"${PROJECT_VERSION}\" content \"${content}\")\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})\n+endforeach()\n+\n+#python script\n+file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)\n+string(REPLACE \"#!/usr/bin/env python\" \"#!/usr/bin/python\" content \"${content}\")\n+file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})\n+\n+#perl modules\n+file(GLOB_RECURSE perl_modules \"${CMAKE_SOURCE_DIR}/perl/*.pm\")\n+\n+foreach(pm ${perl_modules})\n+\tstring(REPLACE \"${CMAKE_SOURCE_DIR}/perl/\" \"\" file_path ${pm})\n+\tfile(STRINGS ${pm} content NEWLINE_CONSUME)\n+\tstring(REPLACE \"@@LOCALEDIR@@\" \"${LOCALEDIR}\" content \"${content}\")\n+\tstring(REPLACE \"@@NO_PERL_CPAN_FALLBACKS@@\" \"\" content \"${content}\")\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})\n+#test-lib.sh requires perl/build/lib to be the build directory of perl modules\n+endforeach()\n+\n+\n+#templates\n+file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches\n+set(hooks_templates\n+\tapplypatch-msg.sample pre-applypatch.sample pre-push.sample\n+\tcommit-msg.sample pre-commit.sample pre-rebase.sample\n+\tfsmonitor-watchman.sample pre-merge-commit.sample pre-receive.sample\n+\tpost-update.sample prepare-commit-msg.sample update.sample)\n+\n+#templates have @.*@ replacement so use configure_file instead\n+#hooks\n+foreach(tm ${hooks_templates})\n+\tconfigure_file(${CMAKE_SOURCE_DIR}/templates/hooks--${tm} ${CMAKE_BINARY_DIR}/templates/blt/hooks/${tm} @ONLY)\n+endforeach()\n+\n+#info\n+configure_file(${CMAKE_SOURCE_DIR}/templates/info--exclude ${CMAKE_BINARY_DIR}/templates/blt/info/exclude @ONLY)\n+\n+#this\n+configure_file(${CMAKE_SOURCE_DIR}/templates/this--description ${CMAKE_BINARY_DIR}/templates/blt/description @ONLY)\n+\n+\n+#translations\n+if(MSGFMT_EXE)\n+\tset(po_files bg  ca  de  el  es  fr  is  it  ko  pt_PT  ru  sv  tr  vi  zh_CN  zh_TW)\n+\tforeach(po ${po_files})\n+\t\tfile(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES)\n+\t\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo\n+\t\t\t\tCOMMAND ${MSGFMT_EXE} --check --statistics -o ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo ${CMAKE_SOURCE_DIR}/po/${po}.po)\n+\t\tlist(APPEND po_gen ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo)\n+\tendforeach()\n+\tadd_custom_target(po-gen ALL DEPENDS ${po_gen})\n+endif()\n-- \ngitgitgadget\n\n"},{"id":"398882","messageId":"cdc53172b3f073095911fe9f7f5ff8ea6546013c.1590759624.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v3.git.1590759624.gitgitgadget@gmail.com","subject":"[PATCH v3 4/8] cmake: support for testing git with ctest","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-05-29T13:40:20Z","receivedAt":"2020-05-29T13:40:35Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThis patch provides an alternate way to test git using ctest.\nCTest ships with CMake, so there is no additional dependency being\nintroduced.\n\nTo perform the tests with ctest do this after building:\nctest -j[number of jobs]\n\nNOTE: -j is optional, the default number of jobs is 1\n\nEach of the jobs does this:\ncd t/ && sh t[something].sh\n\nThe reason for using CTest is that it logs the output of the tests\nin a neat way, which can be helpful during diagnosis of failures.\n\nAfter the tests have run ctest generates three log files located in\n`build-directory`/Testing/Temporary/\n\nThese log files are:\n\nCTestCostData.txt:\nThis file contains the time taken to complete each test.\n\nLastTestsFailed.log:\nThis log file contains the names of the tests that have failed in the\nrun.\n\nLastTest.log:\nThis log file contains the log of all the tests that have run.\nA snippet of the file is given below.\n\n10/901 Testing: D:/my/git-master/t/t0009-prio-queue.sh\n10/901 Test: D:/my/git-master/t/t0009-prio-queue.sh\nCommand: \"sh.exe\" \"D:/my/git-master/t/t0009-prio-queue.sh\"\nDirectory: D:/my/git-master/t\n\"D:/my/git-master/t/t0009-prio-queue.sh\"\nOutput:\n----------------------------------------------------------\nok 1 - basic ordering\nok 2 - mixed put and get\nok 3 - notice empty queue\nok 4 - stack order\npassed all 4 test(s)\n1..4\n<end of output>\nTest time =   1.11 sec\n\nNOTE: Testing only works when building in source for now.\n\nChanges:\nRenamed the variable test_helper_sources to test-tool_SOURCES\nto be consistent with the naming of source variables.\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n contrib/buildsystems/CMakeLists.txt | 124 ++++++++++++++++++++++++++++\n 1 file changed, 124 insertions(+)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 0cde1a02cbc..33a3559eb8c 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -86,6 +86,7 @@ include(CheckIncludeFile)\n include(CheckFunctionExists)\n include(CheckSymbolExists)\n include(CheckStructHasMember)\n+include(CTest)\n \n find_package(ZLIB REQUIRED)\n find_package(CURL)\n@@ -731,3 +732,126 @@ install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/\n if(MSGFMT_EXE)\n \tinstall(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)\n endif()\n+\n+\n+if(BUILD_TESTING)\n+\n+#tests-helpers\n+add_executable(test-fake-ssh ${CMAKE_SOURCE_DIR}/t/helper/test-fake-ssh.c)\n+target_link_libraries(test-fake-ssh common-main)\n+\n+add_executable(test-line-buffer ${CMAKE_SOURCE_DIR}/t/helper/test-line-buffer.c)\n+target_link_libraries(test-line-buffer common-main vcs-svn)\n+\n+add_executable(test-svn-fe ${CMAKE_SOURCE_DIR}/t/helper/test-svn-fe.c)\n+target_link_libraries(test-svn-fe common-main vcs-svn)\n+\n+#test-tool\n+parse_makefile_for_sources(test-tool_SOURCES \"TEST_BUILTINS_OBJS\")\n+\n+list(TRANSFORM test-tool_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/t/helper/\")\n+add_executable(test-tool ${CMAKE_SOURCE_DIR}/t/helper/test-tool.c ${test-tool_SOURCES})\n+target_link_libraries(test-tool common-main)\n+\n+set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool\n+\t\t\tPROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)\n+\n+#wrapper scripts\n+set(wrapper_scripts\n+\tgit git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)\n+\n+set(wrapper_test_scripts\n+\ttest-fake-ssh test-line-buffer test-svn-fe test-tool)\n+\n+\n+foreach(script ${wrapper_scripts})\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n+\tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n+\tstring(REPLACE \"@@PROG@@\" \"${script}\" content \"${content}\")\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n+endforeach()\n+\n+foreach(script ${wrapper_test_scripts})\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n+\tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n+\tstring(REPLACE \"@@PROG@@\" \"t/helper/${script}\" content \"${content}\")\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n+endforeach()\n+\n+file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n+string(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n+string(REPLACE \"@@PROG@@\" \"git-cvsserver\" content \"${content}\")\n+file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})\n+\n+#options for configuring test options\n+option(PERL_TESTS \"Perform tests that use perl\" ON)\n+option(PYTHON_TESTS \"Perform tests that use python\" ON)\n+\n+#GIT-BUILD-OPTIONS\n+set(TEST_SHELL_PATH ${SHELL_PATH})\n+set(DIFF diff)\n+set(PYTHON_PATH /usr/bin/python)\n+set(TAR tar)\n+set(NO_CURL )\n+set(NO_EXPAT )\n+set(USE_LIBPCRE1 )\n+set(USE_LIBPCRE2 )\n+set(NO_LIBPCRE1_JIT )\n+set(NO_PERL )\n+set(NO_PTHREADS )\n+set(NO_PYTHON )\n+set(PAGER_ENV \"LESS=FRX LV=-c\")\n+set(DC_SHA1 YesPlease)\n+set(RUNTIME_PREFIX true)\n+set(NO_GETTEXT )\n+\n+if(NOT CURL_FOUND)\n+\tset(NO_CURL 1)\n+endif()\n+\n+if(NOT EXPAT_FOUND)\n+\tset(NO_EXPAT 1)\n+endif()\n+\n+if(NOT Intl_FOUND)\n+\tset(NO_GETTEXT 1)\n+endif()\n+\n+if(NOT PERL_TESTS)\n+\tset(NO_PERL 1)\n+endif()\n+\n+if(NOT PYTHON_TESTS)\n+\tset(NO_PYTHON 1)\n+endif()\n+\n+file(WRITE ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"SHELL_PATH='${SHELL_PATH}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"TEST_SHELL_PATH='${TEST_SHELL_PATH}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PERL_PATH='${PERL_PATH}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"DIFF='${DIFF}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PYTHON_PATH='${PYTHON_PATH}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"TAR='${TAR}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_CURL='${NO_CURL}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_EXPAT='${NO_EXPAT}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"USE_LIBPCRE1='${USE_LIBPCRE1}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_LIBPCRE1_JIT='${NO_LIBPCRE1_JIT}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PERL='${NO_PERL}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PTHREADS='${NO_PTHREADS}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PAGER_ENV='${PAGER_ENV}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"DC_SHA1='${DC_SHA1}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"X=''\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_GETTEXT='${NO_GETTEXT}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"RUNTIME_PREFIX='${RUNTIME_PREFIX}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PYTHON='${NO_PYTHON}'\\n\")\n+\n+file(GLOB test_scipts \"${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh\")\n+\n+#test\n+foreach(tsh ${test_scipts})\n+\tadd_test(NAME ${tsh}\n+\t\tCOMMAND ${SH_EXE} ${tsh}\n+\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t)\n+endforeach()\n+\n+endif()#BUILD_TESTING\n-- \ngitgitgadget\n\n"},{"id":"398883","messageId":"f41cbd430813e098faa0b139cc95ca877d421e91.1590759624.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v3.git.1590759624.gitgitgadget@gmail.com","subject":"[PATCH v3 6/8] cmake: support for building git on windows with mingw","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-05-29T13:40:22Z","receivedAt":"2020-05-29T13:40:36Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThis patch facilitates building git on Windows with CMake using MinGW\n\nNOTE: The funtions unsetenv and hstrerror are not checked in Windows\nbuilds.\nReasons\nNO_UNSETENV is not compatible with Windows builds.\nlines 262-264 compat/mingw.h\n\ncompat/mingw.h(line 25) provides a definition of hstrerror which\nconflicts with the definition provided in\ngit-compat-util.h(lines 733-736).\n\nTo use CMake on Windows with MinGW do this:\ncmake `relative-path-to-srcdir` -G \"MinGW Makefiles\"\n\nChanges:\nChanged the error message when sh.exe is not found on Windows as\nsuggested by Philip Oakley <philipoakley@iee.email>\n\nv2:\nFixed a bug where a Windows user can pose as Linux user and vice versa.\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n contrib/buildsystems/CMakeLists.txt | 121 ++++++++++++++++++++++------\n 1 file changed, 98 insertions(+), 23 deletions(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex ea26f4612d3..46197d0b806 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -34,6 +34,10 @@ cmake_minimum_required(VERSION 3.14)\n set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n \n find_program(SH_EXE sh)\n+if(NOT SH_EXE)\n+\tmessage(FATAL_ERROR \"sh: shell interpreter was not found in your path, please install one.\"\n+\t\t\t\"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n+endif()\n \n #Create GIT-VERSION-FILE using GIT-VERSION-GEN\n if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)\n@@ -57,7 +61,9 @@ project(git\n \tVERSION ${git_version}\n \tLANGUAGES C)\n \n+\n #TODO gitk git-gui gitweb\n+#TODO Enable NLS on windows natively\n #TODO Add pcre support\n \n #macros for parsing the Makefile for sources and scripts\n@@ -94,6 +100,7 @@ find_package(EXPAT)\n find_package(Iconv)\n find_package(Intl)\n \n+\n if(NOT Intl_FOUND)\n \tadd_compile_definitions(NO_GETTEXT)\n \tif(NOT Iconv_FOUND)\n@@ -115,6 +122,14 @@ if(Intl_FOUND)\n \tinclude_directories(SYSTEM ${Intl_INCLUDE_DIRS})\n endif()\n \n+\n+if(WIN32)\n+\tfind_program(WINDRES_EXE windres)\n+\tif(NOT WINDRES_EXE)\n+\t\tmessage(FATAL_ERROR \"Install windres on Windows for resource files\")\n+\tendif()\n+endif()\n+\n find_program(MSGFMT_EXE msgfmt)\n if(NOT MSGFMT_EXE)\n \tmessage(WARNING \"Text Translations won't be build\")\n@@ -146,11 +161,39 @@ add_compile_definitions(PAGER_ENV=\"LESS=FRX LV=-c\"\n \t\t\tBINDIR=\"bin\"\n \t\t\tGIT_BUILT_FROM_COMMIT=\"\")\n \n-set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n-add_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n+if(WIN32)\n+\tset(FALLBACK_RUNTIME_PREFIX /mingw64)\n+\tadd_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n+else()\n+\tset(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n+\tadd_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n+endif()\n \n-add_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n-list(APPEND compat_SOURCES unix-socket.c)\n+\n+#Platform Specific\n+if(CMAKE_SYSTEM_NAME STREQUAL \"Windows\")\n+\tinclude_directories(${CMAKE_SOURCE_DIR}/compat/win32)\n+\tadd_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32\n+\t\t\t\t_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=\".exe\"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT\n+\t\t\t\tNOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0\n+\t\t\t\tUSE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP\n+\t\t\t\tUNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)\n+\tlist(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c\n+\t\tcompat/win32/pthread.c compat/win32mmap.c compat/win32/syslog.c\n+\t\tcompat/win32/trace2_win32_process_info.c compat/win32/dirent.c\n+\t\tcompat/nedmalloc/nedmalloc.c compat/strdup.c)\n+\tset(NO_UNIX_SOCKETS 1)\n+\n+elseif(CMAKE_SYSTEM_NAME STREQUAL \"Linux\")\n+\tadd_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n+\tlist(APPEND compat_SOURCES unix-socket.c)\n+endif()\n+\n+if(WIN32)\n+\tset(EXE_EXTENSION .exe)\n+else()\n+\tset(EXE_EXTENSION)\n+endif()\n \n #header checks\n check_include_file(libgen.h HAVE_LIBGEN_H)\n@@ -211,7 +254,12 @@ endif()\n #function checks\n set(function_checks\n \tstrcasestr memmem strlcpy strtoimax strtoumax strtoull\n-\tsetenv mkdtemp poll pread memmem unsetenv hstrerror)\n+\tsetenv mkdtemp poll pread memmem)\n+\n+#unsetenv,hstrerror are incompatible with windows build\n+if(NOT WIN32)\n+\tlist(APPEND function_checks unsetenv hstrerror)\n+endif()\n \n foreach(f ${function_checks})\n \tstring(TOUPPER ${f} uf)\n@@ -425,7 +473,13 @@ unset(CMAKE_REQUIRED_INCLUDES)\n #programs\n set(PROGRAMS_BUILT\n \tgit git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst\n-\tgit-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)\n+\tgit-shell git-remote-testsvn)\n+\n+if(NO_UNIX_SOCKETS)\n+\tlist(APPEND excluded_progs git-credential-cache git-credential-cache--daemon)\n+else()\n+\tlist(APPEND PROGRAMS_BUILT git-credential-cache git-credential-cache--daemon)\n+endif()\n \n if(NOT CURL_FOUND)\n \tlist(APPEND excluded_progs git-http-fetch git-http-push)\n@@ -497,15 +551,34 @@ parse_makefile_for_sources(libvcs-svn_SOURCES \"VCSSVN_OBJS\")\n list(TRANSFORM libvcs-svn_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})\n \n+#add git.rc for gcc\n+if(WIN32)\n+\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n+\t\t\tCOMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}\n+\t\t\t\t-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION=\"\\\\\\\"${PROJECT_VERSION}.GIT\\\\\\\"\"\n+\t\t\t\t-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res\n+\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n+\t\t\tVERBATIM)\n+\tadd_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)\n+endif()\n+\n #link all required libraries to common-main\n add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)\n-target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)\n+\n+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})\n if(Intl_FOUND)\n \ttarget_link_libraries(common-main ${Intl_LIBRARIES})\n endif()\n if(Iconv_FOUND)\n \ttarget_link_libraries(common-main ${Iconv_LIBRARIES})\n endif()\n+if(WIN32)\n+\ttarget_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)\n+\tadd_dependencies(common-main git-rc)\n+\ttarget_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)\n+elseif(UNIX)\n+\ttarget_link_libraries(common-main pthread rt)\n+endif()\n \n #git\n parse_makefile_for_sources(git_SOURCES \"BUILTIN_OBJS\")\n@@ -556,11 +629,13 @@ endif()\n add_executable(git-remote-testsvn ${CMAKE_SOURCE_DIR}/remote-testsvn.c)\n target_link_libraries(git-remote-testsvn common-main vcs-svn)\n \n-add_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)\n-target_link_libraries(git-credential-cache common-main)\n+if(NOT NO_UNIX_SOCKETS)\n+\tadd_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)\n+\ttarget_link_libraries(git-credential-cache common-main)\n \n-add_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)\n-target_link_libraries(git-credential-cache--daemon common-main)\n+\tadd_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)\n+\ttarget_link_libraries(git-credential-cache--daemon common-main)\n+endif()\n \n \n set(git_builtin_extra\n@@ -572,16 +647,16 @@ set(git_builtin_extra\n foreach(s ${git_SOURCES} ${git_builtin_extra})\n \tstring(REPLACE \"${CMAKE_SOURCE_DIR}/builtin/\" \"\" s ${s})\n \tstring(REPLACE \".c\" \"\" s ${s})\n-\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git git-${s})\\n\")\n-\tlist(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})\n+\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git${EXE_EXTENSION} git-${s}${EXE_EXTENSION})\\n\")\n+\tlist(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s}${EXE_EXTENSION})\n endforeach()\n \n if(CURL_FOUND)\n \tset(remote_exes\n \t\tgit-remote-https git-remote-ftp git-remote-ftps)\n \tforeach(s ${remote_exes})\n-\t\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git-remote-http ${s})\\n\")\n-\t\tlist(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})\n+\t\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git-remote-http${EXE_EXTENSION} ${s}${EXE_EXTENSION})\\n\")\n+\t\tlist(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s}${EXE_EXTENSION})\n \tendforeach()\n endif()\n \n@@ -705,20 +780,20 @@ set(bin_links\n \tgit-receive-pack git-upload-archive git-upload-pack)\n \n foreach(b ${bin_links})\n-install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})\")\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/bin/${b}${EXE_EXTENSION})\")\n endforeach()\n \n-install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)\")\n-install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)\")\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git${EXE_EXTENSION})\")\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell${EXE_EXTENSION})\")\n \n foreach(b ${git_links})\n \tstring(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n-\tinstall(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n+\tinstall(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})\")\n endforeach()\n \n foreach(b ${git_http_links})\n \tstring(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n-\tinstall(CODE \"file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n+\tinstall(CODE \"file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})\")\n endforeach()\n \n install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4\n@@ -767,14 +842,14 @@ set(wrapper_test_scripts\n foreach(script ${wrapper_scripts})\n \tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n \tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n-\tstring(REPLACE \"@@PROG@@\" \"${script}\" content \"${content}\")\n+\tstring(REPLACE \"@@PROG@@\" \"${script}${EXE_EXTENSION}\" content \"${content}\")\n \tfile(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n endforeach()\n \n foreach(script ${wrapper_test_scripts})\n \tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n \tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n-\tstring(REPLACE \"@@PROG@@\" \"t/helper/${script}\" content \"${content}\")\n+\tstring(REPLACE \"@@PROG@@\" \"t/helper/${script}${EXE_EXTENSION}\" content \"${content}\")\n \tfile(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n endforeach()\n \n@@ -840,7 +915,7 @@ 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\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PAGER_ENV='${PAGER_ENV}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"DC_SHA1='${DC_SHA1}'\\n\")\n-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"X=''\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"X='${EXE_EXTENSION}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_GETTEXT='${NO_GETTEXT}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"RUNTIME_PREFIX='${RUNTIME_PREFIX}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PYTHON='${NO_PYTHON}'\\n\")\n-- \ngitgitgadget\n\n"},{"id":"398884","messageId":"cdc68f102cb6e5c3eb19d771fee509a8166fa495.1590759624.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v3.git.1590759624.gitgitgadget@gmail.com","subject":"[PATCH v3 5/8] cmake: support for testing git when building out of the source tree","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-05-29T13:40:21Z","receivedAt":"2020-05-29T13:40:37Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThis patch allows git to be tested when performin out of source builds.\n\nThis involves changing GIT_BUILD_DIR in t/test-lib.sh to point to the\nbuild directory. Also some miscellaneous copies from the source directory\nto the build directory.\nThe copies are:\nt/chainlint.sed needed by a bunch of test scripts\npo/is.po needed by t0204-gettext-rencode-sanity\nmergetools/tkdiff needed by t7800-difftool\ncontrib/completion/git-prompt.sh needed by t9903-bash-prompt\ncontrib/completion/git-completion.bash needed by t9902-completion\ncontrib/svn-fe/svnrdump_sim.py needed by t9020-remote-svn\n\nNOTE: t/test-lib.sh is only modified when tests are run not during\nthe build or configure.\nThe trash directory is still srcdir/t\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n contrib/buildsystems/CMakeLists.txt | 20 ++++++++++++++++++++\n 1 file changed, 20 insertions(+)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 33a3559eb8c..ea26f4612d3 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -845,6 +845,26 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_GETTEXT='${NO_GETTEXT}'\\n\"\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"RUNTIME_PREFIX='${RUNTIME_PREFIX}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PYTHON='${NO_PYTHON}'\\n\")\n \n+#Make the tests work when building out of the source tree\n+get_filename_component(CACHE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../CMakeCache.txt ABSOLUTE)\n+if(NOT ${CMAKE_BINARY_DIR}/CMakeCache.txt STREQUAL ${CACHE_PATH})\n+\tfile(RELATIVE_PATH BUILD_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/CMakeCache.txt)\n+\tstring(REPLACE \"/CMakeCache.txt\" \"\" BUILD_DIR_RELATIVE ${BUILD_DIR_RELATIVE})\n+\t#Setting the build directory in test-lib.sh before running tests\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.cmake\n+\t\t\"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh GIT_BUILD_DIR_REPL REGEX \\\"GIT_BUILD_DIR=(.*)\\\")\\n\"\n+\t\t\"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh content NEWLINE_CONSUME)\\n\"\n+\t\t\"string(REPLACE \\\"\\${GIT_BUILD_DIR_REPL}\\\" \\\"GIT_BUILD_DIR=\\\\\\\"$TEST_DIRECTORY\\\\\\\"/../${BUILD_DIR_RELATIVE}\\\" content \\\"\\${content}\\\")\\n\"\n+\t\t\"file(WRITE ${CMAKE_SOURCE_DIR}/t/test-lib.sh \\${content})\")\n+\t#misc copies\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.sed DESTINATION ${CMAKE_BINARY_DIR}/t/)\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/po/is.po DESTINATION ${CMAKE_BINARY_DIR}/po/)\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/mergetools/tkdiff DESTINATION ${CMAKE_BINARY_DIR}/mergetools/)\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-prompt.sh DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-completion.bash DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/contrib/svn-fe/svnrdump_sim.py DESTINATION ${CMAKE_BINARY_DIR}/contrib/svn-fe/)\n+endif()\n+\n file(GLOB test_scipts \"${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh\")\n \n #test\n-- \ngitgitgadget\n\n"},{"id":"398886","messageId":"8f36e30cd2218fa56fb0c2b89f6f51726b0eb285.1590759624.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v3.git.1590759624.gitgitgadget@gmail.com","subject":"[PATCH v3 7/8] cmake: support for building git on windows with msvc and clang.","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-05-29T13:40:23Z","receivedAt":"2020-05-29T13:40:39Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThis patch adds support for Visual Studio and Clang builds\n\nThe minimum required version of CMake is upgraded to 3.15 because\nthis version offers proper support for Clang builds on Windows.\n\nLibintl is not searched for when building with Visual Studio or Clang\nbecause there is no binary compatible version available yet.\n\nNOTE: In the link options invalidcontinue.obj has to be included.\nThe reason for this is because by default, Windows calls abort()'s\ninstead of setting errno=EINVAL when invalid arguments are passed to\nstandard functions.\nThis commit explains it in detail:\n4b623d80f73528a632576990ca51e34c333d5dd6\n\nOn Windows the default generator is Visual Studio,so for Visual Studio\nbuilds do this:\n\ncmake `relative-path-to-srcdir`\n\nNOTE: Visual Studio generator is a multi config generator, which means\nthat Debug and Release builds can be done on the same build directory.\n\nFor Clang builds do this:\n\nOn bash\nCC=Clang cmake `relative-path-to-srcdir` -G Ninja\n\t\t-DCMAKE_BUILD_TYPE=[Debug or Release]\n\nOn cmd\nset CC=Clang\ncmake `relative-path-to-srcdir` -G Ninja\n\t\t-DCMAKE_BUILD_TYPE=[Debug or Release]\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n contrib/buildsystems/CMakeLists.txt | 55 +++++++++++++++++++++++------\n 1 file changed, 45 insertions(+), 10 deletions(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 46197d0b806..0a3f711db88 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -98,8 +98,11 @@ find_package(ZLIB REQUIRED)\n find_package(CURL)\n find_package(EXPAT)\n find_package(Iconv)\n-find_package(Intl)\n \n+#Don't use libintl on Windows Visual Studio and Clang builds\n+if(NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL \"MSVC\" OR CMAKE_C_COMPILER_ID STREQUAL \"Clang\")))\n+\tfind_package(Intl)\n+endif()\n \n if(NOT Intl_FOUND)\n \tadd_compile_definitions(NO_GETTEXT)\n@@ -123,7 +126,7 @@ if(Intl_FOUND)\n endif()\n \n \n-if(WIN32)\n+if(WIN32 AND NOT MSVC)#not required for visual studio builds\n \tfind_program(WINDRES_EXE windres)\n \tif(NOT WINDRES_EXE)\n \t\tmessage(FATAL_ERROR \"Install windres on Windows for resource files\")\n@@ -135,6 +138,13 @@ if(NOT MSGFMT_EXE)\n \tmessage(WARNING \"Text Translations won't be build\")\n endif()\n \n+#Force all visual studio outputs to CMAKE_BINARY_DIR\n+if(CMAKE_C_COMPILER_ID STREQUAL \"MSVC\")\n+\tset(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})\n+\tset(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})\n+\tadd_compile_options(/MP)\n+endif()\n+\n #default behaviour\n include_directories(${CMAKE_SOURCE_DIR})\n add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n@@ -172,6 +182,10 @@ endif()\n \n #Platform Specific\n if(CMAKE_SYSTEM_NAME STREQUAL \"Windows\")\n+\tif(CMAKE_C_COMPILER_ID STREQUAL \"MSVC\" OR CMAKE_C_COMPILER_ID STREQUAL \"Clang\")\n+\t\tinclude_directories(${CMAKE_SOURCE_DIR}/compat/vcbuild/include)\n+\t\tadd_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)\n+\tendif()\n \tinclude_directories(${CMAKE_SOURCE_DIR}/compat/win32)\n \tadd_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32\n \t\t\t\t_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=\".exe\"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT\n@@ -551,14 +565,22 @@ parse_makefile_for_sources(libvcs-svn_SOURCES \"VCSSVN_OBJS\")\n list(TRANSFORM libvcs-svn_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})\n \n-#add git.rc for gcc\n if(WIN32)\n-\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n-\t\t\tCOMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}\n-\t\t\t\t-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION=\"\\\\\\\"${PROJECT_VERSION}.GIT\\\\\\\"\"\n-\t\t\t\t-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res\n-\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n-\t\t\tVERBATIM)\n+\tif(NOT MSVC)#use windres when compiling with gcc and clang\n+\t\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n+\t\t\t\tCOMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}\n+\t\t\t\t\t-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION=\"\\\\\\\"${PROJECT_VERSION}.GIT\\\\\\\"\"\n+\t\t\t\t\t-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res\n+\t\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n+\t\t\t\tVERBATIM)\n+\telse()#MSVC use rc\n+\t\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n+\t\t\t\tCOMMAND ${CMAKE_RC_COMPILER} /d MAJOR=${PROJECT_VERSION_MAJOR} /d MINOR=${PROJECT_VERSION_MINOR}\n+\t\t\t\t\t/d MICRO=${PROJECT_VERSION_PATCH} /d PATCHLEVEL=0 /d GIT_VERSION=\"${PROJECT_VERSION}.GIT\"\n+\t\t\t\t\t/fo ${CMAKE_BINARY_DIR}/git.res ${CMAKE_SOURCE_DIR}/git.rc\n+\t\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n+\t\t\t\tVERBATIM)\n+\tendif()\n \tadd_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)\n endif()\n \n@@ -575,7 +597,13 @@ endif()\n if(WIN32)\n \ttarget_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)\n \tadd_dependencies(common-main git-rc)\n-\ttarget_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)\n+\tif(CMAKE_C_COMPILER_ID STREQUAL \"GNU\")\n+\t\ttarget_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)\n+\telseif(CMAKE_C_COMPILER_ID STREQUAL \"Clang\")\n+\t\ttarget_link_options(common-main PUBLIC -municode -Wl,-nxcompat -Wl,-dynamicbase -Wl,-entry:wmainCRTStartup -Wl,invalidcontinue.obj)\n+\telseif(CMAKE_C_COMPILER_ID STREQUAL \"MSVC\")\n+\t\ttarget_link_options(common-main PUBLIC /IGNORE:4217 /IGNORE:4049 /NOLOGO /ENTRY:wmainCRTStartup /SUBSYSTEM:CONSOLE invalidcontinue.obj)\n+\tendif()\n elseif(UNIX)\n \ttarget_link_libraries(common-main pthread rt)\n endif()\n@@ -831,6 +859,13 @@ target_link_libraries(test-tool common-main)\n set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool\n \t\t\tPROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)\n \n+if(MSVC)\n+\tset_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool\n+\t\t\t\tPROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/t/helper)\n+\tset_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool\n+\t\t\t\tPROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/helper)\n+endif()\n+\n #wrapper scripts\n set(wrapper_scripts\n \tgit git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)\n-- \ngitgitgadget\n\n"},{"id":"398888","messageId":"pull.614.v3.git.1590759624.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v2.git.1589302254.gitgitgadget@gmail.com","subject":"[PATCH v3 0/8] CMake build system for git","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-05-29T13:40:16Z","receivedAt":"2020-05-29T13:40:41Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"This is an attempt to build Git using CMake. CMake is cross-platform build\ngenerator which works well on a variety of platforms(primarily Linux and\nWindows). Using CMake we can check whether certain headers exist, certain\nfunctions exist, the required libraries are present and configure the build\naccordingly. Using CMake we can also build and test Git out of source,\nresulting in a clean source tree.\n\nTested platforms\n\nUbuntu 18.04 GCC 7.4 Clang 8.0.1\n\nWindows MinGW GCC 9.2 Clang 9 Visual Studio 2015,2017,2019\n\nChanges:\n\n1) The CMake script has been relocated to contrib/buildsystems 2) The CMake\nscript parses the Makefile for the sources. 3) Philip suggested to change\nthe error message if sh/bash was not found on windows. 4) CMake now tests\nfor ICONV_OMITS_BOM, NO_ST_BLOCKS_IN_STRUCT_STAT\n\nChanges v2: Changes 1,2,4 have been rebased to PATCH 01/xx CMake uses\nGIT-VERSION-GEN to get the version of Git\n\nSibi Siddharthan (8):\n  Introduce CMake support for configuring Git\n  cmake: generate the shell/perl/python scripts and templates,\n    translations\n  cmake: installation support for git\n  cmake: support for testing git with ctest\n  cmake: support for testing git when building out of the source tree\n  cmake: support for building git on windows with mingw\n  cmake: support for building git on windows with msvc and clang.\n  ci: modification of main.yml to use cmake for vs-build job\n\n .github/workflows/main.yml          |  38 +-\n contrib/buildsystems/CMakeLists.txt | 987 ++++++++++++++++++++++++++++\n 2 files changed, 1009 insertions(+), 16 deletions(-)\n create mode 100644 contrib/buildsystems/CMakeLists.txt\n\n\nbase-commit: 90737beb8258c0a99181b6308eef898d77979c71\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-614%2FSibiSiddharthan%2Fgit-og-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-614/SibiSiddharthan/git-og-v3\nPull-Request: https://github.com/gitgitgadget/git/pull/614\n\nRange-diff vs v2:\n\n  1:  70ab1f03dd5 !  1:  09c972de52b Introduce CMake support for configuring Git on Linux\n     @@ Metadata\n      Author: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n      \n       ## Commit message ##\n     -    Introduce CMake support for configuring Git on Linux\n     +    Introduce CMake support for configuring Git\n      \n          At the moment, the recommended way to configure Git's builds is to\n          simply run `make`. If that does not work, the recommended strategy is to\n     @@ Commit message\n          occupies around two gigabytes (!) on disk and downloads about three\n          quarters of a gigabyte worth of Git objects).\n      \n     -    To make this a little less awkward, the Git for Windows project offers\n     -    the `vs/master` branch which has a full Visual Studio solution generated\n     -    and committed. This branch can therefore be used to tinker with Git in\n     -    Visual Studio _without_ having to download the full Git for Windows SDK.\n     -    Unfortunatly, that branch is auto-generated from Git for Windows'\n     -    `master`. If a developer wants to tinker, say, with `pu`, they are out\n     -    of luck.\n     -\n     -    CMake was invented to make this sort of problem go away, by providing a\n     -    more standardized, cross-platform way to configure builds.\n     +    The build infrastructure for Git is written around being able to run\n     +    make, which is not supported natively on Windows.\n     +    To help Windows developers a CMake build script is introduced here.\n      \n          With a working support CMake, developers on Windows need only install\n          CMake, configure their build, load the generated Visual Studio solution\n     @@ Commit message\n          With a CMake script an out of source build of git is possible resulting\n          in a clean source tree.\n      \n     -    Note: earlier endeavors on the Git mailing list to introduce CMake ended\n     -    up in dead water. The primary reason for that was that reviewers\n     -    _expected_ CMake support to fall out of maintenance, unless the\n     -    contributor would promise to keep an eye on keeping CMake support up to\n     -    date. However, in the meantime, support for automated testing has been\n     -    introduced in Git's source code, and a later patch will modify the\n     -    (still experimental) GitHub workflow to continually verify that CMake\n     -    support is still complete. That will make maintenance reasonably easy.\n     -\n          Note: this patch asks for the minimum version v3.14 of CMake (which is\n          not all that old as of time of writing) because that is the first\n          version to offer a platform-independent way to generate hardlinks as\n          part of the build. This is needed to generate all those hardlinks for\n          the built-in commands of Git.\n      \n     -    Instructions to run CMake:\n     -\n     -    cmake `relative-path-to-srcdir` -DCMAKE_BUILD_TYPE=Release\n     +    Changes\n     +    The CMake script parses the Makefile for:\n     +    LIB_OBJS\n     +    BUILTIN_OBJS\n     +    XDIFF_OBJS\n     +    VCSSVN_OBJS\n     +    TEST_BUILTINS_OBJS\n      \n     -    Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding\n     -    compiler flags\n     -    Debug : -g\n     -    Release: -O3\n     -    RelWithDebInfo : -O2 -g\n     -    MinSizeRel : -Os\n     -    empty(default) :\n     +    By doing this we avoid duplication of text between the Makefile and\n     +    the CMake script.\n      \n     -    NOTE: -DCMAKE_BUILD_TYPE is optional\n     +    The CMake script has been relocated to contrib/buildsystems.\n      \n     -    This process generates a Makefile.\n     -    Then run `make` to build Git.\n     -\n     -    NOTE: By default CMake uses Makefile as the build tool on Linux, to use\n     -    another tool say `ninja` add this to the command line when configuring.\n     -    `-G Ninja`\n     +    The CMake script uses GIT-VERSION-GEN to determine the version of Git\n     +    being built.\n      \n          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n      \n     - ## CMakeLists.txt (new) ##\n     + ## contrib/buildsystems/CMakeLists.txt (new) ##\n      @@\n      +#\n      +#\tCopyright (c) 2020 Sibi Siddharthan\n      +#\n      +\n     ++#[[\n     ++\n     ++Instructions to run CMake:\n     ++\n     ++cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release\n     ++\n     ++Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding\n     ++compiler flags\n     ++Debug : -g\n     ++Release: -O3\n     ++RelWithDebInfo : -O2 -g\n     ++MinSizeRel : -Os\n     ++empty(default) :\n     ++\n     ++NOTE: -DCMAKE_BUILD_TYPE is optional. For multi-config generators like Visual Studio\n     ++this option is ignored\n     ++\n     ++This process generates a Makefile(Linux) , Visual Studio solution(Windows) by default.\n     ++Run `make` to build Git on Linux.\n     ++Open git.sln on Windows and build Git.\n     ++\n     ++NOTE: By default CMake uses Makefile as the build tool on Linux and Visual Studio in Windows,\n     ++to use another tool say `ninja` add this to the command line when configuring.\n     ++`-G Ninja`\n     ++\n     ++]]\n      +cmake_minimum_required(VERSION 3.14)\n      +\n     -+#Parse GIT-VERSION-GEN to get the version\n     -+file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX \"DEF_VER=v(.*)\")\n     -+string(REPLACE \"DEF_VER=v\" \"\" git_version ${git_version})\n     -+string(REPLACE \".GIT\" \".0\" git_version ${git_version})#for building from a snapshot\n     ++#set the source directory to root of git\n     ++set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n     ++\n     ++find_program(SH_EXE sh)\n     ++\n     ++#Create GIT-VERSION-FILE using GIT-VERSION-GEN\n     ++if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)\n     ++\tmessage(\"Generating GIT-VERSION-FILE\")\n     ++\texecute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN\n     ++\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR})\n     ++endif()\n     ++\n     ++#Parse GIT-VERSION-FILE to get the version\n     ++file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE git_version REGEX \"GIT_VERSION = (.*)\")\n     ++string(REPLACE \"GIT_VERSION = \" \"\" git_version ${git_version})\n     ++string(FIND ${git_version} \"GIT\" location)\n     ++if(location EQUAL -1)\n     ++\tstring(REGEX MATCH \"[0-9]*\\\\.[0-9]*\\\\.[0-9]*\" git_version ${git_version})\n     ++else()\n     ++\tstring(REGEX MATCH \"[0-9]*\\\\.[0-9]*\" git_version ${git_version})\n     ++\tstring(APPEND git_version \".0\") #for building from a snapshot\n     ++endif()\n      +\n      +project(git\n      +\tVERSION ${git_version}\n      +\tLANGUAGES C)\n      +\n      +\n     ++#macros for parsing the Makefile for sources\n     ++macro(parse_makefile_for_sources list_var regex)\n     ++\tfile(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX \"^${regex} \\\\+=(.*)\")\n     ++\tstring(REPLACE \"${regex} +=\" \"\" ${list_var} ${${list_var}})\n     ++\tstring(REPLACE \"$(COMPAT_OBJS)\" \"\" ${list_var} ${${list_var}}) #remove \"$(COMPAT_OBJS)\" This is only for libgit.\n     ++\tstring(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces\n     ++\tstring(REPLACE \".o\" \".c;\" ${list_var} ${${list_var}}) #change .o to .c, ; is for converting the string into a list\n     ++\tlist(TRANSFORM ${list_var} STRIP) #remove trailing/leading whitespaces for each element in list\n     ++\tlist(REMOVE_ITEM ${list_var} \"\") #remove empty list elements\n     ++endmacro()\n     ++\n      +include(CheckTypeSize)\n      +include(CheckCSourceRuns)\n      +include(CheckCSourceCompiles)\n     @@ CMakeLists.txt (new)\n      +\tinclude_directories(SYSTEM ${Intl_INCLUDE_DIRS})\n      +endif()\n      +\n     -+find_program(SH_EXE sh)\n     -+\n      +#default behaviour\n      +include_directories(${CMAKE_SOURCE_DIR})\n      +add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n     @@ CMakeLists.txt (new)\n      +#function checks\n      +set(function_checks\n      +\tstrcasestr memmem strlcpy strtoimax strtoumax strtoull\n     -+\tsetenv  mkdtemp poll pread  memmem unsetenv hstrerror)\n     ++\tsetenv mkdtemp poll pread memmem unsetenv hstrerror)\n      +\n      +foreach(f ${function_checks})\n      +\tstring(TOUPPER ${f} uf)\n     @@ CMakeLists.txt (new)\n      +endforeach()\n      +\n      +if(NOT HAVE_POLL_H OR NOT HAVE_SYS_POLL_H OR NOT HAVE_POLL)\n     -+\tinclude_directories(compat/poll)\n     ++\tinclude_directories(${CMAKE_SOURCE_DIR}/compat/poll)\n      +\tadd_compile_definitions(NO_POLL)\n      +\tlist(APPEND compat_SOURCES compat/poll/poll.c)\n      +endif()\n     @@ CMakeLists.txt (new)\n      +\tadd_compile_definitions(HAVE_CLOCK_MONOTONIC)\n      +endif()\n      +\n     ++#check for st_blocks in struct stat\n     ++check_struct_has_member(\"struct stat\" st_blocks \"sys/stat.h\" STRUCT_STAT_HAS_ST_BLOCKS)\n     ++if(NOT STRUCT_STAT_HAS_ST_BLOCKS)\n     ++\tadd_compile_definitions(NO_ST_BLOCKS_IN_STRUCT_STAT)\n     ++endif()\n      +\n      +#compile checks\n      +check_c_source_runs(\"\n     @@ CMakeLists.txt (new)\n      +int main(){return 0;}\"\n      +HAVE_REGEX)\n      +if(NOT HAVE_REGEX)\n     -+\tinclude_directories(compat/regex )\n     ++\tinclude_directories(${CMAKE_SOURCE_DIR}/compat/regex)\n      +\tlist(APPEND compat_SOURCES compat/regex/regex.c )\n      +\tadd_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)\n      +endif()\n     @@ CMakeLists.txt (new)\n      +\tadd_compile_definitions(HAVE_BSD_SYSCTL)\n      +endif()\n      +\n     ++set(CMAKE_REQUIRED_LIBRARIES ${Iconv_LIBRARIES})\n     ++set(CMAKE_REQUIRED_INCLUDES ${Iconv_INCLUDE_DIRS})\n     ++\n     ++check_c_source_compiles(\"\n     ++#include <iconv.h>\n     ++\n     ++extern size_t iconv(iconv_t cd,\n     ++\t\tchar **inbuf, size_t *inbytesleft,\n     ++\t\tchar **outbuf, size_t *outbytesleft);\n     ++\n     ++int main(){return 0;}\"\n     ++HAVE_NEW_ICONV)\n     ++if(HAVE_NEW_ICONV)\n     ++\tset(HAVE_OLD_ICONV 0)\n     ++else()\n     ++\tset(HAVE_OLD_ICONV 1)\n     ++endif()\n     ++\n     ++check_c_source_runs(\"\n     ++#include <iconv.h>\n     ++#if ${HAVE_OLD_ICONV}\n     ++typedef const char *iconv_ibp;\n     ++#else\n     ++typedef char *iconv_ibp;\n     ++#endif\n     ++\n     ++int main()\n     ++{\n     ++\tint v;\n     ++\ticonv_t conv;\n     ++\tchar in[] = \\\"a\\\"; iconv_ibp pin = in;\n     ++\tchar out[20] = \\\"\\\"; char *pout = out;\n     ++\tsize_t isz = sizeof in;\n     ++\tsize_t osz = sizeof out;\n     ++\n     ++\tconv = iconv_open(\\\"UTF-16\\\", \\\"UTF-8\\\");\n     ++\ticonv(conv, &pin, &isz, &pout, &osz);\n     ++\ticonv_close(conv);\n     ++\tv = (unsigned char)(out[0]) + (unsigned char)(out[1]);\n     ++\treturn v != 0xfe + 0xff;\n     ++}\"\n     ++ICONV_DOESNOT_OMIT_BOM)\n     ++if(NOT ICONV_DOESNOT_OMIT_BOM)\n     ++\tadd_compile_definitions(ICONV_OMITS_BOM)\n     ++endif()\n     ++\n     ++unset(CMAKE_REQUIRED_LIBRARIES)\n     ++unset(CMAKE_REQUIRED_INCLUDES)\n     ++\n     ++\n      +#programs\n      +set(PROGRAMS_BUILT\n      +\tgit git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst\n     @@ CMakeLists.txt (new)\n      +list(APPEND EXCLUSION_PROGS empty)\n      +set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING \"Programs not built\" FORCE)\n      +\n     -+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)\n     ++if(NOT EXISTS ${CMAKE_BINARY_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)\n      +\tlist(REMOVE_ITEM EXCLUSION_PROGS empty)\n      +\tmessage(\"Generating command-list.h\")\n      +\texecute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt\n      +\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n     -+\t\t\tOUTPUT_FILE ${CMAKE_SOURCE_DIR}/command-list.h)\n     ++\t\t\tOUTPUT_FILE ${CMAKE_BINARY_DIR}/command-list.h)\n      +endif()\n      +\n     -+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/config-list.h)\n     ++if(NOT EXISTS ${CMAKE_BINARY_DIR}/config-list.h)\n      +\tmessage(\"Generating config-list.h\")\n      +\texecute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh\n      +\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n     -+\t\t\tOUTPUT_FILE ${CMAKE_SOURCE_DIR}/config-list.h)\n     ++\t\t\tOUTPUT_FILE ${CMAKE_BINARY_DIR}/config-list.h)\n      +endif()\n      +\n     ++include_directories(${CMAKE_BINARY_DIR})\n      +\n      +#build\n     -+set(libgit_SOURCES\n     -+\tabspath.c add-interactive.c add-patch.c advice.c alias.c\n     -+\talloc.c apply.c archive.c archive-tar.c archive-zip.c argv-array.c\n     -+\tattr.c base85.c bisect.c blame.c blob.c bloom.c branch.c bulk-checkin.c\n     -+\tbundle.c cache-tree.c chdir-notify.c checkout.c color.c column.c\n     -+\tcombine-diff.c commit.c commit-graph.c commit-reach.c compat/obstack.c\n     -+\tcompat/terminal.c config.c connect.c connected.c convert.c copy.c credential.c\n     -+\tcsum-file.c ctype.c date.c decorate.c delta-islands.c diffcore-break.c\n     -+\tdiffcore-delta.c diffcore-order.c diffcore-pickaxe.c diffcore-rename.c\n     -+\tdiff-delta.c diff-lib.c diff-no-index.c diff.c dir.c dir-iterator.c editor.c\n     -+\tentry.c environment.c ewah/bitmap.c ewah/ewah_bitmap.c ewah/ewah_io.c\n     -+\tewah/ewah_rlw.c exec-cmd.c fetch-negotiator.c fetch-pack.c fmt-merge-msg.c fsck.c fsmonitor.c\n     -+\tgettext.c gpg-interface.c graph.c grep.c hashmap.c linear-assignment.c help.c hex.c\n     -+\tident.c interdiff.c json-writer.c kwset.c levenshtein.c line-log.c line-range.c list-objects.c\n     -+\tlist-objects-filter.c list-objects-filter-options.c ll-merge.c lockfile.c\n     -+\tlog-tree.c ls-refs.c mailinfo.c mailmap.c match-trees.c mem-pool.c merge.c merge-blobs.c\n     -+\tmerge-recursive.c mergesort.c midx.c name-hash.c negotiator/default.c\n     -+\tnegotiator/skipping.c notes.c notes-cache.c notes-merge.c notes-utils.c object.c oidmap.c\n     -+\toidset.c oid-array.c packfile.c pack-bitmap.c pack-bitmap-write.c pack-check.c pack-objects.c\n     -+\tpack-revindex.c pack-write.c pager.c parse-options.c parse-options-cb.c patch-delta.c\n     -+\tpatch-ids.c path.c pathspec.c pkt-line.c preload-index.c pretty.c prio-queue.c progress.c\n     -+\tpromisor-remote.c prompt.c protocol.c prune-packed.c quote.c range-diff.c reachable.c read-cache.c rebase.c\n     -+\trebase-interactive.c reflog-walk.c refs.c refs/files-backend.c refs/iterator.c\n     -+\trefs/packed-backend.c refs/ref-cache.c refspec.c ref-filter.c remote.c replace-object.c\n     -+\trepo-settings.c repository.c rerere.c reset.c resolve-undo.c revision.c run-command.c\n     -+\tsend-pack.c sequencer.c serve.c server-info.c setup.c sha1-lookup.c\n     -+\tsha1-file.c sha1-name.c shallow.c sideband.c sigchain.c split-index.c\n     -+\tstable-qsort.c strbuf.c streaming.c string-list.c submodule.c submodule-config.c\n     -+\tsub-process.c symlinks.c tag.c tempfile.c thread-utils.c tmp-objdir.c\n     -+\ttrace.c trace2.c trace2/tr2_cfg.c trace2/tr2_cmd_name.c trace2/tr2_dst.c\n     -+\ttrace2/tr2_sid.c trace2/tr2_sysenv.c trace2/tr2_tbuf.c trace2/tr2_tgt_event.c\n     -+\ttrace2/tr2_tgt_normal.c trace2/tr2_tgt_perf.c trace2/tr2_tls.c trailer.c transport.c\n     -+\ttransport-helper.c tree-diff.c tree.c tree-walk.c unpack-trees.c upload-pack.c url.c\n     -+\turlmatch.c usage.c userdiff.c utf8.c varint.c version.c versioncmp.c walker.c wildmatch.c\n     -+\tworktree.c wrapper.c write-or-die.c ws.c wt-status.c xdiff-interface.c\n     -+\tzlib.c)\n     ++#libgit\n     ++parse_makefile_for_sources(libgit_SOURCES \"LIB_OBJS\")\n      +\n     ++list(TRANSFORM libgit_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n     ++list(TRANSFORM compat_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n      +add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})\n      +\n     -+set(libxdiff_SOURCES\n     -+\txdiff/xdiffi.c xdiff/xprepare.c xdiff/xutils.c xdiff/xemit.c\n     -+\txdiff/xmerge.c xdiff/xpatience.c xdiff/xhistogram.c)\n     ++#libxdiff\n     ++parse_makefile_for_sources(libxdiff_SOURCES \"XDIFF_OBJS\")\n     ++\n     ++list(TRANSFORM libxdiff_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n      +add_library(xdiff STATIC ${libxdiff_SOURCES})\n      +\n     -+set(libvcs-svn_SOURCES\n     -+\tvcs-svn/line_buffer.c vcs-svn/sliding_window.c vcs-svn/fast_export.c\n     -+\tvcs-svn/svndiff.c vcs-svn/svndump.c)\n     ++#libvcs-svn\n     ++parse_makefile_for_sources(libvcs-svn_SOURCES \"VCSSVN_OBJS\")\n     ++\n     ++list(TRANSFORM libvcs-svn_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n      +add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})\n      +\n      +#link all required libraries to common-main\n     -+add_library(common-main OBJECT common-main.c)\n     ++add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)\n      +target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)\n      +if(Intl_FOUND)\n      +\ttarget_link_libraries(common-main ${Intl_LIBRARIES})\n     @@ CMakeLists.txt (new)\n      +\ttarget_link_libraries(common-main ${Iconv_LIBRARIES})\n      +endif()\n      +\n     ++#git\n     ++parse_makefile_for_sources(git_SOURCES \"BUILTIN_OBJS\")\n     ++\n     ++list(TRANSFORM git_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n     ++add_executable(git ${CMAKE_SOURCE_DIR}/git.c ${git_SOURCES})\n     ++target_link_libraries(git common-main)\n      +\n     -+set(git_SOURCES\n     -+\tbuiltin/add.c builtin/am.c builtin/annotate.c builtin/apply.c\n     -+\tbuiltin/archive.c builtin/bisect--helper.c builtin/blame.c\n     -+\tbuiltin/branch.c builtin/bundle.c builtin/cat-file.c builtin/check-attr.c\n     -+\tbuiltin/check-ignore.c builtin/check-mailmap.c builtin/check-ref-format.c\n     -+\tbuiltin/checkout-index.c builtin/checkout.c builtin/clean.c\n     -+\tbuiltin/clone.c builtin/column.c builtin/commit-tree.c\n     -+\tbuiltin/commit.c builtin/commit-graph.c builtin/config.c\n     -+\tbuiltin/count-objects.c builtin/credential.c builtin/describe.c\n     -+\tbuiltin/diff-files.c builtin/diff-index.c builtin/diff-tree.c\n     -+\tbuiltin/diff.c builtin/difftool.c builtin/env--helper.c\n     -+\tbuiltin/fast-export.c builtin/fetch-pack.c builtin/fetch.c builtin/fmt-merge-msg.c\n     -+\tbuiltin/for-each-ref.c builtin/fsck.c builtin/gc.c\n     -+\tbuiltin/get-tar-commit-id.c builtin/grep.c builtin/hash-object.c\n     -+\tbuiltin/help.c builtin/index-pack.c builtin/init-db.c\n     -+\tbuiltin/interpret-trailers.c builtin/log.c builtin/ls-files.c\n     -+\tbuiltin/ls-remote.c builtin/ls-tree.c builtin/mailinfo.c builtin/mailsplit.c\n     -+\tbuiltin/merge.c builtin/merge-base.c builtin/merge-file.c builtin/merge-index.c\n     -+\tbuiltin/merge-ours.c builtin/merge-recursive.c builtin/merge-tree.c\n     -+\tbuiltin/mktag.c builtin/mktree.c builtin/multi-pack-index.c builtin/mv.c\n     -+\tbuiltin/name-rev.c builtin/notes.c builtin/pack-objects.c builtin/pack-redundant.c\n     -+\tbuiltin/pack-refs.c builtin/patch-id.c builtin/prune-packed.c builtin/prune.c\n     -+\tbuiltin/pull.c builtin/push.c builtin/range-diff.c builtin/read-tree.c\n     -+\tbuiltin/rebase.c builtin/receive-pack.c builtin/reflog.c builtin/remote.c\n     -+\tbuiltin/remote-ext.c builtin/remote-fd.c builtin/repack.c builtin/replace.c\n     -+\tbuiltin/rerere.c builtin/reset.c builtin/rev-list.c builtin/rev-parse.c\n     -+\tbuiltin/revert.c builtin/rm.c builtin/send-pack.c builtin/shortlog.c\n     -+\tbuiltin/show-branch.c builtin/show-index.c builtin/show-ref.c\n     -+\tbuiltin/sparse-checkout.c builtin/stash.c builtin/stripspace.c\n     -+\tbuiltin/submodule--helper.c builtin/symbolic-ref.c builtin/tag.c\n     -+\tbuiltin/unpack-file.c builtin/unpack-objects.c builtin/update-index.c\n     -+\tbuiltin/update-ref.c builtin/update-server-info.c builtin/upload-archive.c\n     -+\tbuiltin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c\n     -+\tbuiltin/verify-tag.c builtin/worktree.c builtin/write-tree.c)\n     -+\n     -+add_executable(git git.c ${git_SOURCES})\n     -+target_link_libraries(git common-main )\n     -+\n     -+add_executable(git-bugreport bugreport.c)\n     ++add_executable(git-bugreport ${CMAKE_SOURCE_DIR}/bugreport.c)\n      +target_link_libraries(git-bugreport common-main)\n      +\n     -+add_executable(git-credential-store credential-store.c)\n     ++add_executable(git-credential-store ${CMAKE_SOURCE_DIR}/credential-store.c)\n      +target_link_libraries(git-credential-store common-main)\n      +\n     -+add_executable(git-daemon daemon.c)\n     ++add_executable(git-daemon ${CMAKE_SOURCE_DIR}/daemon.c)\n      +target_link_libraries(git-daemon common-main)\n      +\n     -+add_executable(git-fast-import fast-import.c)\n     ++add_executable(git-fast-import ${CMAKE_SOURCE_DIR}/fast-import.c)\n      +target_link_libraries(git-fast-import common-main)\n      +\n     -+add_executable(git-http-backend http-backend.c)\n     ++add_executable(git-http-backend ${CMAKE_SOURCE_DIR}/http-backend.c)\n      +target_link_libraries(git-http-backend common-main)\n      +\n     -+add_executable(git-sh-i18n--envsubst sh-i18n--envsubst.c)\n     ++add_executable(git-sh-i18n--envsubst ${CMAKE_SOURCE_DIR}/sh-i18n--envsubst.c)\n      +target_link_libraries(git-sh-i18n--envsubst common-main)\n      +\n     -+add_executable(git-shell shell.c)\n     ++add_executable(git-shell ${CMAKE_SOURCE_DIR}/shell.c)\n      +target_link_libraries(git-shell common-main)\n      +\n      +if(CURL_FOUND)\n     -+\tadd_library(http_obj OBJECT http.c)\n     ++\tadd_library(http_obj OBJECT ${CMAKE_SOURCE_DIR}/http.c)\n      +\n     -+\tadd_executable(git-imap-send imap-send.c)\n     ++\tadd_executable(git-imap-send ${CMAKE_SOURCE_DIR}/imap-send.c)\n      +\ttarget_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})\n      +\n     -+\tadd_executable(git-http-fetch http-walker.c http-fetch.c)\n     ++\tadd_executable(git-http-fetch ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/http-fetch.c)\n      +\ttarget_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})\n      +\n     -+\tadd_executable(git-remote-http http-walker.c remote-curl.c)\n     ++\tadd_executable(git-remote-http ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/remote-curl.c)\n      +\ttarget_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )\n      +\n      +\tif(EXPAT_FOUND)\n     -+\t\tadd_executable(git-http-push http-push.c)\n     ++\t\tadd_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)\n      +\t\ttarget_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})\n      +\tendif()\n      +endif()\n      +\n     -+add_executable(git-remote-testsvn remote-testsvn.c)\n     ++add_executable(git-remote-testsvn ${CMAKE_SOURCE_DIR}/remote-testsvn.c)\n      +target_link_libraries(git-remote-testsvn common-main vcs-svn)\n      +\n     -+add_executable(git-credential-cache credential-cache.c)\n     ++add_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)\n      +target_link_libraries(git-credential-cache common-main)\n      +\n     -+add_executable(git-credential-cache--daemon credential-cache--daemon.c)\n     ++add_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)\n      +target_link_libraries(git-credential-cache--daemon common-main)\n      +\n      +\n     @@ CMakeLists.txt (new)\n      +\n      +#Creating hardlinks\n      +foreach(s ${git_SOURCES} ${git_builtin_extra})\n     -+\tstring(REPLACE \"builtin/\" \"\" s ${s})\n     ++\tstring(REPLACE \"${CMAKE_SOURCE_DIR}/builtin/\" \"\" s ${s})\n      +\tstring(REPLACE \".c\" \"\" s ${s})\n      +\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git git-${s})\\n\")\n      +\tlist(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})\n     @@ CMakeLists.txt (new)\n      +\t\tCOMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake\n      +\t\tDEPENDS git git-remote-http)\n      +add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})\n     - \\ No newline at end of file\n  2:  ca242cf5bda !  2:  f19794fdbc0 cmake: generate the shell/perl/python scripts and templates, translations\n     @@ Metadata\n       ## Commit message ##\n          cmake: generate the shell/perl/python scripts and templates, translations\n      \n     -    This patch implements the placeholder substitution to generate, say,\n     -    `git-request-pull` from `git-request-pull.sh`.\n     +    Implement the placeholder substitution to generate scripted\n     +    Porcelain commands, e.g. git-request-pull out of\n     +    git-request-pull.sh\n      \n     -    The shell/perl/python scripts and template are generated using CMake\n     -    (very similar to what sed does).\n     +    Generate shell/perl/python scripts and template using CMake instead of\n     +    using sed like the build procedure in the Makefile does.\n      \n          The text translations are only build if `msgfmt` is found in your path.\n      \n          NOTE: The scripts and templates are generated during configuration.\n      \n     +    Changes\n     +    The CMake script parses the Makefile for:\n     +    SCRIPT_SH\n     +    SCRIPT_PERL\n     +\n          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n      \n     - ## CMakeLists.txt ##\n     -@@ CMakeLists.txt: endif()\n     + ## contrib/buildsystems/CMakeLists.txt ##\n     +@@ contrib/buildsystems/CMakeLists.txt: project(git\n     + \tLANGUAGES C)\n     + \n     + \n     +-#macros for parsing the Makefile for sources\n     ++#macros for parsing the Makefile for sources and scripts\n     + macro(parse_makefile_for_sources list_var regex)\n     + \tfile(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX \"^${regex} \\\\+=(.*)\")\n     + \tstring(REPLACE \"${regex} +=\" \"\" ${list_var} ${${list_var}})\n     +@@ contrib/buildsystems/CMakeLists.txt: macro(parse_makefile_for_sources list_var regex)\n     + \tlist(REMOVE_ITEM ${list_var} \"\") #remove empty list elements\n     + endmacro()\n       \n     - find_program(SH_EXE sh)\n     ++macro(parse_makefile_for_scripts list_var regex lang)\n     ++\tfile(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX \"^${regex} \\\\+=(.*)\")\n     ++\tstring(REPLACE \"${regex} +=\" \"\" ${list_var} ${${list_var}})\n     ++\tstring(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces\n     ++\tstring(REPLACE \" \" \";\" ${list_var} ${${list_var}}) #convert string to a list\n     ++\tlist(TRANSFORM ${list_var} REPLACE \"${lang}\" \"\") #do the replacement\n     ++endmacro()\n     ++\n     + include(CheckTypeSize)\n     + include(CheckCSourceRuns)\n     + include(CheckCSourceCompiles)\n     +@@ contrib/buildsystems/CMakeLists.txt: if(Intl_FOUND)\n     + \tinclude_directories(SYSTEM ${Intl_INCLUDE_DIRS})\n     + endif()\n       \n      +find_program(MSGFMT_EXE msgfmt)\n      +if(NOT MSGFMT_EXE)\n     @@ CMakeLists.txt: endif()\n       #default behaviour\n       include_directories(${CMAKE_SOURCE_DIR})\n       add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n     -@@ CMakeLists.txt: endif()\n     - add_custom_command(OUTPUT ${git_links} ${git_http_links}\n     +@@ contrib/buildsystems/CMakeLists.txt: add_custom_command(OUTPUT ${git_links} ${git_http_links}\n       \t\tCOMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake\n       \t\tDEPENDS git git-remote-http)\n     --add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})\n     - \\ No newline at end of file\n     -+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})\n     + add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})\n      +\n      +\n      +#creating required scripts\n     @@ CMakeLists.txt: endif()\n      +set(INSTLIBDIR ${FALLBACK_RUNTIME_PREFIX}/share/perl5)\n      +\n      +#shell scripts\n     ++parse_makefile_for_scripts(git_sh_scripts \"SCRIPT_SH\" \".sh\")\n      +set(git_shell_scripts\n     -+\tgit-bisect git-difftool--helper git-filter-branch\n     -+\tgit-merge-octopus git-merge-one-file git-merge-resolve\n     -+\tgit-mergetool git-quiltimport\n     -+\tgit-request-pull git-submodule git-web--browse\n     ++\t${git_sh_scripts}\n      +\tgit-mergetool--lib git-parse-remote git-rebase--preserve-merges\n      +\tgit-sh-setup git-sh-i18n git-instaweb)\n      +\n     @@ CMakeLists.txt: endif()\n      +endforeach()\n      +\n      +#perl scripts\n     -+set(git_perl_scripts\n     -+\tgit-add--interactive git-archimport git-cvsexportcommit\n     -+\tgit-cvsimport git-cvsserver git-send-email git-svn)\n     ++parse_makefile_for_scripts(git_perl_scripts \"SCRIPT_PERL\" \".perl\")\n      +\n      +#create perl header\n      +file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )\n  3:  b2974432d77 !  3:  6ec73d3e967 cmake: installation support for git\n     @@ Metadata\n       ## Commit message ##\n          cmake: installation support for git\n      \n     -    This patch provides the facility to install the built binaries and\n     -    scripts.\n     +    Install the built binaries and scripts using CMake\n      \n          This is very similar to `make install`.\n          By default the destination directory(DESTDIR) is /usr/local/ on Linux\n     @@ Commit message\n      \n          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n      \n     - ## CMakeLists.txt ##\n     -@@ CMakeLists.txt: project(git\n     + ## contrib/buildsystems/CMakeLists.txt ##\n     +@@ contrib/buildsystems/CMakeLists.txt: project(git\n       \tVERSION ${git_version}\n       \tLANGUAGES C)\n       \n      +#TODO gitk git-gui gitweb\n      +#TODO Add pcre support\n       \n     - include(CheckTypeSize)\n     - include(CheckCSourceRuns)\n     -@@ CMakeLists.txt: if(MSGFMT_EXE)\n     + #macros for parsing the Makefile for sources and scripts\n     + macro(parse_makefile_for_sources list_var regex)\n     +@@ contrib/buildsystems/CMakeLists.txt: if(MSGFMT_EXE)\n       \tendforeach()\n       \tadd_custom_target(po-gen ALL DEPENDS ${po_gen})\n       endif()\n     @@ CMakeLists.txt: if(MSGFMT_EXE)\n      +install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4\n      +\tDESTINATION libexec/git-core)\n      +\n     -+install(DIRECTORY mergetools DESTINATION libexec/git-core)\n     ++install(DIRECTORY ${CMAKE_SOURCE_DIR}/mergetools DESTINATION libexec/git-core)\n      +install(DIRECTORY ${CMAKE_BINARY_DIR}/perl/build/lib/ DESTINATION share/perl5\n      +\tFILES_MATCHING PATTERN \"*.pm\")\n      +install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/templates)\n  4:  2bd8870fb96 !  4:  cdc53172b3f cmake: support for testing git with ctest\n     @@ Commit message\n      \n          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n      \n     - ## CMakeLists.txt ##\n     -@@ CMakeLists.txt: include(CheckIncludeFile)\n     + ## contrib/buildsystems/CMakeLists.txt ##\n     +@@ contrib/buildsystems/CMakeLists.txt: include(CheckIncludeFile)\n       include(CheckFunctionExists)\n       include(CheckSymbolExists)\n       include(CheckStructHasMember)\n     @@ CMakeLists.txt: include(CheckIncludeFile)\n       \n       find_package(ZLIB REQUIRED)\n       find_package(CURL)\n     -@@ CMakeLists.txt: install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/\n     +@@ contrib/buildsystems/CMakeLists.txt: install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/\n       if(MSGFMT_EXE)\n       \tinstall(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)\n       endif()\n     @@ CMakeLists.txt: install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION\n      +if(BUILD_TESTING)\n      +\n      +#tests-helpers\n     -+add_executable(test-fake-ssh t/helper/test-fake-ssh.c)\n     ++add_executable(test-fake-ssh ${CMAKE_SOURCE_DIR}/t/helper/test-fake-ssh.c)\n      +target_link_libraries(test-fake-ssh common-main)\n      +\n     -+add_executable(test-line-buffer t/helper/test-line-buffer.c)\n     ++add_executable(test-line-buffer ${CMAKE_SOURCE_DIR}/t/helper/test-line-buffer.c)\n      +target_link_libraries(test-line-buffer common-main vcs-svn)\n      +\n     -+add_executable(test-svn-fe t/helper/test-svn-fe.c)\n     ++add_executable(test-svn-fe ${CMAKE_SOURCE_DIR}/t/helper/test-svn-fe.c)\n      +target_link_libraries(test-svn-fe common-main vcs-svn)\n      +\n     -+set(test-tool_SOURCES\n     -+\tt/helper/test-tool.c t/helper/test-advise.c t/helper/test-bloom.c t/helper/test-chmtime.c\n     -+\tt/helper/test-config.c t/helper/test-ctype.c t/helper/test-date.c t/helper/test-delta.c\n     -+\tt/helper/test-dir-iterator.c t/helper/test-drop-caches.c t/helper/test-dump-cache-tree.c\n     -+\tt/helper/test-dump-fsmonitor.c t/helper/test-dump-split-index.c\n     -+\tt/helper/test-dump-untracked-cache.c t/helper/test-example-decorate.c\n     -+\tt/helper/test-genrandom.c t/helper/test-genzeros.c t/helper/test-hash.c\n     -+\tt/helper/test-hashmap.c t/helper/test-hash-speed.c t/helper/test-index-version.c\n     -+\tt/helper/test-json-writer.c t/helper/test-lazy-init-name-hash.c\n     -+\tt/helper/test-match-trees.c t/helper/test-mergesort.c t/helper/test-mktemp.c\n     -+\tt/helper/test-oidmap.c t/helper/test-online-cpus.c t/helper/test-parse-options.c\n     -+\tt/helper/test-parse-pathspec-file.c t/helper/test-path-utils.c t/helper/test-pkt-line.c\n     -+\tt/helper/test-prio-queue.c t/helper/test-progress.c t/helper/test-reach.c\n     -+\tt/helper/test-read-cache.c t/helper/test-read-graph.c t/helper/test-read-midx.c\n     -+\tt/helper/test-ref-store.c t/helper/test-regex.c t/helper/test-repository.c\n     -+\tt/helper/test-revision-walking.c t/helper/test-run-command.c t/helper/test-scrap-cache-tree.c\n     -+\tt/helper/test-serve-v2.c t/helper/test-sha1.c t/helper/test-oid-array.c t/helper/test-sha256.c\n     -+\tt/helper/test-sigchain.c t/helper/test-strcmp-offset.c t/helper/test-string-list.c\n     -+\tt/helper/test-submodule-config.c t/helper/test-submodule-nested-repo-config.c t/helper/test-subprocess.c\n     -+\tt/helper/test-trace2.c t/helper/test-urlmatch-normalization.c t/helper/test-xml-encode.c\n     -+\tt/helper/test-wildmatch.c t/helper/test-windows-named-pipe.c t/helper/test-write-cache.c)\n     -+\n     -+add_executable(test-tool ${test-tool_SOURCES})\n     ++#test-tool\n     ++parse_makefile_for_sources(test-tool_SOURCES \"TEST_BUILTINS_OBJS\")\n     ++\n     ++list(TRANSFORM test-tool_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/t/helper/\")\n     ++add_executable(test-tool ${CMAKE_SOURCE_DIR}/t/helper/test-tool.c ${test-tool_SOURCES})\n      +target_link_libraries(test-tool common-main)\n      +\n      +set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool\n     @@ CMakeLists.txt: install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION\n      +endforeach()\n      +\n      +endif()#BUILD_TESTING\n     - \\ No newline at end of file\n  5:  096f6311ad5 !  5:  cdc68f102cb cmake: support for testing git when building out of the source tree\n     @@ Commit message\n      \n          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n      \n     - ## CMakeLists.txt ##\n     -@@ CMakeLists.txt: file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_GETTEXT='${NO_GETTEXT}'\\n\"\n     + ## contrib/buildsystems/CMakeLists.txt ##\n     +@@ contrib/buildsystems/CMakeLists.txt: file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_GETTEXT='${NO_GETTEXT}'\\n\"\n       file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"RUNTIME_PREFIX='${RUNTIME_PREFIX}'\\n\")\n       file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PYTHON='${NO_PYTHON}'\\n\")\n       \n      +#Make the tests work when building out of the source tree\n     -+if(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})\n     ++get_filename_component(CACHE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../CMakeCache.txt ABSOLUTE)\n     ++if(NOT ${CMAKE_BINARY_DIR}/CMakeCache.txt STREQUAL ${CACHE_PATH})\n      +\tfile(RELATIVE_PATH BUILD_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/CMakeCache.txt)\n      +\tstring(REPLACE \"/CMakeCache.txt\" \"\" BUILD_DIR_RELATIVE ${BUILD_DIR_RELATIVE})\n      +\t#Setting the build directory in test-lib.sh before running tests\n  6:  00cae10bbb7 !  6:  f41cbd43081 cmake: support for building git on windows with mingw\n     @@ Commit message\n          Changed the error message when sh.exe is not found on Windows as\n          suggested by Philip Oakley <philipoakley@iee.email>\n      \n     +    v2:\n     +    Fixed a bug where a Windows user can pose as Linux user and vice versa.\n     +\n          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n      \n     - ## CMakeLists.txt ##\n     -@@ CMakeLists.txt: project(git\n     + ## contrib/buildsystems/CMakeLists.txt ##\n     +@@ contrib/buildsystems/CMakeLists.txt: cmake_minimum_required(VERSION 3.14)\n     + set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n     + \n     + find_program(SH_EXE sh)\n     ++if(NOT SH_EXE)\n     ++\tmessage(FATAL_ERROR \"sh: shell interpreter was not found in your path, please install one.\"\n     ++\t\t\t\"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n     ++endif()\n     + \n     + #Create GIT-VERSION-FILE using GIT-VERSION-GEN\n     + if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)\n     +@@ contrib/buildsystems/CMakeLists.txt: project(git\n       \tVERSION ${git_version}\n       \tLANGUAGES C)\n       \n     @@ CMakeLists.txt: project(git\n      +#TODO Enable NLS on windows natively\n       #TODO Add pcre support\n       \n     -+\n     - include(CheckTypeSize)\n     - include(CheckCSourceRuns)\n     - include(CheckCSourceCompiles)\n     -@@ CMakeLists.txt: find_package(EXPAT)\n     + #macros for parsing the Makefile for sources and scripts\n     +@@ contrib/buildsystems/CMakeLists.txt: find_package(EXPAT)\n       find_package(Iconv)\n       find_package(Intl)\n       \n     @@ CMakeLists.txt: find_package(EXPAT)\n       if(NOT Intl_FOUND)\n       \tadd_compile_definitions(NO_GETTEXT)\n       \tif(NOT Iconv_FOUND)\n     -@@ CMakeLists.txt: if(Intl_FOUND)\n     +@@ contrib/buildsystems/CMakeLists.txt: if(Intl_FOUND)\n     + \tinclude_directories(SYSTEM ${Intl_INCLUDE_DIRS})\n       endif()\n       \n     - find_program(SH_EXE sh)\n     -+if(NOT SH_EXE)\n     -+\tmessage(FATAL_ERROR \"sh: shell interpreter was not found in your path, please install one.\"\n     -+\t\t\t\"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n     -+endif()\n      +\n      +if(WIN32)\n      +\tfind_program(WINDRES_EXE windres)\n     @@ CMakeLists.txt: if(Intl_FOUND)\n      +\t\tmessage(FATAL_ERROR \"Install windres on Windows for resource files\")\n      +\tendif()\n      +endif()\n     - \n     ++\n       find_program(MSGFMT_EXE msgfmt)\n       if(NOT MSGFMT_EXE)\n     -@@ CMakeLists.txt: add_compile_definitions(PAGER_ENV=\"LESS=FRX LV=-c\"\n     + \tmessage(WARNING \"Text Translations won't be build\")\n     +@@ contrib/buildsystems/CMakeLists.txt: add_compile_definitions(PAGER_ENV=\"LESS=FRX LV=-c\"\n       \t\t\tBINDIR=\"bin\"\n       \t\t\tGIT_BUILT_FROM_COMMIT=\"\")\n       \n     @@ CMakeLists.txt: add_compile_definitions(PAGER_ENV=\"LESS=FRX LV=-c\"\n      -list(APPEND compat_SOURCES unix-socket.c)\n      +\n      +#Platform Specific\n     -+if(${CMAKE_SYSTEM_NAME} STREQUAL \"Windows\")\n     -+\tinclude_directories(compat/win32)\n     ++if(CMAKE_SYSTEM_NAME STREQUAL \"Windows\")\n     ++\tinclude_directories(${CMAKE_SOURCE_DIR}/compat/win32)\n      +\tadd_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32\n      +\t\t\t\t_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=\".exe\"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT\n     -+\t\t\t\tNOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0 NO_ST_BLOCKS_IN_STRUCT_STAT\n     ++\t\t\t\tNOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0\n      +\t\t\t\tUSE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP\n      +\t\t\t\tUNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)\n      +\tlist(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c\n     @@ CMakeLists.txt: add_compile_definitions(PAGER_ENV=\"LESS=FRX LV=-c\"\n      +\t\tcompat/nedmalloc/nedmalloc.c compat/strdup.c)\n      +\tset(NO_UNIX_SOCKETS 1)\n      +\n     -+elseif(${CMAKE_SYSTEM_NAME} STREQUAL \"Linux\")\n     ++elseif(CMAKE_SYSTEM_NAME STREQUAL \"Linux\")\n      +\tadd_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n      +\tlist(APPEND compat_SOURCES unix-socket.c)\n      +endif()\n     @@ CMakeLists.txt: add_compile_definitions(PAGER_ENV=\"LESS=FRX LV=-c\"\n       \n       #header checks\n       check_include_file(libgen.h HAVE_LIBGEN_H)\n     -@@ CMakeLists.txt: endif()\n     +@@ contrib/buildsystems/CMakeLists.txt: endif()\n       #function checks\n       set(function_checks\n       \tstrcasestr memmem strlcpy strtoimax strtoumax strtoull\n     --\tsetenv  mkdtemp poll pread  memmem unsetenv hstrerror)\n     -+\tsetenv  mkdtemp poll pread  memmem)\n     +-\tsetenv mkdtemp poll pread memmem unsetenv hstrerror)\n     ++\tsetenv mkdtemp poll pread memmem)\n      +\n      +#unsetenv,hstrerror are incompatible with windows build\n      +if(NOT WIN32)\n     @@ CMakeLists.txt: endif()\n       \n       foreach(f ${function_checks})\n       \tstring(TOUPPER ${f} uf)\n     -@@ CMakeLists.txt: endif()\n     +@@ contrib/buildsystems/CMakeLists.txt: unset(CMAKE_REQUIRED_INCLUDES)\n       #programs\n       set(PROGRAMS_BUILT\n       \tgit git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst\n     @@ CMakeLists.txt: endif()\n       \n       if(NOT CURL_FOUND)\n       \tlist(APPEND excluded_progs git-http-fetch git-http-push)\n     -@@ CMakeLists.txt: set(libvcs-svn_SOURCES\n     - \tvcs-svn/svndiff.c vcs-svn/svndump.c)\n     +@@ contrib/buildsystems/CMakeLists.txt: parse_makefile_for_sources(libvcs-svn_SOURCES \"VCSSVN_OBJS\")\n     + list(TRANSFORM libvcs-svn_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n       add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})\n       \n      +#add git.rc for gcc\n     @@ CMakeLists.txt: set(libvcs-svn_SOURCES\n      +endif()\n      +\n       #link all required libraries to common-main\n     - add_library(common-main OBJECT common-main.c)\n     + add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)\n      -target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)\n      +\n      +target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})\n     @@ CMakeLists.txt: set(libvcs-svn_SOURCES\n      +\ttarget_link_libraries(common-main pthread rt)\n      +endif()\n       \n     - \n     - set(git_SOURCES\n     -@@ CMakeLists.txt: endif()\n     - add_executable(git-remote-testsvn remote-testsvn.c)\n     + #git\n     + parse_makefile_for_sources(git_SOURCES \"BUILTIN_OBJS\")\n     +@@ contrib/buildsystems/CMakeLists.txt: endif()\n     + add_executable(git-remote-testsvn ${CMAKE_SOURCE_DIR}/remote-testsvn.c)\n       target_link_libraries(git-remote-testsvn common-main vcs-svn)\n       \n     --add_executable(git-credential-cache credential-cache.c)\n     +-add_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)\n      -target_link_libraries(git-credential-cache common-main)\n      +if(NOT NO_UNIX_SOCKETS)\n     -+\tadd_executable(git-credential-cache credential-cache.c)\n     ++\tadd_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)\n      +\ttarget_link_libraries(git-credential-cache common-main)\n       \n     --add_executable(git-credential-cache--daemon credential-cache--daemon.c)\n     +-add_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)\n      -target_link_libraries(git-credential-cache--daemon common-main)\n     -+\tadd_executable(git-credential-cache--daemon credential-cache--daemon.c)\n     ++\tadd_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)\n      +\ttarget_link_libraries(git-credential-cache--daemon common-main)\n      +endif()\n       \n       \n       set(git_builtin_extra\n     -@@ CMakeLists.txt: set(git_builtin_extra\n     +@@ contrib/buildsystems/CMakeLists.txt: set(git_builtin_extra\n       foreach(s ${git_SOURCES} ${git_builtin_extra})\n     - \tstring(REPLACE \"builtin/\" \"\" s ${s})\n     + \tstring(REPLACE \"${CMAKE_SOURCE_DIR}/builtin/\" \"\" s ${s})\n       \tstring(REPLACE \".c\" \"\" s ${s})\n      -\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git git-${s})\\n\")\n      -\tlist(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})\n     @@ CMakeLists.txt: set(git_builtin_extra\n       \tendforeach()\n       endif()\n       \n     -@@ CMakeLists.txt: set(bin_links\n     +@@ contrib/buildsystems/CMakeLists.txt: set(bin_links\n       \tgit-receive-pack git-upload-archive git-upload-pack)\n       \n       foreach(b ${bin_links})\n     @@ CMakeLists.txt: set(bin_links\n       endforeach()\n       \n       install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4\n     -@@ CMakeLists.txt: set(wrapper_test_scripts\n     +@@ contrib/buildsystems/CMakeLists.txt: set(wrapper_test_scripts\n       foreach(script ${wrapper_scripts})\n       \tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n       \tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n     @@ CMakeLists.txt: set(wrapper_test_scripts\n       \tfile(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n       endforeach()\n       \n     -@@ CMakeLists.txt: file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PTHREADS='${NO_PTHREADS}'\\\n     +@@ contrib/buildsystems/CMakeLists.txt: 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\")\n       file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PAGER_ENV='${PAGER_ENV}'\\n\")\n       file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"DC_SHA1='${DC_SHA1}'\\n\")\n  7:  af6c606881d !  7:  8f36e30cd22 cmake: support for building git on windows with msvc and clang.\n     @@ Commit message\n      \n          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n      \n     - ## CMakeLists.txt ##\n     -@@\n     - #\tCopyright (c) 2020 Sibi Siddharthan\n     - #\n     - \n     --cmake_minimum_required(VERSION 3.14)\n     -+cmake_minimum_required(VERSION 3.15)\n     - \n     - #Parse GIT-VERSION-GEN to get the version\n     - file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX \"DEF_VER=v(.*)\")\n     -@@ CMakeLists.txt: find_package(ZLIB REQUIRED)\n     + ## contrib/buildsystems/CMakeLists.txt ##\n     +@@ contrib/buildsystems/CMakeLists.txt: find_package(ZLIB REQUIRED)\n       find_package(CURL)\n       find_package(EXPAT)\n       find_package(Iconv)\n     @@ CMakeLists.txt: find_package(ZLIB REQUIRED)\n       \n       if(NOT Intl_FOUND)\n       \tadd_compile_definitions(NO_GETTEXT)\n     -@@ CMakeLists.txt: if(NOT SH_EXE)\n     - \t\t\t\"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n     +@@ contrib/buildsystems/CMakeLists.txt: if(Intl_FOUND)\n       endif()\n       \n     + \n      -if(WIN32)\n      +if(WIN32 AND NOT MSVC)#not required for visual studio builds\n       \tfind_program(WINDRES_EXE windres)\n       \tif(NOT WINDRES_EXE)\n       \t\tmessage(FATAL_ERROR \"Install windres on Windows for resource files\")\n     -@@ CMakeLists.txt: if(NOT MSGFMT_EXE)\n     +@@ contrib/buildsystems/CMakeLists.txt: if(NOT MSGFMT_EXE)\n       \tmessage(WARNING \"Text Translations won't be build\")\n       endif()\n       \n     @@ CMakeLists.txt: if(NOT MSGFMT_EXE)\n       #default behaviour\n       include_directories(${CMAKE_SOURCE_DIR})\n       add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n     -@@ CMakeLists.txt: endif()\n     +@@ contrib/buildsystems/CMakeLists.txt: endif()\n       \n       #Platform Specific\n     - if(${CMAKE_SYSTEM_NAME} STREQUAL \"Windows\")\n     + if(CMAKE_SYSTEM_NAME STREQUAL \"Windows\")\n      +\tif(CMAKE_C_COMPILER_ID STREQUAL \"MSVC\" OR CMAKE_C_COMPILER_ID STREQUAL \"Clang\")\n     -+\t\tinclude_directories(compat/vcbuild/include)\n     ++\t\tinclude_directories(${CMAKE_SOURCE_DIR}/compat/vcbuild/include)\n      +\t\tadd_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)\n      +\tendif()\n     - \tinclude_directories(compat/win32)\n     + \tinclude_directories(${CMAKE_SOURCE_DIR}/compat/win32)\n       \tadd_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32\n       \t\t\t\t_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=\".exe\"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT\n     -@@ CMakeLists.txt: set(libvcs-svn_SOURCES\n     - \tvcs-svn/svndiff.c vcs-svn/svndump.c)\n     +@@ contrib/buildsystems/CMakeLists.txt: parse_makefile_for_sources(libvcs-svn_SOURCES \"VCSSVN_OBJS\")\n     + list(TRANSFORM libvcs-svn_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n       add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})\n       \n      -#add git.rc for gcc\n     @@ CMakeLists.txt: set(libvcs-svn_SOURCES\n       \tadd_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)\n       endif()\n       \n     -@@ CMakeLists.txt: endif()\n     +@@ contrib/buildsystems/CMakeLists.txt: endif()\n       if(WIN32)\n       \ttarget_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)\n       \tadd_dependencies(common-main git-rc)\n     @@ CMakeLists.txt: endif()\n       elseif(UNIX)\n       \ttarget_link_libraries(common-main pthread rt)\n       endif()\n     -@@ CMakeLists.txt: target_link_libraries(test-tool common-main)\n     +@@ contrib/buildsystems/CMakeLists.txt: target_link_libraries(test-tool common-main)\n       set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool\n       \t\t\tPROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)\n       \n  8:  f496cd7d8aa <  -:  ----------- cmake: added checks for struct stat and libiconv\n  9:  9c674372fb5 <  -:  ----------- cmake: relocated script file contrib/buildsystems\n 10:  b0a321a714a <  -:  ----------- cmake: parse the makefile for the sources.\n 11:  fa1b8032906 !  8:  bb329d16ce0 ci: modification of main.yml to use cmake for vs-build job\n     @@\n       ## Metadata ##\n     -Author: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n     +Author: Sibi Siddharthan <sibisiv.siddharthan@gmail.com>\n      \n       ## Commit message ##\n          ci: modification of main.yml to use cmake for vs-build job\n      \n     -    This patch modifies .github/workflows/main.yml to use CMake for\n     -    Visual Studio builds.\n     +    Teach .github/workflows/main.yml to use CMake for VS builds.\n      \n          Modified the vs-test step to match windows-test step. This speeds\n          up the vs-test. Calling git-cmd from powershell and then calling git-bash\n     @@ Commit message\n          building git (eg zlib,libiconv). So we extract the libraries before we\n          configure.\n      \n     -    Changes:\n     -    The CMake script has been relocated to contib/buildsystems, so point\n     -    to the CMakeLists.txt in the invocation commands.\n     -\n     -    The generation command now uses the absolute paths for the generation\n     -    step.\n     -\n          To check for ICONV_OMITS_BOM libiconv.dll needs to be in the working\n          directory of script or path. So we copy the dlls before we configure.\n      \n     -    Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n     +    Signed-off-by: Sibi Siddharthan <sibisiv.siddharthan@gmail.com>\n      \n       ## .github/workflows/main.yml ##\n      @@ .github/workflows/main.yml: jobs:\n     -     - name: download git-sdk-64-minimal\n     -       shell: bash\n     -       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 -\n     +         ## Unzip and remove the artifact\n     +         unzip artifacts.zip\n     +         rm artifacts.zip\n      -    - name: generate Visual Studio solution\n      -      shell: powershell\n      -      run: |\n     @@ .github/workflows/main.yml: jobs:\n               & git-sdk-64-minimal\\usr\\bin\\bash.exe -lc @\"\n                 mkdir -p artifacts &&\n                 eval \\\"`$(make -n artifacts-tar INCLUDE_DLLS_IN_ARTIFACTS=YesPlease ARTIFACTS_DIRECTORY=artifacts 2>&1 | grep ^tar)\\\"\n     -@@ .github/workflows/main.yml: jobs:\n     -         nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n     -     steps:\n     -     - uses: actions/checkout@v1\n     --    - name: download git-64-portable\n     -+    - name: download git-sdk-64-minimal\n     -       shell: bash\n     --      run: a=git-64-portable && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -\n     -+      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 -\n     -     - name: download build artifacts\n     -       uses: actions/download-artifact@v1\n     -       with:\n      @@ .github/workflows/main.yml: jobs:\n           - name: extract build artifacts\n             shell: bash\n     @@ .github/workflows/main.yml: jobs:\n             shell: powershell\n             env:\n               MSYSTEM: MINGW64\n     -         NO_SVN_TESTS: 1\n     -         GIT_TEST_SKIP_REBASE_P: 1\n     -       run: |\n     --        & git-64-portable\\git-cmd.exe --command=usr\\bin\\bash.exe -lc @\"\n     --          # Let Git ignore the SDK and the test-cache\n     --          printf '%s\\n' /git-64-portable/ /test-cache/ >>.git/info/exclude\n     -+        & .\\git-sdk-64-minimal\\usr\\bin\\bash.exe -lc @\"\n     -+          # Let Git ignore the SDK\n     -+          printf '%s\\n' /git-sdk-64-minimal/ >>.git/info/exclude\n     +@@ .github/workflows/main.yml: jobs:\n     +           # Let Git ignore the SDK and the test-cache\n     +           printf '%s\\n' /git-sdk-64-minimal/ /test-cache/ >>.git/info/exclude\n       \n      -          cd t &&\n      -          PATH=\\\"`$PWD/helper:`$PATH\\\" &&\n     @@ .github/workflows/main.yml: jobs:\n      +        name: failed-tests-windows\n      +        path: ${{env.FAILED_TEST_ARTIFACTS}}\n         regular:\n     -     strategy:\n     -       matrix:\n     +     needs: ci-config\n     +     if: needs.ci-config.outputs.enabled == 'yes'\n     +@@ .github/workflows/main.yml: jobs:\n     +     steps:\n     +     - uses: actions/checkout@v1\n     +     - run: ci/install-dependencies.sh\n     +-    - run: ci/test-documentation.sh\n     ++    - run: ci/test-documentation.sh\n     + \\ No newline at end of file\n\n-- \ngitgitgadget\n"},{"id":"398887","messageId":"bb329d16ce0999e198addf83d56f75762c830e1f.1590759624.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v3.git.1590759624.gitgitgadget@gmail.com","subject":"[PATCH v3 8/8] ci: modification of main.yml to use cmake for vs-build job","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-05-29T13:40:24Z","receivedAt":"2020-05-29T13:40:42Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiv.siddharthan@gmail.com>\n\nTeach .github/workflows/main.yml to use CMake for VS builds.\n\nModified the vs-test step to match windows-test step. This speeds\nup the vs-test. Calling git-cmd from powershell and then calling git-bash\nto perform the tests slows things down(factor of about 6). So git-bash\nis directly called from powershell to perform the tests using prove.\n\nNOTE: Since GitHub keeps the same directory for each job\n(with respect to path) absolute paths are used in the bin-wrapper\nscripts.\n\nGitHub has switched to CMake 3.17.1 which changed the behaviour of\nFindCURL module. An extra definition (-DCURL_NO_CURL_CMAKE=ON) has been\nadded to revert to the old behaviour.\n\nEdit(Explanation for the reordering of build steps):\nIn the configuration phase CMake looks for the required libraries for\nbuilding git (eg zlib,libiconv). So we extract the libraries before we\nconfigure.\n\nTo check for ICONV_OMITS_BOM libiconv.dll needs to be in the working\ndirectory of script or path. So we copy the dlls before we configure.\n\nSigned-off-by: Sibi Siddharthan <sibisiv.siddharthan@gmail.com>\n---\n .github/workflows/main.yml | 38 ++++++++++++++++++++++----------------\n 1 file changed, 22 insertions(+), 16 deletions(-)\n\ndiff --git a/.github/workflows/main.yml b/.github/workflows/main.yml\nindex 84a5dcff7a0..f0f0af720e4 100644\n--- a/.github/workflows/main.yml\n+++ b/.github/workflows/main.yml\n@@ -145,13 +145,6 @@ jobs:\n         ## Unzip and remove the artifact\n         unzip artifacts.zip\n         rm artifacts.zip\n-    - name: generate Visual Studio solution\n-      shell: powershell\n-      run: |\n-        & .\\git-sdk-64-minimal\\usr\\bin\\bash.exe -lc @\"\n-          make NDEBUG=1 DEVELOPER=1 vcxproj\n-        \"@\n-        if (!$?) { exit(1) }\n     - name: download vcpkg artifacts\n       shell: powershell\n       run: |\n@@ -163,6 +156,14 @@ jobs:\n         Remove-Item compat.zip\n     - name: add msbuild to PATH\n       uses: microsoft/setup-msbuild@v1.0.0\n+    - name: copy dlls to root\n+      shell: powershell\n+      run: |\n+        & compat\\vcbuild\\vcpkg_copy_dlls.bat release\n+        if (!$?) { exit(1) }\n+    - name: generate Visual Studio solution\n+      shell: bash\n+      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\n     - name: MSBuild\n       run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142\n     - name: bundle artifact tar\n@@ -171,8 +172,6 @@ jobs:\n         MSVC: 1\n         VCPKG_ROOT: ${{github.workspace}}\\compat\\vcbuild\\vcpkg\n       run: |\n-        & compat\\vcbuild\\vcpkg_copy_dlls.bat release\n-        if (!$?) { exit(1) }\n         & git-sdk-64-minimal\\usr\\bin\\bash.exe -lc @\"\n           mkdir -p artifacts &&\n           eval \\\"`$(make -n artifacts-tar INCLUDE_DLLS_IN_ARTIFACTS=YesPlease ARTIFACTS_DIRECTORY=artifacts 2>&1 | grep ^tar)\\\"\n@@ -203,7 +202,7 @@ jobs:\n     - name: extract build artifacts\n       shell: bash\n       run: tar xf artifacts.tar.gz\n-    - name: test (parallel)\n+    - name: test\n       shell: powershell\n       env:\n         MSYSTEM: MINGW64\n@@ -214,12 +213,19 @@ jobs:\n           # Let Git ignore the SDK and the test-cache\n           printf '%s\\n' /git-sdk-64-minimal/ /test-cache/ >>.git/info/exclude\n \n-          cd t &&\n-          PATH=\\\"`$PWD/helper:`$PATH\\\" &&\n-          test-tool.exe run-command testsuite --jobs=10 -V -x --write-junit-xml \\\n-                  `$(test-tool.exe path-utils slice-tests \\\n-                          ${{matrix.nr}} 10 t[0-9]*.sh)\n+          ci/run-test-slice.sh ${{matrix.nr}} 10\n         \"@\n+    - name: ci/print-test-failures.sh\n+      if: failure()\n+      shell: powershell\n+      run: |\n+        & .\\git-sdk-64-minimal\\usr\\bin\\bash.exe -lc ci/print-test-failures.sh\n+    - name: Upload failed tests' directories\n+      if: failure() && env.FAILED_TEST_ARTIFACTS != ''\n+      uses: actions/upload-artifact@v1\n+      with:\n+        name: failed-tests-windows\n+        path: ${{env.FAILED_TEST_ARTIFACTS}}\n   regular:\n     needs: ci-config\n     if: needs.ci-config.outputs.enabled == 'yes'\n@@ -302,4 +308,4 @@ jobs:\n     steps:\n     - uses: actions/checkout@v1\n     - run: ci/install-dependencies.sh\n-    - run: ci/test-documentation.sh\n+    - run: ci/test-documentation.sh\n\\ No newline at end of file\n-- \ngitgitgadget\n"},{"id":"398904","messageId":"xmqqy2pay216.fsf@gitster.c.googlers.com","threadId":"53305","inReplyTo":"09c972de52b35b14a4c6f44b10c3dfc1732b2c7a.1590759624.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v3 1/8] Introduce CMake support for configuring Git","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-29T19:27:49Z","receivedAt":"2020-05-29T19:27:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Sibi Siddharthan via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n>\n> At the moment, the recommended way to configure Git's builds is to\n> ...\n> Note: this patch asks for the minimum version v3.14 of CMake (which is\n> not all that old as of time of writing) because that is the first\n> version to offer a platform-independent way to generate hardlinks as\n> part of the build. This is needed to generate all those hardlinks for\n> the built-in commands of Git.\n\nAll of the above reads reasonable.\n\n> Changes\n> The CMake script parses the Makefile for:\n> LIB_OBJS\n> BUILTIN_OBJS\n> XDIFF_OBJS\n> VCSSVN_OBJS\n> TEST_BUILTINS_OBJS\n>\n> By doing this we avoid duplication of text between the Makefile and\n> the CMake script.\n>\n> The CMake script has been relocated to contrib/buildsystems.\n>\n> The CMake script uses GIT-VERSION-GEN to determine the version of Git\n> being built.\n\nEverything after the \"Changes\" line does not belong to the commit\nlog, as it is no use for those who read \"git log\" output and\nencounter the \"first\" attempt to add CMake support there.  There is\nno need to tell them that you did things differently from this\nversion in the past, as they simply do not know what you did in the\nprevious iterations, nor particularly care about them.\n\nThese *do* help reviewers who saw previous iterations, and the space\nafter the three-dash line below is the right/recommended place for\nthem.\n\nThe above applies to other patches in this series.\n\n> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> ---\n>  contrib/buildsystems/CMakeLists.txt | 575 ++++++++++++++++++++++++++++\n>  1 file changed, 575 insertions(+)\n>  create mode 100644 contrib/buildsystems/CMakeLists.txt\n>\n> diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\n> new file mode 100644\n> index 00000000000..8e2b27f44a6\n> --- /dev/null\n> +++ b/contrib/buildsystems/CMakeLists.txt\n> @@ -0,0 +1,575 @@\n> +#\n> +#\tCopyright (c) 2020 Sibi Siddharthan\n> +#\n> +\n> +#[[\n> +\n> +Instructions to run CMake:\n> +\n> +cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release\n\nThe readers can infer from `relative-path-to-CMakeLists` that they\ncan run this command from anywhere, e.g.\n\n\t$ cd $HOME\n\t$ tar xf /var/tmp/git-2.7.0.tar\n\t$ cd /tmp\n\t$ cmake $HOME/git/contrib/buildsystems/CMakeLists.txt\n\nbut when given the freedom/flexibility to use it from \"anywhere\",\nthey are faced by an extra choice to make.  It may be helpful to\nreaders to elaborate a bit more to help them decide where in the\ndirectory hierarchy they would want to run this command.  In the\nabove example sequence, I chose /tmp, but if I used /var/tmp as the\nstarting place instead, what becomes different?  The answer might\nbe \"resulting 'git' binary is stored in the directory you run the\n'cmake' command in\", and by spelling it out, it helps readers to\nmake an informed decision.\n\n> +Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding\n> +compiler flags\n> +Debug : -g\n> +Release: -O3\n> +RelWithDebInfo : -O2 -g\n> +MinSizeRel : -Os\n> +empty(default) :\n> +\n> +NOTE: -DCMAKE_BUILD_TYPE is optional. For multi-config generators like Visual Studio\n> +this option is ignored\n\nQuite helpful.\n\n> +This process generates a Makefile(Linux) , Visual Studio solution(Windows) by default.\n> +Run `make` to build Git on Linux.\n> +Open git.sln on Windows and build Git.\n> +\n> +NOTE: By default CMake uses Makefile as the build tool on Linux and Visual Studio in Windows,\n\nThe above makes it sound as if Linux and VS are the only two systems\nwe care about, but is it really Linux, or UNIX-flavoured systems in\ngeneral?  In other words, are we excluding friends on BSD and macOS\nwith the above?\n\nThe above is not a complaint about \"exclusion\", but is a complaint\nabout unclarity.\n\n> +to use another tool say `ninja` add this to the command line when configuring.\n> +`-G Ninja`\n> +\n> +]]\n> +cmake_minimum_required(VERSION 3.14)\n> ...\n> +check_c_source_compiles(\"\n\nThe \"source\" given to check_c_source_{compiles,runs} may be allowed\nto be anything, but I'd prefer to see it follow some consistent\nstyle, preferrably our CodingGuidelines (except for git specific\nbits like \"do not include standard system file but instead just use\ngit-compat-util.h\", which of course should not apply).  This is a\ncomment not only about the two instances below I use as examples,\nbut all C-source snippets in this patch.\n\n> +#include <alloca.h>\n> +int\n> +main ()\n> +{\n\n\tint main(void)\n\t{\n\nis how we start this function.\n\n> +char *p = (char *) alloca (2 * sizeof (int));\n\nAnd the decl of function local variable here would be indented by a\nHT like the remainder of the function.  No SP between function name\nand the parentheses around its arguments.  NP SP after sizeof,\neither.\n\n> +\tif (p) return 0;\n> +\treturn 0;\n> +}\"\n> +HAVE_ALLOCA_H)\n> ...\n> +check_c_source_runs(\"\n> +#include<stdio.h>\n> +#include<stdarg.h>\n> +#include<string.h>\n> +#include<stdlib.h>\n> +int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)\n> +{\n> +\tint ret;\n> +\tva_list ap;\n> +\n> +\tva_start(ap, format);\n> +\tret = vsnprintf(str, maxsize, format, ap);\n> +\tva_end(ap);\n> +\treturn ret;\n> +}\n> +\n> +int\n> +main ()\n> +{\n\nLikewise.\n\n> +\tchar buf[6];\n> +\tif (test_vsnprintf(buf, 3, \\\"%s\\\", \\\"12345\\\") != 5\n> +\t\t|| strcmp(buf, \\\"12\\\")) return 1;\n> +\tif (snprintf(buf, 3, \\\"%s\\\", \\\"12345\\\") != 5\n> +\t\t|| strcmp(buf, \\\"12\\\")) return 1;\n> +\n> +\treturn 0;\n> +}\"\n\nThanks.\n"},{"id":"398905","messageId":"xmqqwo4uy20z.fsf@gitster.c.googlers.com","threadId":"53305","inReplyTo":"f19794fdbc09cc3c57392dc522920f7b01691d88.1590759624.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v3 2/8] cmake: generate the shell/perl/python scripts and templates, translations","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-29T19:27:56Z","receivedAt":"2020-05-29T19:28:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Sibi Siddharthan via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n>\n> Implement the placeholder substitution to generate scripted\n> Porcelain commands, e.g. git-request-pull out of\n> git-request-pull.sh\n>\n> Generate shell/perl/python scripts and template using CMake instead of\n> using sed like the build procedure in the Makefile does.\n>\n> The text translations are only build if `msgfmt` is found in your path.\n>\n> NOTE: The scripts and templates are generated during configuration.\n\nOK.\n\n> Changes\n> The CMake script parses the Makefile for:\n> SCRIPT_SH\n> SCRIPT_PERL\n\nBelow the three-dash line.\n\n> +#shell scripts\n> +parse_makefile_for_scripts(git_sh_scripts \"SCRIPT_SH\" \".sh\")\n\nOK.\n\n> +set(git_shell_scripts\n> +\t${git_sh_scripts}\n> +\tgit-mergetool--lib git-parse-remote git-rebase--preserve-merges\n> +\tgit-sh-setup git-sh-i18n git-instaweb)\n\nDo we need to have enumeration here, which can drift out of sync\nwith the reality?  Wouldn't we want to avoid it with something like\n\n parse_makefile_for_scripts(git_sh_lib \"SCRIPT_LIB\" \"\")\n\ntoo?\n\n> +#perl modules\n> +file(GLOB_RECURSE perl_modules \"${CMAKE_SOURCE_DIR}/perl/*.pm\")\n> +\n> +foreach(pm ${perl_modules})\n> +\tstring(REPLACE \"${CMAKE_SOURCE_DIR}/perl/\" \"\" file_path ${pm})\n> +\tfile(STRINGS ${pm} content NEWLINE_CONSUME)\n> +\tstring(REPLACE \"@@LOCALEDIR@@\" \"${LOCALEDIR}\" content \"${content}\")\n> +\tstring(REPLACE \"@@NO_PERL_CPAN_FALLBACKS@@\" \"\" content \"${content}\")\n> +\tfile(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})\n> +#test-lib.sh requires perl/build/lib to be the build directory of perl modules\n> +endforeach()\n> +\n> +\n> +#templates\n> +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches\n> +set(hooks_templates\n> +\tapplypatch-msg.sample pre-applypatch.sample pre-push.sample\n> +\tcommit-msg.sample pre-commit.sample pre-rebase.sample\n> +\tfsmonitor-watchman.sample pre-merge-commit.sample pre-receive.sample\n> +\tpost-update.sample prepare-commit-msg.sample update.sample)\n\nDo we need to have enumeration here, which can drift out of sync\nwith the reality?  Wouldn't we want to avoid it with file(GLOB) or\nsomething?\n\n> +#templates have @.*@ replacement so use configure_file instead\n> +#hooks\n> +foreach(tm ${hooks_templates})\n> +\tconfigure_file(${CMAKE_SOURCE_DIR}/templates/hooks--${tm} ${CMAKE_BINARY_DIR}/templates/blt/hooks/${tm} @ONLY)\n> +endforeach()\n> +\n> +#info\n> +configure_file(${CMAKE_SOURCE_DIR}/templates/info--exclude ${CMAKE_BINARY_DIR}/templates/blt/info/exclude @ONLY)\n> +\n> +#this\n> +configure_file(${CMAKE_SOURCE_DIR}/templates/this--description ${CMAKE_BINARY_DIR}/templates/blt/description @ONLY)\n\nI was hoping that we could drive any build system without having to\nhave separate rules like the above.  The idea behind all files with\nfunny double-dash in its name under templates/ directory is:\n\n - double-dash denotes directory boundary\n\n - when a template input ends with double-dash, it tells us to\n   create a directory\n\n - leading \"this--\" denotes \"not in a subdirectory but at the top\n   level of the generated template directory\"\n\nso that each of them knows what the name of the file and directory\nhierarchy of the final destination is, and the result of transforming\ncan be created and deposited at the final place mechanically with a\nsingle rule.\n\n> +#translations\n> +if(MSGFMT_EXE)\n> +\tset(po_files bg  ca  de  el  es  fr  is  it  ko  pt_PT  ru  sv  tr  vi  zh_CN  zh_TW)\n\nDo we need to have enumeration here, which can drift out of sync\nwith the reality?  Wouldn't globbing for *.po be sufficient?\n\n> +\tforeach(po ${po_files})\n> +\t\tfile(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES)\n> +\t\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo\n> +\t\t\t\tCOMMAND ${MSGFMT_EXE} --check --statistics -o ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo ${CMAKE_SOURCE_DIR}/po/${po}.po)\n> +\t\tlist(APPEND po_gen ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo)\n> +\tendforeach()\n> +\tadd_custom_target(po-gen ALL DEPENDS ${po_gen})\n> +endif()\n\nThanks.\n"},{"id":"398926","messageId":"20200530131730.GA2151@danh.dev","threadId":"53305","inReplyTo":"09c972de52b35b14a4c6f44b10c3dfc1732b2c7a.1590759624.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v3 1/8] Introduce CMake support for configuring Git","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-05-30T13:17:30Z","receivedAt":"2020-05-30T13:17:39Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"Hi Sibi,\n\nOn 2020-05-29 13:40:17+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> +file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE git_version REGEX \"GIT_VERSION = (.*)\")\n> +string(REPLACE \"GIT_VERSION = \" \"\" git_version ${git_version})\n> +string(FIND ${git_version} \"GIT\" location)\n> +if(location EQUAL -1)\n> +\tstring(REGEX MATCH \"[0-9]*\\\\.[0-9]*\\\\.[0-9]*\" git_version ${git_version})\n\nThis will strip everything begins with first non-number.\n\nWith the same Git repo,\nThe git binary generated via Makefile reports version:\n\n\tgit version 2.27.0.rc2.274.g860c8aebb9.dirty\n\nThe git binary generated via CMake reports:\n\n\tgit version 2.27.0.GIT\n\nAnyway, I pretty much defer this step to build step. Since this will\nreport the version when *cmake* is run. And *cmake* will be unlikely\nrun again if nothing related to CMake is being changed.\n\n-- \nDanh\n"},{"id":"398927","messageId":"20200530134923.GB2151@danh.dev","threadId":"53305","inReplyTo":"cdc53172b3f073095911fe9f7f5ff8ea6546013c.1590759624.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v3 4/8] cmake: support for testing git with ctest","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-05-30T13:49:23Z","receivedAt":"2020-05-30T13:49:29Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2020-05-29 13:40:20+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> \n> This patch provides an alternate way to test git using ctest.\n> CTest ships with CMake, so there is no additional dependency being\n> introduced.\n> \n> To perform the tests with ctest do this after building:\n> ctest -j[number of jobs]\n\nOr we can just run: make test\nCMake will run: ctest itself.\n\nAh, OK, that's not equivalence. make -j9 test doesn't work :/\n\nAnyway, there're test is failing in Linux with this CMake.\n\n\t$git_repo/t/../build/bin-wrappers/git is not executable; using GIT_EXEC_PATH\n\nIt looks like CMake Generator forgets \"chmod +x bin-wrappers/git\"\n\n> Test time =   1.11 sec\n> \n> NOTE: Testing only works when building in source for now.\n\nOK, so this maybe the pain point, let me build in source again.\nHm, no, I still see the same problems.\nWorse, CMake overrides my current Makefile.\nLuckily, I don't have any changes in Makefile.\n\n> +endif()#BUILD_TESTING\n\nWe can use:\n\n\tendif(BUILD_TESTING)\n\n-- \nDanh\n"},{"id":"398928","messageId":"20200530140847.GC2151@danh.dev","threadId":"53305","inReplyTo":"8f36e30cd2218fa56fb0c2b89f6f51726b0eb285.1590759624.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v3 7/8] cmake: support for building git on windows with msvc and clang.","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-05-30T14:08:47Z","receivedAt":"2020-05-30T14:08:53Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2020-05-29 13:40:23+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> \n> This patch adds support for Visual Studio and Clang builds\n> \n> The minimum required version of CMake is upgraded to 3.15 because\n> this version offers proper support for Clang builds on Windows.\n> \n> Libintl is not searched for when building with Visual Studio or Clang\n> because there is no binary compatible version available yet.\n> \n> NOTE: In the link options invalidcontinue.obj has to be included.\n> The reason for this is because by default, Windows calls abort()'s\n> instead of setting errno=EINVAL when invalid arguments are passed to\n> standard functions.\n> This commit explains it in detail:\n> 4b623d80f73528a632576990ca51e34c333d5dd6\n\nI think it's better to say:\n\n\tSee 4b623d80f7 (MSVC: link in invalidcontinue.obj for better\n\tPOSIX compatibility, 2014-03-29) for detail.\n\n\n(I haven't read the referenced commit, FWIW)\n\n> On Windows the default generator is Visual Studio,so for Visual Studio\n> builds do this:\n> \n> cmake `relative-path-to-srcdir`\n> \n> NOTE: Visual Studio generator is a multi config generator, which means\n> that Debug and Release builds can be done on the same build directory.\n> \n> For Clang builds do this:\n> \n> On bash\n> CC=Clang cmake `relative-path-to-srcdir` -G Ninja\n\nI think you meant CC=clang, note the lowercase c,\nthat will cmake this note applicable for case-sensitive filesystem.\n\n... reading this patch ...\n\nSo, this is applicable for Windows only, it's fine as is, then.\nIt's still better to lowercase it, though.\n\n> \t\t-DCMAKE_BUILD_TYPE=[Debug or Release]\n> \n> On cmd\n> set CC=Clang\n> cmake `relative-path-to-srcdir` -G Ninja\n> \t\t-DCMAKE_BUILD_TYPE=[Debug or Release]\n> \n> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> ---\n>  contrib/buildsystems/CMakeLists.txt | 55 +++++++++++++++++++++++------\n>  1 file changed, 45 insertions(+), 10 deletions(-)\n> \n> diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\n> index 46197d0b806..0a3f711db88 100644\n> --- a/contrib/buildsystems/CMakeLists.txt\n> +++ b/contrib/buildsystems/CMakeLists.txt\n> @@ -98,8 +98,11 @@ find_package(ZLIB REQUIRED)\n>  find_package(CURL)\n>  find_package(EXPAT)\n>  find_package(Iconv)\n> -find_package(Intl)\n>  \n> +#Don't use libintl on Windows Visual Studio and Clang builds\n> +if(NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL \"MSVC\" OR CMAKE_C_COMPILER_ID STREQUAL \"Clang\")))\n\nPersonally, I find this is a bit ugly.\nDoes it work to move the if(WIN32) down there, here.\nThen make sub-condition for MSVC and Clang?\n\n> +\tfind_package(Intl)\n> +endif()\n>  \n>  if(NOT Intl_FOUND)\n>  \tadd_compile_definitions(NO_GETTEXT)\n> @@ -123,7 +126,7 @@ if(Intl_FOUND)\n>  endif()\n>  \n>  \n> -if(WIN32)\n> +if(WIN32 AND NOT MSVC)#not required for visual studio builds\n\nfor the down there, I meant here.\nUsing \"NOT MSVC\" here and `CMAKE_C_COMPILER_ID STREQUAL \"MSVC\"` above\nmay puzzle people interest in this patch.\n\n>  \tfind_program(WINDRES_EXE windres)\n>  \tif(NOT WINDRES_EXE)\n>  \t\tmessage(FATAL_ERROR \"Install windres on Windows for resource files\")\n> @@ -135,6 +138,13 @@ if(NOT MSGFMT_EXE)\n>  \tmessage(WARNING \"Text Translations won't be build\")\n>  endif()\n>  \n> +#Force all visual studio outputs to CMAKE_BINARY_DIR\n> +if(CMAKE_C_COMPILER_ID STREQUAL \"MSVC\")\n> +\tset(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})\n> +\tset(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})\n> +\tadd_compile_options(/MP)\n> +endif()\n> +\n>  #default behaviour\n>  include_directories(${CMAKE_SOURCE_DIR})\n>  add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n> @@ -172,6 +182,10 @@ endif()\n>  \n>  #Platform Specific\n>  if(CMAKE_SYSTEM_NAME STREQUAL \"Windows\")\n\nI missed this line from previous patch\n(and my comment in previous round, which suggested remove ${})\nDoes `if(WIN32)` and `if(CMAKE_SYSTEM_NAME STREQUAL \"Windows\")` have\ndifferent meanings?\nI don't know much about CMake on Windows to really sure about this.\n\n-- \nDanh\n"},{"id":"398929","messageId":"20200530141448.GD2151@danh.dev","threadId":"53305","inReplyTo":"bb329d16ce0999e198addf83d56f75762c830e1f.1590759624.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v3 8/8] ci: modification of main.yml to use cmake for vs-build job","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-05-30T14:14:48Z","receivedAt":"2020-05-30T14:14:53Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2020-05-29 13:40:24+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> To check for ICONV_OMITS_BOM libiconv.dll needs to be in the working\n> directory of script or path. So we copy the dlls before we configure.\n\nIf ICONV_OMITS_BOM is such a troublemaker for CMake,\nI'm fine with not supporting it at all.\n\nIt seems like noone except me have interest in ICONV_OMITS_BOM.\n\n> @@ -302,4 +308,4 @@ jobs:\n>      steps:\n>      - uses: actions/checkout@v1\n>      - run: ci/install-dependencies.sh\n> -    - run: ci/test-documentation.sh\n> +    - run: ci/test-documentation.sh\n> \\ No newline at end of file\n\nPlease fix your editor ;)\n\n-- \nDanh\n"},{"id":"398940","messageId":"CAKiG+9WWqHJNz_fEaQ+Rw3sRJSFOutCt772v1mbZeOS2rWpDOA@mail.gmail.com","threadId":"53305","inReplyTo":"xmqqy2pay216.fsf@gitster.c.googlers.com","subject":"Re: [PATCH v3 1/8] Introduce CMake support for configuring Git","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-05-30T18:50:43Z","receivedAt":"2020-05-30T18:51:01Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Sat, May 30, 2020 at 12:57 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> \"Sibi Siddharthan via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>\n> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> >\n> > At the moment, the recommended way to configure Git's builds is to\n> > ...\n> > Note: this patch asks for the minimum version v3.14 of CMake (which is\n> > not all that old as of time of writing) because that is the first\n> > version to offer a platform-independent way to generate hardlinks as\n> > part of the build. This is needed to generate all those hardlinks for\n> > the built-in commands of Git.\n>\n> All of the above reads reasonable.\n>\n> > Changes\n> > The CMake script parses the Makefile for:\n> > LIB_OBJS\n> > BUILTIN_OBJS\n> > XDIFF_OBJS\n> > VCSSVN_OBJS\n> > TEST_BUILTINS_OBJS\n> >\n> > By doing this we avoid duplication of text between the Makefile and\n> > the CMake script.\n> >\n> > The CMake script has been relocated to contrib/buildsystems.\n> >\n> > The CMake script uses GIT-VERSION-GEN to determine the version of Git\n> > being built.\n>\n> Everything after the \"Changes\" line does not belong to the commit\n> log, as it is no use for those who read \"git log\" output and\n> encounter the \"first\" attempt to add CMake support there.  There is\n> no need to tell them that you did things differently from this\n> version in the past, as they simply do not know what you did in the\n> previous iterations, nor particularly care about them.\n>\n> These *do* help reviewers who saw previous iterations, and the space\n> after the three-dash line below is the right/recommended place for\n> them.\n>\n> The above applies to other patches in this series.\n\nDo you mean this line '---' below?\nIf so how do I place the changelog below them?\nI just do `/submit` at gigitgadet/git.\n\n>\n> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> > ---\n> >  contrib/buildsystems/CMakeLists.txt | 575 ++++++++++++++++++++++++++++\n> >  1 file changed, 575 insertions(+)\n> >  create mode 100644 contrib/buildsystems/CMakeLists.txt\n> >\n> > diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\n> > new file mode 100644\n> > index 00000000000..8e2b27f44a6\n> > --- /dev/null\n> > +++ b/contrib/buildsystems/CMakeLists.txt\n> > @@ -0,0 +1,575 @@\n> > +#\n> > +#    Copyright (c) 2020 Sibi Siddharthan\n> > +#\n> > +\n> > +#[[\n> > +\n> > +Instructions to run CMake:\n> > +\n> > +cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release\n>\n> The readers can infer from `relative-path-to-CMakeLists` that they\n> can run this command from anywhere, e.g.\n>\n>         $ cd $HOME\n>         $ tar xf /var/tmp/git-2.7.0.tar\n>         $ cd /tmp\n>         $ cmake $HOME/git/contrib/buildsystems/CMakeLists.txt\n>\n> but when given the freedom/flexibility to use it from \"anywhere\",\n> they are faced by an extra choice to make.  It may be helpful to\n> readers to elaborate a bit more to help them decide where in the\n> directory hierarchy they would want to run this command.  In the\n> above example sequence, I chose /tmp, but if I used /var/tmp as the\n> starting place instead, what becomes different?  The answer might\n> be \"resulting 'git' binary is stored in the directory you run the\n> 'cmake' command in\", and by spelling it out, it helps readers to\n> make an informed decision.\n>\n\nOkay\n\n> > +Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding\n> > +compiler flags\n> > +Debug : -g\n> > +Release: -O3\n> > +RelWithDebInfo : -O2 -g\n> > +MinSizeRel : -Os\n> > +empty(default) :\n> > +\n> > +NOTE: -DCMAKE_BUILD_TYPE is optional. For multi-config generators like Visual Studio\n> > +this option is ignored\n>\n> Quite helpful.\n>\n> > +This process generates a Makefile(Linux) , Visual Studio solution(Windows) by default.\n> > +Run `make` to build Git on Linux.\n> > +Open git.sln on Windows and build Git.\n> > +\n> > +NOTE: By default CMake uses Makefile as the build tool on Linux and Visual Studio in Windows,\n>\n> The above makes it sound as if Linux and VS are the only two systems\n> we care about, but is it really Linux, or UNIX-flavoured systems in\n> general?  In other words, are we excluding friends on BSD and macOS\n> with the above?\n>\n> The above is not a complaint about \"exclusion\", but is a complaint\n> about unclarity.\n>\n\nWill specify for other systems as well.\n\n> > +to use another tool say `ninja` add this to the command line when configuring.\n> > +`-G Ninja`\n> > +\n> > +]]\n> > +cmake_minimum_required(VERSION 3.14)\n> > ...\n> > +check_c_source_compiles(\"\n>\n> The \"source\" given to check_c_source_{compiles,runs} may be allowed\n> to be anything, but I'd prefer to see it follow some consistent\n> style, preferrably our CodingGuidelines (except for git specific\n> bits like \"do not include standard system file but instead just use\n> git-compat-util.h\", which of course should not apply).  This is a\n> comment not only about the two instances below I use as examples,\n> but all C-source snippets in this patch.\n>\n> > +#include <alloca.h>\n> > +int\n> > +main ()\n> > +{\n>\n>         int main(void)\n>         {\n>\n> is how we start this function.\n>\n> > +char *p = (char *) alloca (2 * sizeof (int));\n>\n> And the decl of function local variable here would be indented by a\n> HT like the remainder of the function.  No SP between function name\n> and the parentheses around its arguments.  NP SP after sizeof,\n> either.\n>\n> > +     if (p) return 0;\n> > +     return 0;\n> > +}\"\n> > +HAVE_ALLOCA_H)\n> > ...\n> > +check_c_source_runs(\"\n> > +#include<stdio.h>\n> > +#include<stdarg.h>\n> > +#include<string.h>\n> > +#include<stdlib.h>\n> > +int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)\n> > +{\n> > +     int ret;\n> > +     va_list ap;\n> > +\n> > +     va_start(ap, format);\n> > +     ret = vsnprintf(str, maxsize, format, ap);\n> > +     va_end(ap);\n> > +     return ret;\n> > +}\n> > +\n> > +int\n> > +main ()\n> > +{\n>\n> Likewise.\n>\n> > +     char buf[6];\n> > +     if (test_vsnprintf(buf, 3, \\\"%s\\\", \\\"12345\\\") != 5\n> > +             || strcmp(buf, \\\"12\\\")) return 1;\n> > +     if (snprintf(buf, 3, \\\"%s\\\", \\\"12345\\\") != 5\n> > +             || strcmp(buf, \\\"12\\\")) return 1;\n> > +\n> > +     return 0;\n> > +}\"\n>\n\nWill format the checks.\n\nThank You,\nSibi Siddharthan\n\n> Thanks.\n"},{"id":"398941","messageId":"CAKiG+9Ue1fqrzqHduZY4Pnsh4q+Thqq618JymkonmVhGewmM1g@mail.gmail.com","threadId":"53305","inReplyTo":"xmqqwo4uy20z.fsf@gitster.c.googlers.com","subject":"Re: [PATCH v3 2/8] cmake: generate the shell/perl/python scripts and templates, translations","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-05-30T18:56:56Z","receivedAt":"2020-05-30T18:57:10Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Sat, May 30, 2020 at 12:58 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> \"Sibi Siddharthan via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>\n> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> >\n> > Implement the placeholder substitution to generate scripted\n> > Porcelain commands, e.g. git-request-pull out of\n> > git-request-pull.sh\n> >\n> > Generate shell/perl/python scripts and template using CMake instead of\n> > using sed like the build procedure in the Makefile does.\n> >\n> > The text translations are only build if `msgfmt` is found in your path.\n> >\n> > NOTE: The scripts and templates are generated during configuration.\n>\n> OK.\n>\n> > Changes\n> > The CMake script parses the Makefile for:\n> > SCRIPT_SH\n> > SCRIPT_PERL\n>\n> Below the three-dash line.\n>\n> > +#shell scripts\n> > +parse_makefile_for_scripts(git_sh_scripts \"SCRIPT_SH\" \".sh\")\n>\n> OK.\n>\n> > +set(git_shell_scripts\n> > +     ${git_sh_scripts}\n> > +     git-mergetool--lib git-parse-remote git-rebase--preserve-merges\n> > +     git-sh-setup git-sh-i18n git-instaweb)\n>\n> Do we need to have enumeration here, which can drift out of sync\n> with the reality?  Wouldn't we want to avoid it with something like\n>\n>  parse_makefile_for_scripts(git_sh_lib \"SCRIPT_LIB\" \"\")\n>\n> too?\n>\n\nWill do.\n\n> > +#perl modules\n> > +file(GLOB_RECURSE perl_modules \"${CMAKE_SOURCE_DIR}/perl/*.pm\")\n> > +\n> > +foreach(pm ${perl_modules})\n> > +     string(REPLACE \"${CMAKE_SOURCE_DIR}/perl/\" \"\" file_path ${pm})\n> > +     file(STRINGS ${pm} content NEWLINE_CONSUME)\n> > +     string(REPLACE \"@@LOCALEDIR@@\" \"${LOCALEDIR}\" content \"${content}\")\n> > +     string(REPLACE \"@@NO_PERL_CPAN_FALLBACKS@@\" \"\" content \"${content}\")\n> > +     file(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})\n> > +#test-lib.sh requires perl/build/lib to be the build directory of perl modules\n> > +endforeach()\n> > +\n> > +\n> > +#templates\n> > +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches\n> > +set(hooks_templates\n> > +     applypatch-msg.sample pre-applypatch.sample pre-push.sample\n> > +     commit-msg.sample pre-commit.sample pre-rebase.sample\n> > +     fsmonitor-watchman.sample pre-merge-commit.sample pre-receive.sample\n> > +     post-update.sample prepare-commit-msg.sample update.sample)\n>\n> Do we need to have enumeration here, which can drift out of sync\n> with the reality?  Wouldn't we want to avoid it with file(GLOB) or\n> something?\n>\n\nWill glob the above, and the po files as well.\n\n> > +#templates have @.*@ replacement so use configure_file instead\n> > +#hooks\n> > +foreach(tm ${hooks_templates})\n> > +     configure_file(${CMAKE_SOURCE_DIR}/templates/hooks--${tm} ${CMAKE_BINARY_DIR}/templates/blt/hooks/${tm} @ONLY)\n> > +endforeach()\n> > +\n> > +#info\n> > +configure_file(${CMAKE_SOURCE_DIR}/templates/info--exclude ${CMAKE_BINARY_DIR}/templates/blt/info/exclude @ONLY)\n> > +\n> > +#this\n> > +configure_file(${CMAKE_SOURCE_DIR}/templates/this--description ${CMAKE_BINARY_DIR}/templates/blt/description @ONLY)\n>\n> I was hoping that we could drive any build system without having to\n> have separate rules like the above.  The idea behind all files with\n> funny double-dash in its name under templates/ directory is:\n>\n\nSo, I have to write the logic for determining the directories?\nIf so will do.\n\n>  - double-dash denotes directory boundary\n>\n>  - when a template input ends with double-dash, it tells us to\n>    create a directory\n>\n>  - leading \"this--\" denotes \"not in a subdirectory but at the top\n>    level of the generated template directory\"\n>\n> so that each of them knows what the name of the file and directory\n> hierarchy of the final destination is, and the result of transforming\n> can be created and deposited at the final place mechanically with a\n> single rule.\n>\n> > +#translations\n> > +if(MSGFMT_EXE)\n> > +     set(po_files bg  ca  de  el  es  fr  is  it  ko  pt_PT  ru  sv  tr  vi  zh_CN  zh_TW)\n>\n> Do we need to have enumeration here, which can drift out of sync\n> with the reality?  Wouldn't globbing for *.po be sufficient?\n>\n> > +     foreach(po ${po_files})\n> > +             file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES)\n> > +             add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo\n> > +                             COMMAND ${MSGFMT_EXE} --check --statistics -o ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo ${CMAKE_SOURCE_DIR}/po/${po}.po)\n> > +             list(APPEND po_gen ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo)\n> > +     endforeach()\n> > +     add_custom_target(po-gen ALL DEPENDS ${po_gen})\n> > +endif()\n>\n> Thanks.\n"},{"id":"398942","messageId":"CAKiG+9WxoffdtQPvVk=8nG+Q58VvrCd4T41bP3ef3wn+FV8h4A@mail.gmail.com","threadId":"53305","inReplyTo":"20200530134923.GB2151@danh.dev","subject":"Re: [PATCH v3 4/8] cmake: support for testing git with ctest","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-05-30T19:04:52Z","receivedAt":"2020-05-30T19:05:07Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Sat, May 30, 2020 at 7:19 PM Đoàn Trần Công Danh\n<congdanhqx@gmail.com> wrote:\n>\n> On 2020-05-29 13:40:20+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> >\n> > This patch provides an alternate way to test git using ctest.\n> > CTest ships with CMake, so there is no additional dependency being\n> > introduced.\n> >\n> > To perform the tests with ctest do this after building:\n> > ctest -j[number of jobs]\n>\n> Or we can just run: make test\n> CMake will run: ctest itself.\n>\n> Ah, OK, that's not equivalence. make -j9 test doesn't work :/\n>\n\nNo, it does not.\nmake test -> ctest --force-new-ctest-process.\n\n> Anyway, there're test is failing in Linux with this CMake.\n>\n>         $git_repo/t/../build/bin-wrappers/git is not executable; using GIT_EXEC_PATH\n>\n> It looks like CMake Generator forgets \"chmod +x bin-wrappers/git\"\n>\n\nCMake does not support changing permissions of files easily.\nYou have to juggle them around to a temporary location and\nchange the permissions when you do `file(COPY ...)`.\n\nWill look into this.\n\n> > Test time =   1.11 sec\n> >\n> > NOTE: Testing only works when building in source for now.\n>\n> OK, so this maybe the pain point, let me build in source again.\n> Hm, no, I still see the same problems.\n> Worse, CMake overrides my current Makefile.\n> Luckily, I don't have any changes in Makefile.\n>\n\nPlease read the next PATCH, it supports out of source building and testing.\n\n> > +endif()#BUILD_TESTING\n>\n> We can use:\n>\n>         endif(BUILD_TESTING)\n>\n\nThe docs suggest that this way of endif() is for backwards compat only.\nNot sure if I should change this, as CMake might remove this in the\nfuture(very unlikely though).\n\nThank You,\nSibi Siddharthan\n\n> --\n> Danh\n"},{"id":"398943","messageId":"CAKiG+9XrSb_WeLVzjSqQmdHRqUeha+cRRAFmAJeC_=9o3DB3iQ@mail.gmail.com","threadId":"53305","inReplyTo":"20200530140847.GC2151@danh.dev","subject":"Re: [PATCH v3 7/8] cmake: support for building git on windows with msvc and clang.","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-05-30T19:08:57Z","receivedAt":"2020-05-30T19:09:12Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Sat, May 30, 2020 at 7:38 PM Đoàn Trần Công Danh\n<congdanhqx@gmail.com> wrote:\n>\n> On 2020-05-29 13:40:23+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> >\n> > This patch adds support for Visual Studio and Clang builds\n> >\n> > The minimum required version of CMake is upgraded to 3.15 because\n> > this version offers proper support for Clang builds on Windows.\n> >\n> > Libintl is not searched for when building with Visual Studio or Clang\n> > because there is no binary compatible version available yet.\n> >\n> > NOTE: In the link options invalidcontinue.obj has to be included.\n> > The reason for this is because by default, Windows calls abort()'s\n> > instead of setting errno=EINVAL when invalid arguments are passed to\n> > standard functions.\n> > This commit explains it in detail:\n> > 4b623d80f73528a632576990ca51e34c333d5dd6\n>\n> I think it's better to say:\n>\n>         See 4b623d80f7 (MSVC: link in invalidcontinue.obj for better\n>         POSIX compatibility, 2014-03-29) for detail.\n>\n>\n> (I haven't read the referenced commit, FWIW)\n>\n> > On Windows the default generator is Visual Studio,so for Visual Studio\n> > builds do this:\n> >\n> > cmake `relative-path-to-srcdir`\n> >\n> > NOTE: Visual Studio generator is a multi config generator, which means\n> > that Debug and Release builds can be done on the same build directory.\n> >\n> > For Clang builds do this:\n> >\n> > On bash\n> > CC=Clang cmake `relative-path-to-srcdir` -G Ninja\n>\n> I think you meant CC=clang, note the lowercase c,\n> that will cmake this note applicable for case-sensitive filesystem.\n>\n> ... reading this patch ...\n>\n> So, this is applicable for Windows only, it's fine as is, then.\n> It's still better to lowercase it, though.\n\nwill change it,(typo)\n\n>\n> >               -DCMAKE_BUILD_TYPE=[Debug or Release]\n> >\n> > On cmd\n> > set CC=Clang\n> > cmake `relative-path-to-srcdir` -G Ninja\n> >               -DCMAKE_BUILD_TYPE=[Debug or Release]\n> >\n> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> > ---\n> >  contrib/buildsystems/CMakeLists.txt | 55 +++++++++++++++++++++++------\n> >  1 file changed, 45 insertions(+), 10 deletions(-)\n> >\n> > diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\n> > index 46197d0b806..0a3f711db88 100644\n> > --- a/contrib/buildsystems/CMakeLists.txt\n> > +++ b/contrib/buildsystems/CMakeLists.txt\n> > @@ -98,8 +98,11 @@ find_package(ZLIB REQUIRED)\n> >  find_package(CURL)\n> >  find_package(EXPAT)\n> >  find_package(Iconv)\n> > -find_package(Intl)\n> >\n> > +#Don't use libintl on Windows Visual Studio and Clang builds\n> > +if(NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL \"MSVC\" OR CMAKE_C_COMPILER_ID STREQUAL \"Clang\")))\n>\n> Personally, I find this is a bit ugly.\n> Does it work to move the if(WIN32) down there, here.\n> Then make sub-condition for MSVC and Clang?\n>\n> > +     find_package(Intl)\n> > +endif()\n> >\n> >  if(NOT Intl_FOUND)\n> >       add_compile_definitions(NO_GETTEXT)\n> > @@ -123,7 +126,7 @@ if(Intl_FOUND)\n> >  endif()\n> >\n> >\n> > -if(WIN32)\n> > +if(WIN32 AND NOT MSVC)#not required for visual studio builds\n>\n\nCan do that.\n\n> for the down there, I meant here.\n> Using \"NOT MSVC\" here and `CMAKE_C_COMPILER_ID STREQUAL \"MSVC\"` above\n> may puzzle people interest in this patch.\n>\n> >       find_program(WINDRES_EXE windres)\n> >       if(NOT WINDRES_EXE)\n> >               message(FATAL_ERROR \"Install windres on Windows for resource files\")\n> > @@ -135,6 +138,13 @@ if(NOT MSGFMT_EXE)\n> >       message(WARNING \"Text Translations won't be build\")\n> >  endif()\n> >\n> > +#Force all visual studio outputs to CMAKE_BINARY_DIR\n> > +if(CMAKE_C_COMPILER_ID STREQUAL \"MSVC\")\n> > +     set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})\n> > +     set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})\n> > +     add_compile_options(/MP)\n> > +endif()\n> > +\n> >  #default behaviour\n> >  include_directories(${CMAKE_SOURCE_DIR})\n> >  add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n> > @@ -172,6 +182,10 @@ endif()\n> >\n> >  #Platform Specific\n> >  if(CMAKE_SYSTEM_NAME STREQUAL \"Windows\")\n>\n> I missed this line from previous patch\n> (and my comment in previous round, which suggested remove ${})\n> Does `if(WIN32)` and `if(CMAKE_SYSTEM_NAME STREQUAL \"Windows\")` have\n> different meanings?\n> I don't know much about CMake on Windows to really sure about this.\n>\n\nThey are the same.\nThe reason for using CMAKE_SYSTEM_NAME instead of (WIN32,UNIX,APPLE...) is that\nif you specify `if(UNIX)` it means both Linux and Darwin, whereas if you specify\nif(CMAKE_SYSTEM_NAME STREQUAL \"Linux\") it means Linux only.\n\nThank You,\nSibi Siddharthan\n\n> --\n> Danh\n"},{"id":"398944","messageId":"CAKiG+9X8kEB+7n+DF5nj21KcNv_eihTTU7uQjNHAy=bvWr7=Ww@mail.gmail.com","threadId":"53305","inReplyTo":"20200530141448.GD2151@danh.dev","subject":"Re: [PATCH v3 8/8] ci: modification of main.yml to use cmake for vs-build job","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-05-30T19:13:24Z","receivedAt":"2020-05-30T19:13:38Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Sat, May 30, 2020 at 7:44 PM Đoàn Trần Công Danh\n<congdanhqx@gmail.com> wrote:\n>\n> On 2020-05-29 13:40:24+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> > To check for ICONV_OMITS_BOM libiconv.dll needs to be in the working\n> > directory of script or path. So we copy the dlls before we configure.\n>\n> If ICONV_OMITS_BOM is such a troublemaker for CMake,\n> I'm fine with not supporting it at all.\n>\n> It seems like noone except me have interest in ICONV_OMITS_BOM.\n>\n\nIt is not a problem supporting this check. This check has to be\nimplemented sometime down the road.(as it is specified in the\nMakefile)\nThe issue currently is that this check is a bit big (~50 loc)\nincluding setup and cleanup. This might be a burden\nfor the reviewers as the only reason for considering CMake support is\nto support windows developers.\n\n> > @@ -302,4 +308,4 @@ jobs:\n> >      steps:\n> >      - uses: actions/checkout@v1\n> >      - run: ci/install-dependencies.sh\n> > -    - run: ci/test-documentation.sh\n> > +    - run: ci/test-documentation.sh\n> > \\ No newline at end of file\n>\n> Please fix your editor ;)\n>\n> --\n> Danh\n"},{"id":"398948","messageId":"20200531012835.GA2148@danh.dev","threadId":"53305","inReplyTo":"CAKiG+9WxoffdtQPvVk=8nG+Q58VvrCd4T41bP3ef3wn+FV8h4A@mail.gmail.com","subject":"Re: [PATCH v3 4/8] cmake: support for testing git with ctest","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-05-31T01:28:35Z","receivedAt":"2020-05-31T01:28:43Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2020-05-31 00:34:52+0530, Sibi Siddharthan <sibisiddharthan.github@gmail.com> wrote:\n> > Anyway, there're test is failing in Linux with this CMake.\n> >\n> >         $git_repo/t/../build/bin-wrappers/git is not executable; using GIT_EXEC_PATH\n> >\n> > It looks like CMake Generator forgets \"chmod +x bin-wrappers/git\"\n> >\n> \n> CMake does not support changing permissions of files easily.\n> You have to juggle them around to a temporary location and\n> change the permissions when you do `file(COPY ...)`.\n\nDoes it work better to use `configure_file` and `file(COPY)`\n\n> > OK, so this maybe the pain point, let me build in source again.\n> > Hm, no, I still see the same problems.\n> > Worse, CMake overrides my current Makefile.\n> > Luckily, I don't have any changes in Makefile.\n> >\n> \n> Please read the next PATCH, it supports out of source building and testing.\n\nIt's the remind to NOT mess with Git's Makefile ;)\n\n> > > +endif()#BUILD_TESTING\n> >\n> > We can use:\n> >\n> >         endif(BUILD_TESTING)\n> >\n> \n> The docs suggest that this way of endif() is for backwards compat only.\n> Not sure if I should change this, as CMake might remove this in the\n> future(very unlikely though).\n\nI don't have strong opinion for this syntax.\n\n-- \nDanh\n"},{"id":"398952","messageId":"xmqqpnakw02x.fsf@gitster.c.googlers.com","threadId":"53305","inReplyTo":"CAKiG+9WWqHJNz_fEaQ+Rw3sRJSFOutCt772v1mbZeOS2rWpDOA@mail.gmail.com","subject":"Re: [PATCH v3 1/8] Introduce CMake support for configuring Git","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-31T16:17:26Z","receivedAt":"2020-05-31T16:17:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n\n> On Sat, May 30, 2020 at 12:57 AM Junio C Hamano <gitster@pobox.com> wrote:\n>> ...\n>> Everything after the \"Changes\" line does not belong to the commit\n>> log, as it is no use for those who read \"git log\" output and\n>> encounter the \"first\" attempt to add CMake support there.  There is\n>> no need to tell them that you did things differently from this\n>> version in the past, as they simply do not know what you did in the\n>> previous iterations, nor particularly care about them.\n>>\n>> These *do* help reviewers who saw previous iterations, and the space\n>> after the three-dash line below is the right/recommended place for\n>> them.\n>>\n>> The above applies to other patches in this series.\n>\n> Do you mean this line '---' below?\n\nYes.\n\n> If so how do I place the changelog below them?\n> I just do `/submit` at gigitgadet/git.\n\nSorry, I don't use GGG, so the question needs to be redirected to\nthose who do and enhance (Dscho cc'ed).\n\n>> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n>> > ---\n\nHere is what I meant, but another place that is suitable to describe\ndifferences from previous rounds is the cover letter.  If the split\nof tasks between steps in a multi-patch series hasn't changed from\nthe previous round, it makes it easier to review if the changes\nsince the last round for each individual step is described in the\nmessage itself, like you did.  It just needs to be done outside the\nlog message.\n\nThanks.\n"},{"id":"398960","messageId":"nycvar.QRO.7.76.6.2005300957140.56@tvgsbejvaqbjf.bet","threadId":"53305","inReplyTo":"xmqqpnakw02x.fsf@gitster.c.googlers.com","subject":"Re: [PATCH v3 1/8] Introduce CMake support for configuring Git","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-05-30T08:00:54Z","receivedAt":"2020-05-31T21:18:25Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 31 May 2020, Junio C Hamano wrote:\n\n> Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n>\n> > On Sat, May 30, 2020 at 12:57 AM Junio C Hamano <gitster@pobox.com> wrote:\n> >> ...\n> >> Everything after the \"Changes\" line does not belong to the commit\n> >> log, as it is no use for those who read \"git log\" output and\n> >> encounter the \"first\" attempt to add CMake support there.  There is\n> >> no need to tell them that you did things differently from this\n> >> version in the past, as they simply do not know what you did in the\n> >> previous iterations, nor particularly care about them.\n> >>\n> >> These *do* help reviewers who saw previous iterations, and the space\n> >> after the three-dash line below is the right/recommended place for\n> >> them.\n> >>\n> >> The above applies to other patches in this series.\n> >\n> > Do you mean this line '---' below?\n>\n> Yes.\n>\n> > If so how do I place the changelog below them?\n> > I just do `/submit` at gigitgadet/git.\n>\n> Sorry, I don't use GGG, so the question needs to be redirected to\n> those who do and enhance (Dscho cc'ed).\n\nThere is currently no support for that in GitGitGadget.\n\nThe idea was to put such commentary into the cover letter, usually by\nediting the first PR comment and appending the additional information\nbefore `/submit`ing.\n\nIIRC some support was added to `format-patch` to potentially pick up\ncomments via notes to be added after the `---` line. So it should not be\nall too hard, I simply cannot afford the time for that right now (but I'd\nof course be glad to review/accept PRs at\nhttps://github.com/gitgitgadget/gitgitgadget).\n\nCiao,\nDscho\n\n> >> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> >> > ---\n>\n> Here is what I meant, but another place that is suitable to describe\n> differences from previous rounds is the cover letter.  If the split\n> of tasks between steps in a multi-patch series hasn't changed from\n> the previous round, it makes it easier to review if the changes\n> since the last round for each individual step is described in the\n> message itself, like you did.  It just needs to be done outside the\n> log message.\n>\n> Thanks.\n>\n"},{"id":"399314","messageId":"CAKiG+9VcAx2xRFzrqQpXFc+sVuRZ2ydoVYTpCtWpi9z2Oa0fCw@mail.gmail.com","threadId":"53305","inReplyTo":"CAKiG+9Ue1fqrzqHduZY4Pnsh4q+Thqq618JymkonmVhGewmM1g@mail.gmail.com","subject":"Re: [PATCH v3 2/8] cmake: generate the shell/perl/python scripts and templates, translations","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-06-08T20:07:56Z","receivedAt":"2020-06-08T20:08:10Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"Hi Junio,\n\nI have done the suggested changes namely:\n1) Format code inside check_c_source_compiles/runs\n2) Moved the changelog of the patch series from the commit messages to\nthe cover letter\n3) parse for SCRIPT_LIB\n4) glob templates and po files\n5) add logic as to where the template file should be built.\n\nAny other changes I should do before I a new version of the patch series?\n\nThank You,\nSibi Siddharthan\n"},{"id":"399326","messageId":"xmqqa71djjiz.fsf@gitster.c.googlers.com","threadId":"53305","inReplyTo":"CAKiG+9VcAx2xRFzrqQpXFc+sVuRZ2ydoVYTpCtWpi9z2Oa0fCw@mail.gmail.com","subject":"Re: [PATCH v3 2/8] cmake: generate the shell/perl/python scripts and templates, translations","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-06-08T22:10:44Z","receivedAt":"2020-06-08T22:10:52Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n\n> Hi Junio,\n>\n> I have done the suggested changes namely:\n> 1) Format code inside check_c_source_compiles/runs\n> 2) Moved the changelog of the patch series from the commit messages to\n> the cover letter\n> 3) parse for SCRIPT_LIB\n> 4) glob templates and po files\n> 5) add logic as to where the template file should be built.\n>\n> Any other changes I should do before I a new version of the patch series?\n>\n> Thank You,\n> Sibi Siddharthan\n\nSorry, but I read too many patch series that I do not remember\nglitches I pointed out in the previous round of individual topics.\n\nSo asking that question is waste of both of our times.  Just use the\ntime necessary to compose that message to instead proofread one more\ntime, scan the review thread of previous round and make sure you\ntook everybody's input into consideration (you do not have to follow\neverything other people said---you just need to be able to solidly\nstand behind the decision you made to follow or not follow them in\nyour latest version).\n\nThanks.\n"},{"id":"399612","messageId":"pull.614.v4.git.1591986566.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v3.git.1590759624.gitgitgadget@gmail.com","subject":"[PATCH v4 0/8] CMake build system for git","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-06-12T18:29:18Z","receivedAt":"2020-06-12T18:29:32Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"This is an attempt to build Git using CMake. CMake is cross-platform build\ngenerator which works well on a variety of platforms(primarily Linux and\nWindows). Using CMake we can check whether certain headers exist, certain\nfunctions exist, the required libraries are present and configure the build\naccordingly. Using CMake we can also build and test Git out of source,\nresulting in a clean source tree.\n\nTested platforms\n\nUbuntu 18.04 GCC 7.4 Clang 8.0.1\n\nWindows MinGW GCC 9.2 Clang 9 Visual Studio 2015,2017,2019\n\nChanges:\n\n1) The CMake script has been relocated to contrib/buildsystems 2) The CMake\nscript parses the Makefile for the sources. LIB_OBJS BUILTIN_OBJS XDIFF_OBJS\nVCSSVN_OBJS TEST_BUILTINS_OBJS SCRIPT_SH SCRIPT_PERL 3) Philip suggested to\nchange the error message if sh/bash was not found on windows. 4) CMake now\ntests for ICONV_OMITS_BOM, NO_ST_BLOCKS_IN_STRUCT_STAT 5) Renamed the\nvariable test_helper_sources to test-tool_SOURCES [PATCH 4/8] to be\nconsistent with the naming of source variables.\n\nChanges v2: Changes 1,2,4 have been rebased to PATCH 01/xx CMake uses\nGIT-VERSION-GEN to get the version of Git Fixed a bug where a Windows user\ncan pose as Linux user and vice versa. [PATCH 6/8]\n\nChanges v3: Patch changes are moved from the commit messages and are placed\nhere. Code inside check_c_source_(compiles/runs) have been formatted\naccording to git coding guidelines. [PATCH 1/8] The CMake script parses the\nMakefile for SCRIPT_LIB also. [PATCH 2/8] The CMake script globs templates,\npo files. Logic has been added to place the template files in their\nrespective directories instead of hard-coding them. [PATCH 2/8]\n\nSibi Siddharthan (8):\n  Introduce CMake support for configuring Git\n  cmake: generate the shell/perl/python scripts and templates,\n    translations\n  cmake: installation support for git\n  cmake: support for testing git with ctest\n  cmake: support for testing git when building out of the source tree\n  cmake: support for building git on windows with mingw\n  cmake: support for building git on windows with msvc and clang.\n  ci: modification of main.yml to use cmake for vs-build job\n\n .github/workflows/main.yml          |   36 +-\n contrib/buildsystems/CMakeLists.txt | 1003 +++++++++++++++++++++++++++\n 2 files changed, 1024 insertions(+), 15 deletions(-)\n create mode 100644 contrib/buildsystems/CMakeLists.txt\n\n\nbase-commit: c72c7da667dba3465fb566ecb23457950e28893c\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-614%2FSibiSiddharthan%2Fgit-og-v4\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-614/SibiSiddharthan/git-og-v4\nPull-Request: https://github.com/gitgitgadget/git/pull/614\n\nRange-diff vs v3:\n\n 1:  09c972de52b ! 1:  c4e1ba74464 Introduce CMake support for configuring Git\n     @@ Commit message\n          part of the build. This is needed to generate all those hardlinks for\n          the built-in commands of Git.\n      \n     -    Changes\n     -    The CMake script parses the Makefile for:\n     -    LIB_OBJS\n     -    BUILTIN_OBJS\n     -    XDIFF_OBJS\n     -    VCSSVN_OBJS\n     -    TEST_BUILTINS_OBJS\n     -\n     -    By doing this we avoid duplication of text between the Makefile and\n     -    the CMake script.\n     -\n     -    The CMake script has been relocated to contrib/buildsystems.\n     -\n     -    The CMake script uses GIT-VERSION-GEN to determine the version of Git\n     -    being built.\n     -\n          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n      \n       ## contrib/buildsystems/CMakeLists.txt (new) ##\n     @@ contrib/buildsystems/CMakeLists.txt (new)\n      +Instructions to run CMake:\n      +\n      +cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release\n     ++Eg.\n     ++From the root of git source tree\n     ++\t`cmake contrib/buildsystems/ `\n     ++This will build the git binaries at the root\n     ++\n     ++For out of source builds, say build in 'git/git-build/'\n     ++\t`mkdir git-build;cd git-build; cmake ../contrib/buildsystems/`\n     ++This will build the git binaries in git-build directory\n      +\n      +Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding\n      +compiler flags\n     @@ contrib/buildsystems/CMakeLists.txt (new)\n      +NOTE: -DCMAKE_BUILD_TYPE is optional. For multi-config generators like Visual Studio\n      +this option is ignored\n      +\n     -+This process generates a Makefile(Linux) , Visual Studio solution(Windows) by default.\n     -+Run `make` to build Git on Linux.\n     ++This process generates a Makefile(Linux/*BSD/MacOS) , Visual Studio solution(Windows) by default.\n     ++Run `make` to build Git on Linux/*BSD/MacOS.\n      +Open git.sln on Windows and build Git.\n      +\n      +NOTE: By default CMake uses Makefile as the build tool on Linux and Visual Studio in Windows,\n     @@ contrib/buildsystems/CMakeLists.txt (new)\n      +\n      +check_c_source_compiles(\"\n      +#include <alloca.h>\n     -+int\n     -+main ()\n     ++\n     ++int main(void)\n      +{\n     -+char *p = (char *) alloca (2 * sizeof (int));\n     -+\tif (p) return 0;\n     ++\tchar *p = (char *) alloca(2 * sizeof(int));\n     ++\n     ++\tif (p)\n     ++\t\treturn 0;\n      +\treturn 0;\n      +}\"\n      +HAVE_ALLOCA_H)\n     @@ contrib/buildsystems/CMakeLists.txt (new)\n      +#include<stdarg.h>\n      +#include<string.h>\n      +#include<stdlib.h>\n     ++\n      +int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)\n      +{\n      +\tint ret;\n     @@ contrib/buildsystems/CMakeLists.txt (new)\n      +\treturn ret;\n      +}\n      +\n     -+int\n     -+main ()\n     ++int main(void)\n      +{\n      +\tchar buf[6];\n     ++\n      +\tif (test_vsnprintf(buf, 3, \\\"%s\\\", \\\"12345\\\") != 5\n     -+\t\t|| strcmp(buf, \\\"12\\\")) return 1;\n     ++\t\t|| strcmp(buf, \\\"12\\\"))\n     ++\t\t\treturn 1;\n      +\tif (snprintf(buf, 3, \\\"%s\\\", \\\"12345\\\") != 5\n     -+\t\t|| strcmp(buf, \\\"12\\\")) return 1;\n     -+\n     ++\t\t|| strcmp(buf, \\\"12\\\"))\n     ++\t\t\treturn 1;\n      +\treturn 0;\n      +}\"\n      +SNPRINTF_OK)\n     @@ contrib/buildsystems/CMakeLists.txt (new)\n      +\n      +check_c_source_runs(\"\n      +#include<stdio.h>\n     -+int\n     -+main ()\n     ++\n     ++int main(void)\n      +{\n      +\tFILE *f = fopen(\\\".\\\", \\\"r\\\");\n     -+\treturn f != NULL;\n      +\n     -+\treturn 0;\n     ++\treturn f != NULL;\n      +}\"\n      +FREAD_READS_DIRECTORIES_NO)\n      +if(NOT FREAD_READS_DIRECTORIES_NO)\n     @@ contrib/buildsystems/CMakeLists.txt (new)\n      +#ifndef REG_STARTEND\n      +#error oops we dont have it\n      +#endif\n     -+int main(){return 0;}\"\n     ++\n     ++int main(void)\n     ++{\n     ++\treturn 0;\n     ++}\"\n      +HAVE_REGEX)\n      +if(NOT HAVE_REGEX)\n      +\tinclude_directories(${CMAKE_SOURCE_DIR}/compat/regex)\n     @@ contrib/buildsystems/CMakeLists.txt (new)\n      +#include <sys/types.h>\n      +#include <sys/sysctl.h>\n      +\n     -+int\n     -+main ()\n     ++int main(void)\n      +{\n      +\tint val, mib[2];\n      +\tsize_t len;\n     @@ contrib/buildsystems/CMakeLists.txt (new)\n      +\tmib[1] = 1;\n      +\tlen = sizeof(val);\n      +\treturn sysctl(mib, 2, &val, &len, NULL, 0) ? 1 : 0;\n     -+\n     -+\treturn 0;\n      +}\"\n      +HAVE_BSD_SYSCTL)\n      +if(HAVE_BSD_SYSCTL)\n     @@ contrib/buildsystems/CMakeLists.txt (new)\n      +\t\tchar **inbuf, size_t *inbytesleft,\n      +\t\tchar **outbuf, size_t *outbytesleft);\n      +\n     -+int main(){return 0;}\"\n     ++int main(void)\n     ++{\n     ++\treturn 0;\n     ++}\"\n      +HAVE_NEW_ICONV)\n      +if(HAVE_NEW_ICONV)\n      +\tset(HAVE_OLD_ICONV 0)\n     @@ contrib/buildsystems/CMakeLists.txt (new)\n      +typedef char *iconv_ibp;\n      +#endif\n      +\n     -+int main()\n     ++int main(void)\n      +{\n      +\tint v;\n      +\ticonv_t conv;\n     -+\tchar in[] = \\\"a\\\"; iconv_ibp pin = in;\n     -+\tchar out[20] = \\\"\\\"; char *pout = out;\n     -+\tsize_t isz = sizeof in;\n     -+\tsize_t osz = sizeof out;\n     ++\tchar in[] = \\\"a\\\";\n     ++\ticonv_ibp pin = in;\n     ++\tchar out[20] = \\\"\\\";\n     ++\tchar *pout = out;\n     ++\tsize_t isz = sizeof(in);\n     ++\tsize_t osz = sizeof(out);\n      +\n      +\tconv = iconv_open(\\\"UTF-16\\\", \\\"UTF-8\\\");\n      +\ticonv(conv, &pin, &isz, &pout, &osz);\n 2:  f19794fdbc0 ! 2:  abb9e6e1d58 cmake: generate the shell/perl/python scripts and templates, translations\n     @@ Commit message\n      \n          NOTE: The scripts and templates are generated during configuration.\n      \n     -    Changes\n     -    The CMake script parses the Makefile for:\n     -    SCRIPT_SH\n     -    SCRIPT_PERL\n     -\n          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n      \n       ## contrib/buildsystems/CMakeLists.txt ##\n     @@ contrib/buildsystems/CMakeLists.txt: macro(parse_makefile_for_sources list_var r\n      +\tstring(REPLACE \"${regex} +=\" \"\" ${list_var} ${${list_var}})\n      +\tstring(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces\n      +\tstring(REPLACE \" \" \";\" ${list_var} ${${list_var}}) #convert string to a list\n     -+\tlist(TRANSFORM ${list_var} REPLACE \"${lang}\" \"\") #do the replacement\n     ++\tif(NOT ${lang}) #exclude for SCRIPT_LIB\n     ++\t\tlist(TRANSFORM ${list_var} REPLACE \"${lang}\" \"\") #do the replacement\n     ++\tendif()\n      +endmacro()\n      +\n       include(CheckTypeSize)\n     @@ contrib/buildsystems/CMakeLists.txt: add_custom_command(OUTPUT ${git_links} ${gi\n      +\n      +#shell scripts\n      +parse_makefile_for_scripts(git_sh_scripts \"SCRIPT_SH\" \".sh\")\n     ++parse_makefile_for_scripts(git_shlib_scripts \"SCRIPT_LIB\" \"\")\n      +set(git_shell_scripts\n     -+\t${git_sh_scripts}\n     -+\tgit-mergetool--lib git-parse-remote git-rebase--preserve-merges\n     -+\tgit-sh-setup git-sh-i18n git-instaweb)\n     ++\t${git_sh_scripts} ${git_shlib_scripts} git-instaweb)\n      +\n      +foreach(script ${git_shell_scripts})\n      +\tfile(STRINGS ${CMAKE_SOURCE_DIR}/${script}.sh content NEWLINE_CONSUME)\n     @@ contrib/buildsystems/CMakeLists.txt: add_custom_command(OUTPUT ${git_links} ${gi\n      +\n      +\n      +#templates\n     ++file(GLOB templates \"${CMAKE_SOURCE_DIR}/templates/*\")\n     ++list(TRANSFORM templates REPLACE \"${CMAKE_SOURCE_DIR}/templates/\" \"\")\n     ++list(REMOVE_ITEM templates \".gitignore\")\n     ++list(REMOVE_ITEM templates \"Makefile\")\n     ++\n     ++list(REMOVE_ITEM templates \"branches--\")\n      +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches\n     -+set(hooks_templates\n     -+\tapplypatch-msg.sample pre-applypatch.sample pre-push.sample\n     -+\tcommit-msg.sample pre-commit.sample pre-rebase.sample\n     -+\tfsmonitor-watchman.sample pre-merge-commit.sample pre-receive.sample\n     -+\tpost-update.sample prepare-commit-msg.sample update.sample)\n      +\n      +#templates have @.*@ replacement so use configure_file instead\n     -+#hooks\n     -+foreach(tm ${hooks_templates})\n     -+\tconfigure_file(${CMAKE_SOURCE_DIR}/templates/hooks--${tm} ${CMAKE_BINARY_DIR}/templates/blt/hooks/${tm} @ONLY)\n     ++foreach(tm ${templates})\n     ++\tstring(REPLACE \"--\" \"/\" blt_tm ${tm})\n     ++\tstring(REPLACE \"this\" \"\" blt_tm ${blt_tm})# for this--\n     ++\tconfigure_file(${CMAKE_SOURCE_DIR}/templates/${tm} ${CMAKE_BINARY_DIR}/templates/blt/${blt_tm} @ONLY)\n      +endforeach()\n      +\n     -+#info\n     -+configure_file(${CMAKE_SOURCE_DIR}/templates/info--exclude ${CMAKE_BINARY_DIR}/templates/blt/info/exclude @ONLY)\n     -+\n     -+#this\n     -+configure_file(${CMAKE_SOURCE_DIR}/templates/this--description ${CMAKE_BINARY_DIR}/templates/blt/description @ONLY)\n     -+\n      +\n      +#translations\n      +if(MSGFMT_EXE)\n     -+\tset(po_files bg  ca  de  el  es  fr  is  it  ko  pt_PT  ru  sv  tr  vi  zh_CN  zh_TW)\n     ++\tfile(GLOB po_files \"${CMAKE_SOURCE_DIR}/po/*.po\")\n     ++\tlist(TRANSFORM po_files REPLACE \"${CMAKE_SOURCE_DIR}/po/\" \"\")\n     ++\tlist(TRANSFORM po_files REPLACE \".po\" \"\")\n      +\tforeach(po ${po_files})\n      +\t\tfile(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES)\n      +\t\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo\n 3:  6ec73d3e967 ! 3:  4a0dd23cbbf cmake: installation support for git\n     @@ Commit message\n      \n          Then run `make install`\n      \n     -    Changes:\n     -    Removed a comment regarding the installation of gitk.\n     -\n          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n      \n       ## contrib/buildsystems/CMakeLists.txt ##\n 4:  cdc53172b3f ! 4:  db05180e98a cmake: support for testing git with ctest\n     @@ Commit message\n      \n          NOTE: Testing only works when building in source for now.\n      \n     -    Changes:\n     -    Renamed the variable test_helper_sources to test-tool_SOURCES\n     -    to be consistent with the naming of source variables.\n     -\n          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n      \n       ## contrib/buildsystems/CMakeLists.txt ##\n 5:  cdc68f102cb = 5:  17e7f3e9de6 cmake: support for testing git when building out of the source tree\n 6:  f41cbd43081 ! 6:  549f0cd5fff cmake: support for building git on windows with mingw\n     @@ Commit message\n          To use CMake on Windows with MinGW do this:\n          cmake `relative-path-to-srcdir` -G \"MinGW Makefiles\"\n      \n     -    Changes:\n     -    Changed the error message when sh.exe is not found on Windows as\n     -    suggested by Philip Oakley <philipoakley@iee.email>\n     -\n     -    v2:\n     -    Fixed a bug where a Windows user can pose as Linux user and vice versa.\n     -\n          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n      \n       ## contrib/buildsystems/CMakeLists.txt ##\n 7:  8f36e30cd22 ! 7:  f85ea0ac0ca cmake: support for building git on windows with msvc and clang.\n     @@ Commit message\n          For Clang builds do this:\n      \n          On bash\n     -    CC=Clang cmake `relative-path-to-srcdir` -G Ninja\n     +    CC=clang cmake `relative-path-to-srcdir` -G Ninja\n                          -DCMAKE_BUILD_TYPE=[Debug or Release]\n      \n          On cmd\n 8:  bb329d16ce0 ! 8:  2f7cf41e08f ci: modification of main.yml to use cmake for vs-build job\n     @@ Commit message\n          FindCURL module. An extra definition (-DCURL_NO_CURL_CMAKE=ON) has been\n          added to revert to the old behaviour.\n      \n     -    Edit(Explanation for the reordering of build steps):\n          In the configuration phase CMake looks for the required libraries for\n          building git (eg zlib,libiconv). So we extract the libraries before we\n          configure.\n     @@ Commit message\n          To check for ICONV_OMITS_BOM libiconv.dll needs to be in the working\n          directory of script or path. So we copy the dlls before we configure.\n      \n     -    Signed-off-by: Sibi Siddharthan <sibisiv.siddharthan@gmail.com>\n     +    Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n      \n       ## .github/workflows/main.yml ##\n      @@ .github/workflows/main.yml: jobs:\n     @@ .github/workflows/main.yml: jobs:\n         regular:\n           needs: ci-config\n           if: needs.ci-config.outputs.enabled == 'yes'\n     -@@ .github/workflows/main.yml: jobs:\n     -     steps:\n     -     - uses: actions/checkout@v1\n     -     - run: ci/install-dependencies.sh\n     --    - run: ci/test-documentation.sh\n     -+    - run: ci/test-documentation.sh\n     - \\ No newline at end of file\n\n-- \ngitgitgadget\n"},{"id":"399613","messageId":"4a0dd23cbbf3f3f45df9ba70057827e216d8c491.1591986566.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v4.git.1591986566.gitgitgadget@gmail.com","subject":"[PATCH v4 3/8] cmake: installation support for git","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-06-12T18:29:21Z","receivedAt":"2020-06-12T18:29:36Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nInstall the built binaries and scripts using CMake\n\nThis is very similar to `make install`.\nBy default the destination directory(DESTDIR) is /usr/local/ on Linux\nTo set a custom installation path do this:\ncmake `relative-path-to-srcdir`\n\t-DCMAKE_INSTALL_PREFIX=`preferred-install-path`\n\nThen run `make install`\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n contrib/buildsystems/CMakeLists.txt | 49 +++++++++++++++++++++++++++++\n 1 file changed, 49 insertions(+)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex b3863bffee6..e8ed2439e46 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -65,6 +65,8 @@ project(git\n \tVERSION ${git_version}\n \tLANGUAGES C)\n \n+#TODO gitk git-gui gitweb\n+#TODO Add pcre support\n \n #macros for parsing the Makefile for sources and scripts\n macro(parse_makefile_for_sources list_var regex)\n@@ -698,3 +700,50 @@ if(MSGFMT_EXE)\n \tendforeach()\n \tadd_custom_target(po-gen ALL DEPENDS ${po_gen})\n endif()\n+\n+\n+#to help with the install\n+list(TRANSFORM git_shell_scripts PREPEND \"${CMAKE_BINARY_DIR}/\")\n+list(TRANSFORM git_perl_scripts PREPEND \"${CMAKE_BINARY_DIR}/\")\n+\n+#install\n+install(TARGETS git git-shell\n+\tRUNTIME DESTINATION bin)\n+install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver\n+\tDESTINATION bin)\n+\n+list(REMOVE_ITEM PROGRAMS_BUILT git git-shell)\n+install(TARGETS ${PROGRAMS_BUILT}\n+\tRUNTIME DESTINATION libexec/git-core)\n+\n+set(bin_links\n+\tgit-receive-pack git-upload-archive git-upload-pack)\n+\n+foreach(b ${bin_links})\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})\")\n+endforeach()\n+\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)\")\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)\")\n+\n+foreach(b ${git_links})\n+\tstring(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n+\tinstall(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n+endforeach()\n+\n+foreach(b ${git_http_links})\n+\tstring(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n+\tinstall(CODE \"file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n+endforeach()\n+\n+install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4\n+\tDESTINATION libexec/git-core)\n+\n+install(DIRECTORY ${CMAKE_SOURCE_DIR}/mergetools DESTINATION libexec/git-core)\n+install(DIRECTORY ${CMAKE_BINARY_DIR}/perl/build/lib/ DESTINATION share/perl5\n+\tFILES_MATCHING PATTERN \"*.pm\")\n+install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/templates)\n+\n+if(MSGFMT_EXE)\n+\tinstall(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)\n+endif()\n-- \ngitgitgadget\n\n"},{"id":"399614","messageId":"c4e1ba74464cfae882cde646d3c79778244b8f5e.1591986566.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v4.git.1591986566.gitgitgadget@gmail.com","subject":"[PATCH v4 1/8] Introduce CMake support for configuring Git","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-06-12T18:29:19Z","receivedAt":"2020-06-12T18:29:36Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nAt the moment, the recommended way to configure Git's builds is to\nsimply run `make`. If that does not work, the recommended strategy is to\nlook at the top of the `Makefile` to see whether any \"Makefile knob\" has\nto be turned on/off, e.g. `make NO_OPENSSL=YesPlease`.\n\nAlternatively, Git also has an `autoconf` setup which allows configuring\nbuilds via `./configure [<option>...]`.\n\nBoth of these options are fine if the developer works on Unix or Linux.\nBut on Windows, we have to jump through hoops to configure a build\n(read: we force the user to install a full Git for Windows SDK, which\noccupies around two gigabytes (!) on disk and downloads about three\nquarters of a gigabyte worth of Git objects).\n\nThe build infrastructure for Git is written around being able to run\nmake, which is not supported natively on Windows.\nTo help Windows developers a CMake build script is introduced here.\n\nWith a working support CMake, developers on Windows need only install\nCMake, configure their build, load the generated Visual Studio solution\nand immediately start modifying the code and build their own version of\nGit. Likewise, developers on other platforms can use the convenient GUI\ntools provided by CMake to configure their build.\n\nSo let's start building CMake support for Git.\n\nThis is only the first step, and to make it easier to review, it only\nallows for configuring builds on the platform that is easiest to\nconfigure for: Linux.\n\nThe CMake script checks whether the headers are present(eg. libgen.h),\nwhether the functions are present(eg. memmem), whether the funtions work\nproperly (eg. snprintf) and generate the required compile definitions\nfor the platform. The script also searches for the required libraries,\nif it fails to find the required libraries the respective executables\nwon't be built.(eg. If libcurl is not found then git-remote-http won't\nbe built). This will help building Git easier.\n\nWith a CMake script an out of source build of git is possible resulting\nin a clean source tree.\n\nNote: this patch asks for the minimum version v3.14 of CMake (which is\nnot all that old as of time of writing) because that is the first\nversion to offer a platform-independent way to generate hardlinks as\npart of the build. This is needed to generate all those hardlinks for\nthe built-in commands of Git.\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n contrib/buildsystems/CMakeLists.txt | 592 ++++++++++++++++++++++++++++\n 1 file changed, 592 insertions(+)\n create mode 100644 contrib/buildsystems/CMakeLists.txt\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nnew file mode 100644\nindex 00000000000..1e910d9df85\n--- /dev/null\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -0,0 +1,592 @@\n+#\n+#\tCopyright (c) 2020 Sibi Siddharthan\n+#\n+\n+#[[\n+\n+Instructions to run CMake:\n+\n+cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release\n+Eg.\n+From the root of git source tree\n+\t`cmake contrib/buildsystems/ `\n+This will build the git binaries at the root\n+\n+For out of source builds, say build in 'git/git-build/'\n+\t`mkdir git-build;cd git-build; cmake ../contrib/buildsystems/`\n+This will build the git binaries in git-build directory\n+\n+Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding\n+compiler flags\n+Debug : -g\n+Release: -O3\n+RelWithDebInfo : -O2 -g\n+MinSizeRel : -Os\n+empty(default) :\n+\n+NOTE: -DCMAKE_BUILD_TYPE is optional. For multi-config generators like Visual Studio\n+this option is ignored\n+\n+This process generates a Makefile(Linux/*BSD/MacOS) , Visual Studio solution(Windows) by default.\n+Run `make` to build Git on Linux/*BSD/MacOS.\n+Open git.sln on Windows and build Git.\n+\n+NOTE: By default CMake uses Makefile as the build tool on Linux and Visual Studio in Windows,\n+to use another tool say `ninja` add this to the command line when configuring.\n+`-G Ninja`\n+\n+]]\n+cmake_minimum_required(VERSION 3.14)\n+\n+#set the source directory to root of git\n+set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n+\n+find_program(SH_EXE sh)\n+\n+#Create GIT-VERSION-FILE using GIT-VERSION-GEN\n+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)\n+\tmessage(\"Generating GIT-VERSION-FILE\")\n+\texecute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN\n+\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR})\n+endif()\n+\n+#Parse GIT-VERSION-FILE to get the version\n+file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE git_version REGEX \"GIT_VERSION = (.*)\")\n+string(REPLACE \"GIT_VERSION = \" \"\" git_version ${git_version})\n+string(FIND ${git_version} \"GIT\" location)\n+if(location EQUAL -1)\n+\tstring(REGEX MATCH \"[0-9]*\\\\.[0-9]*\\\\.[0-9]*\" git_version ${git_version})\n+else()\n+\tstring(REGEX MATCH \"[0-9]*\\\\.[0-9]*\" git_version ${git_version})\n+\tstring(APPEND git_version \".0\") #for building from a snapshot\n+endif()\n+\n+project(git\n+\tVERSION ${git_version}\n+\tLANGUAGES C)\n+\n+\n+#macros for parsing the Makefile for sources\n+macro(parse_makefile_for_sources list_var regex)\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX \"^${regex} \\\\+=(.*)\")\n+\tstring(REPLACE \"${regex} +=\" \"\" ${list_var} ${${list_var}})\n+\tstring(REPLACE \"$(COMPAT_OBJS)\" \"\" ${list_var} ${${list_var}}) #remove \"$(COMPAT_OBJS)\" This is only for libgit.\n+\tstring(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces\n+\tstring(REPLACE \".o\" \".c;\" ${list_var} ${${list_var}}) #change .o to .c, ; is for converting the string into a list\n+\tlist(TRANSFORM ${list_var} STRIP) #remove trailing/leading whitespaces for each element in list\n+\tlist(REMOVE_ITEM ${list_var} \"\") #remove empty list elements\n+endmacro()\n+\n+include(CheckTypeSize)\n+include(CheckCSourceRuns)\n+include(CheckCSourceCompiles)\n+include(CheckIncludeFile)\n+include(CheckFunctionExists)\n+include(CheckSymbolExists)\n+include(CheckStructHasMember)\n+\n+find_package(ZLIB REQUIRED)\n+find_package(CURL)\n+find_package(EXPAT)\n+find_package(Iconv)\n+find_package(Intl)\n+\n+if(NOT Intl_FOUND)\n+\tadd_compile_definitions(NO_GETTEXT)\n+\tif(NOT Iconv_FOUND)\n+\t\tadd_compile_definitions(NO_ICONV)\n+\tendif()\n+endif()\n+\n+include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})\n+if(CURL_FOUND)\n+\tinclude_directories(SYSTEM ${CURL_INCLUDE_DIRS})\n+endif()\n+if(EXPAT_FOUND)\n+\tinclude_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})\n+endif()\n+if(Iconv_FOUND)\n+\tinclude_directories(SYSTEM ${Iconv_INCLUDE_DIRS})\n+endif()\n+if(Intl_FOUND)\n+\tinclude_directories(SYSTEM ${Intl_INCLUDE_DIRS})\n+endif()\n+\n+#default behaviour\n+include_directories(${CMAKE_SOURCE_DIR})\n+add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n+add_compile_definitions(SHA256_BLK INTERNAL_QSORT RUNTIME_PREFIX)\n+add_compile_definitions(NO_OPENSSL SHA1_DC SHA1DC_NO_STANDARD_INCLUDES\n+\t\t\tSHA1DC_INIT_SAFE_HASH_DEFAULT=0\n+\t\t\tSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"cache.h\"\n+\t\t\tSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"git-compat-util.h\" )\n+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)\n+\n+\n+add_compile_definitions(PAGER_ENV=\"LESS=FRX LV=-c\"\n+\t\t\tETC_GITATTRIBUTES=\"etc/gitattributes\"\n+\t\t\tETC_GITCONFIG=\"etc/gitconfig\"\n+\t\t\tGIT_EXEC_PATH=\"libexec/git-core\"\n+\t\t\tGIT_LOCALE_PATH=\"share/locale\"\n+\t\t\tGIT_MAN_PATH=\"share/man\"\n+\t\t\tGIT_INFO_PATH=\"share/info\"\n+\t\t\tGIT_HTML_PATH=\"share/doc/git-doc\"\n+\t\t\tDEFAULT_HELP_FORMAT=\"html\"\n+\t\t\tDEFAULT_GIT_TEMPLATE_DIR=\"share/git-core/templates\"\n+\t\t\tGIT_VERSION=\"${PROJECT_VERSION}.GIT\"\n+\t\t\tGIT_USER_AGENT=\"git/${PROJECT_VERSION}.GIT\"\n+\t\t\tBINDIR=\"bin\"\n+\t\t\tGIT_BUILT_FROM_COMMIT=\"\")\n+\n+set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n+add_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n+\n+add_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n+list(APPEND compat_SOURCES unix-socket.c)\n+\n+#header checks\n+check_include_file(libgen.h HAVE_LIBGEN_H)\n+if(NOT HAVE_LIBGEN_H)\n+\tadd_compile_definitions(NO_LIBGEN_H)\n+\tlist(APPEND compat_SOURCES compat/basename.c)\n+endif()\n+\n+check_include_file(sys/sysinfo.h HAVE_SYSINFO)\n+if(HAVE_SYSINFO)\n+\tadd_compile_definitions(HAVE_SYSINFO)\n+endif()\n+\n+check_c_source_compiles(\"\n+#include <alloca.h>\n+\n+int main(void)\n+{\n+\tchar *p = (char *) alloca(2 * sizeof(int));\n+\n+\tif (p)\n+\t\treturn 0;\n+\treturn 0;\n+}\"\n+HAVE_ALLOCA_H)\n+if(HAVE_ALLOCA_H)\n+\tadd_compile_definitions(HAVE_ALLOCA_H)\n+endif()\n+\n+check_include_file(strings.h HAVE_STRINGS_H)\n+if(HAVE_STRINGS_H)\n+\tadd_compile_definitions(HAVE_STRINGS_H)\n+endif()\n+\n+check_include_file(sys/select.h HAVE_SYS_SELECT_H)\n+if(NOT HAVE_SYS_SELECT_H)\n+\tadd_compile_definitions(NO_SYS_SELECT_H)\n+endif()\n+\n+check_include_file(sys/poll.h HAVE_SYS_POLL_H)\n+if(NOT HAVE_SYS_POLL_H)\n+\tadd_compile_definitions(NO_SYS_POLL_H)\n+endif()\n+\n+check_include_file(poll.h HAVE_POLL_H)\n+if(NOT HAVE_POLL_H)\n+\tadd_compile_definitions(NO_POLL_H)\n+endif()\n+\n+check_include_file(inttypes.h HAVE_INTTYPES_H)\n+if(NOT HAVE_INTTYPES_H)\n+\tadd_compile_definitions(NO_INTTYPES_H)\n+endif()\n+\n+check_include_file(paths.h HAVE_PATHS_H)\n+if(HAVE_PATHS_H)\n+\tadd_compile_definitions(HAVE_PATHS_H)\n+endif()\n+\n+#function checks\n+set(function_checks\n+\tstrcasestr memmem strlcpy strtoimax strtoumax strtoull\n+\tsetenv mkdtemp poll pread memmem unsetenv hstrerror)\n+\n+foreach(f ${function_checks})\n+\tstring(TOUPPER ${f} uf)\n+\tcheck_function_exists(${f} HAVE_${uf})\n+\tif(NOT HAVE_${uf})\n+\t\tadd_compile_definitions(NO_${uf})\n+\tendif()\n+endforeach()\n+\n+if(NOT HAVE_POLL_H OR NOT HAVE_SYS_POLL_H OR NOT HAVE_POLL)\n+\tinclude_directories(${CMAKE_SOURCE_DIR}/compat/poll)\n+\tadd_compile_definitions(NO_POLL)\n+\tlist(APPEND compat_SOURCES compat/poll/poll.c)\n+endif()\n+\n+if(NOT HAVE_STRCASESTR)\n+\tlist(APPEND compat_SOURCES compat/strcasestr.c)\n+endif()\n+\n+if(NOT HAVE_STRLCPY)\n+\tlist(APPEND compat_SOURCES compat/strlcpy.c)\n+endif()\n+\n+if(NOT HAVE_STRTOUMAX)\n+\tlist(APPEND compat_SOURCES compat/strtoumax.c compat/strtoimax.c)\n+endif()\n+\n+if(NOT HAVE_SETENV)\n+\tlist(APPEND compat_SOURCES compat/setenv.c)\n+endif()\n+\n+if(NOT HAVE_MKDTEMP)\n+\tlist(APPEND compat_SOURCES compat/mkdtemp.c)\n+endif()\n+\n+if(NOT HAVE_PREAD)\n+\tlist(APPEND compat_SOURCES compat/pread.c)\n+endif()\n+\n+if(NOT HAVE_MEMMEM)\n+\tlist(APPEND compat_SOURCES compat/memmem.c)\n+endif()\n+\n+if(NOT WIN32)\n+\tif(NOT HAVE_UNSETENV)\n+\t\tlist(APPEND compat_SOURCES compat/unsetenv.c)\n+\tendif()\n+\n+\tif(NOT HAVE_HSTRERROR)\n+\t\tlist(APPEND compat_SOURCES compat/hstrerror.c)\n+\tendif()\n+endif()\n+\n+check_function_exists(getdelim HAVE_GETDELIM)\n+if(HAVE_GETDELIM)\n+\tadd_compile_definitions(HAVE_GETDELIM)\n+endif()\n+\n+check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)\n+check_symbol_exists(CLOCK_MONOTONIC \"time.h\" HAVE_CLOCK_MONOTONIC)\n+if(HAVE_CLOCK_GETTIME)\n+\tadd_compile_definitions(HAVE_CLOCK_GETTIME)\n+endif()\n+if(HAVE_CLOCK_MONOTONIC)\n+\tadd_compile_definitions(HAVE_CLOCK_MONOTONIC)\n+endif()\n+\n+#check for st_blocks in struct stat\n+check_struct_has_member(\"struct stat\" st_blocks \"sys/stat.h\" STRUCT_STAT_HAS_ST_BLOCKS)\n+if(NOT STRUCT_STAT_HAS_ST_BLOCKS)\n+\tadd_compile_definitions(NO_ST_BLOCKS_IN_STRUCT_STAT)\n+endif()\n+\n+#compile checks\n+check_c_source_runs(\"\n+#include<stdio.h>\n+#include<stdarg.h>\n+#include<string.h>\n+#include<stdlib.h>\n+\n+int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)\n+{\n+\tint ret;\n+\tva_list ap;\n+\n+\tva_start(ap, format);\n+\tret = vsnprintf(str, maxsize, format, ap);\n+\tva_end(ap);\n+\treturn ret;\n+}\n+\n+int main(void)\n+{\n+\tchar buf[6];\n+\n+\tif (test_vsnprintf(buf, 3, \\\"%s\\\", \\\"12345\\\") != 5\n+\t\t|| strcmp(buf, \\\"12\\\"))\n+\t\t\treturn 1;\n+\tif (snprintf(buf, 3, \\\"%s\\\", \\\"12345\\\") != 5\n+\t\t|| strcmp(buf, \\\"12\\\"))\n+\t\t\treturn 1;\n+\treturn 0;\n+}\"\n+SNPRINTF_OK)\n+if(NOT SNPRINTF_OK)\n+\tadd_compile_definitions(SNPRINTF_RETURNS_BOGUS)\n+\tlist(APPEND compat_SOURCES compat/snprintf.c)\n+endif()\n+\n+check_c_source_runs(\"\n+#include<stdio.h>\n+\n+int main(void)\n+{\n+\tFILE *f = fopen(\\\".\\\", \\\"r\\\");\n+\n+\treturn f != NULL;\n+}\"\n+FREAD_READS_DIRECTORIES_NO)\n+if(NOT FREAD_READS_DIRECTORIES_NO)\n+\tadd_compile_definitions(FREAD_READS_DIRECTORIES)\n+\tlist(APPEND compat_SOURCES compat/fopen.c)\n+endif()\n+\n+check_c_source_compiles(\"\n+#include <regex.h>\n+#ifndef REG_STARTEND\n+#error oops we dont have it\n+#endif\n+\n+int main(void)\n+{\n+\treturn 0;\n+}\"\n+HAVE_REGEX)\n+if(NOT HAVE_REGEX)\n+\tinclude_directories(${CMAKE_SOURCE_DIR}/compat/regex)\n+\tlist(APPEND compat_SOURCES compat/regex/regex.c )\n+\tadd_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)\n+endif()\n+\n+\n+check_c_source_compiles(\"\n+#include <stddef.h>\n+#include <sys/types.h>\n+#include <sys/sysctl.h>\n+\n+int main(void)\n+{\n+\tint val, mib[2];\n+\tsize_t len;\n+\n+\tmib[0] = CTL_HW;\n+\tmib[1] = 1;\n+\tlen = sizeof(val);\n+\treturn sysctl(mib, 2, &val, &len, NULL, 0) ? 1 : 0;\n+}\"\n+HAVE_BSD_SYSCTL)\n+if(HAVE_BSD_SYSCTL)\n+\tadd_compile_definitions(HAVE_BSD_SYSCTL)\n+endif()\n+\n+set(CMAKE_REQUIRED_LIBRARIES ${Iconv_LIBRARIES})\n+set(CMAKE_REQUIRED_INCLUDES ${Iconv_INCLUDE_DIRS})\n+\n+check_c_source_compiles(\"\n+#include <iconv.h>\n+\n+extern size_t iconv(iconv_t cd,\n+\t\tchar **inbuf, size_t *inbytesleft,\n+\t\tchar **outbuf, size_t *outbytesleft);\n+\n+int main(void)\n+{\n+\treturn 0;\n+}\"\n+HAVE_NEW_ICONV)\n+if(HAVE_NEW_ICONV)\n+\tset(HAVE_OLD_ICONV 0)\n+else()\n+\tset(HAVE_OLD_ICONV 1)\n+endif()\n+\n+check_c_source_runs(\"\n+#include <iconv.h>\n+#if ${HAVE_OLD_ICONV}\n+typedef const char *iconv_ibp;\n+#else\n+typedef char *iconv_ibp;\n+#endif\n+\n+int main(void)\n+{\n+\tint v;\n+\ticonv_t conv;\n+\tchar in[] = \\\"a\\\";\n+\ticonv_ibp pin = in;\n+\tchar out[20] = \\\"\\\";\n+\tchar *pout = out;\n+\tsize_t isz = sizeof(in);\n+\tsize_t osz = sizeof(out);\n+\n+\tconv = iconv_open(\\\"UTF-16\\\", \\\"UTF-8\\\");\n+\ticonv(conv, &pin, &isz, &pout, &osz);\n+\ticonv_close(conv);\n+\tv = (unsigned char)(out[0]) + (unsigned char)(out[1]);\n+\treturn v != 0xfe + 0xff;\n+}\"\n+ICONV_DOESNOT_OMIT_BOM)\n+if(NOT ICONV_DOESNOT_OMIT_BOM)\n+\tadd_compile_definitions(ICONV_OMITS_BOM)\n+endif()\n+\n+unset(CMAKE_REQUIRED_LIBRARIES)\n+unset(CMAKE_REQUIRED_INCLUDES)\n+\n+\n+#programs\n+set(PROGRAMS_BUILT\n+\tgit git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst\n+\tgit-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)\n+\n+if(NOT CURL_FOUND)\n+\tlist(APPEND excluded_progs git-http-fetch git-http-push)\n+\tadd_compile_definitions(NO_CURL)\n+\tmessage(WARNING \"git-http-push and git-http-fetch will not be built\")\n+else()\n+\tlist(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)\n+\tif(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)\n+\t\tadd_compile_definitions(USE_CURL_FOR_IMAP_SEND)\n+\tendif()\n+endif()\n+\n+if(NOT EXPAT_FOUND)\n+\tlist(APPEND excluded_progs git-http-push)\n+\tadd_compile_definitions(NO_EXPAT)\n+else()\n+\tlist(APPEND PROGRAMS_BUILT git-http-push)\n+\tif(EXPAT_VERSION_STRING VERSION_LESS_EQUAL 1.2)\n+\t\tadd_compile_definitions(EXPAT_NEEDS_XMLPARSE_H)\n+\tendif()\n+endif()\n+\n+list(REMOVE_DUPLICATES excluded_progs)\n+list(REMOVE_DUPLICATES PROGRAMS_BUILT)\n+\n+\n+foreach(p ${excluded_progs})\n+\tlist(APPEND EXCLUSION_PROGS --exclude-program ${p} )\n+endforeach()\n+\n+#for comparing null values\n+list(APPEND EXCLUSION_PROGS empty)\n+set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING \"Programs not built\" FORCE)\n+\n+if(NOT EXISTS ${CMAKE_BINARY_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)\n+\tlist(REMOVE_ITEM EXCLUSION_PROGS empty)\n+\tmessage(\"Generating command-list.h\")\n+\texecute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt\n+\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n+\t\t\tOUTPUT_FILE ${CMAKE_BINARY_DIR}/command-list.h)\n+endif()\n+\n+if(NOT EXISTS ${CMAKE_BINARY_DIR}/config-list.h)\n+\tmessage(\"Generating config-list.h\")\n+\texecute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh\n+\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n+\t\t\tOUTPUT_FILE ${CMAKE_BINARY_DIR}/config-list.h)\n+endif()\n+\n+include_directories(${CMAKE_BINARY_DIR})\n+\n+#build\n+#libgit\n+parse_makefile_for_sources(libgit_SOURCES \"LIB_OBJS\")\n+\n+list(TRANSFORM libgit_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n+list(TRANSFORM compat_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n+add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})\n+\n+#libxdiff\n+parse_makefile_for_sources(libxdiff_SOURCES \"XDIFF_OBJS\")\n+\n+list(TRANSFORM libxdiff_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n+add_library(xdiff STATIC ${libxdiff_SOURCES})\n+\n+#libvcs-svn\n+parse_makefile_for_sources(libvcs-svn_SOURCES \"VCSSVN_OBJS\")\n+\n+list(TRANSFORM libvcs-svn_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n+add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})\n+\n+#link all required libraries to common-main\n+add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)\n+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)\n+if(Intl_FOUND)\n+\ttarget_link_libraries(common-main ${Intl_LIBRARIES})\n+endif()\n+if(Iconv_FOUND)\n+\ttarget_link_libraries(common-main ${Iconv_LIBRARIES})\n+endif()\n+\n+#git\n+parse_makefile_for_sources(git_SOURCES \"BUILTIN_OBJS\")\n+\n+list(TRANSFORM git_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n+add_executable(git ${CMAKE_SOURCE_DIR}/git.c ${git_SOURCES})\n+target_link_libraries(git common-main)\n+\n+add_executable(git-bugreport ${CMAKE_SOURCE_DIR}/bugreport.c)\n+target_link_libraries(git-bugreport common-main)\n+\n+add_executable(git-credential-store ${CMAKE_SOURCE_DIR}/credential-store.c)\n+target_link_libraries(git-credential-store common-main)\n+\n+add_executable(git-daemon ${CMAKE_SOURCE_DIR}/daemon.c)\n+target_link_libraries(git-daemon common-main)\n+\n+add_executable(git-fast-import ${CMAKE_SOURCE_DIR}/fast-import.c)\n+target_link_libraries(git-fast-import common-main)\n+\n+add_executable(git-http-backend ${CMAKE_SOURCE_DIR}/http-backend.c)\n+target_link_libraries(git-http-backend common-main)\n+\n+add_executable(git-sh-i18n--envsubst ${CMAKE_SOURCE_DIR}/sh-i18n--envsubst.c)\n+target_link_libraries(git-sh-i18n--envsubst common-main)\n+\n+add_executable(git-shell ${CMAKE_SOURCE_DIR}/shell.c)\n+target_link_libraries(git-shell common-main)\n+\n+if(CURL_FOUND)\n+\tadd_library(http_obj OBJECT ${CMAKE_SOURCE_DIR}/http.c)\n+\n+\tadd_executable(git-imap-send ${CMAKE_SOURCE_DIR}/imap-send.c)\n+\ttarget_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})\n+\n+\tadd_executable(git-http-fetch ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/http-fetch.c)\n+\ttarget_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})\n+\n+\tadd_executable(git-remote-http ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/remote-curl.c)\n+\ttarget_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )\n+\n+\tif(EXPAT_FOUND)\n+\t\tadd_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)\n+\t\ttarget_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})\n+\tendif()\n+endif()\n+\n+add_executable(git-remote-testsvn ${CMAKE_SOURCE_DIR}/remote-testsvn.c)\n+target_link_libraries(git-remote-testsvn common-main vcs-svn)\n+\n+add_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)\n+target_link_libraries(git-credential-cache common-main)\n+\n+add_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)\n+target_link_libraries(git-credential-cache--daemon common-main)\n+\n+\n+set(git_builtin_extra\n+\tcherry cherry-pick format-patch fsck-objects\n+\tinit merge-subtree restore show\n+\tstage status switch whatchanged)\n+\n+#Creating hardlinks\n+foreach(s ${git_SOURCES} ${git_builtin_extra})\n+\tstring(REPLACE \"${CMAKE_SOURCE_DIR}/builtin/\" \"\" s ${s})\n+\tstring(REPLACE \".c\" \"\" s ${s})\n+\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git git-${s})\\n\")\n+\tlist(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})\n+endforeach()\n+\n+if(CURL_FOUND)\n+\tset(remote_exes\n+\t\tgit-remote-https git-remote-ftp git-remote-ftps)\n+\tforeach(s ${remote_exes})\n+\t\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git-remote-http ${s})\\n\")\n+\t\tlist(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})\n+\tendforeach()\n+endif()\n+\n+add_custom_command(OUTPUT ${git_links} ${git_http_links}\n+\t\tCOMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake\n+\t\tDEPENDS git git-remote-http)\n+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})\n-- \ngitgitgadget\n\n"},{"id":"399615","messageId":"db05180e98af42b5d0887298adbb2f2db6c1d6e7.1591986566.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v4.git.1591986566.gitgitgadget@gmail.com","subject":"[PATCH v4 4/8] cmake: support for testing git with ctest","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-06-12T18:29:22Z","receivedAt":"2020-06-12T18:29:38Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThis patch provides an alternate way to test git using ctest.\nCTest ships with CMake, so there is no additional dependency being\nintroduced.\n\nTo perform the tests with ctest do this after building:\nctest -j[number of jobs]\n\nNOTE: -j is optional, the default number of jobs is 1\n\nEach of the jobs does this:\ncd t/ && sh t[something].sh\n\nThe reason for using CTest is that it logs the output of the tests\nin a neat way, which can be helpful during diagnosis of failures.\n\nAfter the tests have run ctest generates three log files located in\n`build-directory`/Testing/Temporary/\n\nThese log files are:\n\nCTestCostData.txt:\nThis file contains the time taken to complete each test.\n\nLastTestsFailed.log:\nThis log file contains the names of the tests that have failed in the\nrun.\n\nLastTest.log:\nThis log file contains the log of all the tests that have run.\nA snippet of the file is given below.\n\n10/901 Testing: D:/my/git-master/t/t0009-prio-queue.sh\n10/901 Test: D:/my/git-master/t/t0009-prio-queue.sh\nCommand: \"sh.exe\" \"D:/my/git-master/t/t0009-prio-queue.sh\"\nDirectory: D:/my/git-master/t\n\"D:/my/git-master/t/t0009-prio-queue.sh\"\nOutput:\n----------------------------------------------------------\nok 1 - basic ordering\nok 2 - mixed put and get\nok 3 - notice empty queue\nok 4 - stack order\npassed all 4 test(s)\n1..4\n<end of output>\nTest time =   1.11 sec\n\nNOTE: Testing only works when building in source for now.\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n contrib/buildsystems/CMakeLists.txt | 124 ++++++++++++++++++++++++++++\n 1 file changed, 124 insertions(+)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex e8ed2439e46..1d57ac86772 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -96,6 +96,7 @@ include(CheckIncludeFile)\n include(CheckFunctionExists)\n include(CheckSymbolExists)\n include(CheckStructHasMember)\n+include(CTest)\n \n find_package(ZLIB REQUIRED)\n find_package(CURL)\n@@ -747,3 +748,126 @@ install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/\n if(MSGFMT_EXE)\n \tinstall(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)\n endif()\n+\n+\n+if(BUILD_TESTING)\n+\n+#tests-helpers\n+add_executable(test-fake-ssh ${CMAKE_SOURCE_DIR}/t/helper/test-fake-ssh.c)\n+target_link_libraries(test-fake-ssh common-main)\n+\n+add_executable(test-line-buffer ${CMAKE_SOURCE_DIR}/t/helper/test-line-buffer.c)\n+target_link_libraries(test-line-buffer common-main vcs-svn)\n+\n+add_executable(test-svn-fe ${CMAKE_SOURCE_DIR}/t/helper/test-svn-fe.c)\n+target_link_libraries(test-svn-fe common-main vcs-svn)\n+\n+#test-tool\n+parse_makefile_for_sources(test-tool_SOURCES \"TEST_BUILTINS_OBJS\")\n+\n+list(TRANSFORM test-tool_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/t/helper/\")\n+add_executable(test-tool ${CMAKE_SOURCE_DIR}/t/helper/test-tool.c ${test-tool_SOURCES})\n+target_link_libraries(test-tool common-main)\n+\n+set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool\n+\t\t\tPROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)\n+\n+#wrapper scripts\n+set(wrapper_scripts\n+\tgit git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)\n+\n+set(wrapper_test_scripts\n+\ttest-fake-ssh test-line-buffer test-svn-fe test-tool)\n+\n+\n+foreach(script ${wrapper_scripts})\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n+\tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n+\tstring(REPLACE \"@@PROG@@\" \"${script}\" content \"${content}\")\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n+endforeach()\n+\n+foreach(script ${wrapper_test_scripts})\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n+\tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n+\tstring(REPLACE \"@@PROG@@\" \"t/helper/${script}\" content \"${content}\")\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n+endforeach()\n+\n+file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n+string(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n+string(REPLACE \"@@PROG@@\" \"git-cvsserver\" content \"${content}\")\n+file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})\n+\n+#options for configuring test options\n+option(PERL_TESTS \"Perform tests that use perl\" ON)\n+option(PYTHON_TESTS \"Perform tests that use python\" ON)\n+\n+#GIT-BUILD-OPTIONS\n+set(TEST_SHELL_PATH ${SHELL_PATH})\n+set(DIFF diff)\n+set(PYTHON_PATH /usr/bin/python)\n+set(TAR tar)\n+set(NO_CURL )\n+set(NO_EXPAT )\n+set(USE_LIBPCRE1 )\n+set(USE_LIBPCRE2 )\n+set(NO_LIBPCRE1_JIT )\n+set(NO_PERL )\n+set(NO_PTHREADS )\n+set(NO_PYTHON )\n+set(PAGER_ENV \"LESS=FRX LV=-c\")\n+set(DC_SHA1 YesPlease)\n+set(RUNTIME_PREFIX true)\n+set(NO_GETTEXT )\n+\n+if(NOT CURL_FOUND)\n+\tset(NO_CURL 1)\n+endif()\n+\n+if(NOT EXPAT_FOUND)\n+\tset(NO_EXPAT 1)\n+endif()\n+\n+if(NOT Intl_FOUND)\n+\tset(NO_GETTEXT 1)\n+endif()\n+\n+if(NOT PERL_TESTS)\n+\tset(NO_PERL 1)\n+endif()\n+\n+if(NOT PYTHON_TESTS)\n+\tset(NO_PYTHON 1)\n+endif()\n+\n+file(WRITE ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"SHELL_PATH='${SHELL_PATH}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"TEST_SHELL_PATH='${TEST_SHELL_PATH}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PERL_PATH='${PERL_PATH}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"DIFF='${DIFF}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PYTHON_PATH='${PYTHON_PATH}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"TAR='${TAR}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_CURL='${NO_CURL}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_EXPAT='${NO_EXPAT}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"USE_LIBPCRE1='${USE_LIBPCRE1}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_LIBPCRE1_JIT='${NO_LIBPCRE1_JIT}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PERL='${NO_PERL}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PTHREADS='${NO_PTHREADS}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PAGER_ENV='${PAGER_ENV}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"DC_SHA1='${DC_SHA1}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"X=''\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_GETTEXT='${NO_GETTEXT}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"RUNTIME_PREFIX='${RUNTIME_PREFIX}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PYTHON='${NO_PYTHON}'\\n\")\n+\n+file(GLOB test_scipts \"${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh\")\n+\n+#test\n+foreach(tsh ${test_scipts})\n+\tadd_test(NAME ${tsh}\n+\t\tCOMMAND ${SH_EXE} ${tsh}\n+\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t)\n+endforeach()\n+\n+endif()#BUILD_TESTING\n-- \ngitgitgadget\n\n"},{"id":"399619","messageId":"abb9e6e1d585b34d55ec2b447a80f7ddf6dcb7da.1591986566.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v4.git.1591986566.gitgitgadget@gmail.com","subject":"[PATCH v4 2/8] cmake: generate the shell/perl/python scripts and templates, translations","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-06-12T18:29:20Z","receivedAt":"2020-06-12T18:29:42Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nImplement the placeholder substitution to generate scripted\nPorcelain commands, e.g. git-request-pull out of\ngit-request-pull.sh\n\nGenerate shell/perl/python scripts and template using CMake instead of\nusing sed like the build procedure in the Makefile does.\n\nThe text translations are only build if `msgfmt` is found in your path.\n\nNOTE: The scripts and templates are generated during configuration.\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n contrib/buildsystems/CMakeLists.txt | 110 +++++++++++++++++++++++++++-\n 1 file changed, 109 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 1e910d9df85..b3863bffee6 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -66,7 +66,7 @@ project(git\n \tLANGUAGES C)\n \n \n-#macros for parsing the Makefile for sources\n+#macros for parsing the Makefile for sources and scripts\n macro(parse_makefile_for_sources list_var regex)\n \tfile(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX \"^${regex} \\\\+=(.*)\")\n \tstring(REPLACE \"${regex} +=\" \"\" ${list_var} ${${list_var}})\n@@ -77,6 +77,16 @@ macro(parse_makefile_for_sources list_var regex)\n \tlist(REMOVE_ITEM ${list_var} \"\") #remove empty list elements\n endmacro()\n \n+macro(parse_makefile_for_scripts list_var regex lang)\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX \"^${regex} \\\\+=(.*)\")\n+\tstring(REPLACE \"${regex} +=\" \"\" ${list_var} ${${list_var}})\n+\tstring(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces\n+\tstring(REPLACE \" \" \";\" ${list_var} ${${list_var}}) #convert string to a list\n+\tif(NOT ${lang}) #exclude for SCRIPT_LIB\n+\t\tlist(TRANSFORM ${list_var} REPLACE \"${lang}\" \"\") #do the replacement\n+\tendif()\n+endmacro()\n+\n include(CheckTypeSize)\n include(CheckCSourceRuns)\n include(CheckCSourceCompiles)\n@@ -112,6 +122,11 @@ if(Intl_FOUND)\n \tinclude_directories(SYSTEM ${Intl_INCLUDE_DIRS})\n endif()\n \n+find_program(MSGFMT_EXE msgfmt)\n+if(NOT MSGFMT_EXE)\n+\tmessage(WARNING \"Text Translations won't be build\")\n+endif()\n+\n #default behaviour\n include_directories(${CMAKE_SOURCE_DIR})\n add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n@@ -590,3 +605,96 @@ add_custom_command(OUTPUT ${git_links} ${git_http_links}\n \t\tCOMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake\n \t\tDEPENDS git git-remote-http)\n add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})\n+\n+\n+#creating required scripts\n+set(SHELL_PATH /bin/sh)\n+set(PERL_PATH /usr/bin/perl)\n+set(LOCALEDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)\n+set(GITWEBDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)\n+set(INSTLIBDIR ${FALLBACK_RUNTIME_PREFIX}/share/perl5)\n+\n+#shell scripts\n+parse_makefile_for_scripts(git_sh_scripts \"SCRIPT_SH\" \".sh\")\n+parse_makefile_for_scripts(git_shlib_scripts \"SCRIPT_LIB\" \"\")\n+set(git_shell_scripts\n+\t${git_sh_scripts} ${git_shlib_scripts} git-instaweb)\n+\n+foreach(script ${git_shell_scripts})\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/${script}.sh content NEWLINE_CONSUME)\n+\tstring(REPLACE \"@SHELL_PATH@\" \"${SHELL_PATH}\" content \"${content}\")\n+\tstring(REPLACE \"@@DIFF@@\" \"diff\" content \"${content}\")\n+\tstring(REPLACE \"@LOCALEDIR@\" \"${LOCALEDIR}\" content \"${content}\")\n+\tstring(REPLACE \"@GITWEBDIR@\" \"${GITWEBDIR}\" content \"${content}\")\n+\tstring(REPLACE \"@@NO_CURL@@\" \"\" content \"${content}\")\n+\tstring(REPLACE \"@@USE_GETTEXT_SCHEME@@\" \"\" content \"${content}\")\n+\tstring(REPLACE \"# @@BROKEN_PATH_FIX@@\" \"\" content \"${content}\")\n+\tstring(REPLACE \"@@PERL@@\" \"${PERL_PATH}\" content \"${content}\")\n+\tstring(REPLACE \"@@SANE_TEXT_GREP@@\" \"-a\" content \"${content}\")\n+\tstring(REPLACE \"@@PAGER_ENV@@\" \"LESS=FRX LV=-c\" content \"${content}\")\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})\n+endforeach()\n+\n+#perl scripts\n+parse_makefile_for_scripts(git_perl_scripts \"SCRIPT_PERL\" \".perl\")\n+\n+#create perl header\n+file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )\n+string(REPLACE \"@@PATHSEP@@\" \":\" perl_header \"${perl_header}\")\n+string(REPLACE \"@@INSTLIBDIR@@\" \"${INSTLIBDIR}\" perl_header \"${perl_header}\")\n+\n+foreach(script ${git_perl_scripts})\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/${script}.perl content NEWLINE_CONSUME)\n+\tstring(REPLACE \"#!/usr/bin/perl\" \"#!/usr/bin/perl\\n${perl_header}\\n\" content \"${content}\")\n+\tstring(REPLACE \"@@GIT_VERSION@@\" \"${PROJECT_VERSION}\" content \"${content}\")\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})\n+endforeach()\n+\n+#python script\n+file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)\n+string(REPLACE \"#!/usr/bin/env python\" \"#!/usr/bin/python\" content \"${content}\")\n+file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})\n+\n+#perl modules\n+file(GLOB_RECURSE perl_modules \"${CMAKE_SOURCE_DIR}/perl/*.pm\")\n+\n+foreach(pm ${perl_modules})\n+\tstring(REPLACE \"${CMAKE_SOURCE_DIR}/perl/\" \"\" file_path ${pm})\n+\tfile(STRINGS ${pm} content NEWLINE_CONSUME)\n+\tstring(REPLACE \"@@LOCALEDIR@@\" \"${LOCALEDIR}\" content \"${content}\")\n+\tstring(REPLACE \"@@NO_PERL_CPAN_FALLBACKS@@\" \"\" content \"${content}\")\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})\n+#test-lib.sh requires perl/build/lib to be the build directory of perl modules\n+endforeach()\n+\n+\n+#templates\n+file(GLOB templates \"${CMAKE_SOURCE_DIR}/templates/*\")\n+list(TRANSFORM templates REPLACE \"${CMAKE_SOURCE_DIR}/templates/\" \"\")\n+list(REMOVE_ITEM templates \".gitignore\")\n+list(REMOVE_ITEM templates \"Makefile\")\n+\n+list(REMOVE_ITEM templates \"branches--\")\n+file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches\n+\n+#templates have @.*@ replacement so use configure_file instead\n+foreach(tm ${templates})\n+\tstring(REPLACE \"--\" \"/\" blt_tm ${tm})\n+\tstring(REPLACE \"this\" \"\" blt_tm ${blt_tm})# for this--\n+\tconfigure_file(${CMAKE_SOURCE_DIR}/templates/${tm} ${CMAKE_BINARY_DIR}/templates/blt/${blt_tm} @ONLY)\n+endforeach()\n+\n+\n+#translations\n+if(MSGFMT_EXE)\n+\tfile(GLOB po_files \"${CMAKE_SOURCE_DIR}/po/*.po\")\n+\tlist(TRANSFORM po_files REPLACE \"${CMAKE_SOURCE_DIR}/po/\" \"\")\n+\tlist(TRANSFORM po_files REPLACE \".po\" \"\")\n+\tforeach(po ${po_files})\n+\t\tfile(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES)\n+\t\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo\n+\t\t\t\tCOMMAND ${MSGFMT_EXE} --check --statistics -o ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo ${CMAKE_SOURCE_DIR}/po/${po}.po)\n+\t\tlist(APPEND po_gen ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo)\n+\tendforeach()\n+\tadd_custom_target(po-gen ALL DEPENDS ${po_gen})\n+endif()\n-- \ngitgitgadget\n\n"},{"id":"399616","messageId":"17e7f3e9de65f7275b56f47e7ae727c7f3e1b34d.1591986566.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v4.git.1591986566.gitgitgadget@gmail.com","subject":"[PATCH v4 5/8] cmake: support for testing git when building out of the source tree","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-06-12T18:29:23Z","receivedAt":"2020-06-12T18:29:43Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThis patch allows git to be tested when performin out of source builds.\n\nThis involves changing GIT_BUILD_DIR in t/test-lib.sh to point to the\nbuild directory. Also some miscellaneous copies from the source directory\nto the build directory.\nThe copies are:\nt/chainlint.sed needed by a bunch of test scripts\npo/is.po needed by t0204-gettext-rencode-sanity\nmergetools/tkdiff needed by t7800-difftool\ncontrib/completion/git-prompt.sh needed by t9903-bash-prompt\ncontrib/completion/git-completion.bash needed by t9902-completion\ncontrib/svn-fe/svnrdump_sim.py needed by t9020-remote-svn\n\nNOTE: t/test-lib.sh is only modified when tests are run not during\nthe build or configure.\nThe trash directory is still srcdir/t\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n contrib/buildsystems/CMakeLists.txt | 20 ++++++++++++++++++++\n 1 file changed, 20 insertions(+)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 1d57ac86772..f9976378d2d 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -861,6 +861,26 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_GETTEXT='${NO_GETTEXT}'\\n\"\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"RUNTIME_PREFIX='${RUNTIME_PREFIX}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PYTHON='${NO_PYTHON}'\\n\")\n \n+#Make the tests work when building out of the source tree\n+get_filename_component(CACHE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../CMakeCache.txt ABSOLUTE)\n+if(NOT ${CMAKE_BINARY_DIR}/CMakeCache.txt STREQUAL ${CACHE_PATH})\n+\tfile(RELATIVE_PATH BUILD_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/CMakeCache.txt)\n+\tstring(REPLACE \"/CMakeCache.txt\" \"\" BUILD_DIR_RELATIVE ${BUILD_DIR_RELATIVE})\n+\t#Setting the build directory in test-lib.sh before running tests\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.cmake\n+\t\t\"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh GIT_BUILD_DIR_REPL REGEX \\\"GIT_BUILD_DIR=(.*)\\\")\\n\"\n+\t\t\"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh content NEWLINE_CONSUME)\\n\"\n+\t\t\"string(REPLACE \\\"\\${GIT_BUILD_DIR_REPL}\\\" \\\"GIT_BUILD_DIR=\\\\\\\"$TEST_DIRECTORY\\\\\\\"/../${BUILD_DIR_RELATIVE}\\\" content \\\"\\${content}\\\")\\n\"\n+\t\t\"file(WRITE ${CMAKE_SOURCE_DIR}/t/test-lib.sh \\${content})\")\n+\t#misc copies\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.sed DESTINATION ${CMAKE_BINARY_DIR}/t/)\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/po/is.po DESTINATION ${CMAKE_BINARY_DIR}/po/)\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/mergetools/tkdiff DESTINATION ${CMAKE_BINARY_DIR}/mergetools/)\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-prompt.sh DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-completion.bash DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/contrib/svn-fe/svnrdump_sim.py DESTINATION ${CMAKE_BINARY_DIR}/contrib/svn-fe/)\n+endif()\n+\n file(GLOB test_scipts \"${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh\")\n \n #test\n-- \ngitgitgadget\n\n"},{"id":"399617","messageId":"f85ea0ac0ca5160a23a0a4ea26b7090638bcaf11.1591986566.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v4.git.1591986566.gitgitgadget@gmail.com","subject":"[PATCH v4 7/8] cmake: support for building git on windows with msvc and clang.","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-06-12T18:29:25Z","receivedAt":"2020-06-12T18:29:44Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThis patch adds support for Visual Studio and Clang builds\n\nThe minimum required version of CMake is upgraded to 3.15 because\nthis version offers proper support for Clang builds on Windows.\n\nLibintl is not searched for when building with Visual Studio or Clang\nbecause there is no binary compatible version available yet.\n\nNOTE: In the link options invalidcontinue.obj has to be included.\nThe reason for this is because by default, Windows calls abort()'s\ninstead of setting errno=EINVAL when invalid arguments are passed to\nstandard functions.\nThis commit explains it in detail:\n4b623d80f73528a632576990ca51e34c333d5dd6\n\nOn Windows the default generator is Visual Studio,so for Visual Studio\nbuilds do this:\n\ncmake `relative-path-to-srcdir`\n\nNOTE: Visual Studio generator is a multi config generator, which means\nthat Debug and Release builds can be done on the same build directory.\n\nFor Clang builds do this:\n\nOn bash\nCC=clang cmake `relative-path-to-srcdir` -G Ninja\n\t\t-DCMAKE_BUILD_TYPE=[Debug or Release]\n\nOn cmd\nset CC=Clang\ncmake `relative-path-to-srcdir` -G Ninja\n\t\t-DCMAKE_BUILD_TYPE=[Debug or Release]\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n contrib/buildsystems/CMakeLists.txt | 55 +++++++++++++++++++++++------\n 1 file changed, 45 insertions(+), 10 deletions(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 9aff2b9f4f9..8367b73e947 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -108,8 +108,11 @@ find_package(ZLIB REQUIRED)\n find_package(CURL)\n find_package(EXPAT)\n find_package(Iconv)\n-find_package(Intl)\n \n+#Don't use libintl on Windows Visual Studio and Clang builds\n+if(NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL \"MSVC\" OR CMAKE_C_COMPILER_ID STREQUAL \"Clang\")))\n+\tfind_package(Intl)\n+endif()\n \n if(NOT Intl_FOUND)\n \tadd_compile_definitions(NO_GETTEXT)\n@@ -133,7 +136,7 @@ if(Intl_FOUND)\n endif()\n \n \n-if(WIN32)\n+if(WIN32 AND NOT MSVC)#not required for visual studio builds\n \tfind_program(WINDRES_EXE windres)\n \tif(NOT WINDRES_EXE)\n \t\tmessage(FATAL_ERROR \"Install windres on Windows for resource files\")\n@@ -145,6 +148,13 @@ if(NOT MSGFMT_EXE)\n \tmessage(WARNING \"Text Translations won't be build\")\n endif()\n \n+#Force all visual studio outputs to CMAKE_BINARY_DIR\n+if(CMAKE_C_COMPILER_ID STREQUAL \"MSVC\")\n+\tset(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})\n+\tset(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})\n+\tadd_compile_options(/MP)\n+endif()\n+\n #default behaviour\n include_directories(${CMAKE_SOURCE_DIR})\n add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n@@ -182,6 +192,10 @@ endif()\n \n #Platform Specific\n if(CMAKE_SYSTEM_NAME STREQUAL \"Windows\")\n+\tif(CMAKE_C_COMPILER_ID STREQUAL \"MSVC\" OR CMAKE_C_COMPILER_ID STREQUAL \"Clang\")\n+\t\tinclude_directories(${CMAKE_SOURCE_DIR}/compat/vcbuild/include)\n+\t\tadd_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)\n+\tendif()\n \tinclude_directories(${CMAKE_SOURCE_DIR}/compat/win32)\n \tadd_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32\n \t\t\t\t_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=\".exe\"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT\n@@ -570,14 +584,22 @@ parse_makefile_for_sources(libvcs-svn_SOURCES \"VCSSVN_OBJS\")\n list(TRANSFORM libvcs-svn_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})\n \n-#add git.rc for gcc\n if(WIN32)\n-\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n-\t\t\tCOMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}\n-\t\t\t\t-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION=\"\\\\\\\"${PROJECT_VERSION}.GIT\\\\\\\"\"\n-\t\t\t\t-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res\n-\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n-\t\t\tVERBATIM)\n+\tif(NOT MSVC)#use windres when compiling with gcc and clang\n+\t\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n+\t\t\t\tCOMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}\n+\t\t\t\t\t-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION=\"\\\\\\\"${PROJECT_VERSION}.GIT\\\\\\\"\"\n+\t\t\t\t\t-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res\n+\t\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n+\t\t\t\tVERBATIM)\n+\telse()#MSVC use rc\n+\t\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n+\t\t\t\tCOMMAND ${CMAKE_RC_COMPILER} /d MAJOR=${PROJECT_VERSION_MAJOR} /d MINOR=${PROJECT_VERSION_MINOR}\n+\t\t\t\t\t/d MICRO=${PROJECT_VERSION_PATCH} /d PATCHLEVEL=0 /d GIT_VERSION=\"${PROJECT_VERSION}.GIT\"\n+\t\t\t\t\t/fo ${CMAKE_BINARY_DIR}/git.res ${CMAKE_SOURCE_DIR}/git.rc\n+\t\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n+\t\t\t\tVERBATIM)\n+\tendif()\n \tadd_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)\n endif()\n \n@@ -594,7 +616,13 @@ endif()\n if(WIN32)\n \ttarget_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)\n \tadd_dependencies(common-main git-rc)\n-\ttarget_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)\n+\tif(CMAKE_C_COMPILER_ID STREQUAL \"GNU\")\n+\t\ttarget_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)\n+\telseif(CMAKE_C_COMPILER_ID STREQUAL \"Clang\")\n+\t\ttarget_link_options(common-main PUBLIC -municode -Wl,-nxcompat -Wl,-dynamicbase -Wl,-entry:wmainCRTStartup -Wl,invalidcontinue.obj)\n+\telseif(CMAKE_C_COMPILER_ID STREQUAL \"MSVC\")\n+\t\ttarget_link_options(common-main PUBLIC /IGNORE:4217 /IGNORE:4049 /NOLOGO /ENTRY:wmainCRTStartup /SUBSYSTEM:CONSOLE invalidcontinue.obj)\n+\tendif()\n elseif(UNIX)\n \ttarget_link_libraries(common-main pthread rt)\n endif()\n@@ -847,6 +875,13 @@ target_link_libraries(test-tool common-main)\n set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool\n \t\t\tPROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)\n \n+if(MSVC)\n+\tset_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool\n+\t\t\t\tPROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/t/helper)\n+\tset_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool\n+\t\t\t\tPROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/helper)\n+endif()\n+\n #wrapper scripts\n set(wrapper_scripts\n \tgit git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)\n-- \ngitgitgadget\n\n"},{"id":"399618","messageId":"549f0cd5fffef38e8d85246a9aa2593674aad68c.1591986566.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v4.git.1591986566.gitgitgadget@gmail.com","subject":"[PATCH v4 6/8] cmake: support for building git on windows with mingw","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-06-12T18:29:24Z","receivedAt":"2020-06-12T18:29:45Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThis patch facilitates building git on Windows with CMake using MinGW\n\nNOTE: The funtions unsetenv and hstrerror are not checked in Windows\nbuilds.\nReasons\nNO_UNSETENV is not compatible with Windows builds.\nlines 262-264 compat/mingw.h\n\ncompat/mingw.h(line 25) provides a definition of hstrerror which\nconflicts with the definition provided in\ngit-compat-util.h(lines 733-736).\n\nTo use CMake on Windows with MinGW do this:\ncmake `relative-path-to-srcdir` -G \"MinGW Makefiles\"\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n contrib/buildsystems/CMakeLists.txt | 121 ++++++++++++++++++++++------\n 1 file changed, 98 insertions(+), 23 deletions(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex f9976378d2d..9aff2b9f4f9 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -42,6 +42,10 @@ cmake_minimum_required(VERSION 3.14)\n set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n \n find_program(SH_EXE sh)\n+if(NOT SH_EXE)\n+\tmessage(FATAL_ERROR \"sh: shell interpreter was not found in your path, please install one.\"\n+\t\t\t\"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n+endif()\n \n #Create GIT-VERSION-FILE using GIT-VERSION-GEN\n if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)\n@@ -65,7 +69,9 @@ project(git\n \tVERSION ${git_version}\n \tLANGUAGES C)\n \n+\n #TODO gitk git-gui gitweb\n+#TODO Enable NLS on windows natively\n #TODO Add pcre support\n \n #macros for parsing the Makefile for sources and scripts\n@@ -104,6 +110,7 @@ find_package(EXPAT)\n find_package(Iconv)\n find_package(Intl)\n \n+\n if(NOT Intl_FOUND)\n \tadd_compile_definitions(NO_GETTEXT)\n \tif(NOT Iconv_FOUND)\n@@ -125,6 +132,14 @@ if(Intl_FOUND)\n \tinclude_directories(SYSTEM ${Intl_INCLUDE_DIRS})\n endif()\n \n+\n+if(WIN32)\n+\tfind_program(WINDRES_EXE windres)\n+\tif(NOT WINDRES_EXE)\n+\t\tmessage(FATAL_ERROR \"Install windres on Windows for resource files\")\n+\tendif()\n+endif()\n+\n find_program(MSGFMT_EXE msgfmt)\n if(NOT MSGFMT_EXE)\n \tmessage(WARNING \"Text Translations won't be build\")\n@@ -156,11 +171,39 @@ add_compile_definitions(PAGER_ENV=\"LESS=FRX LV=-c\"\n \t\t\tBINDIR=\"bin\"\n \t\t\tGIT_BUILT_FROM_COMMIT=\"\")\n \n-set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n-add_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n+if(WIN32)\n+\tset(FALLBACK_RUNTIME_PREFIX /mingw64)\n+\tadd_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n+else()\n+\tset(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n+\tadd_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n+endif()\n \n-add_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n-list(APPEND compat_SOURCES unix-socket.c)\n+\n+#Platform Specific\n+if(CMAKE_SYSTEM_NAME STREQUAL \"Windows\")\n+\tinclude_directories(${CMAKE_SOURCE_DIR}/compat/win32)\n+\tadd_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32\n+\t\t\t\t_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=\".exe\"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT\n+\t\t\t\tNOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0\n+\t\t\t\tUSE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP\n+\t\t\t\tUNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)\n+\tlist(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c\n+\t\tcompat/win32/pthread.c compat/win32mmap.c compat/win32/syslog.c\n+\t\tcompat/win32/trace2_win32_process_info.c compat/win32/dirent.c\n+\t\tcompat/nedmalloc/nedmalloc.c compat/strdup.c)\n+\tset(NO_UNIX_SOCKETS 1)\n+\n+elseif(CMAKE_SYSTEM_NAME STREQUAL \"Linux\")\n+\tadd_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n+\tlist(APPEND compat_SOURCES unix-socket.c)\n+endif()\n+\n+if(WIN32)\n+\tset(EXE_EXTENSION .exe)\n+else()\n+\tset(EXE_EXTENSION)\n+endif()\n \n #header checks\n check_include_file(libgen.h HAVE_LIBGEN_H)\n@@ -223,7 +266,12 @@ endif()\n #function checks\n set(function_checks\n \tstrcasestr memmem strlcpy strtoimax strtoumax strtoull\n-\tsetenv mkdtemp poll pread memmem unsetenv hstrerror)\n+\tsetenv mkdtemp poll pread memmem)\n+\n+#unsetenv,hstrerror are incompatible with windows build\n+if(NOT WIN32)\n+\tlist(APPEND function_checks unsetenv hstrerror)\n+endif()\n \n foreach(f ${function_checks})\n \tstring(TOUPPER ${f} uf)\n@@ -444,7 +492,13 @@ unset(CMAKE_REQUIRED_INCLUDES)\n #programs\n set(PROGRAMS_BUILT\n \tgit git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst\n-\tgit-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)\n+\tgit-shell git-remote-testsvn)\n+\n+if(NO_UNIX_SOCKETS)\n+\tlist(APPEND excluded_progs git-credential-cache git-credential-cache--daemon)\n+else()\n+\tlist(APPEND PROGRAMS_BUILT git-credential-cache git-credential-cache--daemon)\n+endif()\n \n if(NOT CURL_FOUND)\n \tlist(APPEND excluded_progs git-http-fetch git-http-push)\n@@ -516,15 +570,34 @@ parse_makefile_for_sources(libvcs-svn_SOURCES \"VCSSVN_OBJS\")\n list(TRANSFORM libvcs-svn_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})\n \n+#add git.rc for gcc\n+if(WIN32)\n+\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n+\t\t\tCOMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}\n+\t\t\t\t-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION=\"\\\\\\\"${PROJECT_VERSION}.GIT\\\\\\\"\"\n+\t\t\t\t-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res\n+\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n+\t\t\tVERBATIM)\n+\tadd_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)\n+endif()\n+\n #link all required libraries to common-main\n add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)\n-target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)\n+\n+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})\n if(Intl_FOUND)\n \ttarget_link_libraries(common-main ${Intl_LIBRARIES})\n endif()\n if(Iconv_FOUND)\n \ttarget_link_libraries(common-main ${Iconv_LIBRARIES})\n endif()\n+if(WIN32)\n+\ttarget_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)\n+\tadd_dependencies(common-main git-rc)\n+\ttarget_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)\n+elseif(UNIX)\n+\ttarget_link_libraries(common-main pthread rt)\n+endif()\n \n #git\n parse_makefile_for_sources(git_SOURCES \"BUILTIN_OBJS\")\n@@ -575,11 +648,13 @@ endif()\n add_executable(git-remote-testsvn ${CMAKE_SOURCE_DIR}/remote-testsvn.c)\n target_link_libraries(git-remote-testsvn common-main vcs-svn)\n \n-add_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)\n-target_link_libraries(git-credential-cache common-main)\n+if(NOT NO_UNIX_SOCKETS)\n+\tadd_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)\n+\ttarget_link_libraries(git-credential-cache common-main)\n \n-add_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)\n-target_link_libraries(git-credential-cache--daemon common-main)\n+\tadd_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)\n+\ttarget_link_libraries(git-credential-cache--daemon common-main)\n+endif()\n \n \n set(git_builtin_extra\n@@ -591,16 +666,16 @@ set(git_builtin_extra\n foreach(s ${git_SOURCES} ${git_builtin_extra})\n \tstring(REPLACE \"${CMAKE_SOURCE_DIR}/builtin/\" \"\" s ${s})\n \tstring(REPLACE \".c\" \"\" s ${s})\n-\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git git-${s})\\n\")\n-\tlist(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})\n+\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git${EXE_EXTENSION} git-${s}${EXE_EXTENSION})\\n\")\n+\tlist(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s}${EXE_EXTENSION})\n endforeach()\n \n if(CURL_FOUND)\n \tset(remote_exes\n \t\tgit-remote-https git-remote-ftp git-remote-ftps)\n \tforeach(s ${remote_exes})\n-\t\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git-remote-http ${s})\\n\")\n-\t\tlist(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})\n+\t\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git-remote-http${EXE_EXTENSION} ${s}${EXE_EXTENSION})\\n\")\n+\t\tlist(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s}${EXE_EXTENSION})\n \tendforeach()\n endif()\n \n@@ -721,20 +796,20 @@ set(bin_links\n \tgit-receive-pack git-upload-archive git-upload-pack)\n \n foreach(b ${bin_links})\n-install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})\")\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/bin/${b}${EXE_EXTENSION})\")\n endforeach()\n \n-install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)\")\n-install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)\")\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git${EXE_EXTENSION})\")\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell${EXE_EXTENSION})\")\n \n foreach(b ${git_links})\n \tstring(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n-\tinstall(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n+\tinstall(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})\")\n endforeach()\n \n foreach(b ${git_http_links})\n \tstring(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n-\tinstall(CODE \"file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n+\tinstall(CODE \"file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})\")\n endforeach()\n \n install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4\n@@ -783,14 +858,14 @@ set(wrapper_test_scripts\n foreach(script ${wrapper_scripts})\n \tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n \tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n-\tstring(REPLACE \"@@PROG@@\" \"${script}\" content \"${content}\")\n+\tstring(REPLACE \"@@PROG@@\" \"${script}${EXE_EXTENSION}\" content \"${content}\")\n \tfile(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n endforeach()\n \n foreach(script ${wrapper_test_scripts})\n \tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n \tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n-\tstring(REPLACE \"@@PROG@@\" \"t/helper/${script}\" content \"${content}\")\n+\tstring(REPLACE \"@@PROG@@\" \"t/helper/${script}${EXE_EXTENSION}\" content \"${content}\")\n \tfile(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n endforeach()\n \n@@ -856,7 +931,7 @@ 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\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PAGER_ENV='${PAGER_ENV}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"DC_SHA1='${DC_SHA1}'\\n\")\n-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"X=''\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"X='${EXE_EXTENSION}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_GETTEXT='${NO_GETTEXT}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"RUNTIME_PREFIX='${RUNTIME_PREFIX}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PYTHON='${NO_PYTHON}'\\n\")\n-- \ngitgitgadget\n\n"},{"id":"399620","messageId":"2f7cf41e08fd995c544fa4a60bb5d22cf7144b76.1591986566.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v4.git.1591986566.gitgitgadget@gmail.com","subject":"[PATCH v4 8/8] ci: modification of main.yml to use cmake for vs-build job","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-06-12T18:29:26Z","receivedAt":"2020-06-12T18:29:49Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiv.siddharthan@gmail.com>\n\nTeach .github/workflows/main.yml to use CMake for VS builds.\n\nModified the vs-test step to match windows-test step. This speeds\nup the vs-test. Calling git-cmd from powershell and then calling git-bash\nto perform the tests slows things down(factor of about 6). So git-bash\nis directly called from powershell to perform the tests using prove.\n\nNOTE: Since GitHub keeps the same directory for each job\n(with respect to path) absolute paths are used in the bin-wrapper\nscripts.\n\nGitHub has switched to CMake 3.17.1 which changed the behaviour of\nFindCURL module. An extra definition (-DCURL_NO_CURL_CMAKE=ON) has been\nadded to revert to the old behaviour.\n\nIn the configuration phase CMake looks for the required libraries for\nbuilding git (eg zlib,libiconv). So we extract the libraries before we\nconfigure.\n\nTo check for ICONV_OMITS_BOM libiconv.dll needs to be in the working\ndirectory of script or path. So we copy the dlls before we configure.\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n .github/workflows/main.yml | 36 +++++++++++++++++++++---------------\n 1 file changed, 21 insertions(+), 15 deletions(-)\n\ndiff --git a/.github/workflows/main.yml b/.github/workflows/main.yml\nindex 84a5dcff7a0..77fbb08fd31 100644\n--- a/.github/workflows/main.yml\n+++ b/.github/workflows/main.yml\n@@ -145,13 +145,6 @@ jobs:\n         ## Unzip and remove the artifact\n         unzip artifacts.zip\n         rm artifacts.zip\n-    - name: generate Visual Studio solution\n-      shell: powershell\n-      run: |\n-        & .\\git-sdk-64-minimal\\usr\\bin\\bash.exe -lc @\"\n-          make NDEBUG=1 DEVELOPER=1 vcxproj\n-        \"@\n-        if (!$?) { exit(1) }\n     - name: download vcpkg artifacts\n       shell: powershell\n       run: |\n@@ -163,6 +156,14 @@ jobs:\n         Remove-Item compat.zip\n     - name: add msbuild to PATH\n       uses: microsoft/setup-msbuild@v1.0.0\n+    - name: copy dlls to root\n+      shell: powershell\n+      run: |\n+        & compat\\vcbuild\\vcpkg_copy_dlls.bat release\n+        if (!$?) { exit(1) }\n+    - name: generate Visual Studio solution\n+      shell: bash\n+      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\n     - name: MSBuild\n       run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142\n     - name: bundle artifact tar\n@@ -171,8 +172,6 @@ jobs:\n         MSVC: 1\n         VCPKG_ROOT: ${{github.workspace}}\\compat\\vcbuild\\vcpkg\n       run: |\n-        & compat\\vcbuild\\vcpkg_copy_dlls.bat release\n-        if (!$?) { exit(1) }\n         & git-sdk-64-minimal\\usr\\bin\\bash.exe -lc @\"\n           mkdir -p artifacts &&\n           eval \\\"`$(make -n artifacts-tar INCLUDE_DLLS_IN_ARTIFACTS=YesPlease ARTIFACTS_DIRECTORY=artifacts 2>&1 | grep ^tar)\\\"\n@@ -203,7 +202,7 @@ jobs:\n     - name: extract build artifacts\n       shell: bash\n       run: tar xf artifacts.tar.gz\n-    - name: test (parallel)\n+    - name: test\n       shell: powershell\n       env:\n         MSYSTEM: MINGW64\n@@ -214,12 +213,19 @@ jobs:\n           # Let Git ignore the SDK and the test-cache\n           printf '%s\\n' /git-sdk-64-minimal/ /test-cache/ >>.git/info/exclude\n \n-          cd t &&\n-          PATH=\\\"`$PWD/helper:`$PATH\\\" &&\n-          test-tool.exe run-command testsuite --jobs=10 -V -x --write-junit-xml \\\n-                  `$(test-tool.exe path-utils slice-tests \\\n-                          ${{matrix.nr}} 10 t[0-9]*.sh)\n+          ci/run-test-slice.sh ${{matrix.nr}} 10\n         \"@\n+    - name: ci/print-test-failures.sh\n+      if: failure()\n+      shell: powershell\n+      run: |\n+        & .\\git-sdk-64-minimal\\usr\\bin\\bash.exe -lc ci/print-test-failures.sh\n+    - name: Upload failed tests' directories\n+      if: failure() && env.FAILED_TEST_ARTIFACTS != ''\n+      uses: actions/upload-artifact@v1\n+      with:\n+        name: failed-tests-windows\n+        path: ${{env.FAILED_TEST_ARTIFACTS}}\n   regular:\n     needs: ci-config\n     if: needs.ci-config.outputs.enabled == 'yes'\n-- \ngitgitgadget\n"},{"id":"399781","messageId":"20200615140049.1647-1-oystwa@gmail.com","threadId":"53305","inReplyTo":"c4e1ba74464cfae882cde646d3c79778244b8f5e.1591986566.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v4 1/8] Introduce CMake support for configuring Git","fromName":"Øystein Walle","fromEmail":"oystwa@gmail.com","sentAt":"2020-06-15T14:00:49Z","receivedAt":"2020-06-15T14:01:05Z","isPatch":true,"sender":{"key":"oystwa@gmail.com","avatar":"https://avatars.githubusercontent.com/u/794585?v=4"},"body":"Hi,\n\nI haven't been able to pay much attention lately. I see this is v4 of this\npatch series and thought I took a quick look and didn't find anything, it's\npossible some of this has been addressed already. If so I apologize.\n\n> So let's start building CMake support for Git.\n\nYay!\n\n> +\n> +Instructions to run CMake:\n> +\n> +cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release\n> +Eg.\n> +From the root of git source tree\n> +\t`cmake contrib/buildsystems/ `\n> +This will build the git binaries at the root\n> +\n> +For out of source builds, say build in 'git/git-build/'\n> +\t`mkdir git-build;cd git-build; cmake ../contrib/buildsystems/`\n> +This will build the git binaries in git-build directory\n> +\n\nSince the mininum required version is sufficiently high I suggest you\nrecommend the following as well:\n\n    cmake -B build-dir -S contrib/buildsystems\n\nThis might be easier for scripted tasks (packaging and whatnot) since cd\nand mkdir aren't necessary.\n\n> +#set the source directory to root of git\n> +set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n\nSee if you can avoid this. This this will break if another project includes Git\nas part of itself with add_subdirectory() or the ExternalProject module. If all\nyou use it for is paths to other files then you might as well do this:\n\n    set(repo_root \"${CMAKE_CURRENT_LIST_DIR}/../..\")\n\nand use ${repo_root} the places you use ${CMAKE_SOURCE_DIR} now.\n\nAFAIK the places CMake accepts relative paths it's usually relative to\nCMAKE_CURRENT_SOURCE_DIR and not CMAKE_SOURCE_DIR, anyway. I don't think it's\nautomagically updated when CMAKE_SOURCE_DIR is changed.\n\n> +include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})\n> +if(CURL_FOUND)\n> +\tinclude_directories(SYSTEM ${CURL_INCLUDE_DIRS})\n> +endif()\n\nThis is better handled like this these days:\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 8367b73e94..ca1f90e58c 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -121,10 +121,6 @@ if(NOT Intl_FOUND)\n \tendif()\n endif()\n \n-include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})\n-if(CURL_FOUND)\n-\tinclude_directories(SYSTEM ${CURL_INCLUDE_DIRS})\n-endif()\n if(EXPAT_FOUND)\n \tinclude_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})\n endif()\n@@ -606,7 +602,7 @@ endif()\n #link all required libraries to common-main\n add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)\n \n-target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})\n+target_link_libraries(common-main libgit xdiff ZLIB::ZLIB)\n if(Intl_FOUND)\n \ttarget_link_libraries(common-main ${Intl_LIBRARIES})\n endif()\n@@ -659,17 +655,17 @@ if(CURL_FOUND)\n \tadd_library(http_obj OBJECT ${CMAKE_SOURCE_DIR}/http.c)\n \n \tadd_executable(git-imap-send ${CMAKE_SOURCE_DIR}/imap-send.c)\n-\ttarget_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})\n+\ttarget_link_libraries(git-imap-send http_obj common-main CURL::libcurl)\n \n \tadd_executable(git-http-fetch ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/http-fetch.c)\n-\ttarget_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})\n+\ttarget_link_libraries(git-http-fetch http_obj common-main CURL::libcurl)\n \n \tadd_executable(git-remote-http ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/remote-curl.c)\n-\ttarget_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )\n+\ttarget_link_libraries(git-remote-http http_obj common-main CURL::libcurl)\n \n \tif(EXPAT_FOUND)\n \t\tadd_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)\n-\t\ttarget_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})\n+\t\ttarget_link_libraries(git-http-push http_obj common-main CURL::libcurl ${EXPAT_LIBRARIES})\n \tendif()\n endif()\n \nWith this change we're feeding proper CMake targets to target_link_libraries()\ninstead of just a bunch of strings. CMake can know a lot about a target, such\nas it's dependencies, required macros and so on[1]. This means some boilerplate\ncode can be removed: Notice that the manual handling of Zlib's include path is\ngone. The same can perhaps be done for the other libraries as well but I\nhaven't checked that.\n\n> +include_directories(${CMAKE_SOURCE_DIR})\n> +(...)\n> +include_directories(${CMAKE_BINARY_DIR})\n\nSee if CMAKE_INCLUDE_CURRENT_DIR[2] makes this unneeded. It might not since you\noverwrite CMAKE_SOURCE_DIR manually.\n\nØsse\n\n[1]: https://cmake.org/cmake/help/latest/manual/cmake-properties.7.html#properties-on-targets\n[2]: https://cmake.org/cmake/help/latest/variable/CMAKE_INCLUDE_CURRENT_DIR.html\n"},{"id":"399782","messageId":"20200615140236.1707-1-oystwa@gmail.com","threadId":"53305","inReplyTo":"db05180e98af42b5d0887298adbb2f2db6c1d6e7.1591986566.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v4 4/8] cmake: support for testing git with ctest","fromName":"Øystein Walle","fromEmail":"oystwa@gmail.com","sentAt":"2020-06-15T14:02:36Z","receivedAt":"2020-06-15T14:02:57Z","isPatch":true,"sender":{"key":"oystwa@gmail.com","avatar":"https://avatars.githubusercontent.com/u/794585?v=4"},"body":"> +\n> +if(BUILD_TESTING)\n> +\n\nThis variable should perhaps be declared as an option using option()[1] since\nit's a knob the user is supposed to be able to switch. This makes it listed by\n`cmake -L`, and shown in ccmake and cmake-gui. In short, it's made more\ndisoverable.\n\n> file(APPEND ...)\n> file(APPEND ...)\n> file(APPEND ...)\n> (...)\n\nMaybe make this one multiline string and have one file(APPEND ...) at the end?\nIt looks a bit... big.\n\nØsse\n\n[1]: ttps://cmake.org/cmake/help/v3.18/command/option.html\n"},{"id":"399783","messageId":"20200615140349.1783-1-oystwa@gmail.com","threadId":"53305","inReplyTo":"549f0cd5fffef38e8d85246a9aa2593674aad68c.1591986566.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v4 6/8] cmake: support for building git on windows with mingw","fromName":"Øystein Walle","fromEmail":"oystwa@gmail.com","sentAt":"2020-06-15T14:03:49Z","receivedAt":"2020-06-15T14:03:58Z","isPatch":true,"sender":{"key":"oystwa@gmail.com","avatar":"https://avatars.githubusercontent.com/u/794585?v=4"},"body":"> +if(WIN32)\n> +\tset(EXE_EXTENSION .exe)\n> +else()\n> +\tset(EXE_EXTENSION)\n> +endif()\n\nYou can probably use CMAKE_EXECUTABLE_SUFFIX here. See:\nhttps://cmake.org/cmake/help/latest/variable/CMAKE_EXECUTABLE_SUFFIX.html\n\nØsse\n\n"},{"id":"399784","messageId":"20200615140442.1847-1-oystwa@gmail.com","threadId":"53305","inReplyTo":"f85ea0ac0ca5160a23a0a4ea26b7090638bcaf11.1591986566.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v4 7/8] cmake: support for building git on windows with msvc and clang","fromName":"Øystein Walle","fromEmail":"oystwa@gmail.com","sentAt":"2020-06-15T14:04:42Z","receivedAt":"2020-06-15T14:05:02Z","isPatch":true,"sender":{"key":"oystwa@gmail.com","avatar":"https://avatars.githubusercontent.com/u/794585?v=4"},"body":"> +#Force all visual studio outputs to CMAKE_BINARY_DIR\n\nWhat is the reasoning for this? AFAIK this makes it impossible to customize it\nfrom the outside by doing `cmake -DFOO=bar ...`.  \n\n>  if(WIN32)\n> -\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n> -\t\t\tCOMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}\n> -\t\t\t\t-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION=\"\\\\\\\"${PROJECT_VERSION}.GIT\\\\\\\"\"\n> -\t\t\t\t-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res\n> -\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n> -\t\t\tVERBATIM)\n> +\tif(NOT MSVC)#use windres when compiling with gcc and clang\n> +\t\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n> +\t\t\t\tCOMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}\n> +\t\t\t\t\t-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION=\"\\\\\\\"${PROJECT_VERSION}.GIT\\\\\\\"\"\n> +\t\t\t\t\t-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res\n> +\t\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n> +\t\t\t\tVERBATIM)\n> +\telse()#MSVC use rc\n> +\t\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n> +\t\t\t\tCOMMAND ${CMAKE_RC_COMPILER} /d MAJOR=${PROJECT_VERSION_MAJOR} /d MINOR=${PROJECT_VERSION_MINOR}\n> +\t\t\t\t\t/d MICRO=${PROJECT_VERSION_PATCH} /d PATCHLEVEL=0 /d GIT_VERSION=\"${PROJECT_VERSION}.GIT\"\n> +\t\t\t\t\t/fo ${CMAKE_BINARY_DIR}/git.res ${CMAKE_SOURCE_DIR}/git.rc\n> +\t\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n> +\t\t\t\tVERBATIM)\n> +\tendif()\n>  \tadd_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)\n>  endif()\n\nIf you list a .rc in the call to add_executable() then CMake knows how to\nhandle it and will invoke the resource compiler on it. I am not 100% sure how\nto provide additional arguments right now, but I believe it will lead to\nsimpler code than using add_custom_command() and add_custom_target().\n\nØsse\n\n"},{"id":"399804","messageId":"CAKiG+9XbpLpWWsEg+RCqxzJ70Hx-=qqxDL_Yy96weM5fLoVwuA@mail.gmail.com","threadId":"53305","inReplyTo":"20200615140236.1707-1-oystwa@gmail.com","subject":"Re: [PATCH v4 4/8] cmake: support for testing git with ctest","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-06-15T19:45:12Z","receivedAt":"2020-06-15T19:45:25Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Mon, Jun 15, 2020 at 7:32 PM Øystein Walle <oystwa@gmail.com> wrote:\n>\n> > +\n> > +if(BUILD_TESTING)\n> > +\n>\n> This variable should perhaps be declared as an option using option()[1] since\n> it's a knob the user is supposed to be able to switch. This makes it listed by\n> `cmake -L`, and shown in ccmake and cmake-gui. In short, it's made more\n> disoverable.\n>\n\nWhen you `include(CTest)` the option BUILD_TESTING is automatically added.\n\nThank You,\nSibi Siddharthan\n"},{"id":"399805","messageId":"CAKiG+9X66yf_F8F3XuYFdFyBWiFRZ_rf0Y1mE5LVCjsi-AzKbg@mail.gmail.com","threadId":"53305","inReplyTo":"20200615140349.1783-1-oystwa@gmail.com","subject":"Re: [PATCH v4 6/8] cmake: support for building git on windows with mingw","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-06-15T19:47:08Z","receivedAt":"2020-06-15T19:47:21Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Mon, Jun 15, 2020 at 7:33 PM Øystein Walle <oystwa@gmail.com> wrote:\n>\n> > +if(WIN32)\n> > +     set(EXE_EXTENSION .exe)\n> > +else()\n> > +     set(EXE_EXTENSION)\n> > +endif()\n>\n> You can probably use CMAKE_EXECUTABLE_SUFFIX here. See:\n> https://cmake.org/cmake/help/latest/variable/CMAKE_EXECUTABLE_SUFFIX.html\n>\n\nCould have done it that way, will try to change it once the patch\nseries gets merged with next or master.\n\n> Øsse\n>\n"},{"id":"399807","messageId":"CAKiG+9Xm2h-cXYhd7Mmc6NEa7u2i2cYznBBgHSvMGN15LX3iXQ@mail.gmail.com","threadId":"53305","inReplyTo":"20200615140442.1847-1-oystwa@gmail.com","subject":"Re: [PATCH v4 7/8] cmake: support for building git on windows with msvc and clang","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-06-15T19:56:35Z","receivedAt":"2020-06-15T19:56:48Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Mon, Jun 15, 2020 at 7:34 PM Øystein Walle <oystwa@gmail.com> wrote:\n>\n> > +#Force all visual studio outputs to CMAKE_BINARY_DIR\n>\n> What is the reasoning for this? AFAIK this makes it impossible to customize it\n> from the outside by doing `cmake -DFOO=bar ...`.\n>\n\nWhen you test git, the test system expects the binaries to be in a\nparticular directory relative to a bunch of miscellaneous\nscripts(wrappers,etc).\nSince Visual Studio is multi config generator the binaries go into\nCMAKE_BINARY_DIR/(Debug|Release|RelWithDebInfo...). By doing it this\nway it is a bit easier to handle, along with the other generators like\nMakefile or Ninja.\n\n\n> >  if(WIN32)\n> > -     add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n> > -                     COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}\n> > -                             -DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION=\"\\\\\\\"${PROJECT_VERSION}.GIT\\\\\\\"\"\n> > -                             -i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res\n> > -                     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n> > -                     VERBATIM)\n> > +     if(NOT MSVC)#use windres when compiling with gcc and clang\n> > +             add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n> > +                             COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}\n> > +                                     -DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION=\"\\\\\\\"${PROJECT_VERSION}.GIT\\\\\\\"\"\n> > +                                     -i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res\n> > +                             WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n> > +                             VERBATIM)\n> > +     else()#MSVC use rc\n> > +             add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n> > +                             COMMAND ${CMAKE_RC_COMPILER} /d MAJOR=${PROJECT_VERSION_MAJOR} /d MINOR=${PROJECT_VERSION_MINOR}\n> > +                                     /d MICRO=${PROJECT_VERSION_PATCH} /d PATCHLEVEL=0 /d GIT_VERSION=\"${PROJECT_VERSION}.GIT\"\n> > +                                     /fo ${CMAKE_BINARY_DIR}/git.res ${CMAKE_SOURCE_DIR}/git.rc\n> > +                             WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n> > +                             VERBATIM)\n> > +     endif()\n> >       add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)\n> >  endif()\n>\n> If you list a .rc in the call to add_executable() then CMake knows how to\n> handle it and will invoke the resource compiler on it. I am not 100% sure how\n> to provide additional arguments right now, but I believe it will lead to\n> simpler code than using add_custom_command() and add_custom_target().\n>\n> Øsse\n>\n\nCMake does know how to handle rc commands including defines.\nThe issue here is the conflicting redefinition of GIT_VERSION which is\nused in the source files.\nAnd CMake uses llvm-rc(completely broken as of llvm 9.0) for the rc compiler.\nHence the above monstrocity.\n\nThank You,\nSibi Siddharthan\n"},{"id":"399808","messageId":"CAKiG+9U8mVASyM-wcooFk69diYPmHMpymAQyLJcEL1N8X_Awuw@mail.gmail.com","threadId":"53305","inReplyTo":"20200615140049.1647-1-oystwa@gmail.com","subject":"Re: [PATCH v4 1/8] Introduce CMake support for configuring Git","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-06-15T20:04:46Z","receivedAt":"2020-06-15T20:05:00Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Mon, Jun 15, 2020 at 7:31 PM Øystein Walle <oystwa@gmail.com> wrote:\n>\n> Hi,\n>\n> I haven't been able to pay much attention lately. I see this is v4 of this\n> patch series and thought I took a quick look and didn't find anything, it's\n> possible some of this has been addressed already. If so I apologize.\n>\n> > So let's start building CMake support for Git.\n>\n> Yay!\n>\n> > +\n> > +Instructions to run CMake:\n> > +\n> > +cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release\n> > +Eg.\n> > +From the root of git source tree\n> > +     `cmake contrib/buildsystems/ `\n> > +This will build the git binaries at the root\n> > +\n> > +For out of source builds, say build in 'git/git-build/'\n> > +     `mkdir git-build;cd git-build; cmake ../contrib/buildsystems/`\n> > +This will build the git binaries in git-build directory\n> > +\n>\n> Since the mininum required version is sufficiently high I suggest you\n> recommend the following as well:\n>\n>     cmake -B build-dir -S contrib/buildsystems\n>\n> This might be easier for scripted tasks (packaging and whatnot) since cd\n> and mkdir aren't necessary.\n>\n\nWe could do that.\n\n> > +#set the source directory to root of git\n> > +set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n>\n> See if you can avoid this. This this will break if another project includes Git\n> as part of itself with add_subdirectory() or the ExternalProject module. If all\n> you use it for is paths to other files then you might as well do this:\n>\n>     set(repo_root \"${CMAKE_CURRENT_LIST_DIR}/../..\")\n>\n> and use ${repo_root} the places you use ${CMAKE_SOURCE_DIR} now.\n>\n> AFAIK the places CMake accepts relative paths it's usually relative to\n> CMAKE_CURRENT_SOURCE_DIR and not CMAKE_SOURCE_DIR, anyway. I don't think it's\n> automagically updated when CMAKE_SOURCE_DIR is changed.\n>\n\nSince we are using a single list file, it is fine.\nI understand your concern that git is included as part of another\nproject things might break, but that is really rare.\nI will try to fix these issues after adding support for BSD and APPLE systems.\nThe main priority for this patch series is to help git-for-windows\ndevelopers for now.\n\n> > +include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})\n> > +if(CURL_FOUND)\n> > +     include_directories(SYSTEM ${CURL_INCLUDE_DIRS})\n> > +endif()\n>\n> This is better handled like this these days:\n>\n> diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\n> index 8367b73e94..ca1f90e58c 100644\n> --- a/contrib/buildsystems/CMakeLists.txt\n> +++ b/contrib/buildsystems/CMakeLists.txt\n> @@ -121,10 +121,6 @@ if(NOT Intl_FOUND)\n>         endif()\n>  endif()\n>\n> -include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})\n> -if(CURL_FOUND)\n> -       include_directories(SYSTEM ${CURL_INCLUDE_DIRS})\n> -endif()\n>  if(EXPAT_FOUND)\n>         include_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})\n>  endif()\n> @@ -606,7 +602,7 @@ endif()\n>  #link all required libraries to common-main\n>  add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)\n>\n> -target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})\n> +target_link_libraries(common-main libgit xdiff ZLIB::ZLIB)\n>  if(Intl_FOUND)\n>         target_link_libraries(common-main ${Intl_LIBRARIES})\n>  endif()\n> @@ -659,17 +655,17 @@ if(CURL_FOUND)\n>         add_library(http_obj OBJECT ${CMAKE_SOURCE_DIR}/http.c)\n>\n>         add_executable(git-imap-send ${CMAKE_SOURCE_DIR}/imap-send.c)\n> -       target_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})\n> +       target_link_libraries(git-imap-send http_obj common-main CURL::libcurl)\n>\n>         add_executable(git-http-fetch ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/http-fetch.c)\n> -       target_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})\n> +       target_link_libraries(git-http-fetch http_obj common-main CURL::libcurl)\n>\n>         add_executable(git-remote-http ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/remote-curl.c)\n> -       target_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )\n> +       target_link_libraries(git-remote-http http_obj common-main CURL::libcurl)\n>\n>         if(EXPAT_FOUND)\n>                 add_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)\n> -               target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})\n> +               target_link_libraries(git-http-push http_obj common-main CURL::libcurl ${EXPAT_LIBRARIES})\n>         endif()\n>  endif()\n>\n> With this change we're feeding proper CMake targets to target_link_libraries()\n> instead of just a bunch of strings. CMake can know a lot about a target, such\n> as it's dependencies, required macros and so on[1]. This means some boilerplate\n> code can be removed: Notice that the manual handling of Zlib's include path is\n> gone. The same can perhaps be done for the other libraries as well but I\n> haven't checked that.\n>\n\nIt depends on the implementation of the CMake modules. We can do as\nyou suggested for Zlib and curl.\nIconv added exported targets recently.\nIntl still does not have this syntax yet.\nUsing ${*_LIBRARIES} works all across the board.\n\nThank You\nSibi Siddharthan\n\n> > +include_directories(${CMAKE_SOURCE_DIR})\n> > +(...)\n> > +include_directories(${CMAKE_BINARY_DIR})\n>\n> See if CMAKE_INCLUDE_CURRENT_DIR[2] makes this unneeded. It might not since you\n> overwrite CMAKE_SOURCE_DIR manually.\n>\n> Øsse\n>\n> [1]: https://cmake.org/cmake/help/latest/manual/cmake-properties.7.html#properties-on-targets\n> [2]: https://cmake.org/cmake/help/latest/variable/CMAKE_INCLUDE_CURRENT_DIR.html\n"},{"id":"400025","messageId":"xmqq8sglq8zn.fsf@gitster.c.googlers.com","threadId":"53305","inReplyTo":"CAKiG+9X66yf_F8F3XuYFdFyBWiFRZ_rf0Y1mE5LVCjsi-AzKbg@mail.gmail.com","subject":"Re: [PATCH v4 6/8] cmake: support for building git on windows with mingw","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-06-18T04:43:40Z","receivedAt":"2020-06-18T04:43:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n\n> On Mon, Jun 15, 2020 at 7:33 PM Øystein Walle <oystwa@gmail.com> wrote:\n>>\n>> > +if(WIN32)\n>> > +     set(EXE_EXTENSION .exe)\n>> > +else()\n>> > +     set(EXE_EXTENSION)\n>> > +endif()\n>>\n>> You can probably use CMAKE_EXECUTABLE_SUFFIX here. See:\n>> https://cmake.org/cmake/help/latest/variable/CMAKE_EXECUTABLE_SUFFIX.html\n>>\n>\n> Could have done it that way, will try to change it once the patch\n> series gets merged with next or master.\n\nIf it is something that makes the result even simpler than the above\nquoted 5 lines, I do not see a reason to postpone it and use that\nsimpler way from the beginning.\n\nThanks.\n"},{"id":"400075","messageId":"CAKiG+9VZUqDi=EbbqY2vLAiD6LEFMfR_2UHE+gbt_RpKNanUCA@mail.gmail.com","threadId":"53305","inReplyTo":"xmqq8sglq8zn.fsf@gitster.c.googlers.com","subject":"Re: [PATCH v4 6/8] cmake: support for building git on windows with mingw","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-06-18T19:55:22Z","receivedAt":"2020-06-18T19:55:38Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Thu, Jun 18, 2020 at 10:13 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n>\n> > On Mon, Jun 15, 2020 at 7:33 PM Øystein Walle <oystwa@gmail.com> wrote:\n> >>\n> >> > +if(WIN32)\n> >> > +     set(EXE_EXTENSION .exe)\n> >> > +else()\n> >> > +     set(EXE_EXTENSION)\n> >> > +endif()\n> >>\n> >> You can probably use CMAKE_EXECUTABLE_SUFFIX here. See:\n> >> https://cmake.org/cmake/help/latest/variable/CMAKE_EXECUTABLE_SUFFIX.html\n> >>\n> >\n> > Could have done it that way, will try to change it once the patch\n> > series gets merged with next or master.\n>\n> If it is something that makes the result even simpler than the above\n> quoted 5 lines, I do not see a reason to postpone it and use that\n> simpler way from the beginning.\n>\n\nSince this patch series has been merged with pu, I didn't know whether\nI should wait till the patch gets merged into 'next' or do the change\nimmediately.\nIf I do this change should I fixup the commit that introduced\nEXE_EXTENSION or commit on top of HEAD? Please tell. I will do the\nchanges immediately and submit another PATCH series.\n\nOne more thing, there is an issue with the scripts' permissions when\nrun in Linux. They don't have execute permissions.\nSince the main focus of the CMake build is to help windows devs,\nshould I defer this modification until a later time, or should I do\nthem immediately.\nThe changes will involve adding a line of code to each of the script\nvarieties(sh,perl,python) so 3 more lines of extra code.\n\nThank You,\nSibi Siddharthan\n\n> Thanks.\n"},{"id":"400076","messageId":"xmqqk104nnll.fsf@gitster.c.googlers.com","threadId":"53305","inReplyTo":"CAKiG+9VZUqDi=EbbqY2vLAiD6LEFMfR_2UHE+gbt_RpKNanUCA@mail.gmail.com","subject":"Re: [PATCH v4 6/8] cmake: support for building git on windows with mingw","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-06-18T20:08:38Z","receivedAt":"2020-06-18T20:08:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n\n> Since this patch series has been merged with pu, I didn't know whether\n> I should wait till the patch gets merged into 'next' or do the change\n> immediately.\n\nAh, OK.  Being in 'pu' does not mean no more than that the patch was\nsent to the list and I happened to have seen it.  If it were ready\nto be merged to 'next', I may have marked it as such in the \"What's\ncooking\" report, but otherwise, the default is to be polished until\nit gets ready.\n\n> One more thing, there is an issue with the scripts' permissions when\n> run in Linux. They don't have execute permissions.\n\nWhat script?  Your scripts you add in the patch series?  What is the\nreason why they lack execute permissions?  Forgot to \"chmod +x\"?\n\nIt sounds like, in addition to issues pointed out during the review\ncycle, you have identified more issues that can be solved to make\nthe series more complete yourself, which is a very good thing.  It\nis hard for anyone to review one's own patches and find issues, and\nyou seem to be getting the hang of it.  These are all good thing to\naddress before the topic becomes ready for 'next'.\n\nAnd there is no need to hurry.  If you do not want to waste time in\nrepeated rewrite and review cycle, the best way may be to go slowly\nand carefully to avoid \"this was known to be suboptimal even when I\nwrote it, but I didn't bother fixing it before sending it out, but\nit was noticed during the review so I have to update it and send a\nnew round\".\n\nThanks.\n"},{"id":"400084","messageId":"CAKiG+9UqvrxyMQufuG=oAP6Yo7+YSoicwqZBJjsZZFQT-Bscjw@mail.gmail.com","threadId":"53305","inReplyTo":"xmqqk104nnll.fsf@gitster.c.googlers.com","subject":"Re: [PATCH v4 6/8] cmake: support for building git on windows with mingw","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-06-18T20:40:42Z","receivedAt":"2020-06-18T20:40:59Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Fri, Jun 19, 2020 at 1:38 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n>\n> > Since this patch series has been merged with pu, I didn't know whether\n> > I should wait till the patch gets merged into 'next' or do the change\n> > immediately.\n>\n> Ah, OK.  Being in 'pu' does not mean no more than that the patch was\n> sent to the list and I happened to have seen it.  If it were ready\n> to be merged to 'next', I may have marked it as such in the \"What's\n> cooking\" report, but otherwise, the default is to be polished until\n> it gets ready.\n>\n> > One more thing, there is an issue with the scripts' permissions when\n> > run in Linux. They don't have execute permissions.\n>\n> What script?  Your scripts you add in the patch series?  What is the\n> reason why they lack execute permissions?  Forgot to \"chmod +x\"?\n>\n> It sounds like, in addition to issues pointed out during the review\n> cycle, you have identified more issues that can be solved to make\n> the series more complete yourself, which is a very good thing.  It\n> is hard for anyone to review one's own patches and find issues, and\n> you seem to be getting the hang of it.  These are all good thing to\n> address before the topic becomes ready for 'next'.\n>\n\nDanh was the one who pointed this out, credit goes to him.\nThe reason I deferred modifying in PATCH v4 was because there was no\neasy way(cross platform)\nto change file permissions. The workaround is to juggle the files to a\ntemporary directory, and then copy them\nto where they are intended to be with the required permissions. This\nadded quite a bit of code.\nSince Windows platform was the priority, I did not address this issue.\n\nI know that this issue needs to be addressed to make the script more\ncomplete, so will have a UNIX conditional block for addressing this\nissue.\n\nThank You,\nSibi Siddharthan\n\n> And there is no need to hurry.  If you do not want to waste time in\n> repeated rewrite and review cycle, the best way may be to go slowly\n> and carefully to avoid \"this was known to be suboptimal even when I\n> wrote it, but I didn't bother fixing it before sending it out, but\n> it was noticed during the review so I have to update it and send a\n> new round\".\n>\n> Thanks.\n"},{"id":"400090","messageId":"xmqq1rmcm6md.fsf@gitster.c.googlers.com","threadId":"53305","inReplyTo":"CAKiG+9UqvrxyMQufuG=oAP6Yo7+YSoicwqZBJjsZZFQT-Bscjw@mail.gmail.com","subject":"Re: [PATCH v4 6/8] cmake: support for building git on windows with mingw","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-06-18T21:00:42Z","receivedAt":"2020-06-18T21:00:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n\n> The reason I deferred modifying in PATCH v4 was because there was no\n> easy way(cross platform)\n> to change file permissions. The workaround is to juggle the files to a\n> temporary directory, and then copy them\n> to where they are intended to be with the required permissions. This\n> added quite a bit of code.\n> Since Windows platform was the priority, I did not address this issue.\n\nI recall asking you, in a very early iteration, if you just\nconcentrate on Windows and do not even pretend you support Linux or\nany other systems, the series can be kept smaller and review\nsimpler, and your answer was \"no, it can be done with just a little\nextra code\".  But I think you are saying it needs \"workaround\" and\nwhat needs to happen in the workaround sounds quite ugly to me.\n\nLet's not worry about cross-platform and instead stick to Windows\nand nothing else for now to expedite the process.  As long as it is\nadvertised as such, nobody would complain that it does not work on\nLinux or macOS.\n\nThanks.\n"},{"id":"400149","messageId":"CAKiG+9VCcH+CGc8=e22Xjc7z=-HL3vbDTDq9a4zZ9ONdmgTpvw@mail.gmail.com","threadId":"53305","inReplyTo":"xmqq1rmcm6md.fsf@gitster.c.googlers.com","subject":"Re: [PATCH v4 6/8] cmake: support for building git on windows with mingw","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-06-19T17:15:20Z","receivedAt":"2020-06-19T17:15:36Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"On Fri, Jun 19, 2020 at 2:30 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n>\n> > The reason I deferred modifying in PATCH v4 was because there was no\n> > easy way(cross platform)\n> > to change file permissions. The workaround is to juggle the files to a\n> > temporary directory, and then copy them\n> > to where they are intended to be with the required permissions. This\n> > added quite a bit of code.\n> > Since Windows platform was the priority, I did not address this issue.\n>\n> I recall asking you, in a very early iteration, if you just\n> concentrate on Windows and do not even pretend you support Linux or\n> any other systems, the series can be kept smaller and review\n> simpler, and your answer was \"no, it can be done with just a little\n> extra code\".  But I think you are saying it needs \"workaround\" and\n> what needs to happen in the workaround sounds quite ugly to me.\n>\n\nI know what I said. This is the worst edge case of this scenario.\n\n> Let's not worry about cross-platform and instead stick to Windows\n> and nothing else for now to expedite the process.  As long as it is\n> advertised as such, nobody would complain that it does not work on\n> Linux or macOS.\n>\n\nOkay.\n\nJust for your information.\nThis is the exact diff that needs to be added to address the issue.\n------------------------------------------\n@@ -761,6 +761,14 @@\n file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)\n string(REPLACE \"#!/usr/bin/env python\" \"#!/usr/bin/python\" content\n\"${content}\")\n file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})\n\n+#Give the scripts execute permissions. This does not apply on Windows\n+if(UNIX)\n+       foreach(script ${git_sh_scripts} git-instaweb\n${git_perl_scripts} git-p4)\n+               add_custom_target(${script}_executable ALL\n+                               chmod +x ${CMAKE_BINARY_DIR}/${script})\n+       endforeach()\n+endif()\n+\n #perl modules\n file(GLOB_RECURSE perl_modules \"${CMAKE_SOURCE_DIR}/perl/*.pm\")\n\n@@ -790,6 +799,12 @@\nforeach(tm ${templates})\n        configure_file(${CMAKE_SOURCE_DIR}/templates/${tm}\n${CMAKE_BINARY_DIR}/templates/blt/${blt_tm} @ONLY)\n endforeach()\n\n+#Give the templates read & execute permissions. This does not apply on Windows\n+if(UNIX)\n+       add_custom_target(templates_executable ALL\n+                       chmod -R +rx ${CMAKE_BINARY_DIR}/templates/blt/)\n+endif()\n+\n\n #translations\n if(MSGFMT_EXE)\n---------------------------------------------------------\nIf this is simple enough, I will add it in the next patch series. If\nnot, when in the future should I implement this?\n\n\nThank You,\nSibi Siddharthan\n"},{"id":"400154","messageId":"xmqqbllfhslz.fsf@gitster.c.googlers.com","threadId":"53305","inReplyTo":"CAKiG+9VCcH+CGc8=e22Xjc7z=-HL3vbDTDq9a4zZ9ONdmgTpvw@mail.gmail.com","subject":"Re: [PATCH v4 6/8] cmake: support for building git on windows with mingw","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-06-19T17:29:12Z","receivedAt":"2020-06-19T17:29:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:\n\n>> Let's not worry about cross-platform and instead stick to Windows\n>> and nothing else for now to expedite the process.  As long as it is\n>> advertised as such, nobody would complain that it does not work on\n>> Linux or macOS.\n>>\n>\n> Okay.\n>\n> Just for your information.\n> This is the exact diff that needs to be added to address the issue.\n\nI do not care how small the diff is.  This won't be the last such\ncase that needs a workaround, and I do not want to see us die from\nthousands of little cuts.\n\nIf anything, a diff that removes things that are needed only because\nwe try to work on non-Windows systems would be more interesting to\nsee.  If it removes a single ifdef(), that would be worth applying.\n\nThanks.\n"},{"id":"400697","messageId":"pull.614.v5.git.1593187898.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v4.git.1591986566.gitgitgadget@gmail.com","subject":"[PATCH v5 0/8] CMake build system for git","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-06-26T16:11:30Z","receivedAt":"2020-06-26T16:11:44Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"This is an attempt to build Git using CMake. CMake is cross-platform build\ngenerator which works well on a variety of platforms(primarily Linux and\nWindows). Using CMake we can check whether certain headers exist, certain\nfunctions exist, the required libraries are present and configure the build\naccordingly. Using CMake we can also build and test Git out of source,\nresulting in a clean source tree.\n\nTested platforms\n\nUbuntu 18.04 GCC 7.4 Clang 8.0.1\n\nWindows MinGW GCC 9.2 Clang 9 Visual Studio 2015,2017,2019\n\nChanges:\n\n1) The CMake script has been relocated to contrib/buildsystems 2) The CMake\nscript parses the Makefile for the sources. LIB_OBJS BUILTIN_OBJS XDIFF_OBJS\nVCSSVN_OBJS TEST_BUILTINS_OBJS SCRIPT_SH SCRIPT_PERL 3) Philip suggested to\nchange the error message if sh/bash was not found on windows. 4) CMake now\ntests for ICONV_OMITS_BOM, NO_ST_BLOCKS_IN_STRUCT_STAT 5) Renamed the\nvariable test_helper_sources to test-tool_SOURCES [PATCH 4/8] to be\nconsistent with the naming of source variables.\n\nChanges v2: Changes 1,2,4 have been rebased to PATCH 01/xx CMake uses\nGIT-VERSION-GEN to get the version of Git Fixed a bug where a Windows user\ncan pose as Linux user and vice versa. [PATCH 6/8]\n\nChanges v3: Patch changes are moved from the commit messages and are placed\nhere. Code inside check_c_source_(compiles/runs) have been formatted\naccording to git coding guidelines. [PATCH 1/8] The CMake script parses the\nMakefile for SCRIPT_LIB also. [PATCH 2/8] The CMake script globs templates,\npo files. Logic has been added to place the template files in their\nrespective directories instead of hard-coding them. [PATCH 2/8]\n\nChanges v4: Removed EXE_EXTENSION conditional stuff using\nCMAKE_EXECUTABLE_SUFFIX [PATCH 4/8] There was an issue in build pipelines\nwhere CMake was not able to find the correct iconv library (caused by an\nupdate that installed PostgreSQL), so we need to manually set the location\nof the iconv library and its includes. This issue is extremely rare and is\nspecific to the implementation of FindIconv.cmake. Other libraries are\nunaffected. [PATCH 8/8]\n\nSibi Siddharthan (8):\n  Introduce CMake support for configuring Git\n  cmake: generate the shell/perl/python scripts and templates,\n    translations\n  cmake: installation support for git\n  cmake: support for testing git with ctest\n  cmake: support for testing git when building out of the source tree\n  cmake: support for building git on windows with mingw\n  cmake: support for building git on windows with msvc and clang.\n  ci: modification of main.yml to use cmake for vs-build job\n\n .github/workflows/main.yml          |   39 +-\n contrib/buildsystems/CMakeLists.txt | 1000 +++++++++++++++++++++++++++\n 2 files changed, 1024 insertions(+), 15 deletions(-)\n create mode 100644 contrib/buildsystems/CMakeLists.txt\n\n\nbase-commit: e8ba1cc988e122f1a74cda161ba3ec1bf22fe88f\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-614%2FSibiSiddharthan%2Fgit-og-v5\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-614/SibiSiddharthan/git-og-v5\nPull-Request: https://github.com/gitgitgadget/git/pull/614\n\nRange-diff vs v4:\n\n 1:  c4e1ba7446 = 1:  07ae9f0a49 Introduce CMake support for configuring Git\n 2:  abb9e6e1d5 ! 2:  74358b389d cmake: generate the shell/perl/python scripts and templates, translations\n     @@ contrib/buildsystems/CMakeLists.txt: add_custom_command(OUTPUT ${git_links} ${gi\n      +list(TRANSFORM templates REPLACE \"${CMAKE_SOURCE_DIR}/templates/\" \"\")\n      +list(REMOVE_ITEM templates \".gitignore\")\n      +list(REMOVE_ITEM templates \"Makefile\")\n     ++list(REMOVE_ITEM templates \"blt\")# Prevents an error when reconfiguring for in source builds\n      +\n      +list(REMOVE_ITEM templates \"branches--\")\n      +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches\n 3:  4a0dd23cbb = 3:  a60e7472d3 cmake: installation support for git\n 4:  db05180e98 = 4:  fedda55fc2 cmake: support for testing git with ctest\n 5:  17e7f3e9de = 5:  398a578558 cmake: support for testing git when building out of the source tree\n 6:  549f0cd5ff ! 6:  10acdbf5e4 cmake: support for building git on windows with mingw\n     @@ contrib/buildsystems/CMakeLists.txt: add_compile_definitions(PAGER_ENV=\"LESS=FRX\n      +\tset(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n      +\tadd_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n      +endif()\n     - \n     --add_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n     --list(APPEND compat_SOURCES unix-socket.c)\n     ++\n      +\n      +#Platform Specific\n      +if(CMAKE_SYSTEM_NAME STREQUAL \"Windows\")\n     @@ contrib/buildsystems/CMakeLists.txt: add_compile_definitions(PAGER_ENV=\"LESS=FRX\n      +\tadd_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n      +\tlist(APPEND compat_SOURCES unix-socket.c)\n      +endif()\n     -+\n     -+if(WIN32)\n     -+\tset(EXE_EXTENSION .exe)\n     -+else()\n     -+\tset(EXE_EXTENSION)\n     -+endif()\n     + \n     +-add_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n     +-list(APPEND compat_SOURCES unix-socket.c)\n     ++set(EXE_EXTENSION ${CMAKE_EXECUTABLE_SUFFIX})\n       \n       #header checks\n       check_include_file(libgen.h HAVE_LIBGEN_H)\n 7:  f85ea0ac0c = 7:  0b921545d2 cmake: support for building git on windows with msvc and clang.\n 8:  2f7cf41e08 ! 8:  3cdefab43a ci: modification of main.yml to use cmake for vs-build job\n     @@ .github/workflows/main.yml: jobs:\n      +        if (!$?) { exit(1) }\n      +    - name: generate Visual Studio solution\n      +      shell: bash\n     -+      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\n     ++      run: |\n     ++        cmake `pwd`/contrib/buildsystems/ -DCMAKE_PREFIX_PATH=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows \\\n     ++        -DIconv_LIBRARY=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows/lib/libiconv.lib -DIconv_INCLUDE_DIR=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows/include \\\n     ++        -DMSGFMT_EXE=`pwd`/git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON\n           - name: MSBuild\n             run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142\n           - name: bundle artifact tar\n\n-- \ngitgitgadget\n"},{"id":"400698","messageId":"07ae9f0a4944530d1e16176b0af808e5bf9a422a.1593187898.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v5.git.1593187898.gitgitgadget@gmail.com","subject":"[PATCH v5 1/8] Introduce CMake support for configuring Git","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-06-26T16:11:31Z","receivedAt":"2020-06-26T16:11:49Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nAt the moment, the recommended way to configure Git's builds is to\nsimply run `make`. If that does not work, the recommended strategy is to\nlook at the top of the `Makefile` to see whether any \"Makefile knob\" has\nto be turned on/off, e.g. `make NO_OPENSSL=YesPlease`.\n\nAlternatively, Git also has an `autoconf` setup which allows configuring\nbuilds via `./configure [<option>...]`.\n\nBoth of these options are fine if the developer works on Unix or Linux.\nBut on Windows, we have to jump through hoops to configure a build\n(read: we force the user to install a full Git for Windows SDK, which\noccupies around two gigabytes (!) on disk and downloads about three\nquarters of a gigabyte worth of Git objects).\n\nThe build infrastructure for Git is written around being able to run\nmake, which is not supported natively on Windows.\nTo help Windows developers a CMake build script is introduced here.\n\nWith a working support CMake, developers on Windows need only install\nCMake, configure their build, load the generated Visual Studio solution\nand immediately start modifying the code and build their own version of\nGit. Likewise, developers on other platforms can use the convenient GUI\ntools provided by CMake to configure their build.\n\nSo let's start building CMake support for Git.\n\nThis is only the first step, and to make it easier to review, it only\nallows for configuring builds on the platform that is easiest to\nconfigure for: Linux.\n\nThe CMake script checks whether the headers are present(eg. libgen.h),\nwhether the functions are present(eg. memmem), whether the funtions work\nproperly (eg. snprintf) and generate the required compile definitions\nfor the platform. The script also searches for the required libraries,\nif it fails to find the required libraries the respective executables\nwon't be built.(eg. If libcurl is not found then git-remote-http won't\nbe built). This will help building Git easier.\n\nWith a CMake script an out of source build of git is possible resulting\nin a clean source tree.\n\nNote: this patch asks for the minimum version v3.14 of CMake (which is\nnot all that old as of time of writing) because that is the first\nversion to offer a platform-independent way to generate hardlinks as\npart of the build. This is needed to generate all those hardlinks for\nthe built-in commands of Git.\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n contrib/buildsystems/CMakeLists.txt | 592 ++++++++++++++++++++++++++++\n 1 file changed, 592 insertions(+)\n create mode 100644 contrib/buildsystems/CMakeLists.txt\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nnew file mode 100644\nindex 0000000000..1e910d9df8\n--- /dev/null\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -0,0 +1,592 @@\n+#\n+#\tCopyright (c) 2020 Sibi Siddharthan\n+#\n+\n+#[[\n+\n+Instructions to run CMake:\n+\n+cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release\n+Eg.\n+From the root of git source tree\n+\t`cmake contrib/buildsystems/ `\n+This will build the git binaries at the root\n+\n+For out of source builds, say build in 'git/git-build/'\n+\t`mkdir git-build;cd git-build; cmake ../contrib/buildsystems/`\n+This will build the git binaries in git-build directory\n+\n+Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding\n+compiler flags\n+Debug : -g\n+Release: -O3\n+RelWithDebInfo : -O2 -g\n+MinSizeRel : -Os\n+empty(default) :\n+\n+NOTE: -DCMAKE_BUILD_TYPE is optional. For multi-config generators like Visual Studio\n+this option is ignored\n+\n+This process generates a Makefile(Linux/*BSD/MacOS) , Visual Studio solution(Windows) by default.\n+Run `make` to build Git on Linux/*BSD/MacOS.\n+Open git.sln on Windows and build Git.\n+\n+NOTE: By default CMake uses Makefile as the build tool on Linux and Visual Studio in Windows,\n+to use another tool say `ninja` add this to the command line when configuring.\n+`-G Ninja`\n+\n+]]\n+cmake_minimum_required(VERSION 3.14)\n+\n+#set the source directory to root of git\n+set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n+\n+find_program(SH_EXE sh)\n+\n+#Create GIT-VERSION-FILE using GIT-VERSION-GEN\n+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)\n+\tmessage(\"Generating GIT-VERSION-FILE\")\n+\texecute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN\n+\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR})\n+endif()\n+\n+#Parse GIT-VERSION-FILE to get the version\n+file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE git_version REGEX \"GIT_VERSION = (.*)\")\n+string(REPLACE \"GIT_VERSION = \" \"\" git_version ${git_version})\n+string(FIND ${git_version} \"GIT\" location)\n+if(location EQUAL -1)\n+\tstring(REGEX MATCH \"[0-9]*\\\\.[0-9]*\\\\.[0-9]*\" git_version ${git_version})\n+else()\n+\tstring(REGEX MATCH \"[0-9]*\\\\.[0-9]*\" git_version ${git_version})\n+\tstring(APPEND git_version \".0\") #for building from a snapshot\n+endif()\n+\n+project(git\n+\tVERSION ${git_version}\n+\tLANGUAGES C)\n+\n+\n+#macros for parsing the Makefile for sources\n+macro(parse_makefile_for_sources list_var regex)\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX \"^${regex} \\\\+=(.*)\")\n+\tstring(REPLACE \"${regex} +=\" \"\" ${list_var} ${${list_var}})\n+\tstring(REPLACE \"$(COMPAT_OBJS)\" \"\" ${list_var} ${${list_var}}) #remove \"$(COMPAT_OBJS)\" This is only for libgit.\n+\tstring(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces\n+\tstring(REPLACE \".o\" \".c;\" ${list_var} ${${list_var}}) #change .o to .c, ; is for converting the string into a list\n+\tlist(TRANSFORM ${list_var} STRIP) #remove trailing/leading whitespaces for each element in list\n+\tlist(REMOVE_ITEM ${list_var} \"\") #remove empty list elements\n+endmacro()\n+\n+include(CheckTypeSize)\n+include(CheckCSourceRuns)\n+include(CheckCSourceCompiles)\n+include(CheckIncludeFile)\n+include(CheckFunctionExists)\n+include(CheckSymbolExists)\n+include(CheckStructHasMember)\n+\n+find_package(ZLIB REQUIRED)\n+find_package(CURL)\n+find_package(EXPAT)\n+find_package(Iconv)\n+find_package(Intl)\n+\n+if(NOT Intl_FOUND)\n+\tadd_compile_definitions(NO_GETTEXT)\n+\tif(NOT Iconv_FOUND)\n+\t\tadd_compile_definitions(NO_ICONV)\n+\tendif()\n+endif()\n+\n+include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})\n+if(CURL_FOUND)\n+\tinclude_directories(SYSTEM ${CURL_INCLUDE_DIRS})\n+endif()\n+if(EXPAT_FOUND)\n+\tinclude_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})\n+endif()\n+if(Iconv_FOUND)\n+\tinclude_directories(SYSTEM ${Iconv_INCLUDE_DIRS})\n+endif()\n+if(Intl_FOUND)\n+\tinclude_directories(SYSTEM ${Intl_INCLUDE_DIRS})\n+endif()\n+\n+#default behaviour\n+include_directories(${CMAKE_SOURCE_DIR})\n+add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n+add_compile_definitions(SHA256_BLK INTERNAL_QSORT RUNTIME_PREFIX)\n+add_compile_definitions(NO_OPENSSL SHA1_DC SHA1DC_NO_STANDARD_INCLUDES\n+\t\t\tSHA1DC_INIT_SAFE_HASH_DEFAULT=0\n+\t\t\tSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"cache.h\"\n+\t\t\tSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"git-compat-util.h\" )\n+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)\n+\n+\n+add_compile_definitions(PAGER_ENV=\"LESS=FRX LV=-c\"\n+\t\t\tETC_GITATTRIBUTES=\"etc/gitattributes\"\n+\t\t\tETC_GITCONFIG=\"etc/gitconfig\"\n+\t\t\tGIT_EXEC_PATH=\"libexec/git-core\"\n+\t\t\tGIT_LOCALE_PATH=\"share/locale\"\n+\t\t\tGIT_MAN_PATH=\"share/man\"\n+\t\t\tGIT_INFO_PATH=\"share/info\"\n+\t\t\tGIT_HTML_PATH=\"share/doc/git-doc\"\n+\t\t\tDEFAULT_HELP_FORMAT=\"html\"\n+\t\t\tDEFAULT_GIT_TEMPLATE_DIR=\"share/git-core/templates\"\n+\t\t\tGIT_VERSION=\"${PROJECT_VERSION}.GIT\"\n+\t\t\tGIT_USER_AGENT=\"git/${PROJECT_VERSION}.GIT\"\n+\t\t\tBINDIR=\"bin\"\n+\t\t\tGIT_BUILT_FROM_COMMIT=\"\")\n+\n+set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n+add_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n+\n+add_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n+list(APPEND compat_SOURCES unix-socket.c)\n+\n+#header checks\n+check_include_file(libgen.h HAVE_LIBGEN_H)\n+if(NOT HAVE_LIBGEN_H)\n+\tadd_compile_definitions(NO_LIBGEN_H)\n+\tlist(APPEND compat_SOURCES compat/basename.c)\n+endif()\n+\n+check_include_file(sys/sysinfo.h HAVE_SYSINFO)\n+if(HAVE_SYSINFO)\n+\tadd_compile_definitions(HAVE_SYSINFO)\n+endif()\n+\n+check_c_source_compiles(\"\n+#include <alloca.h>\n+\n+int main(void)\n+{\n+\tchar *p = (char *) alloca(2 * sizeof(int));\n+\n+\tif (p)\n+\t\treturn 0;\n+\treturn 0;\n+}\"\n+HAVE_ALLOCA_H)\n+if(HAVE_ALLOCA_H)\n+\tadd_compile_definitions(HAVE_ALLOCA_H)\n+endif()\n+\n+check_include_file(strings.h HAVE_STRINGS_H)\n+if(HAVE_STRINGS_H)\n+\tadd_compile_definitions(HAVE_STRINGS_H)\n+endif()\n+\n+check_include_file(sys/select.h HAVE_SYS_SELECT_H)\n+if(NOT HAVE_SYS_SELECT_H)\n+\tadd_compile_definitions(NO_SYS_SELECT_H)\n+endif()\n+\n+check_include_file(sys/poll.h HAVE_SYS_POLL_H)\n+if(NOT HAVE_SYS_POLL_H)\n+\tadd_compile_definitions(NO_SYS_POLL_H)\n+endif()\n+\n+check_include_file(poll.h HAVE_POLL_H)\n+if(NOT HAVE_POLL_H)\n+\tadd_compile_definitions(NO_POLL_H)\n+endif()\n+\n+check_include_file(inttypes.h HAVE_INTTYPES_H)\n+if(NOT HAVE_INTTYPES_H)\n+\tadd_compile_definitions(NO_INTTYPES_H)\n+endif()\n+\n+check_include_file(paths.h HAVE_PATHS_H)\n+if(HAVE_PATHS_H)\n+\tadd_compile_definitions(HAVE_PATHS_H)\n+endif()\n+\n+#function checks\n+set(function_checks\n+\tstrcasestr memmem strlcpy strtoimax strtoumax strtoull\n+\tsetenv mkdtemp poll pread memmem unsetenv hstrerror)\n+\n+foreach(f ${function_checks})\n+\tstring(TOUPPER ${f} uf)\n+\tcheck_function_exists(${f} HAVE_${uf})\n+\tif(NOT HAVE_${uf})\n+\t\tadd_compile_definitions(NO_${uf})\n+\tendif()\n+endforeach()\n+\n+if(NOT HAVE_POLL_H OR NOT HAVE_SYS_POLL_H OR NOT HAVE_POLL)\n+\tinclude_directories(${CMAKE_SOURCE_DIR}/compat/poll)\n+\tadd_compile_definitions(NO_POLL)\n+\tlist(APPEND compat_SOURCES compat/poll/poll.c)\n+endif()\n+\n+if(NOT HAVE_STRCASESTR)\n+\tlist(APPEND compat_SOURCES compat/strcasestr.c)\n+endif()\n+\n+if(NOT HAVE_STRLCPY)\n+\tlist(APPEND compat_SOURCES compat/strlcpy.c)\n+endif()\n+\n+if(NOT HAVE_STRTOUMAX)\n+\tlist(APPEND compat_SOURCES compat/strtoumax.c compat/strtoimax.c)\n+endif()\n+\n+if(NOT HAVE_SETENV)\n+\tlist(APPEND compat_SOURCES compat/setenv.c)\n+endif()\n+\n+if(NOT HAVE_MKDTEMP)\n+\tlist(APPEND compat_SOURCES compat/mkdtemp.c)\n+endif()\n+\n+if(NOT HAVE_PREAD)\n+\tlist(APPEND compat_SOURCES compat/pread.c)\n+endif()\n+\n+if(NOT HAVE_MEMMEM)\n+\tlist(APPEND compat_SOURCES compat/memmem.c)\n+endif()\n+\n+if(NOT WIN32)\n+\tif(NOT HAVE_UNSETENV)\n+\t\tlist(APPEND compat_SOURCES compat/unsetenv.c)\n+\tendif()\n+\n+\tif(NOT HAVE_HSTRERROR)\n+\t\tlist(APPEND compat_SOURCES compat/hstrerror.c)\n+\tendif()\n+endif()\n+\n+check_function_exists(getdelim HAVE_GETDELIM)\n+if(HAVE_GETDELIM)\n+\tadd_compile_definitions(HAVE_GETDELIM)\n+endif()\n+\n+check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)\n+check_symbol_exists(CLOCK_MONOTONIC \"time.h\" HAVE_CLOCK_MONOTONIC)\n+if(HAVE_CLOCK_GETTIME)\n+\tadd_compile_definitions(HAVE_CLOCK_GETTIME)\n+endif()\n+if(HAVE_CLOCK_MONOTONIC)\n+\tadd_compile_definitions(HAVE_CLOCK_MONOTONIC)\n+endif()\n+\n+#check for st_blocks in struct stat\n+check_struct_has_member(\"struct stat\" st_blocks \"sys/stat.h\" STRUCT_STAT_HAS_ST_BLOCKS)\n+if(NOT STRUCT_STAT_HAS_ST_BLOCKS)\n+\tadd_compile_definitions(NO_ST_BLOCKS_IN_STRUCT_STAT)\n+endif()\n+\n+#compile checks\n+check_c_source_runs(\"\n+#include<stdio.h>\n+#include<stdarg.h>\n+#include<string.h>\n+#include<stdlib.h>\n+\n+int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)\n+{\n+\tint ret;\n+\tva_list ap;\n+\n+\tva_start(ap, format);\n+\tret = vsnprintf(str, maxsize, format, ap);\n+\tva_end(ap);\n+\treturn ret;\n+}\n+\n+int main(void)\n+{\n+\tchar buf[6];\n+\n+\tif (test_vsnprintf(buf, 3, \\\"%s\\\", \\\"12345\\\") != 5\n+\t\t|| strcmp(buf, \\\"12\\\"))\n+\t\t\treturn 1;\n+\tif (snprintf(buf, 3, \\\"%s\\\", \\\"12345\\\") != 5\n+\t\t|| strcmp(buf, \\\"12\\\"))\n+\t\t\treturn 1;\n+\treturn 0;\n+}\"\n+SNPRINTF_OK)\n+if(NOT SNPRINTF_OK)\n+\tadd_compile_definitions(SNPRINTF_RETURNS_BOGUS)\n+\tlist(APPEND compat_SOURCES compat/snprintf.c)\n+endif()\n+\n+check_c_source_runs(\"\n+#include<stdio.h>\n+\n+int main(void)\n+{\n+\tFILE *f = fopen(\\\".\\\", \\\"r\\\");\n+\n+\treturn f != NULL;\n+}\"\n+FREAD_READS_DIRECTORIES_NO)\n+if(NOT FREAD_READS_DIRECTORIES_NO)\n+\tadd_compile_definitions(FREAD_READS_DIRECTORIES)\n+\tlist(APPEND compat_SOURCES compat/fopen.c)\n+endif()\n+\n+check_c_source_compiles(\"\n+#include <regex.h>\n+#ifndef REG_STARTEND\n+#error oops we dont have it\n+#endif\n+\n+int main(void)\n+{\n+\treturn 0;\n+}\"\n+HAVE_REGEX)\n+if(NOT HAVE_REGEX)\n+\tinclude_directories(${CMAKE_SOURCE_DIR}/compat/regex)\n+\tlist(APPEND compat_SOURCES compat/regex/regex.c )\n+\tadd_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)\n+endif()\n+\n+\n+check_c_source_compiles(\"\n+#include <stddef.h>\n+#include <sys/types.h>\n+#include <sys/sysctl.h>\n+\n+int main(void)\n+{\n+\tint val, mib[2];\n+\tsize_t len;\n+\n+\tmib[0] = CTL_HW;\n+\tmib[1] = 1;\n+\tlen = sizeof(val);\n+\treturn sysctl(mib, 2, &val, &len, NULL, 0) ? 1 : 0;\n+}\"\n+HAVE_BSD_SYSCTL)\n+if(HAVE_BSD_SYSCTL)\n+\tadd_compile_definitions(HAVE_BSD_SYSCTL)\n+endif()\n+\n+set(CMAKE_REQUIRED_LIBRARIES ${Iconv_LIBRARIES})\n+set(CMAKE_REQUIRED_INCLUDES ${Iconv_INCLUDE_DIRS})\n+\n+check_c_source_compiles(\"\n+#include <iconv.h>\n+\n+extern size_t iconv(iconv_t cd,\n+\t\tchar **inbuf, size_t *inbytesleft,\n+\t\tchar **outbuf, size_t *outbytesleft);\n+\n+int main(void)\n+{\n+\treturn 0;\n+}\"\n+HAVE_NEW_ICONV)\n+if(HAVE_NEW_ICONV)\n+\tset(HAVE_OLD_ICONV 0)\n+else()\n+\tset(HAVE_OLD_ICONV 1)\n+endif()\n+\n+check_c_source_runs(\"\n+#include <iconv.h>\n+#if ${HAVE_OLD_ICONV}\n+typedef const char *iconv_ibp;\n+#else\n+typedef char *iconv_ibp;\n+#endif\n+\n+int main(void)\n+{\n+\tint v;\n+\ticonv_t conv;\n+\tchar in[] = \\\"a\\\";\n+\ticonv_ibp pin = in;\n+\tchar out[20] = \\\"\\\";\n+\tchar *pout = out;\n+\tsize_t isz = sizeof(in);\n+\tsize_t osz = sizeof(out);\n+\n+\tconv = iconv_open(\\\"UTF-16\\\", \\\"UTF-8\\\");\n+\ticonv(conv, &pin, &isz, &pout, &osz);\n+\ticonv_close(conv);\n+\tv = (unsigned char)(out[0]) + (unsigned char)(out[1]);\n+\treturn v != 0xfe + 0xff;\n+}\"\n+ICONV_DOESNOT_OMIT_BOM)\n+if(NOT ICONV_DOESNOT_OMIT_BOM)\n+\tadd_compile_definitions(ICONV_OMITS_BOM)\n+endif()\n+\n+unset(CMAKE_REQUIRED_LIBRARIES)\n+unset(CMAKE_REQUIRED_INCLUDES)\n+\n+\n+#programs\n+set(PROGRAMS_BUILT\n+\tgit git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst\n+\tgit-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)\n+\n+if(NOT CURL_FOUND)\n+\tlist(APPEND excluded_progs git-http-fetch git-http-push)\n+\tadd_compile_definitions(NO_CURL)\n+\tmessage(WARNING \"git-http-push and git-http-fetch will not be built\")\n+else()\n+\tlist(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)\n+\tif(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)\n+\t\tadd_compile_definitions(USE_CURL_FOR_IMAP_SEND)\n+\tendif()\n+endif()\n+\n+if(NOT EXPAT_FOUND)\n+\tlist(APPEND excluded_progs git-http-push)\n+\tadd_compile_definitions(NO_EXPAT)\n+else()\n+\tlist(APPEND PROGRAMS_BUILT git-http-push)\n+\tif(EXPAT_VERSION_STRING VERSION_LESS_EQUAL 1.2)\n+\t\tadd_compile_definitions(EXPAT_NEEDS_XMLPARSE_H)\n+\tendif()\n+endif()\n+\n+list(REMOVE_DUPLICATES excluded_progs)\n+list(REMOVE_DUPLICATES PROGRAMS_BUILT)\n+\n+\n+foreach(p ${excluded_progs})\n+\tlist(APPEND EXCLUSION_PROGS --exclude-program ${p} )\n+endforeach()\n+\n+#for comparing null values\n+list(APPEND EXCLUSION_PROGS empty)\n+set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING \"Programs not built\" FORCE)\n+\n+if(NOT EXISTS ${CMAKE_BINARY_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)\n+\tlist(REMOVE_ITEM EXCLUSION_PROGS empty)\n+\tmessage(\"Generating command-list.h\")\n+\texecute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt\n+\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n+\t\t\tOUTPUT_FILE ${CMAKE_BINARY_DIR}/command-list.h)\n+endif()\n+\n+if(NOT EXISTS ${CMAKE_BINARY_DIR}/config-list.h)\n+\tmessage(\"Generating config-list.h\")\n+\texecute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh\n+\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n+\t\t\tOUTPUT_FILE ${CMAKE_BINARY_DIR}/config-list.h)\n+endif()\n+\n+include_directories(${CMAKE_BINARY_DIR})\n+\n+#build\n+#libgit\n+parse_makefile_for_sources(libgit_SOURCES \"LIB_OBJS\")\n+\n+list(TRANSFORM libgit_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n+list(TRANSFORM compat_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n+add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})\n+\n+#libxdiff\n+parse_makefile_for_sources(libxdiff_SOURCES \"XDIFF_OBJS\")\n+\n+list(TRANSFORM libxdiff_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n+add_library(xdiff STATIC ${libxdiff_SOURCES})\n+\n+#libvcs-svn\n+parse_makefile_for_sources(libvcs-svn_SOURCES \"VCSSVN_OBJS\")\n+\n+list(TRANSFORM libvcs-svn_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n+add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})\n+\n+#link all required libraries to common-main\n+add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)\n+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)\n+if(Intl_FOUND)\n+\ttarget_link_libraries(common-main ${Intl_LIBRARIES})\n+endif()\n+if(Iconv_FOUND)\n+\ttarget_link_libraries(common-main ${Iconv_LIBRARIES})\n+endif()\n+\n+#git\n+parse_makefile_for_sources(git_SOURCES \"BUILTIN_OBJS\")\n+\n+list(TRANSFORM git_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n+add_executable(git ${CMAKE_SOURCE_DIR}/git.c ${git_SOURCES})\n+target_link_libraries(git common-main)\n+\n+add_executable(git-bugreport ${CMAKE_SOURCE_DIR}/bugreport.c)\n+target_link_libraries(git-bugreport common-main)\n+\n+add_executable(git-credential-store ${CMAKE_SOURCE_DIR}/credential-store.c)\n+target_link_libraries(git-credential-store common-main)\n+\n+add_executable(git-daemon ${CMAKE_SOURCE_DIR}/daemon.c)\n+target_link_libraries(git-daemon common-main)\n+\n+add_executable(git-fast-import ${CMAKE_SOURCE_DIR}/fast-import.c)\n+target_link_libraries(git-fast-import common-main)\n+\n+add_executable(git-http-backend ${CMAKE_SOURCE_DIR}/http-backend.c)\n+target_link_libraries(git-http-backend common-main)\n+\n+add_executable(git-sh-i18n--envsubst ${CMAKE_SOURCE_DIR}/sh-i18n--envsubst.c)\n+target_link_libraries(git-sh-i18n--envsubst common-main)\n+\n+add_executable(git-shell ${CMAKE_SOURCE_DIR}/shell.c)\n+target_link_libraries(git-shell common-main)\n+\n+if(CURL_FOUND)\n+\tadd_library(http_obj OBJECT ${CMAKE_SOURCE_DIR}/http.c)\n+\n+\tadd_executable(git-imap-send ${CMAKE_SOURCE_DIR}/imap-send.c)\n+\ttarget_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})\n+\n+\tadd_executable(git-http-fetch ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/http-fetch.c)\n+\ttarget_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})\n+\n+\tadd_executable(git-remote-http ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/remote-curl.c)\n+\ttarget_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )\n+\n+\tif(EXPAT_FOUND)\n+\t\tadd_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)\n+\t\ttarget_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})\n+\tendif()\n+endif()\n+\n+add_executable(git-remote-testsvn ${CMAKE_SOURCE_DIR}/remote-testsvn.c)\n+target_link_libraries(git-remote-testsvn common-main vcs-svn)\n+\n+add_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)\n+target_link_libraries(git-credential-cache common-main)\n+\n+add_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)\n+target_link_libraries(git-credential-cache--daemon common-main)\n+\n+\n+set(git_builtin_extra\n+\tcherry cherry-pick format-patch fsck-objects\n+\tinit merge-subtree restore show\n+\tstage status switch whatchanged)\n+\n+#Creating hardlinks\n+foreach(s ${git_SOURCES} ${git_builtin_extra})\n+\tstring(REPLACE \"${CMAKE_SOURCE_DIR}/builtin/\" \"\" s ${s})\n+\tstring(REPLACE \".c\" \"\" s ${s})\n+\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git git-${s})\\n\")\n+\tlist(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})\n+endforeach()\n+\n+if(CURL_FOUND)\n+\tset(remote_exes\n+\t\tgit-remote-https git-remote-ftp git-remote-ftps)\n+\tforeach(s ${remote_exes})\n+\t\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git-remote-http ${s})\\n\")\n+\t\tlist(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})\n+\tendforeach()\n+endif()\n+\n+add_custom_command(OUTPUT ${git_links} ${git_http_links}\n+\t\tCOMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake\n+\t\tDEPENDS git git-remote-http)\n+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})\n-- \ngitgitgadget\n\n"},{"id":"400699","messageId":"a60e7472d31a24bb5517649e6fdf69e5b8af29d4.1593187898.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v5.git.1593187898.gitgitgadget@gmail.com","subject":"[PATCH v5 3/8] cmake: installation support for git","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-06-26T16:11:33Z","receivedAt":"2020-06-26T16:11:50Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nInstall the built binaries and scripts using CMake\n\nThis is very similar to `make install`.\nBy default the destination directory(DESTDIR) is /usr/local/ on Linux\nTo set a custom installation path do this:\ncmake `relative-path-to-srcdir`\n\t-DCMAKE_INSTALL_PREFIX=`preferred-install-path`\n\nThen run `make install`\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n contrib/buildsystems/CMakeLists.txt | 49 +++++++++++++++++++++++++++++\n 1 file changed, 49 insertions(+)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 6c5bb4e233..bc9258cf3b 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -65,6 +65,8 @@ project(git\n \tVERSION ${git_version}\n \tLANGUAGES C)\n \n+#TODO gitk git-gui gitweb\n+#TODO Add pcre support\n \n #macros for parsing the Makefile for sources and scripts\n macro(parse_makefile_for_sources list_var regex)\n@@ -699,3 +701,50 @@ if(MSGFMT_EXE)\n \tendforeach()\n \tadd_custom_target(po-gen ALL DEPENDS ${po_gen})\n endif()\n+\n+\n+#to help with the install\n+list(TRANSFORM git_shell_scripts PREPEND \"${CMAKE_BINARY_DIR}/\")\n+list(TRANSFORM git_perl_scripts PREPEND \"${CMAKE_BINARY_DIR}/\")\n+\n+#install\n+install(TARGETS git git-shell\n+\tRUNTIME DESTINATION bin)\n+install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver\n+\tDESTINATION bin)\n+\n+list(REMOVE_ITEM PROGRAMS_BUILT git git-shell)\n+install(TARGETS ${PROGRAMS_BUILT}\n+\tRUNTIME DESTINATION libexec/git-core)\n+\n+set(bin_links\n+\tgit-receive-pack git-upload-archive git-upload-pack)\n+\n+foreach(b ${bin_links})\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})\")\n+endforeach()\n+\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)\")\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)\")\n+\n+foreach(b ${git_links})\n+\tstring(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n+\tinstall(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n+endforeach()\n+\n+foreach(b ${git_http_links})\n+\tstring(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n+\tinstall(CODE \"file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n+endforeach()\n+\n+install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4\n+\tDESTINATION libexec/git-core)\n+\n+install(DIRECTORY ${CMAKE_SOURCE_DIR}/mergetools DESTINATION libexec/git-core)\n+install(DIRECTORY ${CMAKE_BINARY_DIR}/perl/build/lib/ DESTINATION share/perl5\n+\tFILES_MATCHING PATTERN \"*.pm\")\n+install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/templates)\n+\n+if(MSGFMT_EXE)\n+\tinstall(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)\n+endif()\n-- \ngitgitgadget\n\n"},{"id":"400700","messageId":"0b921545d2523db7b44d5ee74efc3940e3b8e58b.1593187898.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v5.git.1593187898.gitgitgadget@gmail.com","subject":"[PATCH v5 7/8] cmake: support for building git on windows with msvc and clang.","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-06-26T16:11:37Z","receivedAt":"2020-06-26T16:11:51Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThis patch adds support for Visual Studio and Clang builds\n\nThe minimum required version of CMake is upgraded to 3.15 because\nthis version offers proper support for Clang builds on Windows.\n\nLibintl is not searched for when building with Visual Studio or Clang\nbecause there is no binary compatible version available yet.\n\nNOTE: In the link options invalidcontinue.obj has to be included.\nThe reason for this is because by default, Windows calls abort()'s\ninstead of setting errno=EINVAL when invalid arguments are passed to\nstandard functions.\nThis commit explains it in detail:\n4b623d80f73528a632576990ca51e34c333d5dd6\n\nOn Windows the default generator is Visual Studio,so for Visual Studio\nbuilds do this:\n\ncmake `relative-path-to-srcdir`\n\nNOTE: Visual Studio generator is a multi config generator, which means\nthat Debug and Release builds can be done on the same build directory.\n\nFor Clang builds do this:\n\nOn bash\nCC=clang cmake `relative-path-to-srcdir` -G Ninja\n\t\t-DCMAKE_BUILD_TYPE=[Debug or Release]\n\nOn cmd\nset CC=Clang\ncmake `relative-path-to-srcdir` -G Ninja\n\t\t-DCMAKE_BUILD_TYPE=[Debug or Release]\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n contrib/buildsystems/CMakeLists.txt | 55 +++++++++++++++++++++++------\n 1 file changed, 45 insertions(+), 10 deletions(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 2d7c0ed88e..47215df25b 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -108,8 +108,11 @@ find_package(ZLIB REQUIRED)\n find_package(CURL)\n find_package(EXPAT)\n find_package(Iconv)\n-find_package(Intl)\n \n+#Don't use libintl on Windows Visual Studio and Clang builds\n+if(NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL \"MSVC\" OR CMAKE_C_COMPILER_ID STREQUAL \"Clang\")))\n+\tfind_package(Intl)\n+endif()\n \n if(NOT Intl_FOUND)\n \tadd_compile_definitions(NO_GETTEXT)\n@@ -133,7 +136,7 @@ if(Intl_FOUND)\n endif()\n \n \n-if(WIN32)\n+if(WIN32 AND NOT MSVC)#not required for visual studio builds\n \tfind_program(WINDRES_EXE windres)\n \tif(NOT WINDRES_EXE)\n \t\tmessage(FATAL_ERROR \"Install windres on Windows for resource files\")\n@@ -145,6 +148,13 @@ if(NOT MSGFMT_EXE)\n \tmessage(WARNING \"Text Translations won't be build\")\n endif()\n \n+#Force all visual studio outputs to CMAKE_BINARY_DIR\n+if(CMAKE_C_COMPILER_ID STREQUAL \"MSVC\")\n+\tset(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})\n+\tset(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})\n+\tadd_compile_options(/MP)\n+endif()\n+\n #default behaviour\n include_directories(${CMAKE_SOURCE_DIR})\n add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n@@ -182,6 +192,10 @@ endif()\n \n #Platform Specific\n if(CMAKE_SYSTEM_NAME STREQUAL \"Windows\")\n+\tif(CMAKE_C_COMPILER_ID STREQUAL \"MSVC\" OR CMAKE_C_COMPILER_ID STREQUAL \"Clang\")\n+\t\tinclude_directories(${CMAKE_SOURCE_DIR}/compat/vcbuild/include)\n+\t\tadd_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)\n+\tendif()\n \tinclude_directories(${CMAKE_SOURCE_DIR}/compat/win32)\n \tadd_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32\n \t\t\t\t_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=\".exe\"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT\n@@ -566,14 +580,22 @@ parse_makefile_for_sources(libvcs-svn_SOURCES \"VCSSVN_OBJS\")\n list(TRANSFORM libvcs-svn_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})\n \n-#add git.rc for gcc\n if(WIN32)\n-\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n-\t\t\tCOMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}\n-\t\t\t\t-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION=\"\\\\\\\"${PROJECT_VERSION}.GIT\\\\\\\"\"\n-\t\t\t\t-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res\n-\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n-\t\t\tVERBATIM)\n+\tif(NOT MSVC)#use windres when compiling with gcc and clang\n+\t\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n+\t\t\t\tCOMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}\n+\t\t\t\t\t-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION=\"\\\\\\\"${PROJECT_VERSION}.GIT\\\\\\\"\"\n+\t\t\t\t\t-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res\n+\t\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n+\t\t\t\tVERBATIM)\n+\telse()#MSVC use rc\n+\t\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n+\t\t\t\tCOMMAND ${CMAKE_RC_COMPILER} /d MAJOR=${PROJECT_VERSION_MAJOR} /d MINOR=${PROJECT_VERSION_MINOR}\n+\t\t\t\t\t/d MICRO=${PROJECT_VERSION_PATCH} /d PATCHLEVEL=0 /d GIT_VERSION=\"${PROJECT_VERSION}.GIT\"\n+\t\t\t\t\t/fo ${CMAKE_BINARY_DIR}/git.res ${CMAKE_SOURCE_DIR}/git.rc\n+\t\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n+\t\t\t\tVERBATIM)\n+\tendif()\n \tadd_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)\n endif()\n \n@@ -590,7 +612,13 @@ endif()\n if(WIN32)\n \ttarget_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)\n \tadd_dependencies(common-main git-rc)\n-\ttarget_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)\n+\tif(CMAKE_C_COMPILER_ID STREQUAL \"GNU\")\n+\t\ttarget_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)\n+\telseif(CMAKE_C_COMPILER_ID STREQUAL \"Clang\")\n+\t\ttarget_link_options(common-main PUBLIC -municode -Wl,-nxcompat -Wl,-dynamicbase -Wl,-entry:wmainCRTStartup -Wl,invalidcontinue.obj)\n+\telseif(CMAKE_C_COMPILER_ID STREQUAL \"MSVC\")\n+\t\ttarget_link_options(common-main PUBLIC /IGNORE:4217 /IGNORE:4049 /NOLOGO /ENTRY:wmainCRTStartup /SUBSYSTEM:CONSOLE invalidcontinue.obj)\n+\tendif()\n elseif(UNIX)\n \ttarget_link_libraries(common-main pthread rt)\n endif()\n@@ -844,6 +872,13 @@ target_link_libraries(test-tool common-main)\n set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool\n \t\t\tPROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)\n \n+if(MSVC)\n+\tset_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool\n+\t\t\t\tPROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/t/helper)\n+\tset_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool\n+\t\t\t\tPROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/helper)\n+endif()\n+\n #wrapper scripts\n set(wrapper_scripts\n \tgit git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)\n-- \ngitgitgadget\n\n"},{"id":"400701","messageId":"10acdbf5e4d4c49f69889ab1129d3d6b5a7fd754.1593187898.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v5.git.1593187898.gitgitgadget@gmail.com","subject":"[PATCH v5 6/8] cmake: support for building git on windows with mingw","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-06-26T16:11:36Z","receivedAt":"2020-06-26T16:11:52Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThis patch facilitates building git on Windows with CMake using MinGW\n\nNOTE: The funtions unsetenv and hstrerror are not checked in Windows\nbuilds.\nReasons\nNO_UNSETENV is not compatible with Windows builds.\nlines 262-264 compat/mingw.h\n\ncompat/mingw.h(line 25) provides a definition of hstrerror which\nconflicts with the definition provided in\ngit-compat-util.h(lines 733-736).\n\nTo use CMake on Windows with MinGW do this:\ncmake `relative-path-to-srcdir` -G \"MinGW Makefiles\"\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n contrib/buildsystems/CMakeLists.txt | 117 ++++++++++++++++++++++------\n 1 file changed, 94 insertions(+), 23 deletions(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 2768ee5b71..2d7c0ed88e 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -42,6 +42,10 @@ cmake_minimum_required(VERSION 3.14)\n set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n \n find_program(SH_EXE sh)\n+if(NOT SH_EXE)\n+\tmessage(FATAL_ERROR \"sh: shell interpreter was not found in your path, please install one.\"\n+\t\t\t\"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n+endif()\n \n #Create GIT-VERSION-FILE using GIT-VERSION-GEN\n if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)\n@@ -65,7 +69,9 @@ project(git\n \tVERSION ${git_version}\n \tLANGUAGES C)\n \n+\n #TODO gitk git-gui gitweb\n+#TODO Enable NLS on windows natively\n #TODO Add pcre support\n \n #macros for parsing the Makefile for sources and scripts\n@@ -104,6 +110,7 @@ find_package(EXPAT)\n find_package(Iconv)\n find_package(Intl)\n \n+\n if(NOT Intl_FOUND)\n \tadd_compile_definitions(NO_GETTEXT)\n \tif(NOT Iconv_FOUND)\n@@ -125,6 +132,14 @@ if(Intl_FOUND)\n \tinclude_directories(SYSTEM ${Intl_INCLUDE_DIRS})\n endif()\n \n+\n+if(WIN32)\n+\tfind_program(WINDRES_EXE windres)\n+\tif(NOT WINDRES_EXE)\n+\t\tmessage(FATAL_ERROR \"Install windres on Windows for resource files\")\n+\tendif()\n+endif()\n+\n find_program(MSGFMT_EXE msgfmt)\n if(NOT MSGFMT_EXE)\n \tmessage(WARNING \"Text Translations won't be build\")\n@@ -156,11 +171,35 @@ add_compile_definitions(PAGER_ENV=\"LESS=FRX LV=-c\"\n \t\t\tBINDIR=\"bin\"\n \t\t\tGIT_BUILT_FROM_COMMIT=\"\")\n \n-set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n-add_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n+if(WIN32)\n+\tset(FALLBACK_RUNTIME_PREFIX /mingw64)\n+\tadd_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n+else()\n+\tset(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n+\tadd_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n+endif()\n+\n+\n+#Platform Specific\n+if(CMAKE_SYSTEM_NAME STREQUAL \"Windows\")\n+\tinclude_directories(${CMAKE_SOURCE_DIR}/compat/win32)\n+\tadd_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32\n+\t\t\t\t_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=\".exe\"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT\n+\t\t\t\tNOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0\n+\t\t\t\tUSE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP\n+\t\t\t\tUNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)\n+\tlist(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c\n+\t\tcompat/win32/pthread.c compat/win32mmap.c compat/win32/syslog.c\n+\t\tcompat/win32/trace2_win32_process_info.c compat/win32/dirent.c\n+\t\tcompat/nedmalloc/nedmalloc.c compat/strdup.c)\n+\tset(NO_UNIX_SOCKETS 1)\n+\n+elseif(CMAKE_SYSTEM_NAME STREQUAL \"Linux\")\n+\tadd_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n+\tlist(APPEND compat_SOURCES unix-socket.c)\n+endif()\n \n-add_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n-list(APPEND compat_SOURCES unix-socket.c)\n+set(EXE_EXTENSION ${CMAKE_EXECUTABLE_SUFFIX})\n \n #header checks\n check_include_file(libgen.h HAVE_LIBGEN_H)\n@@ -223,7 +262,12 @@ endif()\n #function checks\n set(function_checks\n \tstrcasestr memmem strlcpy strtoimax strtoumax strtoull\n-\tsetenv mkdtemp poll pread memmem unsetenv hstrerror)\n+\tsetenv mkdtemp poll pread memmem)\n+\n+#unsetenv,hstrerror are incompatible with windows build\n+if(NOT WIN32)\n+\tlist(APPEND function_checks unsetenv hstrerror)\n+endif()\n \n foreach(f ${function_checks})\n \tstring(TOUPPER ${f} uf)\n@@ -444,7 +488,13 @@ unset(CMAKE_REQUIRED_INCLUDES)\n #programs\n set(PROGRAMS_BUILT\n \tgit git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst\n-\tgit-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)\n+\tgit-shell git-remote-testsvn)\n+\n+if(NO_UNIX_SOCKETS)\n+\tlist(APPEND excluded_progs git-credential-cache git-credential-cache--daemon)\n+else()\n+\tlist(APPEND PROGRAMS_BUILT git-credential-cache git-credential-cache--daemon)\n+endif()\n \n if(NOT CURL_FOUND)\n \tlist(APPEND excluded_progs git-http-fetch git-http-push)\n@@ -516,15 +566,34 @@ parse_makefile_for_sources(libvcs-svn_SOURCES \"VCSSVN_OBJS\")\n list(TRANSFORM libvcs-svn_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})\n \n+#add git.rc for gcc\n+if(WIN32)\n+\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n+\t\t\tCOMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}\n+\t\t\t\t-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION=\"\\\\\\\"${PROJECT_VERSION}.GIT\\\\\\\"\"\n+\t\t\t\t-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res\n+\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n+\t\t\tVERBATIM)\n+\tadd_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)\n+endif()\n+\n #link all required libraries to common-main\n add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)\n-target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)\n+\n+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})\n if(Intl_FOUND)\n \ttarget_link_libraries(common-main ${Intl_LIBRARIES})\n endif()\n if(Iconv_FOUND)\n \ttarget_link_libraries(common-main ${Iconv_LIBRARIES})\n endif()\n+if(WIN32)\n+\ttarget_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)\n+\tadd_dependencies(common-main git-rc)\n+\ttarget_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)\n+elseif(UNIX)\n+\ttarget_link_libraries(common-main pthread rt)\n+endif()\n \n #git\n parse_makefile_for_sources(git_SOURCES \"BUILTIN_OBJS\")\n@@ -575,11 +644,13 @@ endif()\n add_executable(git-remote-testsvn ${CMAKE_SOURCE_DIR}/remote-testsvn.c)\n target_link_libraries(git-remote-testsvn common-main vcs-svn)\n \n-add_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)\n-target_link_libraries(git-credential-cache common-main)\n+if(NOT NO_UNIX_SOCKETS)\n+\tadd_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)\n+\ttarget_link_libraries(git-credential-cache common-main)\n \n-add_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)\n-target_link_libraries(git-credential-cache--daemon common-main)\n+\tadd_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)\n+\ttarget_link_libraries(git-credential-cache--daemon common-main)\n+endif()\n \n \n set(git_builtin_extra\n@@ -591,16 +662,16 @@ set(git_builtin_extra\n foreach(s ${git_SOURCES} ${git_builtin_extra})\n \tstring(REPLACE \"${CMAKE_SOURCE_DIR}/builtin/\" \"\" s ${s})\n \tstring(REPLACE \".c\" \"\" s ${s})\n-\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git git-${s})\\n\")\n-\tlist(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})\n+\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git${EXE_EXTENSION} git-${s}${EXE_EXTENSION})\\n\")\n+\tlist(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s}${EXE_EXTENSION})\n endforeach()\n \n if(CURL_FOUND)\n \tset(remote_exes\n \t\tgit-remote-https git-remote-ftp git-remote-ftps)\n \tforeach(s ${remote_exes})\n-\t\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git-remote-http ${s})\\n\")\n-\t\tlist(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})\n+\t\tfile(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake \"file(CREATE_LINK git-remote-http${EXE_EXTENSION} ${s}${EXE_EXTENSION})\\n\")\n+\t\tlist(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s}${EXE_EXTENSION})\n \tendforeach()\n endif()\n \n@@ -722,20 +793,20 @@ set(bin_links\n \tgit-receive-pack git-upload-archive git-upload-pack)\n \n foreach(b ${bin_links})\n-install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})\")\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/bin/${b}${EXE_EXTENSION})\")\n endforeach()\n \n-install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)\")\n-install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)\")\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git${EXE_EXTENSION})\")\n+install(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell${EXE_EXTENSION})\")\n \n foreach(b ${git_links})\n \tstring(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n-\tinstall(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n+\tinstall(CODE \"file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})\")\n endforeach()\n \n foreach(b ${git_http_links})\n \tstring(REPLACE \"${CMAKE_BINARY_DIR}\" \"\" b ${b})\n-\tinstall(CODE \"file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})\")\n+\tinstall(CODE \"file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})\")\n endforeach()\n \n install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4\n@@ -784,14 +855,14 @@ set(wrapper_test_scripts\n foreach(script ${wrapper_scripts})\n \tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n \tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n-\tstring(REPLACE \"@@PROG@@\" \"${script}\" content \"${content}\")\n+\tstring(REPLACE \"@@PROG@@\" \"${script}${EXE_EXTENSION}\" content \"${content}\")\n \tfile(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n endforeach()\n \n foreach(script ${wrapper_test_scripts})\n \tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n \tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n-\tstring(REPLACE \"@@PROG@@\" \"t/helper/${script}\" content \"${content}\")\n+\tstring(REPLACE \"@@PROG@@\" \"t/helper/${script}${EXE_EXTENSION}\" content \"${content}\")\n \tfile(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n endforeach()\n \n@@ -857,7 +928,7 @@ 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\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PAGER_ENV='${PAGER_ENV}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"DC_SHA1='${DC_SHA1}'\\n\")\n-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"X=''\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"X='${EXE_EXTENSION}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_GETTEXT='${NO_GETTEXT}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"RUNTIME_PREFIX='${RUNTIME_PREFIX}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PYTHON='${NO_PYTHON}'\\n\")\n-- \ngitgitgadget\n\n"},{"id":"400703","messageId":"74358b389d1b28eab723f4db32987332c26de154.1593187898.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v5.git.1593187898.gitgitgadget@gmail.com","subject":"[PATCH v5 2/8] cmake: generate the shell/perl/python scripts and templates, translations","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-06-26T16:11:32Z","receivedAt":"2020-06-26T16:11:53Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nImplement the placeholder substitution to generate scripted\nPorcelain commands, e.g. git-request-pull out of\ngit-request-pull.sh\n\nGenerate shell/perl/python scripts and template using CMake instead of\nusing sed like the build procedure in the Makefile does.\n\nThe text translations are only build if `msgfmt` is found in your path.\n\nNOTE: The scripts and templates are generated during configuration.\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n contrib/buildsystems/CMakeLists.txt | 111 +++++++++++++++++++++++++++-\n 1 file changed, 110 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 1e910d9df8..6c5bb4e233 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -66,7 +66,7 @@ project(git\n \tLANGUAGES C)\n \n \n-#macros for parsing the Makefile for sources\n+#macros for parsing the Makefile for sources and scripts\n macro(parse_makefile_for_sources list_var regex)\n \tfile(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX \"^${regex} \\\\+=(.*)\")\n \tstring(REPLACE \"${regex} +=\" \"\" ${list_var} ${${list_var}})\n@@ -77,6 +77,16 @@ macro(parse_makefile_for_sources list_var regex)\n \tlist(REMOVE_ITEM ${list_var} \"\") #remove empty list elements\n endmacro()\n \n+macro(parse_makefile_for_scripts list_var regex lang)\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX \"^${regex} \\\\+=(.*)\")\n+\tstring(REPLACE \"${regex} +=\" \"\" ${list_var} ${${list_var}})\n+\tstring(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces\n+\tstring(REPLACE \" \" \";\" ${list_var} ${${list_var}}) #convert string to a list\n+\tif(NOT ${lang}) #exclude for SCRIPT_LIB\n+\t\tlist(TRANSFORM ${list_var} REPLACE \"${lang}\" \"\") #do the replacement\n+\tendif()\n+endmacro()\n+\n include(CheckTypeSize)\n include(CheckCSourceRuns)\n include(CheckCSourceCompiles)\n@@ -112,6 +122,11 @@ if(Intl_FOUND)\n \tinclude_directories(SYSTEM ${Intl_INCLUDE_DIRS})\n endif()\n \n+find_program(MSGFMT_EXE msgfmt)\n+if(NOT MSGFMT_EXE)\n+\tmessage(WARNING \"Text Translations won't be build\")\n+endif()\n+\n #default behaviour\n include_directories(${CMAKE_SOURCE_DIR})\n add_compile_definitions(GIT_HOST_CPU=\"${CMAKE_SYSTEM_PROCESSOR}\")\n@@ -590,3 +605,97 @@ add_custom_command(OUTPUT ${git_links} ${git_http_links}\n \t\tCOMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake\n \t\tDEPENDS git git-remote-http)\n add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})\n+\n+\n+#creating required scripts\n+set(SHELL_PATH /bin/sh)\n+set(PERL_PATH /usr/bin/perl)\n+set(LOCALEDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)\n+set(GITWEBDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)\n+set(INSTLIBDIR ${FALLBACK_RUNTIME_PREFIX}/share/perl5)\n+\n+#shell scripts\n+parse_makefile_for_scripts(git_sh_scripts \"SCRIPT_SH\" \".sh\")\n+parse_makefile_for_scripts(git_shlib_scripts \"SCRIPT_LIB\" \"\")\n+set(git_shell_scripts\n+\t${git_sh_scripts} ${git_shlib_scripts} git-instaweb)\n+\n+foreach(script ${git_shell_scripts})\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/${script}.sh content NEWLINE_CONSUME)\n+\tstring(REPLACE \"@SHELL_PATH@\" \"${SHELL_PATH}\" content \"${content}\")\n+\tstring(REPLACE \"@@DIFF@@\" \"diff\" content \"${content}\")\n+\tstring(REPLACE \"@LOCALEDIR@\" \"${LOCALEDIR}\" content \"${content}\")\n+\tstring(REPLACE \"@GITWEBDIR@\" \"${GITWEBDIR}\" content \"${content}\")\n+\tstring(REPLACE \"@@NO_CURL@@\" \"\" content \"${content}\")\n+\tstring(REPLACE \"@@USE_GETTEXT_SCHEME@@\" \"\" content \"${content}\")\n+\tstring(REPLACE \"# @@BROKEN_PATH_FIX@@\" \"\" content \"${content}\")\n+\tstring(REPLACE \"@@PERL@@\" \"${PERL_PATH}\" content \"${content}\")\n+\tstring(REPLACE \"@@SANE_TEXT_GREP@@\" \"-a\" content \"${content}\")\n+\tstring(REPLACE \"@@PAGER_ENV@@\" \"LESS=FRX LV=-c\" content \"${content}\")\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})\n+endforeach()\n+\n+#perl scripts\n+parse_makefile_for_scripts(git_perl_scripts \"SCRIPT_PERL\" \".perl\")\n+\n+#create perl header\n+file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )\n+string(REPLACE \"@@PATHSEP@@\" \":\" perl_header \"${perl_header}\")\n+string(REPLACE \"@@INSTLIBDIR@@\" \"${INSTLIBDIR}\" perl_header \"${perl_header}\")\n+\n+foreach(script ${git_perl_scripts})\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/${script}.perl content NEWLINE_CONSUME)\n+\tstring(REPLACE \"#!/usr/bin/perl\" \"#!/usr/bin/perl\\n${perl_header}\\n\" content \"${content}\")\n+\tstring(REPLACE \"@@GIT_VERSION@@\" \"${PROJECT_VERSION}\" content \"${content}\")\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})\n+endforeach()\n+\n+#python script\n+file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)\n+string(REPLACE \"#!/usr/bin/env python\" \"#!/usr/bin/python\" content \"${content}\")\n+file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})\n+\n+#perl modules\n+file(GLOB_RECURSE perl_modules \"${CMAKE_SOURCE_DIR}/perl/*.pm\")\n+\n+foreach(pm ${perl_modules})\n+\tstring(REPLACE \"${CMAKE_SOURCE_DIR}/perl/\" \"\" file_path ${pm})\n+\tfile(STRINGS ${pm} content NEWLINE_CONSUME)\n+\tstring(REPLACE \"@@LOCALEDIR@@\" \"${LOCALEDIR}\" content \"${content}\")\n+\tstring(REPLACE \"@@NO_PERL_CPAN_FALLBACKS@@\" \"\" content \"${content}\")\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})\n+#test-lib.sh requires perl/build/lib to be the build directory of perl modules\n+endforeach()\n+\n+\n+#templates\n+file(GLOB templates \"${CMAKE_SOURCE_DIR}/templates/*\")\n+list(TRANSFORM templates REPLACE \"${CMAKE_SOURCE_DIR}/templates/\" \"\")\n+list(REMOVE_ITEM templates \".gitignore\")\n+list(REMOVE_ITEM templates \"Makefile\")\n+list(REMOVE_ITEM templates \"blt\")# Prevents an error when reconfiguring for in source builds\n+\n+list(REMOVE_ITEM templates \"branches--\")\n+file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches\n+\n+#templates have @.*@ replacement so use configure_file instead\n+foreach(tm ${templates})\n+\tstring(REPLACE \"--\" \"/\" blt_tm ${tm})\n+\tstring(REPLACE \"this\" \"\" blt_tm ${blt_tm})# for this--\n+\tconfigure_file(${CMAKE_SOURCE_DIR}/templates/${tm} ${CMAKE_BINARY_DIR}/templates/blt/${blt_tm} @ONLY)\n+endforeach()\n+\n+\n+#translations\n+if(MSGFMT_EXE)\n+\tfile(GLOB po_files \"${CMAKE_SOURCE_DIR}/po/*.po\")\n+\tlist(TRANSFORM po_files REPLACE \"${CMAKE_SOURCE_DIR}/po/\" \"\")\n+\tlist(TRANSFORM po_files REPLACE \".po\" \"\")\n+\tforeach(po ${po_files})\n+\t\tfile(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES)\n+\t\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo\n+\t\t\t\tCOMMAND ${MSGFMT_EXE} --check --statistics -o ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo ${CMAKE_SOURCE_DIR}/po/${po}.po)\n+\t\tlist(APPEND po_gen ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo)\n+\tendforeach()\n+\tadd_custom_target(po-gen ALL DEPENDS ${po_gen})\n+endif()\n-- \ngitgitgadget\n\n"},{"id":"400702","messageId":"3cdefab43ad54d5fb14a5cbd9a509ed85745aed9.1593187898.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v5.git.1593187898.gitgitgadget@gmail.com","subject":"[PATCH v5 8/8] ci: modification of main.yml to use cmake for vs-build job","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-06-26T16:11:38Z","receivedAt":"2020-06-26T16:11:54Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiv.siddharthan@gmail.com>\n\nTeach .github/workflows/main.yml to use CMake for VS builds.\n\nModified the vs-test step to match windows-test step. This speeds\nup the vs-test. Calling git-cmd from powershell and then calling git-bash\nto perform the tests slows things down(factor of about 6). So git-bash\nis directly called from powershell to perform the tests using prove.\n\nNOTE: Since GitHub keeps the same directory for each job\n(with respect to path) absolute paths are used in the bin-wrapper\nscripts.\n\nGitHub has switched to CMake 3.17.1 which changed the behaviour of\nFindCURL module. An extra definition (-DCURL_NO_CURL_CMAKE=ON) has been\nadded to revert to the old behaviour.\n\nIn the configuration phase CMake looks for the required libraries for\nbuilding git (eg zlib,libiconv). So we extract the libraries before we\nconfigure.\n\nTo check for ICONV_OMITS_BOM libiconv.dll needs to be in the working\ndirectory of script or path. So we copy the dlls before we configure.\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n .github/workflows/main.yml | 39 +++++++++++++++++++++++---------------\n 1 file changed, 24 insertions(+), 15 deletions(-)\n\ndiff --git a/.github/workflows/main.yml b/.github/workflows/main.yml\nindex 84a5dcff7a..44e0fe5839 100644\n--- a/.github/workflows/main.yml\n+++ b/.github/workflows/main.yml\n@@ -145,13 +145,6 @@ jobs:\n         ## Unzip and remove the artifact\n         unzip artifacts.zip\n         rm artifacts.zip\n-    - name: generate Visual Studio solution\n-      shell: powershell\n-      run: |\n-        & .\\git-sdk-64-minimal\\usr\\bin\\bash.exe -lc @\"\n-          make NDEBUG=1 DEVELOPER=1 vcxproj\n-        \"@\n-        if (!$?) { exit(1) }\n     - name: download vcpkg artifacts\n       shell: powershell\n       run: |\n@@ -163,6 +156,17 @@ jobs:\n         Remove-Item compat.zip\n     - name: add msbuild to PATH\n       uses: microsoft/setup-msbuild@v1.0.0\n+    - name: copy dlls to root\n+      shell: powershell\n+      run: |\n+        & compat\\vcbuild\\vcpkg_copy_dlls.bat release\n+        if (!$?) { exit(1) }\n+    - name: generate Visual Studio solution\n+      shell: bash\n+      run: |\n+        cmake `pwd`/contrib/buildsystems/ -DCMAKE_PREFIX_PATH=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows \\\n+        -DIconv_LIBRARY=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows/lib/libiconv.lib -DIconv_INCLUDE_DIR=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows/include \\\n+        -DMSGFMT_EXE=`pwd`/git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON\n     - name: MSBuild\n       run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142\n     - name: bundle artifact tar\n@@ -171,8 +175,6 @@ jobs:\n         MSVC: 1\n         VCPKG_ROOT: ${{github.workspace}}\\compat\\vcbuild\\vcpkg\n       run: |\n-        & compat\\vcbuild\\vcpkg_copy_dlls.bat release\n-        if (!$?) { exit(1) }\n         & git-sdk-64-minimal\\usr\\bin\\bash.exe -lc @\"\n           mkdir -p artifacts &&\n           eval \\\"`$(make -n artifacts-tar INCLUDE_DLLS_IN_ARTIFACTS=YesPlease ARTIFACTS_DIRECTORY=artifacts 2>&1 | grep ^tar)\\\"\n@@ -203,7 +205,7 @@ jobs:\n     - name: extract build artifacts\n       shell: bash\n       run: tar xf artifacts.tar.gz\n-    - name: test (parallel)\n+    - name: test\n       shell: powershell\n       env:\n         MSYSTEM: MINGW64\n@@ -214,12 +216,19 @@ jobs:\n           # Let Git ignore the SDK and the test-cache\n           printf '%s\\n' /git-sdk-64-minimal/ /test-cache/ >>.git/info/exclude\n \n-          cd t &&\n-          PATH=\\\"`$PWD/helper:`$PATH\\\" &&\n-          test-tool.exe run-command testsuite --jobs=10 -V -x --write-junit-xml \\\n-                  `$(test-tool.exe path-utils slice-tests \\\n-                          ${{matrix.nr}} 10 t[0-9]*.sh)\n+          ci/run-test-slice.sh ${{matrix.nr}} 10\n         \"@\n+    - name: ci/print-test-failures.sh\n+      if: failure()\n+      shell: powershell\n+      run: |\n+        & .\\git-sdk-64-minimal\\usr\\bin\\bash.exe -lc ci/print-test-failures.sh\n+    - name: Upload failed tests' directories\n+      if: failure() && env.FAILED_TEST_ARTIFACTS != ''\n+      uses: actions/upload-artifact@v1\n+      with:\n+        name: failed-tests-windows\n+        path: ${{env.FAILED_TEST_ARTIFACTS}}\n   regular:\n     needs: ci-config\n     if: needs.ci-config.outputs.enabled == 'yes'\n-- \ngitgitgadget\n"},{"id":"400704","messageId":"398a578558b7c880770c04398cebdb7eeee23127.1593187898.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v5.git.1593187898.gitgitgadget@gmail.com","subject":"[PATCH v5 5/8] cmake: support for testing git when building out of the source tree","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-06-26T16:11:35Z","receivedAt":"2020-06-26T16:11:56Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThis patch allows git to be tested when performin out of source builds.\n\nThis involves changing GIT_BUILD_DIR in t/test-lib.sh to point to the\nbuild directory. Also some miscellaneous copies from the source directory\nto the build directory.\nThe copies are:\nt/chainlint.sed needed by a bunch of test scripts\npo/is.po needed by t0204-gettext-rencode-sanity\nmergetools/tkdiff needed by t7800-difftool\ncontrib/completion/git-prompt.sh needed by t9903-bash-prompt\ncontrib/completion/git-completion.bash needed by t9902-completion\ncontrib/svn-fe/svnrdump_sim.py needed by t9020-remote-svn\n\nNOTE: t/test-lib.sh is only modified when tests are run not during\nthe build or configure.\nThe trash directory is still srcdir/t\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n contrib/buildsystems/CMakeLists.txt | 20 ++++++++++++++++++++\n 1 file changed, 20 insertions(+)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex 315f234b04..2768ee5b71 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -862,6 +862,26 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_GETTEXT='${NO_GETTEXT}'\\n\"\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"RUNTIME_PREFIX='${RUNTIME_PREFIX}'\\n\")\n file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PYTHON='${NO_PYTHON}'\\n\")\n \n+#Make the tests work when building out of the source tree\n+get_filename_component(CACHE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../CMakeCache.txt ABSOLUTE)\n+if(NOT ${CMAKE_BINARY_DIR}/CMakeCache.txt STREQUAL ${CACHE_PATH})\n+\tfile(RELATIVE_PATH BUILD_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/CMakeCache.txt)\n+\tstring(REPLACE \"/CMakeCache.txt\" \"\" BUILD_DIR_RELATIVE ${BUILD_DIR_RELATIVE})\n+\t#Setting the build directory in test-lib.sh before running tests\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.cmake\n+\t\t\"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh GIT_BUILD_DIR_REPL REGEX \\\"GIT_BUILD_DIR=(.*)\\\")\\n\"\n+\t\t\"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh content NEWLINE_CONSUME)\\n\"\n+\t\t\"string(REPLACE \\\"\\${GIT_BUILD_DIR_REPL}\\\" \\\"GIT_BUILD_DIR=\\\\\\\"$TEST_DIRECTORY\\\\\\\"/../${BUILD_DIR_RELATIVE}\\\" content \\\"\\${content}\\\")\\n\"\n+\t\t\"file(WRITE ${CMAKE_SOURCE_DIR}/t/test-lib.sh \\${content})\")\n+\t#misc copies\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.sed DESTINATION ${CMAKE_BINARY_DIR}/t/)\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/po/is.po DESTINATION ${CMAKE_BINARY_DIR}/po/)\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/mergetools/tkdiff DESTINATION ${CMAKE_BINARY_DIR}/mergetools/)\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-prompt.sh DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-completion.bash DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)\n+\tfile(COPY ${CMAKE_SOURCE_DIR}/contrib/svn-fe/svnrdump_sim.py DESTINATION ${CMAKE_BINARY_DIR}/contrib/svn-fe/)\n+endif()\n+\n file(GLOB test_scipts \"${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh\")\n \n #test\n-- \ngitgitgadget\n\n"},{"id":"400705","messageId":"fedda55fc21aa76f30a22cf6b581ec8c44f338ce.1593187898.git.gitgitgadget@gmail.com","threadId":"53305","inReplyTo":"pull.614.v5.git.1593187898.gitgitgadget@gmail.com","subject":"[PATCH v5 4/8] cmake: support for testing git with ctest","fromName":"Sibi Siddharthan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-06-26T16:11:34Z","receivedAt":"2020-06-26T16:11:59Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n\nThis patch provides an alternate way to test git using ctest.\nCTest ships with CMake, so there is no additional dependency being\nintroduced.\n\nTo perform the tests with ctest do this after building:\nctest -j[number of jobs]\n\nNOTE: -j is optional, the default number of jobs is 1\n\nEach of the jobs does this:\ncd t/ && sh t[something].sh\n\nThe reason for using CTest is that it logs the output of the tests\nin a neat way, which can be helpful during diagnosis of failures.\n\nAfter the tests have run ctest generates three log files located in\n`build-directory`/Testing/Temporary/\n\nThese log files are:\n\nCTestCostData.txt:\nThis file contains the time taken to complete each test.\n\nLastTestsFailed.log:\nThis log file contains the names of the tests that have failed in the\nrun.\n\nLastTest.log:\nThis log file contains the log of all the tests that have run.\nA snippet of the file is given below.\n\n10/901 Testing: D:/my/git-master/t/t0009-prio-queue.sh\n10/901 Test: D:/my/git-master/t/t0009-prio-queue.sh\nCommand: \"sh.exe\" \"D:/my/git-master/t/t0009-prio-queue.sh\"\nDirectory: D:/my/git-master/t\n\"D:/my/git-master/t/t0009-prio-queue.sh\"\nOutput:\n----------------------------------------------------------\nok 1 - basic ordering\nok 2 - mixed put and get\nok 3 - notice empty queue\nok 4 - stack order\npassed all 4 test(s)\n1..4\n<end of output>\nTest time =   1.11 sec\n\nNOTE: Testing only works when building in source for now.\n\nSigned-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n---\n contrib/buildsystems/CMakeLists.txt | 124 ++++++++++++++++++++++++++++\n 1 file changed, 124 insertions(+)\n\ndiff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\nindex bc9258cf3b..315f234b04 100644\n--- a/contrib/buildsystems/CMakeLists.txt\n+++ b/contrib/buildsystems/CMakeLists.txt\n@@ -96,6 +96,7 @@ include(CheckIncludeFile)\n include(CheckFunctionExists)\n include(CheckSymbolExists)\n include(CheckStructHasMember)\n+include(CTest)\n \n find_package(ZLIB REQUIRED)\n find_package(CURL)\n@@ -748,3 +749,126 @@ install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/\n if(MSGFMT_EXE)\n \tinstall(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)\n endif()\n+\n+\n+if(BUILD_TESTING)\n+\n+#tests-helpers\n+add_executable(test-fake-ssh ${CMAKE_SOURCE_DIR}/t/helper/test-fake-ssh.c)\n+target_link_libraries(test-fake-ssh common-main)\n+\n+add_executable(test-line-buffer ${CMAKE_SOURCE_DIR}/t/helper/test-line-buffer.c)\n+target_link_libraries(test-line-buffer common-main vcs-svn)\n+\n+add_executable(test-svn-fe ${CMAKE_SOURCE_DIR}/t/helper/test-svn-fe.c)\n+target_link_libraries(test-svn-fe common-main vcs-svn)\n+\n+#test-tool\n+parse_makefile_for_sources(test-tool_SOURCES \"TEST_BUILTINS_OBJS\")\n+\n+list(TRANSFORM test-tool_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/t/helper/\")\n+add_executable(test-tool ${CMAKE_SOURCE_DIR}/t/helper/test-tool.c ${test-tool_SOURCES})\n+target_link_libraries(test-tool common-main)\n+\n+set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool\n+\t\t\tPROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)\n+\n+#wrapper scripts\n+set(wrapper_scripts\n+\tgit git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)\n+\n+set(wrapper_test_scripts\n+\ttest-fake-ssh test-line-buffer test-svn-fe test-tool)\n+\n+\n+foreach(script ${wrapper_scripts})\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n+\tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n+\tstring(REPLACE \"@@PROG@@\" \"${script}\" content \"${content}\")\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n+endforeach()\n+\n+foreach(script ${wrapper_test_scripts})\n+\tfile(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n+\tstring(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n+\tstring(REPLACE \"@@PROG@@\" \"t/helper/${script}\" content \"${content}\")\n+\tfile(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})\n+endforeach()\n+\n+file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)\n+string(REPLACE \"@@BUILD_DIR@@\" \"${CMAKE_BINARY_DIR}\" content \"${content}\")\n+string(REPLACE \"@@PROG@@\" \"git-cvsserver\" content \"${content}\")\n+file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})\n+\n+#options for configuring test options\n+option(PERL_TESTS \"Perform tests that use perl\" ON)\n+option(PYTHON_TESTS \"Perform tests that use python\" ON)\n+\n+#GIT-BUILD-OPTIONS\n+set(TEST_SHELL_PATH ${SHELL_PATH})\n+set(DIFF diff)\n+set(PYTHON_PATH /usr/bin/python)\n+set(TAR tar)\n+set(NO_CURL )\n+set(NO_EXPAT )\n+set(USE_LIBPCRE1 )\n+set(USE_LIBPCRE2 )\n+set(NO_LIBPCRE1_JIT )\n+set(NO_PERL )\n+set(NO_PTHREADS )\n+set(NO_PYTHON )\n+set(PAGER_ENV \"LESS=FRX LV=-c\")\n+set(DC_SHA1 YesPlease)\n+set(RUNTIME_PREFIX true)\n+set(NO_GETTEXT )\n+\n+if(NOT CURL_FOUND)\n+\tset(NO_CURL 1)\n+endif()\n+\n+if(NOT EXPAT_FOUND)\n+\tset(NO_EXPAT 1)\n+endif()\n+\n+if(NOT Intl_FOUND)\n+\tset(NO_GETTEXT 1)\n+endif()\n+\n+if(NOT PERL_TESTS)\n+\tset(NO_PERL 1)\n+endif()\n+\n+if(NOT PYTHON_TESTS)\n+\tset(NO_PYTHON 1)\n+endif()\n+\n+file(WRITE ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"SHELL_PATH='${SHELL_PATH}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"TEST_SHELL_PATH='${TEST_SHELL_PATH}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PERL_PATH='${PERL_PATH}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"DIFF='${DIFF}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PYTHON_PATH='${PYTHON_PATH}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"TAR='${TAR}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_CURL='${NO_CURL}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_EXPAT='${NO_EXPAT}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"USE_LIBPCRE1='${USE_LIBPCRE1}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_LIBPCRE1_JIT='${NO_LIBPCRE1_JIT}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PERL='${NO_PERL}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PTHREADS='${NO_PTHREADS}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"PAGER_ENV='${PAGER_ENV}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"DC_SHA1='${DC_SHA1}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"X=''\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_GETTEXT='${NO_GETTEXT}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"RUNTIME_PREFIX='${RUNTIME_PREFIX}'\\n\")\n+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS \"NO_PYTHON='${NO_PYTHON}'\\n\")\n+\n+file(GLOB test_scipts \"${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh\")\n+\n+#test\n+foreach(tsh ${test_scipts})\n+\tadd_test(NAME ${tsh}\n+\t\tCOMMAND ${SH_EXE} ${tsh}\n+\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t)\n+endforeach()\n+\n+endif()#BUILD_TESTING\n-- \ngitgitgadget\n\n"},{"id":"400795","messageId":"20200630072521.GC1962986@gmail.com","threadId":"53305","inReplyTo":"10acdbf5e4d4c49f69889ab1129d3d6b5a7fd754.1593187898.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v5 6/8] cmake: support for building git on windows with mingw","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2020-06-30T07:25:21Z","receivedAt":"2020-06-30T07:25:26Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Fri, Jun 26, 2020 at 04:11:36PM +0000, Sibi Siddharthan via GitGitGadget wrote:\n> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> \n> This patch facilitates building git on Windows with CMake using MinGW\n> \n> NOTE: The funtions unsetenv and hstrerror are not checked in Windows\n> builds.\n> Reasons\n> NO_UNSETENV is not compatible with Windows builds.\n> lines 262-264 compat/mingw.h\n> \n> compat/mingw.h(line 25) provides a definition of hstrerror which\n> conflicts with the definition provided in\n> git-compat-util.h(lines 733-736).\n> \n> To use CMake on Windows with MinGW do this:\n> cmake `relative-path-to-srcdir` -G \"MinGW Makefiles\"\n> \n> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> ---\n>  contrib/buildsystems/CMakeLists.txt | 117 ++++++++++++++++++++++------\n>  1 file changed, 94 insertions(+), 23 deletions(-)\n> \n> diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\n> index 2768ee5b71..2d7c0ed88e 100644\n> --- a/contrib/buildsystems/CMakeLists.txt\n> +++ b/contrib/buildsystems/CMakeLists.txt\n> @@ -42,6 +42,10 @@ cmake_minimum_required(VERSION 3.14)\n>  set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n>  \n>  find_program(SH_EXE sh)\n> +if(NOT SH_EXE)\n> +\tmessage(FATAL_ERROR \"sh: shell interpreter was not found in your path, please install one.\"\n> +\t\t\t\"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n> +endif()\n>  \n>  #Create GIT-VERSION-FILE using GIT-VERSION-GEN\n>  if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)\n> @@ -65,7 +69,9 @@ project(git\n>  \tVERSION ${git_version}\n>  \tLANGUAGES C)\n>  \n> +\n>  #TODO gitk git-gui gitweb\n> +#TODO Enable NLS on windows natively\n>  #TODO Add pcre support\n>  \n>  #macros for parsing the Makefile for sources and scripts\n> @@ -104,6 +110,7 @@ find_package(EXPAT)\n>  find_package(Iconv)\n>  find_package(Intl)\n>  \n> +\n>  if(NOT Intl_FOUND)\n>  \tadd_compile_definitions(NO_GETTEXT)\n>  \tif(NOT Iconv_FOUND)\n> @@ -125,6 +132,14 @@ if(Intl_FOUND)\n>  \tinclude_directories(SYSTEM ${Intl_INCLUDE_DIRS})\n>  endif()\n>  \n> +\n> +if(WIN32)\n> +\tfind_program(WINDRES_EXE windres)\n> +\tif(NOT WINDRES_EXE)\n> +\t\tmessage(FATAL_ERROR \"Install windres on Windows for resource files\")\n> +\tendif()\n> +endif()\n> +\n>  find_program(MSGFMT_EXE msgfmt)\n>  if(NOT MSGFMT_EXE)\n>  \tmessage(WARNING \"Text Translations won't be build\")\n> @@ -156,11 +171,35 @@ add_compile_definitions(PAGER_ENV=\"LESS=FRX LV=-c\"\n>  \t\t\tBINDIR=\"bin\"\n>  \t\t\tGIT_BUILT_FROM_COMMIT=\"\")\n>  \n> -set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n> -add_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n> +if(WIN32)\n> +\tset(FALLBACK_RUNTIME_PREFIX /mingw64)\n> +\tadd_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n> +else()\n> +\tset(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n> +\tadd_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n> +endif()\n> +\n> +\n> +#Platform Specific\n> +if(CMAKE_SYSTEM_NAME STREQUAL \"Windows\")\n> +\tinclude_directories(${CMAKE_SOURCE_DIR}/compat/win32)\n> +\tadd_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32\n> +\t\t\t\t_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=\".exe\"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT\n> +\t\t\t\tNOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0\n> +\t\t\t\tUSE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP\n> +\t\t\t\tUNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)\n> +\tlist(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c\n> +\t\tcompat/win32/pthread.c compat/win32mmap.c compat/win32/syslog.c\n> +\t\tcompat/win32/trace2_win32_process_info.c compat/win32/dirent.c\n> +\t\tcompat/nedmalloc/nedmalloc.c compat/strdup.c)\n> +\tset(NO_UNIX_SOCKETS 1)\n> +\n> +elseif(CMAKE_SYSTEM_NAME STREQUAL \"Linux\")\n> +\tadd_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n> +\tlist(APPEND compat_SOURCES unix-socket.c)\n> +endif()\n>  \n> -add_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n> -list(APPEND compat_SOURCES unix-socket.c)\n> +set(EXE_EXTENSION ${CMAKE_EXECUTABLE_SUFFIX})\n>  \n>  #header checks\n>  check_include_file(libgen.h HAVE_LIBGEN_H)\n> @@ -223,7 +262,12 @@ endif()\n>  #function checks\n>  set(function_checks\n>  \tstrcasestr memmem strlcpy strtoimax strtoumax strtoull\n> -\tsetenv mkdtemp poll pread memmem unsetenv hstrerror)\n> +\tsetenv mkdtemp poll pread memmem)\n> +\n> +#unsetenv,hstrerror are incompatible with windows build\n> +if(NOT WIN32)\n> +\tlist(APPEND function_checks unsetenv hstrerror)\n> +endif()\n>  \n>  foreach(f ${function_checks})\n>  \tstring(TOUPPER ${f} uf)\n> @@ -444,7 +488,13 @@ unset(CMAKE_REQUIRED_INCLUDES)\n>  #programs\n>  set(PROGRAMS_BUILT\n>  \tgit git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst\n> -\tgit-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)\n> +\tgit-shell git-remote-testsvn)\n> +\n> +if(NO_UNIX_SOCKETS)\n> +\tlist(APPEND excluded_progs git-credential-cache git-credential-cache--daemon)\n> +else()\n> +\tlist(APPEND PROGRAMS_BUILT git-credential-cache git-credential-cache--daemon)\n> +endif()\n>  \n>  if(NOT CURL_FOUND)\n>  \tlist(APPEND excluded_progs git-http-fetch git-http-push)\n> @@ -516,15 +566,34 @@ parse_makefile_for_sources(libvcs-svn_SOURCES \"VCSSVN_OBJS\")\n>  list(TRANSFORM libvcs-svn_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n>  add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})\n>  \n> +#add git.rc for gcc\n> +if(WIN32)\n> +\tadd_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n> +\t\t\tCOMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}\n> +\t\t\t\t-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION=\"\\\\\\\"${PROJECT_VERSION}.GIT\\\\\\\"\"\n> +\t\t\t\t-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res\n> +\t\t\tWORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n> +\t\t\tVERBATIM)\n> +\tadd_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)\n> +endif()\n> +\n>  #link all required libraries to common-main\n>  add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)\n> -target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)\n> +\n> +target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})\n>  if(Intl_FOUND)\n>  \ttarget_link_libraries(common-main ${Intl_LIBRARIES})\n>  endif()\n>  if(Iconv_FOUND)\n>  \ttarget_link_libraries(common-main ${Iconv_LIBRARIES})\n>  endif()\n> +if(WIN32)\n> +\ttarget_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)\n> +\tadd_dependencies(common-main git-rc)\n> +\ttarget_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)\n> +elseif(UNIX)\n> +\ttarget_link_libraries(common-main pthread rt)\n> +endif()\n\n\nSmall note about pthread.  In CMake land, the typical convention is to\nuse the FindThreads module. [1]\n\nTo use it, add this to the top-level:\n\n\tset(THREADS_PREFER_PTHREAD_FLAG TRUE)\n\tfind_package(Threads REQUIRED)\n\nand then use the Threads::Threads target with target_link_libraries()\ninstead of hard-coding \"pthread\" here.\n\nThat way it'll only use the \"-pthread\" flag and library links as needed.\n\nI'm not sure if mingw makes this advice moot, but I figured it was worth\nmentioning.\n\n[1] https://cmake.org/cmake/help/latest/module/FindThreads.html\n-- \nDavid\n"},{"id":"400937","messageId":"CAKiG+9Vws-_6rYh=Kcc2W3qbo_7LdxrE0WGPwLmGGewM+VqcVg@mail.gmail.com","threadId":"53305","inReplyTo":"20200630072521.GC1962986@gmail.com","subject":"Re: [PATCH v5 6/8] cmake: support for building git on windows with mingw","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-07-01T17:45:00Z","receivedAt":"2020-07-01T17:45:13Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"This module should not be used here as Git is built with pthreads in mind.\nAll of the Linux systems have the pthread library at install. For\nWindows, there is a pthread layer implemented using Win32 calls in\ncompat/win32/pthread.c,h .\n\nIt would be nice if the library checks for pthreads on Windows\n(libwinpthread and similar implementations), but it does not.\n\nThank You,\nSibi Siddharthan\n\nOn Tue, Jun 30, 2020 at 12:55 PM David Aguilar <davvid@gmail.com> wrote:\n>\n> On Fri, Jun 26, 2020 at 04:11:36PM +0000, Sibi Siddharthan via GitGitGadget wrote:\n> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> >\n> > This patch facilitates building git on Windows with CMake using MinGW\n> >\n> > NOTE: The funtions unsetenv and hstrerror are not checked in Windows\n> > builds.\n> > Reasons\n> > NO_UNSETENV is not compatible with Windows builds.\n> > lines 262-264 compat/mingw.h\n> >\n> > compat/mingw.h(line 25) provides a definition of hstrerror which\n> > conflicts with the definition provided in\n> > git-compat-util.h(lines 733-736).\n> >\n> > To use CMake on Windows with MinGW do this:\n> > cmake `relative-path-to-srcdir` -G \"MinGW Makefiles\"\n> >\n> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>\n> > ---\n> >  contrib/buildsystems/CMakeLists.txt | 117 ++++++++++++++++++++++------\n> >  1 file changed, 94 insertions(+), 23 deletions(-)\n> >\n> > diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt\n> > index 2768ee5b71..2d7c0ed88e 100644\n> > --- a/contrib/buildsystems/CMakeLists.txt\n> > +++ b/contrib/buildsystems/CMakeLists.txt\n> > @@ -42,6 +42,10 @@ cmake_minimum_required(VERSION 3.14)\n> >  set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)\n> >\n> >  find_program(SH_EXE sh)\n> > +if(NOT SH_EXE)\n> > +     message(FATAL_ERROR \"sh: shell interpreter was not found in your path, please install one.\"\n> > +                     \"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/\")\n> > +endif()\n> >\n> >  #Create GIT-VERSION-FILE using GIT-VERSION-GEN\n> >  if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)\n> > @@ -65,7 +69,9 @@ project(git\n> >       VERSION ${git_version}\n> >       LANGUAGES C)\n> >\n> > +\n> >  #TODO gitk git-gui gitweb\n> > +#TODO Enable NLS on windows natively\n> >  #TODO Add pcre support\n> >\n> >  #macros for parsing the Makefile for sources and scripts\n> > @@ -104,6 +110,7 @@ find_package(EXPAT)\n> >  find_package(Iconv)\n> >  find_package(Intl)\n> >\n> > +\n> >  if(NOT Intl_FOUND)\n> >       add_compile_definitions(NO_GETTEXT)\n> >       if(NOT Iconv_FOUND)\n> > @@ -125,6 +132,14 @@ if(Intl_FOUND)\n> >       include_directories(SYSTEM ${Intl_INCLUDE_DIRS})\n> >  endif()\n> >\n> > +\n> > +if(WIN32)\n> > +     find_program(WINDRES_EXE windres)\n> > +     if(NOT WINDRES_EXE)\n> > +             message(FATAL_ERROR \"Install windres on Windows for resource files\")\n> > +     endif()\n> > +endif()\n> > +\n> >  find_program(MSGFMT_EXE msgfmt)\n> >  if(NOT MSGFMT_EXE)\n> >       message(WARNING \"Text Translations won't be build\")\n> > @@ -156,11 +171,35 @@ add_compile_definitions(PAGER_ENV=\"LESS=FRX LV=-c\"\n> >                       BINDIR=\"bin\"\n> >                       GIT_BUILT_FROM_COMMIT=\"\")\n> >\n> > -set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n> > -add_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n> > +if(WIN32)\n> > +     set(FALLBACK_RUNTIME_PREFIX /mingw64)\n> > +     add_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n> > +else()\n> > +     set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})\n> > +     add_compile_definitions(FALLBACK_RUNTIME_PREFIX=\"${FALLBACK_RUNTIME_PREFIX}\")\n> > +endif()\n> > +\n> > +\n> > +#Platform Specific\n> > +if(CMAKE_SYSTEM_NAME STREQUAL \"Windows\")\n> > +     include_directories(${CMAKE_SOURCE_DIR}/compat/win32)\n> > +     add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32\n> > +                             _CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=\".exe\"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT\n> > +                             NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0\n> > +                             USE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP\n> > +                             UNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)\n> > +     list(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c\n> > +             compat/win32/pthread.c compat/win32mmap.c compat/win32/syslog.c\n> > +             compat/win32/trace2_win32_process_info.c compat/win32/dirent.c\n> > +             compat/nedmalloc/nedmalloc.c compat/strdup.c)\n> > +     set(NO_UNIX_SOCKETS 1)\n> > +\n> > +elseif(CMAKE_SYSTEM_NAME STREQUAL \"Linux\")\n> > +     add_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n> > +     list(APPEND compat_SOURCES unix-socket.c)\n> > +endif()\n> >\n> > -add_compile_definitions(PROCFS_EXECUTABLE_PATH=\"/proc/self/exe\" HAVE_DEV_TTY )\n> > -list(APPEND compat_SOURCES unix-socket.c)\n> > +set(EXE_EXTENSION ${CMAKE_EXECUTABLE_SUFFIX})\n> >\n> >  #header checks\n> >  check_include_file(libgen.h HAVE_LIBGEN_H)\n> > @@ -223,7 +262,12 @@ endif()\n> >  #function checks\n> >  set(function_checks\n> >       strcasestr memmem strlcpy strtoimax strtoumax strtoull\n> > -     setenv mkdtemp poll pread memmem unsetenv hstrerror)\n> > +     setenv mkdtemp poll pread memmem)\n> > +\n> > +#unsetenv,hstrerror are incompatible with windows build\n> > +if(NOT WIN32)\n> > +     list(APPEND function_checks unsetenv hstrerror)\n> > +endif()\n> >\n> >  foreach(f ${function_checks})\n> >       string(TOUPPER ${f} uf)\n> > @@ -444,7 +488,13 @@ unset(CMAKE_REQUIRED_INCLUDES)\n> >  #programs\n> >  set(PROGRAMS_BUILT\n> >       git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst\n> > -     git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)\n> > +     git-shell git-remote-testsvn)\n> > +\n> > +if(NO_UNIX_SOCKETS)\n> > +     list(APPEND excluded_progs git-credential-cache git-credential-cache--daemon)\n> > +else()\n> > +     list(APPEND PROGRAMS_BUILT git-credential-cache git-credential-cache--daemon)\n> > +endif()\n> >\n> >  if(NOT CURL_FOUND)\n> >       list(APPEND excluded_progs git-http-fetch git-http-push)\n> > @@ -516,15 +566,34 @@ parse_makefile_for_sources(libvcs-svn_SOURCES \"VCSSVN_OBJS\")\n> >  list(TRANSFORM libvcs-svn_SOURCES PREPEND \"${CMAKE_SOURCE_DIR}/\")\n> >  add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})\n> >\n> > +#add git.rc for gcc\n> > +if(WIN32)\n> > +     add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res\n> > +                     COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}\n> > +                             -DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION=\"\\\\\\\"${PROJECT_VERSION}.GIT\\\\\\\"\"\n> > +                             -i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res\n> > +                     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n> > +                     VERBATIM)\n> > +     add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)\n> > +endif()\n> > +\n> >  #link all required libraries to common-main\n> >  add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)\n> > -target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)\n> > +\n> > +target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})\n> >  if(Intl_FOUND)\n> >       target_link_libraries(common-main ${Intl_LIBRARIES})\n> >  endif()\n> >  if(Iconv_FOUND)\n> >       target_link_libraries(common-main ${Iconv_LIBRARIES})\n> >  endif()\n> > +if(WIN32)\n> > +     target_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)\n> > +     add_dependencies(common-main git-rc)\n> > +     target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)\n> > +elseif(UNIX)\n> > +     target_link_libraries(common-main pthread rt)\n> > +endif()\n>\n>\n> Small note about pthread.  In CMake land, the typical convention is to\n> use the FindThreads module. [1]\n>\n> To use it, add this to the top-level:\n>\n>         set(THREADS_PREFER_PTHREAD_FLAG TRUE)\n>         find_package(Threads REQUIRED)\n>\n> and then use the Threads::Threads target with target_link_libraries()\n> instead of hard-coding \"pthread\" here.\n>\n> That way it'll only use the \"-pthread\" flag and library links as needed.\n>\n> I'm not sure if mingw makes this advice moot, but I figured it was worth\n> mentioning.\n>\n> [1] https://cmake.org/cmake/help/latest/module/FindThreads.html\n> --\n> David\n"},{"id":"400938","messageId":"CAKiG+9VSC1ee8ck3Y0Xs4QVGudi4kG=Xc9M3-cRcru1jcLkpnw@mail.gmail.com","threadId":"53305","inReplyTo":"CAKiG+9Vws-_6rYh=Kcc2W3qbo_7LdxrE0WGPwLmGGewM+VqcVg@mail.gmail.com","subject":"Re: [PATCH v5 6/8] cmake: support for building git on windows with mingw","fromName":"Sibi Siddharthan","fromEmail":"sibisiddharthan.github@gmail.com","sentAt":"2020-07-01T17:49:49Z","receivedAt":"2020-07-01T17:50:02Z","isPatch":true,"sender":{"key":"sibisiddharthan.github@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44207430?v=4"},"body":"Sorry for top posting, I realized it only after clicking send :)\n"}]}