Skip to content

Commit e0ddce5

Browse files
Rafal Somlarsomla1
authored andcommitted
bug#30468214 NOT POSSIBLE TO BUILD WITH NINJA - fix jdbc build
It did not work for jdbc because of build location being jdbc/ instead of the root build folder.
1 parent 9b05e7b commit e0ddce5

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

cmake/libutils/merge_archives.cmake.in

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,20 @@ function(main)
126126
#
127127

128128
if(MSBUILD)
129+
129130
parse_build_log_msbuild("${BUILD_LOG}")
131+
set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
132+
130133
else()
134+
131135
# 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+
132139
file(STRINGS "${BUILD_LOG}" DEPS)
140+
list(GET DEPS 0 BUILD_DIR)
141+
list(REMOVE_AT DEPS 0)
142+
133143
endif()
134144

135145
#
@@ -231,6 +241,7 @@ function(merge_libraries_gcc)
231241
-o "${TARGET}"
232242
${link_line}
233243
RESULT_VARIABLE res
244+
WORKING_DIRECTORY ${BUILD_DIR}
234245
)
235246

236247
if(res)
@@ -325,10 +336,12 @@ function(merge_libraries_gcc)
325336
execute_process(
326337
COMMAND ${CMAKE_AR} -r ${TARGET} ${merge_objs}
327338
RESULT_VARIABLE res
339+
WORKING_DIRECTORY ${BUILD_DIR}
328340
)
329341
execute_process(
330342
COMMAND ${CMAKE_RANLIB} ${TARGET}
331343
RESULT_VARIABLE res1
344+
WORKING_DIRECTORY ${BUILD_DIR}
332345
)
333346

334347
if(res OR res1)
@@ -368,6 +381,7 @@ function(merge_libraries_win)
368381
OUTPUT_VARIABLE merge_out
369382
ERROR_VARIABLE merge_err
370383
RESULT_VARIABLE merge_res
384+
WORKING_DIRECTORY ${BUILD_DIR}
371385
)
372386
#message("-- merge_res: ${merge_res}")
373387

@@ -435,6 +449,7 @@ function(merge_libraries_apple)
435449
-o "${TARGET}"
436450
${link_line}
437451
RESULT_VARIABLE res
452+
WORKING_DIRECTORY ${BUILD_DIR}
438453
)
439454

440455
if(res)
@@ -462,6 +477,7 @@ function(merge_libraries_apple)
462477
ERROR_VARIABLE merge_err
463478
RESULT_VARIABLE merge_res
464479
ERROR_QUIET
480+
WORKING_DIRECTORY ${BUILD_DIR}
465481
)
466482
#message("-- merge_res: ${merge_res}")
467483

cmake/libutils/save_linker_opts.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,27 @@
3030

3131
#include <iostream>
3232
#include <fstream>
33+
#include <unistd.h>
3334

3435
using namespace std;
3536

3637
int main(int argc, char* argv[])
3738
{
39+
char pwd[1024];
40+
41+
if (!getcwd(pwd, sizeof(pwd)))
42+
return 1;
43+
3844
//cout << "Got " << argc << " arguments" << endl;
3945
//cout << "Output file: " << argv[1] << endl;
46+
//cout << "pwd: " << pwd << endl;
4047

4148
ofstream out(argv[1]);
4249

50+
// Note: first line in the output is the working directory
51+
52+
out << pwd << endl;
53+
4354
// Note: argv[2] is the compiler/linker command
4455

4556
for(unsigned pos=3; pos < argc; pos++)

0 commit comments

Comments
 (0)