cmake: detect Z3 version. minimum version=4.8.1
MODIFY
CMakeLists.txt
CMakeLists.txt
@@ -30,7 +30,7 @@ if (CYGWIN)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll")
endif()
-find_package(Z3 REQUIRED)
+find_package(Z3 4.8.1 REQUIRED)
include_directories(${Z3_INCLUDE_DIRS})
find_program(RE2C re2c)

MODIFY
cmake/FindZ3.cmake
cmake/FindZ3.cmake
@@ -2,3 +2,24 @@ find_path(Z3_INCLUDE_DIR NAMES z3.h)
find_library(Z3_LIBRARIES NAMES z3)
message(STATUS "Z3: ${Z3_INCLUDE_DIR} ${Z3_LIBRARIES}")
+
+if (Z3_INCLUDE_DIR AND EXISTS "${Z3_INCLUDE_DIR}/z3_version.h")
+ file(STRINGS "${Z3_INCLUDE_DIR}/z3_version.h" Z3_VERSION_STRS
+ REGEX "^#define Z3_(MAJOR|MINOR|BUILD)_(VERSION|NUMBER)[ \t]+[0-9]+$")
+ foreach(VLINE ${Z3_VERSION_STRS})
+ if (VLINE MATCHES "Z3_[A-Z_ \t]+([0-9]+)")
+ list(APPEND Z3_INSTALLED_VERSION "${CMAKE_MATCH_1}")
+ endif()
+ endforeach()
+ unset(Z3_VERSION_STRS)
+ string(JOIN "." Z3_INSTALLED_VERSION ${Z3_INSTALLED_VERSION})
+else()
+ set(Z3_INSTALLED_VERSION "0.0.0")
+endif()
+
+set(Z3_REQUIRED_VERSION "${Z3_FIND_VERSION_MAJOR}.${Z3_FIND_VERSION_MINOR}.${Z3_FIND_VERSION_PATCH}")
+if (${Z3_INSTALLED_VERSION} VERSION_LESS ${Z3_REQUIRED_VERSION})
+ message(FATAL_ERROR "Z3 required version: ${Z3_REQUIRED_VERSION} (installed: ${Z3_INSTALLED_VERSION})")
+else()
+ message(STATUS "Z3 installed version: ${Z3_INSTALLED_VERSION}")
+endif()

cmake: detect Z3 version. minimum version=4.8.1