Skip to content

Commit 4dd729a

Browse files
committed
wip
1 parent 8724c58 commit 4dd729a

File tree

1 file changed

+33
-15
lines changed

1 file changed

+33
-15
lines changed

CMakeLists.txt

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ project(memray)
33

44
set(CMAKE_CXX_STANDARD 17)
55
set(CMAKE_CXX_STANDARD_REQUIRED ON)
6+
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
67

78
# Find Python
89
find_package(Python COMPONENTS Interpreter Development.Module Development.SABIModule REQUIRED)
@@ -15,16 +16,28 @@ endif()
1516

1617
# Find required packages
1718
find_package(PkgConfig REQUIRED)
18-
pkg_check_modules(LZ4 REQUIRED liblz4)
19+
pkg_check_modules(LZ4 liblz4)
1920
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.")
2122
endif()
2223

2324
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+
2530
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()
2841
endif()
2942
endif()
3043

@@ -122,11 +135,21 @@ target_link_libraries(_memray PRIVATE
122135
${DEBUGINFOD_LIBRARIES}
123136
dl
124137
)
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+
)
130153
add_dependencies(_memray libbacktrace)
131154

132155
# _test_utils extension
@@ -164,11 +187,6 @@ python_add_library(_inject MODULE WITH_SOABI USE_SABI 3.7
164187
target_include_directories(_inject PRIVATE
165188
${CMAKE_SOURCE_DIR}/src/memray
166189
)
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-
172190

173191
# Install targets
174192
install(TARGETS _memray _test_utils _inject LIBRARY DESTINATION memray)

0 commit comments

Comments
 (0)