Commit 51a5a9c
Problem: CACHELINE_SIZE conditions check string after numeric comparisons
When getconf returns "undefined" (e.g., on s390x under qemu-user), the
STREQUAL "undefined" check comes after EQUAL 0 and EQUAL -1. While this
works in current CMake versions, performing numeric comparisons on
non-numeric strings before string comparisons is fragile and could have
undefined behavior in some CMake versions.
Solution: reorder conditions to check strings before numeric comparisons
Move STREQUAL "undefined" before the EQUAL comparisons. This ensures
proper string matching is attempted before any numeric coercion, making
the code more robust and easier to understand.
Verified with qemu-user s390x emulation (CMake 3.22):
- getconf LEVEL1_DCACHE_LINESIZE returns "undefined"
- Both orderings work, but string-first is safer
Fixes #48341 parent 00f12d2 commit 51a5a9c
1 file changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
491 | 491 | | |
492 | 492 | | |
493 | 493 | | |
| 494 | + | |
494 | 495 | | |
495 | | - | |
496 | | - | |
| 496 | + | |
497 | 497 | | |
498 | 498 | | |
499 | 499 | | |
| |||
0 commit comments