[llvm] [CMake][Z3]Don't attempt to compile / run if cross-compiling (PR #66355)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 14 03:16:29 PDT 2023


https://github.com/Naville created https://github.com/llvm/llvm-project/pull/66355:

Otherwise CMake might throw and error:
CMake Error: try_run() invoked in cross-compiling mode, please set the following cache variables appropriately:
   Z3_RETURNCODE (advanced)
   Z3_RETURNCODE__TRYRUN_OUTPUT (advanced)

>From 1d8e5b25fccd78d147c5ec373f9d3b61efe1f906 Mon Sep 17 00:00:00 2001
From: Zhang <5205699+Naville at users.noreply.github.com>
Date: Thu, 14 Sep 2023 18:16:11 +0800
Subject: [PATCH] [CMake][Z3]Don't attempt to compile / run if cross-compiling

Otherwise CMake might throw and error:
CMake Error: try_run() invoked in cross-compiling mode, please set the following cache variables appropriately:
   Z3_RETURNCODE (advanced)
   Z3_RETURNCODE__TRYRUN_OUTPUT (advanced)
---
 llvm/cmake/modules/FindZ3.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/cmake/modules/FindZ3.cmake b/llvm/cmake/modules/FindZ3.cmake
index 72fb5a96a52b9d6..2981753c84fe11c 100644
--- a/llvm/cmake/modules/FindZ3.cmake
+++ b/llvm/cmake/modules/FindZ3.cmake
@@ -75,7 +75,7 @@ unset(Z3_VERSION_STRING)
 
 # First, try to check it dynamically, by compiling a small program that
 # prints Z3's version
-if(Z3_INCLUDE_DIR AND Z3_LIBRARIES)
+if(Z3_INCLUDE_DIR AND Z3_LIBRARIES AND NOT CMAKE_CROSSCOMPILING)
   # We do not have the Z3 binary to query for a version. Try to use
   # a small C++ program to detect it via the Z3_get_version() API call.
   check_z3_version(${Z3_INCLUDE_DIR} ${Z3_LIBRARIES})



More information about the llvm-commits mailing list