git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/6] cmake: only look for "sh" in "C:/Program Files" on Windows

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Dec 19, 2022, 18:39 UTC
Message-ID
<patch-4.6-c23f659c054-20221219T183623Z-avarab@gmail.com>
In-Reply-To
<cover-0.6-00000000000-20221219T183623Z-avarab@gmail.com>

Guard the finding of "SH_EXE" in "C:\Program Files" with a check for whether we're on Windows.

This Windows-specific code was first added in [1], and later expanded on [2], but since some of that was added this build recipe has been made portable outside of Windows.

1. 72b6eeb81b1 (cmake: do find Git for Windows' shell interpreter,
   2020-09-28)
2. 476e54b1c60 (cmake: support local installations of git,
   2022-07-27).
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 contrib/buildsystems/CMakeLists.txt | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index d45b9c8e00a..560a15ed35a 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -107,10 +107,17 @@ if(USE_VCPKG)
 	set(CMAKE_TOOLCHAIN_FILE ${VCPKG_DIR}/scripts/buildsystems/vcpkg.cmake CACHE STRING "Vcpkg toolchain file")
 endif()
 
-find_program(SH_EXE sh PATHS "C:/Program Files/Git/bin" "$ENV{LOCALAPPDATA}/Programs/Git/bin")
-if(NOT SH_EXE)
-	message(FATAL_ERROR "sh: shell interpreter was not found in your path, please install one."
-			"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/")
+if(WIN32)
+	find_program(SH_EXE sh PATHS "C:/Program Files/Git/bin" "$ENV{LOCALAPPDATA}/Programs/Git/bin")
+	if(NOT SH_EXE)
+		message(FATAL_ERROR "sh: shell interpreter was not found in your path, please install one."
+				"You can get it as part of 'Git for Windows' install at https://gitforwindows.org/")
+	endif()
+else()
+	find_program(SH_EXE sh)
+	if(NOT SH_EXE)
+		message(FATAL_ERROR "cannot find 'sh' in '$PATH'")
+	endif()
 endif()
 
 #Create GIT-VERSION-FILE using GIT-VERSION-GEN
-- 
2.39.0.1071.g97ce8966538
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 5 of 7 in “cmake: guard OS-specific code & cleanup & chmod +x on *nix”
  1. 0/6 cmake: guard OS-specific code & cleanup & chmod +x on *nixÆvar Arnfjörð Bjarmason, Dec 19, 2022
  2. 1/6 cmake: don't copy chainlint.pl to build directoryÆvar Arnfjörð Bjarmason, Dec 19, 2022
  3. 2/6 cmake: set "USE_LIBPCRE2" in "GIT-BUILD-OPTIONS" for test-lib.shÆvar Arnfjörð Bjarmason, Dec 19, 2022
  4. 3/6 cmake: increase test timeout on Windows onlyÆvar Arnfjörð Bjarmason, Dec 19, 2022
  5. 4/6 cmake: only look for "sh" in "C:/Program Files" on WindowsÆvar Arnfjörð Bjarmason, Dec 19, 2022
  6. 6/6 cmake: chmod +x the bin-wrappers/* & SCRIPT_{SH,PERL} & git-p4Ævar Arnfjörð Bjarmason, Dec 19, 2022
  7. 5/6 cmake: copy over git-p4.py for t983[56] perforce testÆvar Arnfjörð Bjarmason, Dec 19, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.