Ray's Knowledge Base
Unlock

A cmake -P script needs CMP0057 NEW before if(IN_LIST) works on older cmake

PitfallVerified 5 Nov 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

An if(... IN_LIST ...) test in a cmake -P script fails on cmake 3.26.5. The same script passes on the newer cmake on a Mac.

Cause#

The IN_LIST test needs policy CMP0057 set to NEW. The script set no minimum version, so the older default policy applied.

Fix#

Add cmake_policy(SET CMP0057 NEW) near the top of the script, before the first IN_LIST test.

Evidence#

dftracer-utils, 2026-11. Commit 38c5478e added the policy line to the keep-std check script. A full ctest run on a Corona node with cmake 3.26.5 then passed.

Also found by searching

  • if IN_LIST fails in a cmake -P script
  • cmake -P script passes on a new cmake and fails on an old one
  • CMP0057 IN_LIST policy