@@ -126,10 +126,20 @@ function(main)
126
126
#
127
127
128
128
if (MSBUILD )
129
+
129
130
parse_build_log_msbuild ("${BUILD_LOG} " )
131
+ set (BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR} )
132
+
130
133
else ()
134
+
131
135
# In this case BUILD_LOG contains extracted linker options, one per line
136
+ # but the first line is the working directory in which the linker was
137
+ # invoked (important for resolving relative paths)
138
+
132
139
file (STRINGS "${BUILD_LOG} " DEPS )
140
+ list (GET DEPS 0 BUILD_DIR )
141
+ list (REMOVE_AT DEPS 0 )
142
+
133
143
endif ()
134
144
135
145
#
@@ -231,6 +241,7 @@ function(merge_libraries_gcc)
231
241
-o "${TARGET} "
232
242
${link_line}
233
243
RESULT_VARIABLE res
244
+ WORKING_DIRECTORY ${BUILD_DIR}
234
245
)
235
246
236
247
if (res )
@@ -325,10 +336,12 @@ function(merge_libraries_gcc)
325
336
execute_process (
326
337
COMMAND ${CMAKE_AR} -r ${TARGET} ${merge_objs}
327
338
RESULT_VARIABLE res
339
+ WORKING_DIRECTORY ${BUILD_DIR}
328
340
)
329
341
execute_process (
330
342
COMMAND ${CMAKE_RANLIB} ${TARGET}
331
343
RESULT_VARIABLE res1
344
+ WORKING_DIRECTORY ${BUILD_DIR}
332
345
)
333
346
334
347
if (res OR res1 )
@@ -368,6 +381,7 @@ function(merge_libraries_win)
368
381
OUTPUT_VARIABLE merge_out
369
382
ERROR_VARIABLE merge_err
370
383
RESULT_VARIABLE merge_res
384
+ WORKING_DIRECTORY ${BUILD_DIR}
371
385
)
372
386
#message("-- merge_res: ${merge_res}")
373
387
@@ -435,6 +449,7 @@ function(merge_libraries_apple)
435
449
-o "${TARGET} "
436
450
${link_line}
437
451
RESULT_VARIABLE res
452
+ WORKING_DIRECTORY ${BUILD_DIR}
438
453
)
439
454
440
455
if (res )
@@ -462,6 +477,7 @@ function(merge_libraries_apple)
462
477
ERROR_VARIABLE merge_err
463
478
RESULT_VARIABLE merge_res
464
479
ERROR_QUIET
480
+ WORKING_DIRECTORY ${BUILD_DIR}
465
481
)
466
482
#message("-- merge_res: ${merge_res}")
467
483
0 commit comments