11diff --git a/CMakeLists.txt b/CMakeLists.txt
2- index 90184b6fde..640601f24c 100755
2+ index 90184b6fde..109282af09 100755
33--- a/CMakeLists.txt
44+++ b/CMakeLists.txt
5- @@ -22,7 +22,6 @@ else()
5+ @@ -20,9 +20,6 @@ else()
6+ cmake_minimum_required(VERSION 3.15)
7+ cmake_policy(VERSION 3.10)
68 endif()
7- # use to get_property location of static lib
8- # https://cmake.org/cmake/help/v3.0/policy/CMP0026.html?highlight=cmp0026
9+ - # use to get_property location of static lib
10+ - # https://cmake.org/cmake/help/v3.0/policy/CMP0026.html?highlight=cmp0026
911- cmake_policy(SET CMP0026 OLD)
1012 cmake_policy(SET CMP0079 NEW)
1113 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
1214 set(PADDLE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
13- @@ -722,7 +721 ,9 @@ add_subdirectory(paddle)
15+ @@ -722,7 +719 ,9 @@ add_subdirectory(paddle)
1416 if(WITH_PYTHON)
1517 add_subdirectory(python)
1618 endif()
@@ -21,3 +23,37 @@ index 90184b6fde..640601f24c 100755
2123
2224 get_directory_property(all_inc_dirs INCLUDE_DIRECTORIES)
2325 list(JOIN all_inc_dirs "\r\n" all_inc_dirs)
26+ diff --git a/cmake/generic.cmake b/cmake/generic.cmake
27+ index e977207378..e3756a5e1d 100644
28+ --- a/cmake/generic.cmake
29+ +++ b/cmake/generic.cmake
30+ @@ -276,20 +276,17 @@ function(merge_static_libs TARGET_NAME)
31+ set(mri_file
32+ ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.mri
33+ CACHE INTERNAL "phi_static.mri file")
34+ - get_property(
35+ - ABS_MERGE_LIB_PATH
36+ - TARGET ${TARGET_NAME}
37+ - PROPERTY LOCATION)
38+ - file(WRITE ${mri_file} "create ${ABS_MERGE_LIB_PATH}\n")
39+ -
40+ +
41+ + # Use generator expressions to get library paths at build time
42+ + # Note: We need to generate the MRI file at build time, not configure time
43+ + set(mri_content "create $<TARGET_FILE:${TARGET_NAME}>\n")
44+ foreach(lib ${libs})
45+ - get_property(
46+ - ABS_LIB_PATH
47+ - TARGET ${lib}
48+ - PROPERTY LOCATION)
49+ - file(APPEND ${mri_file} "addlib ${ABS_LIB_PATH}\n")
50+ + set(mri_content "${mri_content}addlib $<TARGET_FILE:${lib}>\n")
51+ endforeach()
52+ - file(APPEND ${mri_file} "save\nend\n")
53+ + set(mri_content "${mri_content}save\nend\n")
54+ +
55+ + # Write MRI content to a temporary file that will be processed at build time
56+ + file(GENERATE OUTPUT ${mri_file} CONTENT "${mri_content}")
57+
58+ add_custom_command(
59+ TARGET ${TARGET_NAME}
0 commit comments