Skip to content

Commit

Permalink
Cmake:
Browse files Browse the repository at this point in the history
* Set shared library path to $ORIGIN on linux and BSD fro libraries build by cmake.
* Install J erase and gf complete shared libraries symlinks, and set run time path accordingly.
Python shim: only copy required shared libraries, do not copy symlinks.
  • Loading branch information
mikeov committed Dec 11, 2023
1 parent cffb841 commit 03b41ab
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 27 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ else()
find_package(Boost COMPONENTS regex REQUIRED)
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(CMAKE_INSTALL_RPATH $ORIGIN)
endif()

if (CYGWIN)
set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES} "")
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} ".dll.a" ".lib")
Expand Down
39 changes: 13 additions & 26 deletions cmake/Modules/FindJerasure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -90,37 +90,25 @@ set(Jerasure_SHARED_LIB
# Change relevant run time paths and resolve symlinks.
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
add_custom_command(TARGET Jerasure_proj POST_BUILD
COMMAND install_name_tool -id @rpath/${Gf_complete_SHARED_LIB_NAME}
${Gf_complete_SHARED_LIB}
COMMAND install_name_tool -id @rpath/${Jerasure_SHARED_LIB_NAME}
COMMAND sh -c
"while [ $# -gt 0 ]; do \
p=$(readlink \"$1\" || basename \"$1\") && \
install_name_tool -id @rpath/\"$p\" \"$1\" || exit; \
shift; \
done"
x ${Gf_complete_SHARED_LIB}
${Jerasure_SHARED_LIB}
COMMAND sh -c
"p=$(realpath \"$1\") && install_name_tool -change \"$0\"\"$(basename \"$p\")\" @rpath/\"$2\" \"$3\""
${Gf_complete_LIB_DIR} ${Gf_complete_SHARED_LIB}
${Gf_complete_SHARED_LIB_NAME}
"p=$(readlink \"$0\" || basename \"$0\") && \
install_name_tool -change \"${1}${p}\" @rpath/\"$p\" \"$2\""
${Gf_complete_SHARED_LIB}
${Gf_complete_LIB_DIR}
${Jerasure_SHARED_LIB}
COMMAND mv ${Jerasure_SHARED_LIB} ${Jerasure_SHARED_LIB}.tmp
COMMAND cp ${Jerasure_SHARED_LIB}.tmp ${Jerasure_SHARED_LIB}
COMMAND mv ${Gf_complete_SHARED_LIB} ${Gf_complete_SHARED_LIB}.tmp
COMMAND cp ${Gf_complete_SHARED_LIB}.tmp ${Gf_complete_SHARED_LIB}
VERBATIM
)
elseif(COMMAND chrpath)
add_custom_command(TARGET Jerasure_proj POST_BUILD
COMMAND chrpath -d ${Gf_complete_SHARED_LIB}
COMMAND chrpath -d ${Jerasure_SHARED_LIB}
COMMAND mv ${Jerasure_SHARED_LIB} ${Jerasure_SHARED_LIB}.tmp
COMMAND cp ${Jerasure_SHARED_LIB}.tmp ${Jerasure_SHARED_LIB}
COMMAND mv ${Gf_complete_SHARED_LIB} ${Gf_complete_SHARED_LIB}.tmp
COMMAND cp ${Gf_complete_SHARED_LIB}.tmp ${Gf_complete_SHARED_LIB}
VERBATIM
)
else()
add_custom_command(TARGET Jerasure_proj POST_BUILD
COMMAND mv ${Jerasure_SHARED_LIB} ${Jerasure_SHARED_LIB}.tmp
COMMAND cp ${Jerasure_SHARED_LIB}.tmp ${Jerasure_SHARED_LIB}
COMMAND mv ${Gf_complete_SHARED_LIB} ${Gf_complete_SHARED_LIB}.tmp
COMMAND cp ${Gf_complete_SHARED_LIB}.tmp ${Gf_complete_SHARED_LIB}
COMMAND chrpath -r $ORIGIN ${Jerasure_SHARED_LIB}
VERBATIM
)
endif()
Expand All @@ -146,8 +134,7 @@ else()
LIBRARY DESTINATION lib
USE_SOURCE_PERMISSIONS
FILES_MATCHING
PATTERN ${Gf_complete_SHARED_LIB_NAME}
PATTERN ${Jerasure_SHARED_LIB_NAME}
PATTERN ${CMAKE_SHARED_LIBRARY_PREFIX}*${CMAKE_SHARED_LIBRARY_SUFFIX}*
)
set(JERASURE_SHARED_LIBRARIES
${Jerasure_SHARED_LIB}
Expand Down
12 changes: 11 additions & 1 deletion src/cc/access/kfs_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,17 @@
libs_dir = os.path.join("qfs", libs_dir)
setup_extra_args = {
"packages": ["qfs"],
"package_data": {"qfs": ["lib/*.*"]},
"package_data": {
"qfs": [
os.path.join("lib", f)
for f in os.listdir(libs_dir)
if os.path.isfile(os.path.join(libs_dir, f))
and not os.path.islink(os.path.join(libs_dir, f))
and "qfsc." not in f
and "qfss3io." not in f
and "qfs_access." not in f
]
},
# "ext_package": "qfs",
}
extension_extra_args = {
Expand Down

0 comments on commit 03b41ab

Please sign in to comment.