diff options
author | Dan Liew <daniel.liew@imperial.ac.uk> | 2017-07-25 14:59:31 +0100 |
---|---|---|
committer | Dan Liew <daniel.liew@imperial.ac.uk> | 2017-07-28 08:19:52 +0100 |
commit | 0c964b4792d2d575ef1a3032589943412df5923c (patch) | |
tree | bc8b1f70cc706fa543dcc62b98145c10341d8021 /cmake/find_stp.cmake | |
parent | b46f8186e60a18ec81e2f03783482c76ac234880 (diff) | |
download | klee-0c964b4792d2d575ef1a3032589943412df5923c.tar.gz |
[CMake] Refactor STP detection and change the default value of
`ENABLE_SOLVER_STP` to be set dynamically based on whether STP is available. Previously the default was always off.
Diffstat (limited to 'cmake/find_stp.cmake')
-rw-r--r-- | cmake/find_stp.cmake | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/cmake/find_stp.cmake b/cmake/find_stp.cmake new file mode 100644 index 00000000..7b10f1fe --- /dev/null +++ b/cmake/find_stp.cmake @@ -0,0 +1,57 @@ +#===------------------------------------------------------------------------===# +# +# The KLEE Symbolic Virtual Machine +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +#===------------------------------------------------------------------------===# +# STP: Use CMake facility to detect. The user can pass `-DSTP_DIR=` to force +# a particular directory. + +# Although find_package() will set `STP_DIR` for us add it here so that +# is displayed in `ccmake` and `cmake-gui`. +set(STP_DIR "" CACHE PATH "Path to directory containing STPConfig.cmake") +find_package(STP CONFIG) + +# Set the default so that if the following is true: +# * STP was found +# * ENABLE_SOLVER_STP 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 STP the first time +# subsequent calls to CMake will not change the default. +if (STP_FOUND) + set(ENABLE_SOLVER_STP_DEFAULT ON) +else() + set(ENABLE_SOLVER_STP_DEFAULT OFF) +endif() +option(ENABLE_SOLVER_STP "Enable STP solver support" ${ENABLE_SOLVER_STP_DEFAULT}) + +if (ENABLE_SOLVER_STP) + message(STATUS "STP solver support enabled") + if (STP_FOUND) + message(STATUS "Found STP version ${STP_VERSION}") + # Try the STP shared library first + if ("${STP_SHARED_LIBRARY}" STREQUAL "") + # Try the static library instead + if ("${STP_STATIC_LIBRARY}" STREQUAL "") + message(FATAL_ERROR "Couldn't find STP shared or static library") + endif() + message(STATUS "Using STP static library") + list(APPEND KLEE_SOLVER_LIBRARIES "${STP_STATIC_LIBRARY}") + else() + message(STATUS "Using STP shared library") + list(APPEND KLEE_SOLVER_LIBRARIES "${STP_SHARED_LIBRARY}") + endif() + list(APPEND KLEE_COMPONENT_EXTRA_INCLUDE_DIRS "${STP_INCLUDE_DIRS}") + message(STATUS "STP_DIR: ${STP_DIR}") + set(ENABLE_STP 1) # For config.h + else() + message(FATAL_ERROR "STP not found. Try setting `-DSTP_DIR=/path` where" + " `/path` is the directory containing `STPConfig.cmake`") + endif() +else() + message(STATUS "STP solver support disabled") + set(ENABLE_STP 0) # For config.h +endif() |