diff options
author | Andrea Mattavelli <andreamattavelli@users.noreply.github.com> | 2017-07-28 17:11:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-28 17:11:33 +0100 |
commit | 6dda95ed80dd9a91428eb8f8c7ae12c86627bccc (patch) | |
tree | 92528a92dbd2e35c07e938b8bc9a634fc0287197 /cmake/find_z3.cmake | |
parent | 3bea97fdafc9d68ec2e5c76fcde05d112aef8a38 (diff) | |
parent | be14a1a7b4c465a4559b79df158ce8d2ee4487b9 (diff) | |
download | klee-6dda95ed80dd9a91428eb8f8c7ae12c86627bccc.tar.gz |
Merge pull request #728 from delcypher/cmake_change_default
[CMake] Change some defaults
Diffstat (limited to 'cmake/find_z3.cmake')
-rw-r--r-- | cmake/find_z3.cmake | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/cmake/find_z3.cmake b/cmake/find_z3.cmake new file mode 100644 index 00000000..60e27c26 --- /dev/null +++ b/cmake/find_z3.cmake @@ -0,0 +1,51 @@ +#===------------------------------------------------------------------------===# +# +# The KLEE Symbolic Virtual Machine +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +#===------------------------------------------------------------------------===# + +find_package(Z3) +# Set the default so that if the following is true: +# * Z3 was found +# * ENABLE_SOLVER_Z3 is not already set as a cache variable +# +# then the default is set to `ON`. Otherwise set the default to `OFF`. +# A consequence of this is if we fail to detect Z3 the first time +# subsequent calls to CMake will not change the default. +if (Z3_FOUND) + set(ENABLE_SOLVER_Z3_DEFAULT ON) +else() + set(ENABLE_SOLVER_Z3_DEFAULT OFF) +endif() +option(ENABLE_SOLVER_Z3 "Enable Z3 solver support" ${ENABLE_SOLVER_Z3_DEFAULT}) + +if (ENABLE_SOLVER_Z3) + message(STATUS "Z3 solver support enabled") + if (Z3_FOUND) + message(STATUS "Found Z3") + set(ENABLE_Z3 1) # For config.h + list(APPEND KLEE_COMPONENT_EXTRA_INCLUDE_DIRS ${Z3_INCLUDE_DIRS}) + list(APPEND KLEE_SOLVER_LIBRARIES ${Z3_LIBRARIES}) + + # Check the signature of `Z3_get_error_msg()` + set (_old_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${Z3_LIBRARIES}) + check_prototype_definition(Z3_get_error_msg + "Z3_string Z3_get_error_msg(Z3_context c, Z3_error_code err)" + "NULL" "${Z3_INCLUDE_DIRS}/z3.h" HAVE_Z3_GET_ERROR_MSG_NEEDS_CONTEXT) + set(CMAKE_REQUIRED_LIBRARIES ${_old_CMAKE_REQUIRED_LIBRARIES}) + if (HAVE_Z3_GET_ERROR_MSG_NEEDS_CONTEXT) + message(STATUS "Z3_get_error_msg requires context") + else() + message(STATUS "Z3_get_error_msg does not require context") + endif() + else() + message(FATAL_ERROR "Z3 not found.") + endif() +else() + message(STATUS "Z3 solver support disabled") + set(ENABLE_Z3 0) # For config.h +endif() |