Skip to content

Commit

Permalink
Merge pull request #502 from luhsra/z3-cmake-fix
Browse files Browse the repository at this point in the history
cmake: build correctly with globally installed z3
  • Loading branch information
yuleisui authored Aug 19, 2021
2 parents 1ac1476 + 3ced67b commit 49bb55f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
19 changes: 15 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,22 @@ Please set this to environment variable to point to the LLVM build directory\
else()
set(IN_SOURCE_BUILD 1)
endif()
set(Z3_DIR $ENV{Z3_DIR})

if (DEFINED ENV{Z3_DIR})
get_filename_component(Z3_DIR $ENV{Z3_DIR} REALPATH BASE_DIR ${CMAKE_BINARY_DIR})
set(Z3_LIBRARIES ${Z3_DIR}/bin/libz3.a)
set(Z3_INSTALLS ${Z3_DIR}/include)
set(Z3_EXTRA_LINK_DIR ${Z3_DIR}/bin)
else()
include(FindPkgConfig)
pkg_search_module(Z3 REQUIRED z3)
set(Z3_INSTALLS )
set(Z3_EXTRA_LINK_DIR )
endif()

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/include
${Z3_DIR}/include/)
${Z3_INSTALLS})

# checks if the test-suite is present, if it is then build bc files and add testing to cmake build
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Test-Suite")
Expand All @@ -63,12 +75,11 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Test-Suite")
include(CTest)
endif()

LINK_DIRECTORIES(${Z3_DIR}/bin)
add_subdirectory(lib)
add_subdirectory(tools)

INSTALL(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${CMAKE_CURRENT_BINARY_DIR}/include/ ${Z3_DIR}/include/
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${CMAKE_CURRENT_BINARY_DIR}/include/ ${Z3_INSTALLS}
COMPONENT devel
DESTINATION include/svf
FILES_MATCHING
Expand Down
4 changes: 2 additions & 2 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ file (GLOB SOURCES
MTA/*.cpp
SABER/*.cpp
DDA/*.cpp)
add_llvm_library(Svf STATIC ${SOURCES} LINK_LIBS Cudd ${Z3_DIR}/bin/libz3.a)
add_llvm_library(Svf STATIC ${SOURCES} LINK_LIBS Cudd ${Z3_LIBRARIES})

link_directories( ${CMAKE_BINARY_DIR}/lib/Cudd ${Z3_DIR}/bin)
link_directories(${CMAKE_BINARY_DIR}/lib/Cudd ${Z3_EXTRA_LINK_DIRS})


if(DEFINED IN_SOURCE_BUILD)
Expand Down

0 comments on commit 49bb55f

Please sign in to comment.