Address CMP0012 given unset/empty ZSTD_VERSION

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Major - P3
    • 2.3.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Not Needed
    • None
    • C Drivers
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      For reasons unclear, EVG patch builds are failing due to `pkg_check_modules` finding a zstd library, yet unable to determine its version. The well-behaving output looks as follows (note the absence of a detected version in the output):

      ```
      – Found PkgConfig: /data/mci/9696ef2e2a0391327e26506a37e505ee/tmp/tmp.GzBmZI3KJ5/pkg-config (found version "2.5.1")
      – Checking for module 'libzstd'
      – Found libzstd, version
      – Detected zstd version but version 0.8.0 required
      ```

      However, this is not the output current observed. Instead CMake currently errors with:

      ```
      CMake Error at src/libmongoc/CMakeLists.txt:141 (elseif):
      given arguments:
      "VERSION_LESS" "0.8.0"
      Unknown arguments specified
      ```

      This appears to be due to one or more of [CMP0012](https://cmake.org/cmake/help/latest/policy/CMP0012.html) and [CMP0054](https://cmake.org/cmake/help/latest/policy/CMP0054.html) (note we've already been setting these policies to NEW via `cmake_minimum_required()`), where the unquoted variable expansion "${ZSTD_VERSION}" is [treated as _no argument_ when empty/unset](https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#unquoted-argument) rather than an empty string, as if:

      ```cmake

      1. Expectation: elseif ("" VERSION_LESS "0.8.0")
      2. Actual:
        elseif (VERSION_LESS "0.8.0")
        ```

      I believe the proposed change is a worthwhile improvement, independent of diagnosing why a zstd library is suddenly being found without an accompanying version number.

            Assignee:
            Ezra Chung
            Reporter:
            Ezra Chung
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: