From 15f3822f53592d875d0e09f8ba08b4a5a122c673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Surovi=C4=8D?= Date: Thu, 24 Sep 2020 12:42:51 +0200 Subject: [PATCH 1/2] Syncs up anvill with remill in terms of build --- CMakeLists.txt | 60 ++++---------------------------------------------- 1 file changed, 4 insertions(+), 56 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d8b776ed..eec1393e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ cmake_minimum_required(VERSION 3.2) include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/settings.cmake") include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/utils.cmake") -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") +# list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") FindAndSelectClangCompiler() @@ -40,63 +40,11 @@ endif() # # remill -if(NOT TARGET remill) - if("${PLATFORM_NAME}" STREQUAL "windows") - set(REMILL_FINDPACKAGE_HINTS HINTS "${CMAKE_INSTALL_PREFIX}/remill/lib") - endif() - - find_package(remill REQUIRED ${REMILL_FINDPACKAGE_HINTS}) -endif() - -# llvm -find_package(LLVM REQUIRED CONFIG HINTS ${FINDPACKAGE_LLVM_HINTS}) - -string(REPLACE "." ";" LLVM_VERSION_LIST ${LLVM_PACKAGE_VERSION}) -list(GET LLVM_VERSION_LIST 0 LLVM_MAJOR_VERSION) -list(GET LLVM_VERSION_LIST 1 LLVM_MINOR_VERSION) -set(REMILL_LLVM_VERSION "${LLVM_MAJOR_VERSION}.${LLVM_MINOR_VERSION}") - -set(LLVM_LIBRARIES - LLVMCore LLVMAnalysis LLVMSupport LLVMipo LLVMIRReader - LLVMBitReader LLVMBitWriter LLVMTransformUtils LLVMScalarOpts - LLVMLTO -) -list(APPEND PROJECT_LIBRARIES ${LLVM_LIBRARIES}) -list(APPEND PROJECT_DEFINITIONS ${LLVM_DEFINITIONS}) -list(APPEND PROJECT_INCLUDEDIRECTORIES ${LLVM_INCLUDE_DIRS}) - -# google log module -find_package(glog REQUIRED) -list(APPEND PROJECT_LIBRARIES glog::glog) - -# gflags -find_package(gflags REQUIRED) -list(APPEND PROJECT_LIBRARIES gflags) - -# xed -find_package(XED REQUIRED) -list(APPEND PROJECT_LIBRARIES ${XED_LIBRARIES}) -list(APPEND PROJECT_INCLUDEDIRECTORIES ${XED_INCLUDE_DIRS}) - -# z3 -if (LLVM_Z3_INSTALL_DIR) - find_package(Z3 4.7.1) - set(need_z3 TRUE) -elseif(DEFINED ENV{TRAILOFBITS_LIBRARIES}) - set(LLVM_Z3_INSTALL_DIR "$ENV{TRAILOFBITS_LIBRARIES}/z3") - set(need_z3 TRUE) -else() - set(need_z3 FALSE) -endif() - -if(need_z3) - find_package(Z3 4.7.1) - if (NOT Z3_FOUND) - message(WARNING "Z3 >= 4.7.1 has not been found in LLVM_Z3_INSTALL_DIR: ${LLVM_Z3_INSTALL_DIR}.") - endif() - list(APPEND PROJECT_LIBRARIES Z3) +if("${PLATFORM_NAME}" STREQUAL "windows") + set(REMILL_FINDPACKAGE_HINTS HINTS "${CMAKE_INSTALL_PREFIX}/remill/lib") endif() +find_package(remill REQUIRED ${REMILL_FINDPACKAGE_HINTS}) # # target settings From 0b1fa3af432ee62da51e11a7bcab72670666647b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Surovi=C4=8D?= Date: Thu, 24 Sep 2020 12:47:14 +0200 Subject: [PATCH 2/2] Removes unneeded cmake modules --- CMakeLists.txt | 1 - cmake/modules/FindZ3.cmake | 112 ------------------------------------- cmake/modules/testz3.cpp | 8 --- 3 files changed, 121 deletions(-) delete mode 100644 cmake/modules/FindZ3.cmake delete mode 100644 cmake/modules/testz3.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index eec1393e9..9520348e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,6 @@ cmake_minimum_required(VERSION 3.2) include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/settings.cmake") include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/utils.cmake") -# list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") FindAndSelectClangCompiler() diff --git a/cmake/modules/FindZ3.cmake b/cmake/modules/FindZ3.cmake deleted file mode 100644 index 32f6f4160..000000000 --- a/cmake/modules/FindZ3.cmake +++ /dev/null @@ -1,112 +0,0 @@ -INCLUDE(CheckCXXSourceRuns) - -# Function to check Z3's version -function(check_z3_version z3_include z3_lib) - # Get lib path - get_filename_component(z3_lib_path ${z3_lib} PATH) - - # Try to find a threading module in case Z3 was built with threading support. - # Threads are required elsewhere in LLVM, but not marked as required here because - # Z3 could have been compiled without threading support. - find_package(Threads) - set(z3_link_libs "-lz3" "${CMAKE_THREAD_LIBS_INIT}") - - try_run( - Z3_RETURNCODE - Z3_COMPILED - ${CMAKE_BINARY_DIR} - ${CMAKE_SOURCE_DIR}/cmake/modules/testz3.cpp - COMPILE_DEFINITIONS -I"${z3_include}" - LINK_LIBRARIES -L${z3_lib_path} ${z3_link_libs} - RUN_OUTPUT_VARIABLE SRC_OUTPUT - ) - - if(Z3_COMPILED) - string(REGEX REPLACE "([0-9]*\\.[0-9]*\\.[0-9]*)" "\\1" - z3_version "${SRC_OUTPUT}") - set(Z3_VERSION_STRING ${z3_version} PARENT_SCOPE) - endif() -endfunction(check_z3_version) - -# Looking for Z3 in LLVM_Z3_INSTALL_DIR -find_path(Z3_INCLUDE_DIR NAMES z3.h - NO_DEFAULT_PATH - PATHS ${LLVM_Z3_INSTALL_DIR}/include - PATH_SUFFIXES libz3 z3 - ) - -find_library(Z3_LIBS NAMES z3 libz3 - NO_DEFAULT_PATH - PATHS ${LLVM_Z3_INSTALL_DIR} - PATH_SUFFIXES lib bin - ) - -# If Z3 has not been found in LLVM_Z3_INSTALL_DIR look in the default directories -find_path(Z3_INCLUDE_DIR NAMES z3.h - PATH_SUFFIXES libz3 z3 - ) - -find_library(Z3_LIBS NAMES z3 libz3 - PATH_SUFFIXES lib bin - ) - -# Searching for the version of the Z3 library is a best-effort task -unset(Z3_VERSION_STRING) - -# First, try to check it dynamically, by compiling a small program that -# prints Z3's version -if(Z3_INCLUDE_DIR AND Z3_LIBS) - # We do not have the Z3 binary to query for a version. Try to use - # a small C++ program to detect it via the Z3_get_version() API call. - check_z3_version(${Z3_INCLUDE_DIR} ${Z3_LIBS}) -endif() - -# If the dynamic check fails, we might be cross compiling: if that's the case, -# check the version in the headers, otherwise, fail with a message -if(NOT Z3_VERSION_STRING AND (CMAKE_CROSSCOMPILING AND - Z3_INCLUDE_DIR AND - EXISTS "${Z3_INCLUDE_DIR}/z3_version.h")) - # TODO: print message warning that we couldn't find a compatible lib? - - # Z3 4.8.1+ has the version is in a public header. - file(STRINGS "${Z3_INCLUDE_DIR}/z3_version.h" - z3_version_str REGEX "^#define[\t ]+Z3_MAJOR_VERSION[\t ]+.*") - string(REGEX REPLACE "^.*Z3_MAJOR_VERSION[\t ]+([0-9]).*$" "\\1" - Z3_MAJOR "${z3_version_str}") - - file(STRINGS "${Z3_INCLUDE_DIR}/z3_version.h" - z3_version_str REGEX "^#define[\t ]+Z3_MINOR_VERSION[\t ]+.*") - string(REGEX REPLACE "^.*Z3_MINOR_VERSION[\t ]+([0-9]).*$" "\\1" - Z3_MINOR "${z3_version_str}") - - file(STRINGS "${Z3_INCLUDE_DIR}/z3_version.h" - z3_version_str REGEX "^#define[\t ]+Z3_BUILD_NUMBER[\t ]+.*") - string(REGEX REPLACE "^.*Z3_BUILD_VERSION[\t ]+([0-9]).*$" "\\1" - Z3_BUILD "${z3_version_str}") - - set(Z3_VERSION_STRING ${Z3_MAJOR}.${Z3_MINOR}.${Z3_BUILD}) - unset(z3_version_str) -endif() - -if(NOT Z3_VERSION_STRING) - # Give up: we are unable to obtain a version of the Z3 library. Be - # conservative and force the found version to 0.0.0 to make version - # checks always fail. - set(Z3_VERSION_STRING "0.0.0") -endif() - -# handle the QUIETLY and REQUIRED arguments and set Z3_FOUND to TRUE if -# all listed variables are TRUE -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Z3 - REQUIRED_VARS Z3_LIBS Z3_INCLUDE_DIR - VERSION_VAR Z3_VERSION_STRING) -if(Z3_FOUND AND NOT TARGET Z3) - add_library(Z3 UNKNOWN IMPORTED) - set_target_properties(Z3 PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${Z3_INCLUDE_DIR}" - IMPORTED_LOCATION "${Z3_LIBS}" - ) - set(Z3_LIBRARIES "Z3") -endif() -mark_as_advanced(Z3_INCLUDE_DIR Z3_LIBS Z3_LIBRARIES) diff --git a/cmake/modules/testz3.cpp b/cmake/modules/testz3.cpp deleted file mode 100644 index 2c55ba7d6..000000000 --- a/cmake/modules/testz3.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include -int main() { - unsigned int major, minor, build, rev; - Z3_get_version(&major, &minor, &build, &rev); - printf("%u.%u.%u", major, minor, build); - return 0; -}