cmake: prefer system llvm library

This commit is contained in:
Alexandre Bouvier 2023-01-23 01:51:12 +01:00
parent f99f618d45
commit 34b1ea9c19
11 changed files with 28 additions and 10 deletions

View File

@ -208,6 +208,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
find_package(enet 1.3 MODULE) find_package(enet 1.3 MODULE)
find_package(fmt 9 REQUIRED) find_package(fmt 9 REQUIRED)
find_package(inih MODULE) find_package(inih MODULE)
find_package(LLVM MODULE)
find_package(lz4 REQUIRED) find_package(lz4 REQUIRED)
find_package(nlohmann_json 3.8 REQUIRED) find_package(nlohmann_json 3.8 REQUIRED)
find_package(Opus 1.3 MODULE) find_package(Opus 1.3 MODULE)

View File

@ -0,0 +1,16 @@
# SPDX-FileCopyrightText: 2023 Alexandre Bouvier <contact@amb.tf>
#
# SPDX-License-Identifier: GPL-3.0-or-later
find_package(LLVM QUIET CONFIG)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LLVM CONFIG_MODE)
if (LLVM_FOUND AND NOT TARGET LLVM::Demangle)
add_library(LLVM::Demangle INTERFACE IMPORTED)
llvm_map_components_to_libnames(LLVM_LIBRARIES demangle)
target_compile_definitions(LLVM::Demangle INTERFACE ${LLVM_DEFINITIONS})
target_include_directories(LLVM::Demangle INTERFACE ${LLVM_INCLUDE_DIRS})
target_link_libraries(LLVM::Demangle INTERFACE ${LLVM_LIBRARIES})
endif()

View File

@ -158,6 +158,9 @@ if (YUZU_USE_EXTERNAL_VULKAN_HEADERS)
add_subdirectory(Vulkan-Headers EXCLUDE_FROM_ALL) add_subdirectory(Vulkan-Headers EXCLUDE_FROM_ALL)
endif() endif()
add_library(demangle STATIC) if (NOT TARGET LLVM::Demangle)
target_include_directories(demangle PUBLIC ./demangle) add_library(demangle STATIC)
target_sources(demangle PRIVATE demangle/ItaniumDemangle.cpp) target_include_directories(demangle PUBLIC ./demangle)
target_sources(demangle PRIVATE demangle/ItaniumDemangle.cpp)
add_library(LLVM::Demangle ALIAS demangle)
endif()

View File

@ -11,8 +11,8 @@
// file does not yet support: // file does not yet support:
// - C++ modules TS // - C++ modules TS
#include "Demangle.h" #include "llvm/Demangle/Demangle.h"
#include "ItaniumDemangle.h" #include "llvm/Demangle/ItaniumDemangle.h"
#include <cassert> #include <cassert>
#include <cctype> #include <cctype>

View File

@ -177,7 +177,7 @@ endif()
create_target_directory_groups(common) create_target_directory_groups(common)
target_link_libraries(common PUBLIC ${Boost_LIBRARIES} fmt::fmt microprofile Threads::Threads) target_link_libraries(common PUBLIC ${Boost_LIBRARIES} fmt::fmt microprofile Threads::Threads)
target_link_libraries(common PRIVATE lz4::lz4 zstd::zstd demangle) target_link_libraries(common PRIVATE lz4::lz4 zstd::zstd LLVM::Demangle)
if (YUZU_USE_PRECOMPILED_HEADERS) if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(common PRIVATE precompiled_headers.h) target_precompile_headers(common PRIVATE precompiled_headers.h)

View File

@ -1,13 +1,11 @@
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include <llvm/Demangle/Demangle.h>
#include "common/demangle.h" #include "common/demangle.h"
#include "common/scope_exit.h" #include "common/scope_exit.h"
namespace llvm {
char* itaniumDemangle(const char* mangled_name, char* buf, size_t* n, int* status);
}
namespace Common { namespace Common {
std::string DemangleSymbol(const std::string& mangled) { std::string DemangleSymbol(const std::string& mangled) {