Browse Source

!10187 mac build fix rpath

From: @xiaoyisd
Reviewed-by: @zhoufeng54,@kisnwang
Signed-off-by: @kisnwang
tags/v1.2.0-rc1
mindspore-ci-bot Gitee 5 years ago
parent
commit
aec0fa228a
3 changed files with 69 additions and 1 deletions
  1. +6
    -1
      mindspore/ccsrc/CMakeLists.txt
  2. +62
    -0
      mindspore/ccsrc/minddata/dataset/CMakeLists.txt
  3. +1
    -0
      setup.py

+ 6
- 1
mindspore/ccsrc/CMakeLists.txt View File

@@ -304,7 +304,6 @@ elseif (ENABLE_GPU)
set(MINDSPORE_RPATH ${MINDSPORE_RPATH}:/usr/local/cuda/lib64)
endif ()
set(MINDSPORE_RPATH ${ORIGIN_PATH}/lib:${MINDSPORE_RPATH})

set_target_properties(_c_expression PROPERTIES INSTALL_RPATH ${MINDSPORE_RPATH})

if (CMAKE_SYSTEM_NAME MATCHES "Windows")
@@ -351,6 +350,12 @@ if (ENABLE_GPU)
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)
target_link_libraries(_c_expression PRIVATE mindspore::dnnl mindspore::mkldnn)
endif ()


+ 62
- 0
mindspore/ccsrc/minddata/dataset/CMakeLists.txt View File

@@ -193,6 +193,68 @@ endif ()

################# Link with external libraries ########################
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 (ENABLE_PYTHON)
target_link_libraries(_c_dataengine PRIVATE mindspore::pybind11_module ${PYTHON_LIBRARIES} ${SECUREC_LIBRARY})


+ 1
- 0
setup.py View File

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


Loading…
Cancel
Save