Skip to content

Commit

Permalink
fix copy onednnl 5
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielNSD committed Oct 31, 2024
1 parent 8010d27 commit dd83249
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,27 +150,26 @@ endif()
if(APPLE)
# Copy required dylibs to the build directory and adjust LC_LOAD_DYLIB path
add_custom_command(TARGET metaltranslate POST_BUILD
COMMAND bash -c "
ICU_UC_LIB_NAME=$(otool -L ${EXTERNAL_INSTALL_LOCATION}/lib/libOpenNMTTokenizer.dylib | grep 'libicuuc' | sed -E 's|.*(libicuuc[^ ]*).*|\\1|');
ICU_DATA_LIB_NAME=$(otool -L ${EXTERNAL_INSTALL_LOCATION}/lib/libOpenNMTTokenizer.dylib | grep 'libicudata' | sed -E 's|.*(libicudata[^ ]*).*|\\1|');
DNNL_LIB_NAME=$(otool -L ${EXTERNAL_INSTALL_LOCATION}/lib/libctranslate2.4.3.1.dylib | grep 'libdnnl' | sed -E 's|.*(libdnnl[^ ]*).*|\\1|');
COMMAND ICU_UC_LIB_NAME=$(otool -L ${EXTERNAL_INSTALL_LOCATION}/lib/libOpenNMTTokenizer.dylib | grep 'libicuuc' | sed -E 's|.*(libicuuc[^ ]*).*|\1|')
COMMAND ICU_DATA_LIB_NAME=$(otool -L ${EXTERNAL_INSTALL_LOCATION}/lib/libOpenNMTTokenizer.dylib | grep 'libicudata' | sed -E 's|.*(libicudata[^ ]*).*|\1|')
COMMAND DNNL_LIB_NAME=$(otool -L ${EXTERNAL_INSTALL_LOCATION}/lib/libctranslate2.4.3.1.dylib | grep 'libdnnl' | sed -E 's|.*(libdnnl[^ ]*).*|\1|')

echo 'Extracted ICU UC library name: ${ICU_UC_LIB_NAME}';
echo 'Extracted ICU DATA library name: ${ICU_DATA_LIB_NAME}';
echo 'Extracted DNNL library name: ${DNNL_LIB_NAME}';
COMMAND echo 'Extracted ICU UC library name: ${ICU_UC_LIB_NAME}'
COMMAND echo 'Extracted ICU DATA library name: ${ICU_DATA_LIB_NAME}'
COMMAND echo 'Extracted DNNL library name: ${DNNL_LIB_NAME}'


install_name_tool -change ${ONEDNN_ROOT}/lib/${DNNL_LIB_NAME} @rpath/libdnnl.3.dylib ${EXTERNAL_INSTALL_LOCATION}/lib/libctranslate2.4.3.1.dylib # change lib path of ctranslate2 lib
install_name_tool -change ${ICU_LIBRARY_DIR}/${ICU_UC_LIB_NAME} @rpath/libicuuc.dylib ${EXTERNAL_INSTALL_LOCATION}/lib/libctranslate2.4.3.1.dylib
install_name_tool -change ${ICU_LIBRARY_DIR}/${ICU_DATA_LIB_NAME} @rpath/libicudata.dylib ${EXTERNAL_INSTALL_LOCATION}/lib/libOpenNMTTokenizer.dylib
install_name_tool -change ${ICU_LIBRARY_DIR}/${ICU_UC_LIB_NAME} @rpath/libicuuc.dylib ${EXTERNAL_INSTALL_LOCATION}/lib/libOpenNMTTokenizer.dylib
COMMAND install_name_tool -change ${ONEDNN_ROOT}/lib/${DNNL_LIB_NAME} @rpath/libdnnl.3.dylib ${EXTERNAL_INSTALL_LOCATION}/lib/libctranslate2.4.3.1.dylib # change lib path of ctranslate2 lib
COMMAND install_name_tool -change ${ICU_LIBRARY_DIR}/${ICU_UC_LIB_NAME} @rpath/libicuuc.dylib ${EXTERNAL_INSTALL_LOCATION}/lib/libctranslate2.4.3.1.dylib
COMMAND install_name_tool -change ${ICU_LIBRARY_DIR}/${ICU_DATA_LIB_NAME} @rpath/libicudata.dylib ${EXTERNAL_INSTALL_LOCATION}/lib/libOpenNMTTokenizer.dylib
COMMAND install_name_tool -change ${ICU_LIBRARY_DIR}/${ICU_UC_LIB_NAME} @rpath/libicuuc.dylib ${EXTERNAL_INSTALL_LOCATION}/lib/libOpenNMTTokenizer.dylib

# copy files to build directory
${CMAKE_COMMAND} -E copy ${ONEDNN_ROOT}/lib/libdnnl.3.dylib $<TARGET_FILE_DIR:metaltranslate>
${CMAKE_COMMAND} -E copy ${ICU_LIBRARY_DIR}/libicuuc.dylib $<TARGET_FILE_DIR:metaltranslate>
${CMAKE_COMMAND} -E copy ${ICU_LIBRARY_DIR}/libicudata.dylib $<TARGET_FILE_DIR:metaltranslate>
COMMAND ${CMAKE_COMMAND} -E copy ${ONEDNN_ROOT}/lib/libdnnl.3.dylib $<TARGET_FILE_DIR:metaltranslate>
COMMAND ${CMAKE_COMMAND} -E copy ${ICU_LIBRARY_DIR}/libicuuc.dylib $<TARGET_FILE_DIR:metaltranslate>
COMMAND ${CMAKE_COMMAND} -E copy ${ICU_LIBRARY_DIR}/libicudata.dylib $<TARGET_FILE_DIR:metaltranslate>


"
COMMENT "Adjusting LC_LOAD_DYLIB path for libdnnl"
)
elseif(UNIX)
Expand Down

0 comments on commit dd83249

Please sign in to comment.