From f380ed352072a274eefc1fc997d811f088e3bcc1 Mon Sep 17 00:00:00 2001 From: Matteo Date: Mon, 28 Oct 2024 16:04:05 +0100 Subject: [PATCH] Add Bitwuzla library --- BITWUZLAConfig.cmake.in | 39 ++++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 1 + bitwuzla.cmake | 42 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 BITWUZLAConfig.cmake.in create mode 100644 bitwuzla.cmake diff --git a/BITWUZLAConfig.cmake.in b/BITWUZLAConfig.cmake.in new file mode 100644 index 0000000..3ed1891 --- /dev/null +++ b/BITWUZLAConfig.cmake.in @@ -0,0 +1,39 @@ +if(BITWUZLA_FOUND) + return() +endif() + +get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE) + +find_library(BITWUZLA_LIBRARY bitwuzla PATHS "${PACKAGE_PREFIX_DIR}/lib" NO_CACHE REQUIRED NO_DEFAULT_PATH) +add_library(BITWUZLA::BITWUZLA STATIC IMPORTED) +set_target_properties(BITWUZLA::BITWUZLA PROPERTIES + IMPORTED_CONFIGURATIONS "NOCONFIG" + IMPORTED_LOCATION_NOCONFIG "${BITWUZLA_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${PACKAGE_PREFIX_DIR}/include" +) + +find_library(BITWUZLABB_LIBRARY bitwuzlabb PATHS "${PACKAGE_PREFIX_DIR}/lib" NO_CACHE REQUIRED NO_DEFAULT_PATH) +add_library(BITWUZLA::BITWUZLABB STATIC IMPORTED) +set_target_properties(BITWUZLA::BITWUZLABB PROPERTIES + IMPORTED_CONFIGURATIONS "NOCONFIG" + IMPORTED_LOCATION_NOCONFIG "${BITWUZLABB_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${PACKAGE_PREFIX_DIR}/include" +) + +find_library(BITWUZLABV_LIBRARY bitwuzlabv PATHS "${PACKAGE_PREFIX_DIR}/lib" NO_CACHE REQUIRED NO_DEFAULT_PATH) +add_library(BITWUZLA::BITWUZLABV STATIC IMPORTED) +set_target_properties(BITWUZLA::BITWUZLABV PROPERTIES + IMPORTED_CONFIGURATIONS "NOCONFIG" + IMPORTED_LOCATION_NOCONFIG "${BITWUZLABV_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${PACKAGE_PREFIX_DIR}/include" +) + +find_library(BITWUZLALS_LIBRARY bitwuzlals PATHS "${PACKAGE_PREFIX_DIR}/lib" NO_CACHE REQUIRED NO_DEFAULT_PATH) +add_library(BITWUZLA::BITWUZLALS STATIC IMPORTED) +set_target_properties(BITWUZLA::BITWUZLALS PROPERTIES + IMPORTED_CONFIGURATIONS "NOCONFIG" + IMPORTED_LOCATION_NOCONFIG "${BITWUZLALS_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${PACKAGE_PREFIX_DIR}/include" +) + +set(BITWUZLA_FOUND ON) diff --git a/CMakeLists.txt b/CMakeLists.txt index a7c4afe..81184ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,6 +76,7 @@ simple_git(https://github.com/stp/stp a9bc247d98cd98213b2d0f6821dc51b823c50483 "-DSTATICCOMPILE:STRING=ON" ) include(xed.cmake) +include(bitwuzla.cmake) if(NOT USE_SYSTEM_LLVM) include(llvm.cmake) endif() diff --git a/bitwuzla.cmake b/bitwuzla.cmake new file mode 100644 index 0000000..481cce9 --- /dev/null +++ b/bitwuzla.cmake @@ -0,0 +1,42 @@ +find_package(Python3 COMPONENTS Interpreter REQUIRED) +message(STATUS "Python3: ${Python3_EXECUTABLE}") + +# TODO: pass compiler flags + +set(CONFIGURE_ARGS + "--prefix" + "/install" + "release" +) + +if(BUILD_SHARED_LIBS) + list(APPEND CONFIGURE_ARGS "--shared") +else() + list(APPEND CONFIGURE_ARGS "--static") +endif() + +ExternalProject_Add(bitwuzla + GIT_REPOSITORY + "https://github.com/bitwuzla/bitwuzla" + GIT_TAG + "0.6.0" + GIT_PROGRESS + ON + GIT_SHALLOW + ON + CMAKE_CACHE_ARGS + ${CMAKE_ARGS} + BUILD_IN_SOURCE + 1 + CONFIGURE_COMMAND + "${Python3_EXECUTABLE}" "/configure.py" ${CONFIGURE_ARGS} + BUILD_COMMAND + "ninja" "-C" "/build" "install" + INSTALL_COMMAND + "${CMAKE_COMMAND}" -E copy_directory /install "${CMAKE_INSTALL_PREFIX}" + PREFIX + bitwuzla-prefix +) + +# TODO: generate BITWUZLAVersion.cmake as well file +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/BITWUZLAConfig.cmake.in" "${CMAKE_INSTALL_PREFIX}/lib/cmake/bitwuzla/BITWUZLAConfig.cmake" @ONLY)