@@ -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
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(-)