2024-03-05 02:42:40 -06:00
|
|
|
# SPDX-FileCopyrightText: 2023 Alexandre Bouvier <contact@amb.tf>
|
2024-03-23 20:15:57 -05:00
|
|
|
# SPDX-FileCopyrightText: 2024 suyu Emulator Project
|
2024-03-05 02:42:40 -06:00
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
find_package(LLVM QUIET COMPONENTS CONFIG)
|
|
|
|
if (LLVM_FOUND)
|
|
|
|
separate_arguments(LLVM_DEFINITIONS)
|
|
|
|
if (LLVMDemangle IN_LIST LLVM_AVAILABLE_LIBS)
|
|
|
|
set(LLVM_Demangle_FOUND TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
find_package_handle_standard_args(LLVM HANDLE_COMPONENTS CONFIG_MODE)
|
|
|
|
|
|
|
|
if (LLVM_FOUND AND LLVM_Demangle_FOUND AND NOT TARGET LLVM::Demangle)
|
|
|
|
add_library(LLVM::Demangle INTERFACE IMPORTED)
|
|
|
|
target_compile_definitions(LLVM::Demangle INTERFACE ${LLVM_DEFINITIONS})
|
|
|
|
target_include_directories(LLVM::Demangle INTERFACE ${LLVM_INCLUDE_DIRS})
|
|
|
|
# prefer shared LLVM: https://github.com/llvm/llvm-project/issues/34593
|
|
|
|
# but use ugly hack because llvm_config doesn't support interface library
|
2024-03-08 03:06:48 -06:00
|
|
|
add_library(_dummy_lib SHARED EXCLUDE_FROM_ALL src/suyu/main.cpp)
|
2024-03-05 02:42:40 -06:00
|
|
|
llvm_config(_dummy_lib USE_SHARED demangle)
|
|
|
|
get_target_property(LLVM_LIBRARIES _dummy_lib LINK_LIBRARIES)
|
|
|
|
target_link_libraries(LLVM::Demangle INTERFACE ${LLVM_LIBRARIES})
|
|
|
|
endif()
|