From 68cbd2640d4663fe29e21234dc068769cb9bc673 Mon Sep 17 00:00:00 2001 From: Guilherme Janczak Date: Fri, 3 May 2024 11:56:15 +0000 Subject: [PATCH] fix linking against LLVM shared library 967280f140f39283e9e6997ffa6426329d94f611 broke linking against libLLVM.so because it used the outdated way to link against LLVM from CMake. This causes a compilation failure on systems that don't have the LLVM static libraries, such as Arch Linux. On systems that have the static libraries, it'll use them and increase binary sizes massively. Switch to the newer llvm_config CMake macro from LLVM. --- Source/Core/UICommon/CMakeLists.txt | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/Source/Core/UICommon/CMakeLists.txt b/Source/Core/UICommon/CMakeLists.txt index 87dff079b5..99db3a4eb8 100644 --- a/Source/Core/UICommon/CMakeLists.txt +++ b/Source/Core/UICommon/CMakeLists.txt @@ -52,28 +52,22 @@ if(TARGET LibUSB::LibUSB) endif() if(ENABLE_LLVM) - find_package(LLVM CONFIG QUIET) - if(LLVM_FOUND AND TARGET LLVM) + find_package(LLVM CONFIG) + if(LLVM_FOUND) message(STATUS "LLVM found, enabling LLVM support in disassembler") # Minimal documentation about LLVM's CMake functions is available here: # https://releases.llvm.org/16.0.0/docs/CMake.html#embedding-llvm-in-your-project + # https://groups.google.com/g/llvm-dev/c/YeEVe7HTasQ?pli=1 # # However, you have to read the source code in any case. # Look for LLVM-Config.cmake in your (Unix) system: # $ find /usr -name LLVM-Config\\.cmake 2>/dev/null - separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS}) - target_compile_definitions(uicommon - PRIVATE HAVE_LLVM ${LLVM_DEFINITIONS_LIST} - ) - target_link_directories(uicommon PRIVATE ${LLVM_LIBRARY_DIRS}) llvm_expand_pseudo_components(LLVM_EXPAND_COMPONENTS AllTargetsInfos AllTargetsDisassemblers AllTargetsCodeGens ) - llvm_map_components_to_libnames(LLVM_LIBRARIES + llvm_config(uicommon USE_SHARED mcdisassembler target ${LLVM_EXPAND_COMPONENTS} ) - target_link_libraries(uicommon PRIVATE ${LLVM_LIBRARIES}) - target_include_directories(uicommon PRIVATE ${LLVM_INCLUDE_DIRS}) endif() endif()