!10187 mac build fix rpath

From: @xiaoyisd
Reviewed-by: @zhoufeng54,@kisnwang
Signed-off-by: @kisnwang
This commit is contained in:
mindspore-ci-bot 2020-12-26 11:28:55 +08:00 committed by Gitee
commit aec0fa228a
3 changed files with 69 additions and 1 deletions

View File

@ -304,7 +304,6 @@ elseif (ENABLE_GPU)
set(MINDSPORE_RPATH ${MINDSPORE_RPATH}:/usr/local/cuda/lib64) set(MINDSPORE_RPATH ${MINDSPORE_RPATH}:/usr/local/cuda/lib64)
endif () endif ()
set(MINDSPORE_RPATH ${ORIGIN_PATH}/lib:${MINDSPORE_RPATH}) set(MINDSPORE_RPATH ${ORIGIN_PATH}/lib:${MINDSPORE_RPATH})
set_target_properties(_c_expression PROPERTIES INSTALL_RPATH ${MINDSPORE_RPATH}) set_target_properties(_c_expression PROPERTIES INSTALL_RPATH ${MINDSPORE_RPATH})
if (CMAKE_SYSTEM_NAME MATCHES "Windows") if (CMAKE_SYSTEM_NAME MATCHES "Windows")
@ -351,6 +350,12 @@ if (ENABLE_GPU)
endif () endif ()
endif () endif ()
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(CMAKE_MACOSX_RPATH 1)
set(CMAKE_INSTALL_RPATH "@loader_path/lib;@loader_path")
set_target_properties(_c_expression PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH}")
endif ()
if (ENABLE_CPU) if (ENABLE_CPU)
target_link_libraries(_c_expression PRIVATE mindspore::dnnl mindspore::mkldnn) target_link_libraries(_c_expression PRIVATE mindspore::dnnl mindspore::mkldnn)
endif () endif ()

View File

@ -193,6 +193,68 @@ endif ()
################# Link with external libraries ######################## ################# Link with external libraries ########################
target_link_libraries(_c_dataengine PRIVATE mindspore mindspore_gvar) target_link_libraries(_c_dataengine PRIVATE mindspore mindspore_gvar)
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(CMAKE_MACOSX_RPATH 1)
set(CMAKE_INSTALL_RPATH "@loader_path/lib;@loader_path")
set_target_properties(_c_dataengine PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH}")
endif ()
set(targetso $<TARGET_FILE:_c_dataengine>)
set(target_tiny "libtinyxml")
set(target_icuuc "libicuuc")
set(target_icudata "libicudata")
set(target_icui18n "libicui18n")
function(changerpath targetso linkso)
set(some-file "${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/${linkso}.txt")
set(some-file1 "${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/${linkso}1.txt")
set(some-file2 "${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset/${linkso}2.txt")
add_custom_command(
OUTPUT
${some-file}
COMMAND
otool -L ${targetso} | grep ${linkso} > ${some-file}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset"
VERBATIM
)
add_custom_command(
OUTPUT
${some-file1}
COMMAND
cat ${some-file} | cut -d " " -f 1 | sed -E "s/^.//g" > ${some-file1}
DEPENDS
${some-file}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset"
VERBATIM
)
add_custom_command(
OUTPUT
${some-file2}
COMMAND
awk -F "/" "{print $NF}" ${some-file1} > ${some-file2}
DEPENDS
${some-file1}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset"
VERBATIM
)
add_custom_target(
link_${linkso} ALL
COMMAND install_name_tool -change `cat ${some-file1}` @rpath/`cat ${some-file2}` ${targetso}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/mindspore/ccsrc/minddata/dataset"
DEPENDS ${targetso} ${some-file1} ${some-file2}
COMMENT "install tool name")
endfunction()
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
changerpath(${targetso} ${target_tiny})
changerpath(${targetso} ${target_icuuc})
add_dependencies(link_${target_icuuc} link_${target_tiny})
changerpath(${targetso} ${target_icudata})
add_dependencies(link_${target_icudata} link_${target_icuuc})
changerpath(${targetso} ${target_icui18n})
add_dependencies(link_${target_icui18n} link_${target_icudata})
endif()
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
if (ENABLE_PYTHON) if (ENABLE_PYTHON)
target_link_libraries(_c_dataengine PRIVATE mindspore::pybind11_module ${PYTHON_LIBRARIES} ${SECUREC_LIBRARY}) target_link_libraries(_c_dataengine PRIVATE mindspore::pybind11_module ${PYTHON_LIBRARIES} ${SECUREC_LIBRARY})

View File

@ -131,6 +131,7 @@ package_data = {
'*.dll', '*.dll',
'lib/*.so*', 'lib/*.so*',
'lib/*.a', 'lib/*.a',
'lib/*.dylib*',
'.commit_id', '.commit_id',
'config/*', 'config/*',
'include/*', 'include/*',