From 2062b6212a51677d13a19ebefc59247e69138d7f Mon Sep 17 00:00:00 2001 From: Peter Goodman Date: Tue, 7 Jan 2025 11:55:30 -0500 Subject: [PATCH] Try to fix CMake for ZStd. --- .gitmodules | 1 + CMakeLists.txt | 45 ++++++++++++++++++++---------- vendor/llvm-project/CMakeLists.txt | 5 +--- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/.gitmodules b/.gitmodules index 48989bf4c..7fcbb2c47 100644 --- a/.gitmodules +++ b/.gitmodules @@ -51,6 +51,7 @@ [submodule "vendor/vast/src"] path = vendor/vast/src url = https://github.com/trailofbits/vast.git + branch = mx_codegen [submodule "vendor/intervaltree/src"] path = vendor/intervaltree/src url = https://github.com/ekg/intervaltree.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 60c939027..b446f876e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,26 +57,43 @@ if(NOT TARGET gflags::gflags) endif() endif() -find_package(Filesystem REQUIRED COMPONENTS Final Experimental) -find_package(CapnProto CONFIG REQUIRED) -find_package(xxHash CONFIG REQUIRED) -find_package(zstd CONFIG REQUIRED) +find_package(Filesystem REQUIRED COMPONENTS Final Experimental GLOBAL) +find_package(CapnProto CONFIG REQUIRED GLOBAL) +find_package(xxHash CONFIG REQUIRED GLOBAL) +find_package(zstd CONFIG REQUIRED GLOBAL) + +find_path(ZSTD_INCLUDE_DIRS + NAMES zstd.h + HINTS "${MX_VENDOR_INSTALL_DIR}/${MX_INSTALL_INCLUDE_DIR}" + "${CMAKE_INSTALL_PREFIX}/${MX_INSTALL_INCLUDE_DIR}") + +find_library(ZSTD_LIBRARIES + NAMES zstd + HINTS "${MX_VENDOR_INSTALL_DIR}/${MX_INSTALL_LIB_DIR}" + "${CMAKE_INSTALL_PREFIX}/${MX_INSTALL_LIB_DIR}") + if(NOT TARGET zstd::libzstd_static) - message(FATAL_ERROR "Cannot find appropriate static zstd target; known targets are ${zstd_LIBRARIES}") + add_library(zstd::libzstd_static STATIC IMPORTED) + set_target_properties(zstd::libzstd_static PROPERTIES + INTERFACE_COMPILE_FEATURES "cxx_std_${CMAKE_CXX_STANDARD}" + INTERFACE_INCLUDE_DIRECTORIES ${ZSTD_INCLUDE_DIRS} + INTERFACE_LINK_LIBRARIES ${ZSTD_LIBRARIES} + ) endif() + if(NOT TARGET zstd::zstd) add_library(zstd::zstd ALIAS zstd::libzstd_static) endif() -find_package(gap CONFIG REQUIRED) -find_package(Clang CONFIG REQUIRED) -find_package(pasta CONFIG REQUIRED) -find_package(glog CONFIG REQUIRED) -find_package(reproc++ CONFIG REQUIRED) -find_package(RocksDB CONFIG REQUIRED) -find_package(LLVM CONFIG REQUIRED) -find_package(MLIR CONFIG REQUIRED) -find_package(VAST CONFIG REQUIRED) +find_package(gap CONFIG REQUIRED GLOBAL) +find_package(glog CONFIG REQUIRED GLOBAL) +find_package(reproc++ CONFIG REQUIRED GLOBAL) +find_package(RocksDB CONFIG REQUIRED GLOBAL) +find_package(LLVM CONFIG REQUIRED GLOBAL) +find_package(MLIR CONFIG REQUIRED GLOBAL) +find_package(VAST CONFIG REQUIRED GLOBAL) +find_package(Clang CONFIG REQUIRED GLOBAL) +find_package(pasta CONFIG REQUIRED GLOBAL) include("cmake/mlir.cmake") include("cmake/vast.cmake") diff --git a/vendor/llvm-project/CMakeLists.txt b/vendor/llvm-project/CMakeLists.txt index 24c86e8a8..0c1dcc778 100644 --- a/vendor/llvm-project/CMakeLists.txt +++ b/vendor/llvm-project/CMakeLists.txt @@ -15,8 +15,6 @@ if(NOT MX_USE_VENDORED_CLANG) endif() endif() -find_package(zstd CONFIG REQUIRED QUIET HINTS "${MX_VENDOR_INSTALL_DIR}") - set(src_dir "${CMAKE_CURRENT_LIST_DIR}/src") set(build_dir "${CMAKE_CURRENT_BINARY_DIR}/build") @@ -93,9 +91,8 @@ execute_process(COMMAND ${CMAKE_COMMAND} -DLLVM_INCLUDE_TESTS:BOOL=OFF -DLLVM_INCLUDE_TOOLS:BOOL=ON -DLLVM_INSTALL_UTILS:BOOL=ON - -DLLVM_ENABLE_ZSTD:BOOL=ON + -DLLVM_ENABLE_ZSTD:BOOL=OFF -DLLVM_ENABLE_LLD:BOOL=${LLVM_ENABLE_LLD} - "-Dzstd_DIR=${zstd_DIR}" "${src_dir}/llvm" WORKING_DIRECTORY "${build_dir}")