From 8c0a3b4d811dc52b16840f6cbbf7a1600bbb3e53 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Sun, 29 Mar 2026 17:48:04 +0200 Subject: [PATCH] cmake: enable position independent code (PIE) Fixes the following build error when compiling Fedora 45 RPM: /usr/bin/ld.bfd: tests/unit/CMakeFiles/tests.dir/tests.cpp.o: relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE /usr/bin/ld.bfd: failed to set dynamic section sizes: bad value collect2: error: ld returned 1 exit status See: https://cmake.org/cmake/help/latest/prop_tgt/POSITION_INDEPENDENT_CODE.html https://cmake.org/cmake/help/latest/policy/CMP0083.html --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f9e648a5b..479c20608 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ project(weechat C) # CMake options set(CMAKE_VERBOSE_MAKEFILE OFF) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}") +set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_SKIP_RPATH ON) # compiler options