From db5402dc098374f49f72baa0534017a21bc03205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 23 May 2021 12:16:14 +0200 Subject: [PATCH] build: Use system libraries if so desired. (#210) Co-authored-by: WerWolv --- CMakeLists.txt | 19 +++++++++++++++++-- plugins/libimhex/CMakeLists.txt | 9 ++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 17f19813e..47314e306 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,13 +25,28 @@ findLibraries() detectOS() detectArch() +if (NOT USE_SYSTEM_LLVM) + add_subdirectory(external/llvm) +else() + find_package(LLVM REQUIRED Demangle) +endif() +if (NOT USE_SYSTEM_YARA) + add_subdirectory(external/yara) +else() + find_package(yara REQUIRED) +endif() + # Add bundled dependencies -add_subdirectory(external/llvm) -add_subdirectory(external/yara) add_subdirectory(plugins/libimhex) # Add include directories include_directories(include ${MBEDTLS_INCLUDE_DIRS} ${CAPSTONE_INCLUDE_DIRS} ${MAGIC_INCLUDE_DIRS} ${Python_INCLUDE_DIRS}) +if (USE_SYSTEM_LLVM) + include_directories(include ${LLVM_INCLUDE_DIRS}) +endif() +if (USE_SYSTEM_YARA) + include_directories(include ${YARA_INCLUDE_DIRS}) +endif() addVersionDefines() configurePackageCreation() diff --git a/plugins/libimhex/CMakeLists.txt b/plugins/libimhex/CMakeLists.txt index 64bc6db32..5e4018355 100644 --- a/plugins/libimhex/CMakeLists.txt +++ b/plugins/libimhex/CMakeLists.txt @@ -5,9 +5,16 @@ set(CMAKE_CXX_STANDARD 20) set(BUILD_SHARED_LIBS OFF) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../external/ImGui ${CMAKE_CURRENT_BINARY_DIR}/external/ImGui) -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../external/nlohmann_json ${CMAKE_CURRENT_BINARY_DIR}/external/nlohmann_json) + +if(USE_SYSTEM_NLOHMANN_JSON) + find_package(nlohmann_json REQUIRED) +else() + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../external/nlohmann_json ${CMAKE_CURRENT_BINARY_DIR}/external/nlohmann_json) +endif() + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../external/nativefiledialog ${CMAKE_CURRENT_BINARY_DIR}/external/nativefiledialog EXCLUDE_FROM_ALL) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../external/fmt ${CMAKE_CURRENT_BINARY_DIR}/external/fmt) + set(XDGPP_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../external/xdgpp") set(CMAKE_USE_MBEDTLS ON) set(BUILD_CURL_EXE OFF)