diff options
-rw-r--r-- | CMakeLists.txt | 37 | ||||
-rw-r--r-- | cmake/find_stp.cmake | 57 |
2 files changed, 59 insertions, 35 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e066b89e..325997c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -307,41 +307,8 @@ include(${CMAKE_SOURCE_DIR}/cmake/compiler_warnings.cmake) ################################################################################ # Solvers ################################################################################ - -# STP: Use CMake facility to detect. The user can pass `-DSTP_DIR=` to force -# a particular directory. -option(ENABLE_SOLVER_STP "Enable STP solver support" OFF) -if (ENABLE_SOLVER_STP) - message(STATUS "STP solver support enabled") - # 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) - 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() +# STP +include(${CMAKE_SOURCE_DIR}/cmake/find_stp.cmake) # Z3 option(ENABLE_SOLVER_Z3 "Enable Z3 solver support" OFF) 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() |