Skip to content

Commit 51a5a9c

Browse files
jiridanekbluca
authored andcommitted
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 #4834
1 parent 00f12d2 commit 51a5a9c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,9 +491,9 @@ execute_process(
491491
OUTPUT_VARIABLE CACHELINE_SIZE
492492
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
493493
if(CACHELINE_SIZE STREQUAL ""
494+
OR CACHELINE_SIZE STREQUAL "undefined"
494495
OR CACHELINE_SIZE EQUAL 0
495-
OR CACHELINE_SIZE EQUAL -1
496-
OR CACHELINE_SIZE STREQUAL "undefined")
496+
OR CACHELINE_SIZE EQUAL -1)
497497
set(ZMQ_CACHELINE_SIZE 64)
498498
else()
499499
set(ZMQ_CACHELINE_SIZE ${CACHELINE_SIZE})

0 commit comments

Comments
 (0)