diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake index acf29ae82f0..92a5b9f564d 100644 --- a/cmake/libutils.cmake +++ b/cmake/libutils.cmake @@ -217,7 +217,7 @@ MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE) SET(SCRIPT_CONTENTS "CREATE $\n") FOREACH(LIB ${STATIC_LIBS}) - SET(SCRIPT_CONTENTS "${SCRIPT_CONTENTS}\nADDLIB ${LIB}\n") + SET(SCRIPT_CONTENTS "${SCRIPT_CONTENTS}ADDLIB ${LIB}\n") ENDFOREACH() FILE(WRITE ${MRI_SCRIPT_TPL} "${SCRIPT_CONTENTS}\nSAVE\nEND\n") FILE(GENERATE OUTPUT ${MRI_SCRIPT} INPUT ${MRI_SCRIPT_TPL}) @@ -227,12 +227,14 @@ MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE) COMMAND ${CMAKE_COMMAND} ARGS -DTARGET_SCRIPT="${MRI_SCRIPT}" + -DTOP_DIR="${CMAKE_BINARY_DIR}" -DCMAKE_AR="${CMAKE_AR}" -P "${MYSQL_CMAKE_SCRIPT_DIR}/merge_archives_unix.cmake" COMMAND ${CMAKE_RANLIB} ARGS $ ) SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${MRI_SCRIPT_TPL}) + SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${MRI_SCRIPT}.mri) ENDIF() ENDIF() ENDMACRO() diff --git a/cmake/merge_archives_unix.cmake b/cmake/merge_archives_unix.cmake index 8e5086bb5b7..a66daddaefc 100644 --- a/cmake/merge_archives_unix.cmake +++ b/cmake/merge_archives_unix.cmake @@ -14,7 +14,21 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +# MRI scripts have a problem with +. It's a line contination character +# unfortunately there is no escape character. We know we don't have +# "+" in libraries or the MariaDB paths, but Ubuntu CI builds will have +# in their CI path due to the package names that Ubuntu generates. +# So here we replace the fully expanded paths in the TARGET_SCRIPT, +# strip off the TOP_DIR to make it a relative path to the top level directory +# and then execute AR on the top level directory. + +FILE(READ ${TARGET_SCRIPT} SCRIPT_CONTENTS) +STRING(REPLACE "${TOP_DIR}/" "" SCRIPT_CONTENTS_TRIMMED "${SCRIPT_CONTENTS}") +FILE(WRITE "${TARGET_SCRIPT}.mri" ${SCRIPT_CONTENTS_TRIMMED}) + EXECUTE_PROCESS( + WORKING_DIRECTORY ${TOP_DIR} COMMAND ${CMAKE_AR} -M - INPUT_FILE ${TARGET_SCRIPT} + INPUT_FILE ${TARGET_SCRIPT}.mri )