aboutsummaryrefslogtreecommitdiffhomepage
path: root/CMakeModules/FindLLVM.cmake
diff options
context:
space:
mode:
authorAlexandre Bouvier <[email protected]>2023-02-24 23:45:38 +0100
committerAlexandre Bouvier <[email protected]>2023-02-28 17:46:20 +0100
commit7b8a5413add02004d778252c0b67bf921c1fb7d8 (patch)
tree344fce8b5837273e8791a0f28622d075a215d712 /CMakeModules/FindLLVM.cmake
parentb44527a25908e54b26ce2a4e9fcdf45f36e64993 (diff)
downloadyuzu-android-7b8a5413add02004d778252c0b67bf921c1fb7d8.tar.gz
yuzu-android-7b8a5413add02004d778252c0b67bf921c1fb7d8.zip
cmake: support components in find modules
Diffstat (limited to 'CMakeModules/FindLLVM.cmake')
-rw-r--r--CMakeModules/FindLLVM.cmake18
1 files changed, 14 insertions, 4 deletions
diff --git a/CMakeModules/FindLLVM.cmake b/CMakeModules/FindLLVM.cmake
index 513d9a536..efbd0ca46 100644
--- a/CMakeModules/FindLLVM.cmake
+++ b/CMakeModules/FindLLVM.cmake
@@ -2,15 +2,25 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later
-find_package(LLVM QUIET CONFIG)
+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 CONFIG_MODE)
+find_package_handle_standard_args(LLVM HANDLE_COMPONENTS CONFIG_MODE)
-if (LLVM_FOUND AND NOT TARGET LLVM::Demangle)
+if (LLVM_FOUND AND LLVM_Demangle_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})
+ # prefer shared LLVM: https://github.com/llvm/llvm-project/issues/34593
+ # but use ugly hack because llvm_config doesn't support interface library
+ add_library(_dummy_lib SHARED EXCLUDE_FROM_ALL src/yuzu/main.cpp)
+ 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()