]> granicus.if.org Git - graphviz/commitdiff
fix: use 'find_program' instead of 'find_package' to locate Git in CMake build
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Mon, 8 Nov 2021 00:13:38 +0000 (16:13 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 14 Nov 2021 17:56:48 +0000 (09:56 -0800)
The Cygwin CMake CI task recently started stalling after the “Found FLEX” step.
Reordering CMake steps to debug this revealed that it was definitely the
`find_package(Git REQUIRED)` step that was stalling. I have not been able to
root cause what is going on, but some educated guesses:

  1. A CMake FindGit.cmake bug? This could certainly cause the described
     behavior, but I cannot find anything online to corroborate this and cannot
     see anything in the upstream history of this file¹ that looks like a fix
     for something like this.

  2. Installing a version of CMake via Choco and then running it via Cygwin
     causes some bad Windows/UNIX interaction? Perhaps, but I cannot find any
     corroborating evidence for this either. Also, I cannot guess why such a
     thing would _only_ cause problems in FindGit.cmake.

  3. FindGit.cmake is picking up a Visual Studio shim for Git that responds in a
     way that confuses the `find_package` check? I found vague hints about a
     shim like this online, but I still cannot explain why this would cause a
     stall.

A work around for this is to use the less nuanced `find_program`. This has no
negative impact on the CMake setup because (1) all we are attempting to detect
is the `git` binary itself and (2) the CMake files never call `git` directly
anyway; we are performing this detection to avoid gen_version.py failing
cryptically.

Note that it is not possible to use `REQUIRED` in this `find_program` directive
because this was only added in CMake 3.18 and we currently only require CMake
3.1.

This also re-enables the Cygwin CMake CI task now that it no longer stalls.

Fixes #2145.

¹ https://github.com/Kitware/CMake/commits/master/Modules/FindGit.cmake

.gitlab-ci.yml
CMakeLists.txt

index 819145e28de1f047297e5cd5dd1d7613135579ae..7b67af9a4b86a3f28109360f4649103ef31fba7f 100644 (file)
@@ -840,32 +840,31 @@ windows-mingw64-cmake-build:
     except:
         - tags
 
-# FIXME: https://gitlab.com/graphviz/graphviz/-/issues/2145
-# windows-cygwin-cmake-build:
-#     stage: build
-#     needs: []
-#     script:
-#         # change line endings from crlf to lf
-#         - git rm --cached -r .
-#         - git -c core.autocrlf=false reset --hard
-#         - choco config set cacheLocation choco-cache
-#         - choco install --yes --no-progress cygwin
-#         - $Env:build_system = "cmake"
-#         - C:\tools\cygwin\bin\bash -l -c 'cd $CI_PROJECT_DIR && ci/cygwin-build.sh'
-#     artifacts:
-#         when: always
-#         expire_in: 1 week
-#         paths:
-#             - Packages/*/*/*.zip
-#             - Packages/*/*/*.bz2
-#     cache:
-#         key: windows-cygwin-cmake-build
-#         paths:
-#             - choco-cache
-#     tags:
-#         - windows
-#     except:
-#         - tags
+windows-cygwin-cmake-build:
+    stage: build
+    needs: []
+    script:
+        # change line endings from crlf to lf
+        - git rm --cached -r .
+        - git -c core.autocrlf=false reset --hard
+        - choco config set cacheLocation choco-cache
+        - choco install --yes --no-progress cygwin
+        - $Env:build_system = "cmake"
+        - C:\tools\cygwin\bin\bash -l -c 'cd $CI_PROJECT_DIR && ci/cygwin-build.sh'
+    artifacts:
+        when: always
+        expire_in: 1 week
+        paths:
+            - Packages/*/*/*.zip
+            - Packages/*/*/*.bz2
+    cache:
+        key: windows-cygwin-cmake-build
+        paths:
+            - choco-cache
+    tags:
+        - windows
+    except:
+        - tags
 
 meta-data:
     stage: test
index 98eaaa7c525a7f7cff2f32ece4dccfae863ea165..ad63eb3ceb0fabb560ff365fcbdabb9219da95ba 100644 (file)
@@ -56,7 +56,10 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
 find_package(AWK REQUIRED)
 find_package(BISON 3.0 REQUIRED)
 find_package(FLEX REQUIRED)
-find_package(Git REQUIRED)
+find_program(GIT git)
+if(NOT GIT)
+  message(FATAL_ERROR "git not found")
+endif(NOT GIT)
 find_program(GZIP gzip)
 
 # ================== Convenient values for CMake configuration =================