@@ -3,6 +3,7 @@ project(memray)
3
3
4
4
set (CMAKE_CXX_STANDARD 17)
5
5
set (CMAKE_CXX_STANDARD_REQUIRED ON )
6
+ set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )
6
7
7
8
# Find Python
8
9
find_package (Python COMPONENTS Interpreter Development.Module Development.SABIModule REQUIRED)
@@ -15,16 +16,28 @@ endif()
15
16
16
17
# Find required packages
17
18
find_package (PkgConfig REQUIRED)
18
- pkg_check_modules(LZ4 REQUIRED liblz4)
19
+ pkg_check_modules(LZ4 liblz4)
19
20
if (NOT LZ4_FOUND)
20
- message (FATAL_ERROR "LZ4 library not found. Please install liblz4-dev or equivalent." )
21
+ message (FATAL_ERROR "liblz4 not found. Please install liblz4-dev or equivalent." )
21
22
endif ()
22
23
23
24
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux" )
24
- pkg_check_modules(UNWIND REQUIRED libunwind)
25
+ pkg_check_modules(UNWIND libunwind)
26
+ if (NOT UNWIND_FOUND)
27
+ message (FATAL_ERROR "libunwind not found. Please install libunwind-dev or equivalent." )
28
+ endif ()
29
+
25
30
pkg_check_modules(DEBUGINFOD libdebuginfod)
26
- if (NOT DEBUGINFOD_LIBRARIES)
27
- set (DEBUGINFOD_LIBRARIES "debuginfod" )
31
+ if (NOT DEBUGINFOD_FOUND)
32
+ # Some systems don't have a libdebuginfod.pc file.
33
+ # See if there's a libdebuginfod.so wherever liblz4 or libunwind are.
34
+ include (CheckLibraryExists)
35
+ check_library_exists("libdebuginfod.so" "debuginfod_find_debuginfo" "${LZ4_LIBRARY_DIRS} ;${UNWIND_LIBRARY_DIRS} " DEBUGINFOD)
36
+ if (DEBUGINFOD)
37
+ set (DEBUGINFOD_LIBRARIES "debuginfod" )
38
+ else ()
39
+ message (FATAL_ERROR "libdebuginfod not found. Please install libdebuginfod-dev or equivalent." )
40
+ endif ()
28
41
endif ()
29
42
endif ()
30
43
@@ -122,11 +135,21 @@ target_link_libraries(_memray PRIVATE
122
135
${DEBUGINFOD_LIBRARIES}
123
136
dl
124
137
)
125
- set_target_properties (_memray PROPERTIES INSTALL_RPATH "${DEBUGINFOD_LIBRARY_DIRS} " )
126
-
127
- set (CMAKE_BUILD_RPATH "${LZ4_LIBRARY_DIRS} :" )
128
- target_link_options (_memray PRIVATE ${LZ4_LDFLAGS} ${UNWIND_LDFLAGS} ${DEBUGINFOD_LDFLAGS} )
129
- target_compile_options (_memray PRIVATE ${LZ4_CFLAGS} ${UNWIND_CFLAGS} ${DEBUGINFOD_CFLAGS} )
138
+ target_link_directories (_memray PRIVATE
139
+ ${LZ4_LIBRARY_DIRS}
140
+ ${UNWIND_LIBRARY_DIRS}
141
+ ${DEBUGINFOD_LIBRARY_DIRS}
142
+ )
143
+ target_link_options (_memray PRIVATE
144
+ ${LZ4_LDFLAGS}
145
+ ${UNWIND_LDFLAGS}
146
+ ${DEBUGINFOD_LDFLAGS}
147
+ )
148
+ target_compile_options (_memray PRIVATE
149
+ ${LZ4_CFLAGS}
150
+ ${UNWIND_CFLAGS}
151
+ ${DEBUGINFOD_CFLAGS}
152
+ )
130
153
add_dependencies (_memray libbacktrace)
131
154
132
155
# _test_utils extension
@@ -164,11 +187,6 @@ python_add_library(_inject MODULE WITH_SOABI USE_SABI 3.7
164
187
target_include_directories (_inject PRIVATE
165
188
${CMAKE_SOURCE_DIR} /src/memray
166
189
)
167
- target_compile_options (_test_utils PRIVATE ${COMPILER_FLAGS} )
168
- target_link_options (_test_utils PRIVATE ${LINKER_FLAGS} )
169
- target_compile_options (_inject PRIVATE ${COMPILER_FLAGS} )
170
- target_link_options (_inject PRIVATE ${LINKER_FLAGS} )
171
-
172
190
173
191
# Install targets
174
192
install (TARGETS _memray _test_utils _inject LIBRARY DESTINATION memray)
0 commit comments