diff --git a/llvm/cmake/modules/FindZ3.cmake b/llvm/cmake/modules/FindZ3.cmake --- a/llvm/cmake/modules/FindZ3.cmake +++ b/llvm/cmake/modules/FindZ3.cmake @@ -37,7 +37,7 @@ RUN_OUTPUT_VARIABLE SRC_OUTPUT ) - if(Z3_COMPILED) + if(Z3_COMPILED AND NOT (Z3_RETURNCODE STREQUAL FAILED_TO_RUN)) string(REGEX REPLACE "([0-9]*\\.[0-9]*\\.[0-9]*)" "\\1" z3_version "${SRC_OUTPUT}") set(Z3_VERSION_STRING ${z3_version} PARENT_SCOPE) @@ -82,25 +82,23 @@ # If the dynamic check fails, we might be cross compiling: if that's the case, # check the version in the headers, otherwise, fail with a message -if(NOT Z3_VERSION_STRING AND (CMAKE_CROSSCOMPILING AND - Z3_INCLUDE_DIR AND - EXISTS "${Z3_INCLUDE_DIR}/z3_version.h")) +if(NOT Z3_VERSION_STRING AND (Z3_INCLUDE_DIR AND EXISTS "${Z3_INCLUDE_DIR}/z3_version.h")) # TODO: print message warning that we couldn't find a compatible lib? # Z3 4.8.1+ has the version is in a public header. file(STRINGS "${Z3_INCLUDE_DIR}/z3_version.h" z3_version_str REGEX "^#define[\t ]+Z3_MAJOR_VERSION[\t ]+.*") - string(REGEX REPLACE "^.*Z3_MAJOR_VERSION[\t ]+([0-9]).*$" "\\1" + string(REGEX REPLACE "^.*Z3_MAJOR_VERSION[\t ]+([0-9]+).*$" "\\1" Z3_MAJOR "${z3_version_str}") file(STRINGS "${Z3_INCLUDE_DIR}/z3_version.h" z3_version_str REGEX "^#define[\t ]+Z3_MINOR_VERSION[\t ]+.*") - string(REGEX REPLACE "^.*Z3_MINOR_VERSION[\t ]+([0-9]).*$" "\\1" + string(REGEX REPLACE "^.*Z3_MINOR_VERSION[\t ]+([0-9]+).*$" "\\1" Z3_MINOR "${z3_version_str}") file(STRINGS "${Z3_INCLUDE_DIR}/z3_version.h" z3_version_str REGEX "^#define[\t ]+Z3_BUILD_NUMBER[\t ]+.*") - string(REGEX REPLACE "^.*Z3_BUILD_NUMBER[\t ]+([0-9]).*$" "\\1" + string(REGEX REPLACE "^.*Z3_BUILD_NUMBER[\t ]+([0-9]+).*$" "\\1" Z3_BUILD "${z3_version_str}") set(Z3_VERSION_STRING ${Z3_MAJOR}.${Z3_MINOR}.${Z3_BUILD}) @@ -122,4 +120,4 @@ REQUIRED_VARS Z3_LIBRARIES Z3_INCLUDE_DIR VERSION_VAR Z3_VERSION_STRING) -mark_as_advanced(Z3_INCLUDE_DIR Z3_LIBRARIES) +mark_as_advanced(Z3_INCLUDE_DIR Z3_LIBRARIES) \ No newline at end of file