From b5e44831bdecf9f5e1d941c4c64999cfa589930e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= Date: Sat, 15 Jun 2024 23:34:24 +0200 Subject: [PATCH] mariadb_config: cmake: Don't prefix `/absolute/file.a` with `-l` Because `-l` does not take absolute paths. Context: https://github.com/mariadb-corporation/mariadb-connector-c/commit/8aa86f73adcab01147416e4c5f4876532da4bd4b#commitcomment-143167684 --- mariadb_config/CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mariadb_config/CMakeLists.txt b/mariadb_config/CMakeLists.txt index 0a32343db..82cd63a89 100644 --- a/mariadb_config/CMakeLists.txt +++ b/mariadb_config/CMakeLists.txt @@ -14,9 +14,15 @@ FUNCTION(GET_LIB_NAME LIB_NAME LIB_OUT) SET(LIB_FILE ${LIB_NAME}) ENDIF() + # Apparently `LIB_NAME` can be either a library file name, + # or a general linker arguments (e.g. `-L...` or absolute path + # `/path/to/lib.a`). + # We prefix library names with `-l`; all other arguments + # need to be passed on unmodified. + # We detect those by inspecting the first character. STRING(SUBSTRING ${LIB_NAME} 0 1 LIB_PREFIX) - IF(NOT ${LIB_PREFIX} STREQUAL "-") + IF(NOT (${LIB_PREFIX} STREQUAL "-" OR ${LIB_PREFIX} STREQUAL "/")) SET(LIB_FILE "-l${LIB_FILE}") STRING(REPLACE "-llib" "-l" LIB_FILE ${LIB_FILE}) SET(${LIB_OUT} ${LIB_FILE} PARENT_SCOPE)