Skip to content

Commit 2d637a4

Browse files
committed
Proper cmake failure if z3 version cannot be determined.
1 parent cbac3a4 commit 2d637a4

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

cmake/FindZ3.cmake

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,20 @@ if (USE_Z3)
1919
find_library(Z3_LIBRARY NAMES z3)
2020
find_program(Z3_EXECUTABLE z3 PATH_SUFFIXES bin)
2121

22-
if(Z3_INCLUDE_DIR AND Z3_LIBRARY AND Z3_EXECUTABLE)
23-
execute_process (COMMAND ${Z3_EXECUTABLE} -version
24-
OUTPUT_VARIABLE libz3_version_str
25-
ERROR_QUIET
26-
OUTPUT_STRIP_TRAILING_WHITESPACE)
22+
if(Z3_INCLUDE_DIR AND Z3_LIBRARY)
23+
if(Z3_EXECUTABLE)
24+
execute_process (COMMAND ${Z3_EXECUTABLE} -version
25+
OUTPUT_VARIABLE libz3_version_str
26+
ERROR_QUIET
27+
OUTPUT_STRIP_TRAILING_WHITESPACE)
2728

28-
string(REGEX REPLACE "^Z3 version ([0-9.]+).*" "\\1"
29-
Z3_VERSION_STRING "${libz3_version_str}")
30-
unset(libz3_version_str)
29+
string(REGEX REPLACE "^Z3 version ([0-9.]+).*" "\\1"
30+
Z3_VERSION_STRING "${libz3_version_str}")
31+
unset(libz3_version_str)
32+
else()
33+
message(WARNING "Could not determine the version of z3, since the z3 executable was not found.")
34+
set(Z3_VERSION_STRING "0.0.0")
35+
endif()
3136
endif()
3237
mark_as_advanced(Z3_VERSION_STRING z3_DIR)
3338

0 commit comments

Comments
 (0)