summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2021-01-06 17:22:48 +0100
committerMilian Wolff <milian.wolff@kdab.com>2021-01-11 17:24:42 +0000
commit59416050f2faf5f53009c135d7afbe605af3c5f8 (patch)
tree0b22addf5ba3bfa38838e00c94081f5f37ccfd6a /cmake
parent730dd687d5da090cbc34ba448ca581a235b239c3 (diff)
Use QLibrary to find librustc_demangle at runtime
Don't link to librustc_demangle at compile time, just try to find it at runtime via QLibrary and then use it. This makes it much easier to enable/disable support for rust demangling for packagers. Fixes: https://github.com/KDAB/hotspot/issues/269 Change-Id: Ib33e2699780ed6d827bddeea75f82137daeacc9d Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/FindLibRustcDemangle.cmake22
1 files changed, 22 insertions, 0 deletions
diff --git a/cmake/FindLibRustcDemangle.cmake b/cmake/FindLibRustcDemangle.cmake
new file mode 100644
index 0000000..c247e16
--- /dev/null
+++ b/cmake/FindLibRustcDemangle.cmake
@@ -0,0 +1,22 @@
+if (LIBRUSTC_DEMANGLE_LIBRARIES)
+ set (LibRustcDemangle_FIND_QUIETLY TRUE)
+endif()
+
+find_library(LIBRUSTC_DEMANGLE_LIBRARIES
+ NAMES
+ rustc_demangle
+ PATHS
+ /usr/lib
+ /usr/local/lib
+ /opt/local/lib
+ /sw/lib
+ ENV LIBRARY_PATH
+ ENV LD_LIBRARY_PATH)
+
+include (FindPackageHandleStandardArgs)
+
+# handle the QUIETLY and REQUIRED arguments and set LIBRUSTC_DEMANGLE_FOUND to TRUE if all listed variables are TRUE
+find_package_handle_standard_args(LibRustcDemangle DEFAULT_MSG
+ LIBRUSTC_DEMANGLE_LIBRARIES)
+
+mark_as_advanced(LIBRUSTC_DEMANGLE_LIBRARIES)