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 <qt_ci_bot@qt-project.org>
Reviewed-by: Christophe Giboudeaux <christophe@krop.fr>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Eike Ziller
2021-10-20 12:04:31 +02:00
parent 0101808407
commit ea1655881d

View File

@@ -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}