|
| 1 | +From 26ba5099f19ba2e00f84aff797be7740fead4aee Mon Sep 17 00:00:00 2001 |
| 2 | +From: Philippe Normand < [email protected]> |
| 3 | +Date: Wed, 29 Sep 2021 10:22:00 +0100 |
| 4 | +Subject: [PATCH] cmake: Look for resources in cmake's install lib dir |
| 5 | + |
| 6 | +--- |
| 7 | + CMakeLists.txt | 4 ++++ |
| 8 | + src/config.h.in | 6 ++++++ |
| 9 | + src/util.cc | 11 +++-------- |
| 10 | + 3 files changed, 13 insertions(+), 8 deletions(-) |
| 11 | + create mode 100644 src/config.h.in |
| 12 | + |
| 13 | +diff --git a/CMakeLists.txt b/CMakeLists.txt |
| 14 | +index e28d95aa..d38b3df2 100644 |
| 15 | +--- a/CMakeLists.txt |
| 16 | ++++ b/CMakeLists.txt |
| 17 | +@@ -49,6 +49,10 @@ configure_file( |
| 18 | + ${CMAKE_SOURCE_DIR}/src/git_revision.h.in |
| 19 | + ${CMAKE_BINARY_DIR}/git_revision.h |
| 20 | + ) |
| 21 | ++configure_file( |
| 22 | ++ ${CMAKE_SOURCE_DIR}/src/config.h.in |
| 23 | ++ ${CMAKE_BINARY_DIR}/config.h |
| 24 | ++) |
| 25 | + |
| 26 | + set(FLAGS_COMMON "-D__USE_LARGEFILE64 -pthread") |
| 27 | + set(supports32bit true) |
| 28 | +diff --git a/src/config.h.in b/src/config.h.in |
| 29 | +new file mode 100644 |
| 30 | +index 00000000..059aeb43 |
| 31 | +--- /dev/null |
| 32 | ++++ b/src/config.h.in |
| 33 | +@@ -0,0 +1,6 @@ |
| 34 | ++#ifndef RR_CONFIG_H_ |
| 35 | ++#define RR_CONFIG_H_ |
| 36 | ++ |
| 37 | ++#define RESOURCES_LIB_DIR "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/" |
| 38 | ++ |
| 39 | ++#endif |
| 40 | +diff --git a/src/util.cc b/src/util.cc |
| 41 | +index c57ae7b6..b2ac7bac 100644 |
| 42 | +--- a/src/util.cc |
| 43 | ++++ b/src/util.cc |
| 44 | +@@ -45,6 +45,7 @@ |
| 45 | + #include "kernel_metadata.h" |
| 46 | + #include "log.h" |
| 47 | + #include "seccomp-bpf.h" |
| 48 | ++#include "config.h" |
| 49 | + |
| 50 | + void good_random(uint8_t* out, size_t out_len); |
| 51 | + |
| 52 | +@@ -1261,8 +1262,7 @@ static string read_exe_dir() { |
| 53 | + string resource_path() { |
| 54 | + string resource_path = Flags::get().resource_path; |
| 55 | + if (resource_path.empty()) { |
| 56 | +- static string exe_path = read_exe_dir() + "../"; |
| 57 | +- return exe_path; |
| 58 | ++ return RESOURCES_LIB_DIR; |
| 59 | + } |
| 60 | + return resource_path; |
| 61 | + } |
| 62 | +@@ -1294,16 +1294,11 @@ bool running_under_rr(bool cache) { |
| 63 | + |
| 64 | + string find_helper_library(const char *basepath) |
| 65 | + { |
| 66 | +- string lib_path = resource_path() + "lib64/rr/"; |
| 67 | ++ string lib_path = resource_path() + "rr/"; |
| 68 | + string file_name = lib_path + basepath; |
| 69 | + if (access(file_name.c_str(), F_OK) == 0) { |
| 70 | + return lib_path; |
| 71 | + } |
| 72 | +- lib_path = resource_path() + "lib/rr/"; |
| 73 | +- file_name = lib_path + basepath; |
| 74 | +- if (access(file_name.c_str(), F_OK) == 0) { |
| 75 | +- return lib_path; |
| 76 | +- } |
| 77 | + // File does not exist. Assume install put it in LD_LIBRARY_PATH. |
| 78 | + lib_path = ""; |
| 79 | + return lib_path; |
| 80 | +-- |
| 81 | +2.31.1 |
| 82 | + |
0 commit comments