From 2713842400042841a8b89c02091356f9ffa24dd9 Mon Sep 17 00:00:00 2001 From: Henri Menke Date: Thu, 2 Jul 2026 09:42:21 +0200 Subject: [PATCH] Avoid path doubling issue in CMake files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is no guarantee that `CMAKE_INSTALL_LIBDIR` (and for that matter `LWS_INSTALL_LIBDIR`) are relative paths, so that it would be safe to concatenate it with `CMAKE_INSTALL_PREFIX`. If `CMAKE_INSTALL_LIBDIR` is set to an absolute path, e.g. `/usr/lib` and `CMAKE_INSTALL_PREFIX` is set to `/usr` this leads to path doubling in various places where there now appears `/usr/usr/lib`. Here we use the “full” variants of those variables instead which branch correctly on both absolute and relative paths. --- cmake/lws_config.h.in | 2 +- lib/CMakeLists.txt | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmake/lws_config.h.in b/cmake/lws_config.h.in index d06c38c7c..8e0ce81bf 100644 --- a/cmake/lws_config.h.in +++ b/cmake/lws_config.h.in @@ -7,7 +7,7 @@ #endif #define LWS_INSTALL_DATADIR "${CMAKE_INSTALL_PREFIX}/share" -#define LWS_INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}/${LWS_INSTALL_LIB_DIR}" +#define LWS_INSTALL_LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}" #define LWS_PLUGIN_DIR "${LWS_INSTALL_PLUGIN_DIR}" #define LWS_LIBRARY_VERSION_MAJOR ${LWS_LIBRARY_VERSION_MAJOR} #define LWS_LIBRARY_VERSION_MINOR ${LWS_LIBRARY_VERSION_MINOR} diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index fedb0ed95..d30c2b07e 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -429,8 +429,8 @@ endif() file(WRITE "${PROJECT_BINARY_DIR}/libwebsockets.pc" "prefix=\"${CMAKE_INSTALL_PREFIX}\" exec_prefix=\${prefix} -libdir=\${exec_prefix}/${LWS_INSTALL_LIB_DIR} -includedir=\${prefix}/${LWS_INSTALL_INCLUDE_DIR} +libdir=${CMAKE_INSTALL_FULL_LIBDIR} +includedir=${CMAKE_INSTALL_FULL_INCLUDEDIR} Name: libwebsockets Description: Websockets server and client library @@ -451,8 +451,8 @@ endif() file(WRITE "${PROJECT_BINARY_DIR}/libwebsockets_static.pc" "prefix=\"${CMAKE_INSTALL_PREFIX}\" exec_prefix=\${prefix} -libdir=\${exec_prefix}/${LWS_INSTALL_LIB_DIR} -includedir=\${prefix}/${LWS_INSTALL_INCLUDE_DIR} +libdir=${CMAKE_INSTALL_FULL_LIBDIR} +includedir=${CMAKE_INSTALL_FULL_INCLUDEDIR} Name: libwebsockets_static Description: Websockets server and client static library