forked from SVF-tools/SVF
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed the build system (again) and exported a more useful SVF CMake p…
…ackage for our use-case
- Loading branch information
Showing
50 changed files
with
406 additions
and
711 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,35 @@ | ||
#ifndef CONFIG_H_IN | ||
#define CONFIG_H_IN | ||
#ifndef SVF_CONFIG_H_IN | ||
#define SVF_CONFIG_H_IN | ||
|
||
// Directory structure of SVF source tree (could be moved) | ||
#define SVF_ROOT_DIR "@SVF_SOURCE_DIR@" | ||
#define SVF_SOURCE_DIR "@SVF_SOURCE_DIR@" | ||
#define SVF_BUILD_DIR "@CMAKE_BINARY_DIR@" | ||
|
||
// Expose the root directory SVF is installed to | ||
#define SVF_INSTALL_ROOT "@CMAKE_INSTALL_PREFIX@" | ||
#define SVF_INSTALL_BINDIR "@CMAKE_INSTALL_PREFIX@/@SVF_INSTALL_BINDIR@" | ||
#define SVF_INSTALL_LIBDIR "@CMAKE_INSTALL_PREFIX@/@SVF_INSTALL_LIBDIR@" | ||
#define SVF_INSTALL_INCLUDEDIR "@CMAKE_INSTALL_PREFIX@/@SVF_INSTALL_INCLUDEDIR@" | ||
// Expose the SVF version | ||
#define SVF_VERSION "@SVF_VERSION@" | ||
|
||
// Expose where (relative to installation root) the ExtAPI bitcode file is | ||
#define SVF_EXTAPI_DIR "@CMAKE_INSTALL_PREFIX@/@SVF_EXTAPI_INSTALL_DIR@" | ||
#define SVF_EXTAPI_FILE "@CMAKE_INSTALL_PREFIX@/@SVF_EXTAPI_INSTALL_FILE@" | ||
// Expose the settings of this SVF build tree | ||
#cmakedefine SVF_COVERAGE | ||
#cmakedefine SVF_ASSERTIONS | ||
#cmakedefine SVF_WARN_AS_ERROR | ||
#cmakedefine SVF_EXPORT_DYNAMIC | ||
#cmakedefine SVF_NO_OPAQUE_PTRS | ||
#cmakedefine SVF_SANITIZE "@SVF_SANITIZE@" | ||
|
||
// Build mode used to build SVF | ||
// Also expose some compilation settings and configurations | ||
#define SVF_CXX_STANDARD "@CMAKE_CXX_STANDARD@" | ||
#define SVF_BUILD_TYPE "@CMAKE_BUILD_TYPE@" | ||
|
||
// Sanitiser mode used for building SVF | ||
#cmakedefine SVF_SANITIZE "@SVF_SANITIZE@" | ||
#cmakedefine SVF_ENABLE_EH | ||
#cmakedefine SVF_ENABLE_RTTI | ||
#cmakedefine SVF_SHARED_LIBS | ||
|
||
// Build options used when building SVF | ||
#cmakedefine SVF_COVERAGE | ||
#cmakedefine SVF_WARN_AS_ERROR | ||
#cmakedefine SVF_EXPORT_DYNAMIC | ||
#cmakedefine SVF_ENABLE_ASSERTIONS | ||
// Lastly expose the build and installation directories of SVF | ||
#define SVF_ROOT_DIR "@SVF_SOURCE_DIR@" | ||
#define SVF_BUILD_DIR "@SVF_BINARY_DIR@" | ||
#define SVF_INSTALL_DIR "@CMAKE_INSTALL_PREFIX@" | ||
#define SVF_INSTALL_BINDIR "@CMAKE_INSTALL_FULL_BINDIR@" | ||
#define SVF_INSTALL_LIBDIR "@CMAKE_INSTALL_FULL_LIBDIR@" | ||
#define SVF_INSTALL_INCLUDEDIR "@CMAKE_INSTALL_FULL_INCLUDEDIR@/SVF" | ||
|
||
// Set location(s) of where extapi.bc was built & installed to | ||
#define SVF_BUILD_EXTAPI_BC "@SVF_BINARY_DIR@/@CMAKE_INSTALL_INCLUDEDIR@/SVF/extapi.bc" | ||
#define SVF_INSTALL_EXTAPI_BC "@CMAKE_INSTALL_FULL_INCLUDEDIR@/SVF/extapi.bc" | ||
|
||
#endif // CONFIG_H_IN | ||
#endif // SVF_CONFIG_H_IN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
prefix=@CMAKE_INSTALL_PREFIX@ | ||
exec_prefix=@CMAKE_INSTALL_PREFIX@ | ||
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ | ||
sharedlibdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ | ||
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ | ||
exec_prefix=${prefix} | ||
libdir=${exec_prefix}/lib | ||
includedir=${prefix}/include | ||
|
||
Name: SVF | ||
Description: SVF Points to Analysis Framework | ||
Version: @SVF_VERSION@ | ||
|
||
Requires: | ||
Libs: -L${libdir} -L${sharedlibdir} -lSvfCore -lSvfLLVM | ||
Libs: -L${libdir} -lSvfCore -lSvfLLVM | ||
Cflags: -I${includedir} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,124 +2,65 @@ | |
|
||
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]") | ||
|
||
# Build and source tree information | ||
set(SVF_ROOT_DIR "@SVF_ROOT_DIR@") | ||
set(SVF_SOURCE_DIR "@SVF_SOURCE_DIR@") | ||
set(SVF_BUILD_DIR "@SVF_BUILD_DIR@") | ||
|
||
set(SVF_CORE_ROOT "@SVF_CORE_ROOT@") | ||
set(SVF_CORE_SRCS "@SVF_CORE_SRCS@") | ||
set(SVF_CORE_INCLUDES "@SVF_CORE_INCLUDES@") | ||
|
||
set(SVF_LLVM_ROOT "@SVF_LLVM_ROOT@") | ||
set(SVF_LLVM_SRCS "@SVF_LLVM_SRCS@") | ||
set(SVF_LLVM_TOOLS "@SVF_LLVM_TOOLS@") | ||
set(SVF_LLVM_INCLUDES "@SVF_LLVM_INCLUDES@") | ||
|
||
# Set the installed structures relative to this package's installation location | ||
set(SVF_INSTALL_BINDIR "@PACKAGE_SVF_INSTALL_BINDIR@") | ||
set(SVF_INSTALL_LIBDIR "@PACKAGE_SVF_INSTALL_LIBDIR@") | ||
set(SVF_INSTALL_CMAKEDIR "@PACKAGE_SVF_INSTALL_CMAKEDIR@") | ||
set(SVF_INSTALL_INCLUDEDIR "@PACKAGE_SVF_INSTALL_INCLUDEDIR@") | ||
set(SVF_INSTALL_EXTAPI_DIR "@PACKAGE_SVF_EXTAPI_INSTALL_DIR@") | ||
set(SVF_INSTALL_EXTAPI_FILE "@PACKAGE_SVF_EXTAPI_INSTALL_FILE@") | ||
set(SVF_INSTALL_TOP_LVL_INCLUDEDIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") | ||
include(CMakeFindDependencyMacro) | ||
|
||
# Lastly derive exposed settings about SVF's build configuration | ||
# Expose the settings of this SVF build tree | ||
set(SVF_VERSION "@SVF_VERSION@") | ||
set(SVF_SANITIZE "@SVF_SANITIZE@") | ||
set(SVF_COVERAGE "@SVF_COVERAGE@") | ||
set(SVF_ASSERTIONS "@SVF_ASSERTIONS@") | ||
set(SVF_WARN_AS_ERROR "@SVF_WARN_AS_ERROR@") | ||
set(SVF_EXPORT_DYNAMIC "@SVF_EXPORT_DYNAMIC@") | ||
set(SVF_ENABLE_ASSERTIONS "@SVF_ENABLE_ASSERTIONS@") | ||
set(SVF_ENABLE_OPAQUE_POINTERS "@SVF_ENABLE_OPAQUE_POINTERS@") | ||
set(SVF_NO_OPAQUE_PTRS "@SVF_NO_OPAQUE_PTRS@") | ||
|
||
# Expose some additional build flags like the C++ version and such | ||
# Also expose some compilation settings and configurations | ||
set(SVF_CXX_STANDARD "@CMAKE_CXXS_STANDARD@") | ||
set(SVF_SHARED_LIBS "@BUILD_SHARED_LIBS@") | ||
set(SVF_BUILD_TYPE "@CMAKE_BUILD_TYPE@") | ||
set(SVF_ENABLE_RTTI "@SVF_ENABLE_RTTI@") | ||
set(SVF_CXX_STANDARD "@CMAKE_CXX_STANDARD@") | ||
set(SVF_ENABLE_EXCEPTIONS "@SVF_ENABLE_EXCEPTIONS@") | ||
|
||
message(STATUS "Found SVF Package: | ||
SVF_SOURCE_DIR: ${SVF_SOURCE_DIR} | ||
SVF_BUILD_DIR: ${SVF_BUILD_DIR} | ||
SVF_CORE_ROOT: ${SVF_CORE_ROOT} | ||
SVF_CORE_SRCS: ${SVF_CORE_SRCS} | ||
SVF_CORE_INCLUDES: ${SVF_CORE_INCLUDES} | ||
SVF_LLVM_ROOT: ${SVF_LLVM_ROOT} | ||
SVF_LLVM_SRCS: ${SVF_LLVM_SRCS} | ||
SVF_LLVM_TOOLS: ${SVF_LLVM_TOOLS} | ||
SVF_LLVM_INCLUDES: ${SVF_LLVM_INCLUDES} | ||
|
||
SVF_INSTALL_BINDIR: ${SVF_INSTALL_BINDIR} | ||
SVF_INSTALL_LIBDIR: ${SVF_INSTALL_LIBDIR} | ||
SVF_INSTALL_CMAKEDIR: ${SVF_INSTALL_CMAKEDIR} | ||
SVF_INSTALL_INCLUDEDIR: ${SVF_INSTALL_INCLUDEDIR} | ||
SVF_INSTALL_EXTAPI_DIR: ${SVF_INSTALL_EXTAPI_DIR} | ||
SVF_INSTALL_EXTAPI_FILE: ${SVF_INSTALL_EXTAPI_FILE} | ||
SVF_INSTALL_TOP_LVL_INCLUDEDIR: ${SVF_INSTALL_TOP_LVL_INCLUDEDIR} | ||
SVF_SANITIZE: ${SVF_SANITIZE} | ||
SVF_COVERAGE: ${SVF_COVERAGE} | ||
SVF_WARN_AS_ERROR: ${SVF_WARN_AS_ERROR} | ||
SVF_EXPORT_DYNAMIC: ${SVF_EXPORT_DYNAMIC} | ||
SVF_ENABLE_ASSERTIONS: ${SVF_ENABLE_ASSERTIONS} | ||
SVF_ENABLE_OPAQUE_POINTERS: ${SVF_ENABLE_OPAQUE_POINTERS} | ||
SVF_BUILD_TYPE: ${SVF_BUILD_TYPE} | ||
SVF_ENABLE_RTTI: ${SVF_ENABLE_RTTI} | ||
SVF_CXX_STANDARD: ${SVF_CXX_STANDARD} | ||
SVF_ENABLE_EXCEPTIONS: ${SVF_EABLE_EXCEPTIONS}") | ||
|
||
# Find Z3 and its include directory from the top-level include file; try from CMake package first | ||
# Try to find Z3 using the same mechanism as in the top-level CMake script | ||
find_package( | ||
Z3 | ||
CONFIG | ||
HINTS | ||
${Z3_DIR} | ||
$ENV{Z3_DIR}) | ||
|
||
if(Z3_FOUND) | ||
message(STATUS "Found Z3 CMake package: | ||
Z3 Version Major: ${Z3_VERSION_MAJOR} | ||
Z3 Version Minor: ${Z3_VERSION_MINOR} | ||
Z3 Version Patch: ${Z3_VERSION_PATCH} | ||
Z3 Version Tweak: ${Z3_VERSION_TWEAK} | ||
Z3 Version String: ${Z3_VERSION_STRING} | ||
Z3 C Include Directories: ${Z3_C_INCLUDE_DIRS} | ||
Z3 C++ Include Directories: ${Z3_CXX_INCLUDE_DIRS} | ||
Z3 Libraries: ${Z3_LIBRARIES}") | ||
# Use the imported target from the Z3 CMake package | ||
set(Z3_IMPORTED_TARGET z3::libz3) | ||
else() | ||
find_library( | ||
Z3_LIBRARIES REQUIRED | ||
NAMES z3 | ||
HINTS ${Z3_DIR} ENV Z3_DIR | ||
PATH_SUFFIXES bin lib) | ||
find_path( | ||
Z3_INCLUDES REQUIRED | ||
NAMES z3++.h | ||
HINTS ${Z3_DIR} ENV Z3_DIR | ||
PATH_SUFFIXES include z3) | ||
message(STATUS "Z3 STATUS: | ||
Z3 library file: ${Z3_LIBRARIES} | ||
Z3 include directory: ${Z3_INCLUDES}") | ||
|
||
# Add the Z3 include directory and link the Z3 library to all targets of SVF | ||
set(CMAKE_INSTALL_RPATH ${Z3_INCLUDES}) | ||
include_directories(SYSTEM ${Z3_INCLUDES}) | ||
# Explicitly try to find libz3.so/libz3.a and the header files | ||
if(SVF_SHARED_LIBS) | ||
find_library(Z3_LIBRARIES libz3.so HINTS ${Z3_DIR} ENV Z3_DIR) | ||
else() | ||
find_library(Z3_LIBRARIES libz3.a HINTS ${Z3_DIR} ENV Z3_DIR) | ||
endif() | ||
|
||
# Try to find any (even different static/shared mode) instances of Z3 as a fall-back | ||
if(NOT Z3_LIBRARIES) | ||
find_library(Z3_LIBRARIES z3 HINTS ${Z3_DIR} ENV Z3_DIR REQUIRED) | ||
endif() | ||
|
||
# Also find Z3's header files | ||
find_path(Z3_INCLUDES z3++.h HINTS ${Z3_DIR} ENV Z3_DIR REQUIRED) | ||
|
||
# If found, manually create a Z3 package to nicely export the location(s) | ||
add_library(z3::libz3 UNKNOWN IMPORTED) | ||
set_target_properties(z3::libz3 PROPERTIES IMPORTED_LOCATION "${Z3_LIBRARIES}") | ||
set_target_properties(z3::libz3 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${Z3_INCLUDES}") | ||
|
||
# Set the imported target | ||
set(Z3_IMPORTED_TARGET z3::libz3) | ||
endif() | ||
|
||
include(CMakeFindDependencyMacro) | ||
|
||
find_dependency( | ||
LLVM | ||
CONFIG | ||
REQUIRED | ||
HINTS | ||
"${LLVM_DIR}" | ||
"$ENV{LLVM_DIR}" | ||
PATH_SUFFIXES | ||
"lib" | ||
"lib/cmake" | ||
"lib/cmake/llvm") | ||
"$ENV{LLVM_DIR}") | ||
|
||
check_required_components("@PROJECT_NAME@") |
Oops, something went wrong.