Try to find Z3 using CONFIG_MODE before manual search.

This commit is contained in:
Daniel Kirchner 2019-06-04 14:55:45 +02:00
parent 95e6b2e40d
commit 9f5340fa53
3 changed files with 43 additions and 23 deletions

View File

@ -11,6 +11,10 @@ Compiler Features:
Bugfixes: Bugfixes:
Build System:
* Attempt to use stock Z3 cmake files to find Z3 and only fall back to manual discovery.
### 0.5.9 (2019-05-28) ### 0.5.9 (2019-05-28)

View File

@ -1,4 +1,20 @@
if (USE_Z3) if (USE_Z3)
# Save and clear Z3_FIND_VERSION, since the
# Z3 config module cannot handle version requirements.
set(Z3_FIND_VERSION_ORIG ${Z3_FIND_VERSION})
set(Z3_FIND_VERSION)
# Try to find Z3 using its stock cmake files.
find_package(Z3 QUIET CONFIG)
# Restore Z3_FIND_VERSION for find_package_handle_standard_args.
set(Z3_FIND_VERSION ${Z3_FIND_VERSION_ORIG})
set(Z3_FIND_VERSION_ORIG)
include(FindPackageHandleStandardArgs)
if (Z3_FOUND)
set(Z3_VERSION ${Z3_VERSION_STRING})
find_package_handle_standard_args(Z3 CONFIG_MODE)
else()
find_path(Z3_INCLUDE_DIR NAMES z3++.h PATH_SUFFIXES z3) find_path(Z3_INCLUDE_DIR NAMES z3++.h PATH_SUFFIXES z3)
find_library(Z3_LIBRARY NAMES z3) find_library(Z3_LIBRARY NAMES z3)
find_program(Z3_EXECUTABLE z3 PATH_SUFFIXES bin) find_program(Z3_EXECUTABLE z3 PATH_SUFFIXES bin)
@ -15,15 +31,15 @@ if (USE_Z3)
endif() endif()
mark_as_advanced(Z3_VERSION_STRING z3_DIR) mark_as_advanced(Z3_VERSION_STRING z3_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Z3 find_package_handle_standard_args(Z3
REQUIRED_VARS Z3_LIBRARY Z3_INCLUDE_DIR REQUIRED_VARS Z3_LIBRARY Z3_INCLUDE_DIR
VERSION_VAR Z3_VERSION_STRING) VERSION_VAR Z3_VERSION_STRING)
if (NOT TARGET Z3::Z3) if (NOT TARGET z3::libz3)
add_library(Z3::Z3 UNKNOWN IMPORTED) add_library(z3::libz3 UNKNOWN IMPORTED)
set_property(TARGET Z3::Z3 PROPERTY IMPORTED_LOCATION ${Z3_LIBRARY}) set_property(TARGET z3::libz3 PROPERTY IMPORTED_LOCATION ${Z3_LIBRARY})
set_property(TARGET Z3::Z3 PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${Z3_INCLUDE_DIR}) set_property(TARGET z3::libz3 PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${Z3_INCLUDE_DIR})
endif()
endif() endif()
else() else()
set(Z3_FOUND FALSE) set(Z3_FOUND FALSE)

View File

@ -140,7 +140,7 @@ add_library(solidity ${sources} ${z3_SRCS} ${cvc4_SRCS})
target_link_libraries(solidity PUBLIC yul evmasm langutil devcore ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY}) target_link_libraries(solidity PUBLIC yul evmasm langutil devcore ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY})
if (${Z3_FOUND}) if (${Z3_FOUND})
target_link_libraries(solidity PUBLIC Z3::Z3) target_link_libraries(solidity PUBLIC z3::libz3)
endif() endif()
if (${CVC4_FOUND}) if (${CVC4_FOUND})