Skip to content

Commit 307f303

Browse files
Merge pull request #53 from trailofbits/fix-z3-exports-for-cmake
Avoid exporting a full file path for Z3 in cmake
2 parents 7e4f55f + e0cb5f9 commit 307f303

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

pkgman/patches/FindZ3.cmake

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ find_path(Z3_INCLUDE_DIR NAMES z3.h
3535
PATH_SUFFIXES libz3 z3
3636
)
3737

38-
find_library(Z3_LIBRARIES NAMES z3 libz3
38+
find_library(Z3_LIBS NAMES z3 libz3
3939
NO_DEFAULT_PATH
4040
PATHS ${LLVM_Z3_INSTALL_DIR}
4141
PATH_SUFFIXES lib bin
@@ -46,7 +46,7 @@ find_path(Z3_INCLUDE_DIR NAMES z3.h
4646
PATH_SUFFIXES libz3 z3
4747
)
4848

49-
find_library(Z3_LIBRARIES NAMES z3 libz3
49+
find_library(Z3_LIBS NAMES z3 libz3
5050
PATH_SUFFIXES lib bin
5151
)
5252

@@ -55,10 +55,10 @@ unset(Z3_VERSION_STRING)
5555

5656
# First, try to check it dynamically, by compiling a small program that
5757
# prints Z3's version
58-
if(Z3_INCLUDE_DIR AND Z3_LIBRARIES)
58+
if(Z3_INCLUDE_DIR AND Z3_LIBS)
5959
# We do not have the Z3 binary to query for a version. Try to use
6060
# a small C++ program to detect it via the Z3_get_version() API call.
61-
check_z3_version(${Z3_INCLUDE_DIR} ${Z3_LIBRARIES})
61+
check_z3_version(${Z3_INCLUDE_DIR} ${Z3_LIBS})
6262
endif()
6363

6464
# If the dynamic check fails, we might be cross compiling: if that's the case,
@@ -99,7 +99,14 @@ endif()
9999
# all listed variables are TRUE
100100
include(FindPackageHandleStandardArgs)
101101
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Z3
102-
REQUIRED_VARS Z3_LIBRARIES Z3_INCLUDE_DIR
102+
REQUIRED_VARS Z3_LIBS Z3_INCLUDE_DIR
103103
VERSION_VAR Z3_VERSION_STRING)
104-
105-
mark_as_advanced(Z3_INCLUDE_DIR Z3_LIBRARIES)
104+
if(Z3_FOUND AND NOT TARGET Z3)
105+
add_library(Z3 UNKNOWN IMPORTED)
106+
set_target_properties(Z3 PROPERTIES
107+
INTERFACE_INCLUDE_DIRECTORIES "${Z3_INCLUDE_DIR}"
108+
IMPORTED_LOCATION "${Z3_LIBS}"
109+
)
110+
set(Z3_LIBRARIES "Z3")
111+
endif()
112+
mark_as_advanced(Z3_INCLUDE_DIR Z3_LIBS Z3_LIBRARIES)

0 commit comments

Comments
 (0)