From ea1655881d078d051049ec40c2562db90056a931 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Wed, 20 Oct 2021 12:04:31 +0200 Subject: [PATCH] CMake build: Force -fPIC for static libraries on UNIX Usually that is done by Qt, but not if reduce_relocations is off. Fixes: QTCREATORBUG-26435 Change-Id: Idd337d59555fd6e732215b9c753820672f63c91f Reviewed-by: Qt CI Bot Reviewed-by: Christophe Giboudeaux Reviewed-by: Cristian Adam --- cmake/QtCreatorAPI.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmake/QtCreatorAPI.cmake b/cmake/QtCreatorAPI.cmake index 4496c17ef52..7484f784502 100644 --- a/cmake/QtCreatorAPI.cmake +++ b/cmake/QtCreatorAPI.cmake @@ -203,6 +203,11 @@ function(add_qtc_library name) set(TEST_DEFINES WITH_TESTS SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}") endif() + if(_arg_STATIC AND UNIX) + # not added by Qt if reduce_relocations is turned off for it + set_target_properties(${name} PROPERTIES POSITION_INDEPENDENT_CODE ON) + endif() + extend_qtc_target(${name} INCLUDES ${_arg_INCLUDES} PUBLIC_INCLUDES ${_arg_PUBLIC_INCLUDES}