From: Nathan Moinvaziri Date: Sat, 17 Jan 2026 18:10:49 +0000 (-0800) Subject: Read architecture name from binary in detect-arch. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cda9b506d42d7d6632500c2d46930a2589ceaf08;p=thirdparty%2Fzlib-ng.git Read architecture name from binary in detect-arch. --- diff --git a/cmake/detect-arch.cmake b/cmake/detect-arch.cmake index 3f8e2c4da..d98243fc8 100644 --- a/cmake/detect-arch.cmake +++ b/cmake/detect-arch.cmake @@ -11,15 +11,18 @@ elseif(EMSCRIPTEN) elseif(CMAKE_CROSSCOMPILING) set(ARCH ${CMAKE_C_COMPILER_TARGET}) else() - # Compile and run detect-arch.c which prints architecture name to stderr - try_run( - run_result_unused - compile_result_unused + # Compile detect-arch.c and read the architecture name from the binary + try_compile( + COMPILE_RESULT ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_LIST_DIR}/detect-arch.c CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} - RUN_OUTPUT_VARIABLE RAWOUTPUT + COPY_FILE ${CMAKE_CURRENT_BINARY_DIR}/detect-arch.bin ) + if(COMPILE_RESULT) + file(STRINGS ${CMAKE_CURRENT_BINARY_DIR}/detect-arch.bin + RAWOUTPUT REGEX "archfound [a-zA-Z0-9_]+") + endif() # Find archfound tag, and extract the arch word into ARCH variable string(REGEX REPLACE ".*archfound ([a-zA-Z0-9_]+).*" "\\1" ARCH "${RAWOUTPUT}")