Skip to content

Windows build fails: yajl's Conan recipe sets CMP0026 OLD, incompatible with newer CMake #3604

Description

@fzipi

Summary

The Windows build (vcbuild.bat → Conan → yajl) fails deterministically on GitHub-hosted Windows runners that have picked up a newer Visual Studio/CMake toolchain. yajl/2.1.0's Conan Center recipe's CMakeLists.txt still does cmake_policy(SET CMP0026 OLD), and current CMake has dropped support for CMP0026's OLD behavior entirely, so cmake_policy() itself errors out before configuration can proceed.

Where this was found

Building ModSecurity-nginx's Windows CI job (.github/workflows/test_new.yml, build-windows), which invokes this repo's own Windows build via vcbuild.bat. Not caused by anything in ModSecurity-nginx — it fails inside owasp-modsecurity/ModSecurity's own dependency build step, so any downstream consumer building on an affected Windows toolchain would hit the same thing.

Evidence (from CI log)

yajl/2.1.0: Calling build()
yajl/2.1.0: Apply patch (conan): CMake: fix mingw, disable build of doc/test/perf/example, relocatable shared lib for macos, install DLL into bin folder
yajl/2.1.0: Running CMake.configure()
yajl/2.1.0: RUN: cmake -G "Visual Studio 18 2026" -DCMAKE_TOOLCHAIN_FILE="generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="C:/Users/runneradmin/.conan2/p/b/yajla281b513a4897/p" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" "C:/Users/runneradmin/.conan2/p/b/yajla281b513a4897/b/src"
CMake Error at CMakeLists.txt:17 (cmake_policy):
  Policy CMP0026 may not be set to OLD behavior because this version of CMake
  no longer supports it.  The policy was introduced in CMake version 3.0.0,
  and use of NEW behavior is now required.

  Please either update your CMakeLists.txt files to conform to the new
  behavior or use an older version of CMake that still supports the old
  behavior.  Run cmake --help-policy CMP0026 for more information.

Two further, likely-related errors appear later in the same yajl configure step once the policy issue is worked around/ignored:

CMake Error at reformatter/CMakeLists.txt:38 (GET_TARGET_PROPERTY):
  The LOCATION property may not be read from target "json_reformat".  Use the
  target name directly with add_custom_command, or use the generator
  expression $<TARGET_FILE>, as appropriate.

CMake Error at verify/CMakeLists.txt:32 (GET_TARGET_PROPERTY):
  The LOCATION property may not be read from target "json_verify".  Use the
  target name directly with add_custom_command, or use the generator
  expression $<TARGET_FILE>, as appropriate.

(GET_TARGET_PROPERTY ... LOCATION on a target is also removed/hard-errors under CMake's CMP0026 NEW behavior — consistent with the same root cause: yajl's bundled CMakeLists.txt predates CMake policies this old CMake no longer tolerates.)

The runner's cmake -G "Visual Studio 18 2026" generator string indicates the GitHub-hosted Windows image has moved to a VS2026-preview-class toolchain with a correspondingly newer bundled CMake.

Impact

  • Deterministic, not flaky: every Windows build that reaches the yajl step on an affected toolchain fails the same way. Retrying does not help.
  • Blocks Windows CI for any downstream project (e.g. ModSecurity-nginx) that builds libmodsecurity for Windows via this path.

Suggested fixes (any of)

  • Pin/patch the yajl Conan recipe/version used by vcbuild.bat to one whose CMakeLists.txt doesn't rely on CMP0026 OLD (or pass a policy override / patch it out during the build).
  • Pin an explicit, known-compatible CMake version for the Windows build instead of relying on whatever the toolchain/runner provides.
  • Consider the existing Drop YAJL dependency #3308 ("Drop YAJL dependency") as a longer-term fix that would sidestep this class of issue entirely.

Environment

  • GitHub-hosted Windows runner (windows-2025 image at the time of writing)
  • Conan 2.x, yajl/2.1.0 from conancenter
  • Observed via owasp-modsecurity/ModSecurity-nginx's test_new.yml build-windows job

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions