Enable -fPIC to fix linking static libraries when building with Qt6

Otherwise the build would fail:
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: ../lib/libkonsoleprivate_core.a(ShellCommand.cpp.o): warning: relocation against `_ZN7QString6_emptyE@@Qt_6' in read-only section `.text'
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: ../lib/libkonsoleprivate_core.a(ShellCommand.cpp.o): relocation R_X86_64_PC32 against symbol `_ZN10QByteArray6_emptyE@@Qt_6' can not be used when making a shared object; recompile with -fPIC
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: final link failed: bad value

This seems to affect both STATIC and OBJECT CMake library types.
wilder
Ahmad Samir 4 years ago committed by Tomaz Canabrava
parent 7b89ba176c
commit 28b0d321a3
  1. 3
      src/CMakeLists.txt
  2. 3
      src/colorscheme/CMakeLists.txt
  3. 2
      src/decoders/CMakeLists.txt
  4. 2
      src/keyboardtranslator/CMakeLists.txt
  5. 2
      src/profile/CMakeLists.txt
  6. 3
      src/session/CMakeLists.txt

@ -89,6 +89,8 @@ ecm_qt_declare_logging_category(
)
add_library(konsoleprivate_core STATIC ${konsoleprivate_core_SRCS})
# Needed to link this static lib to shared libs
set_target_properties(konsoleprivate_core PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_link_libraries(konsoleprivate_core ${konsole_LIBS})
set(konsolehelpers_SRCS
@ -98,6 +100,7 @@ add_library(konsolehelpers
STATIC
${konsolehelpers_SRCS}
)
set_target_properties(konsolehelpers PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_link_libraries(konsolehelpers
Qt::Core
Qt::Widgets

@ -26,6 +26,9 @@ add_library(konsolecolorscheme
STATIC
${konsole_colorscheme_SRCS}
)
# Needed to link this static lib to shared libs
set_target_properties(konsolecolorscheme PROPERTIES POSITION_INDEPENDENT_CODE ON)
generate_export_header(konsolecolorscheme BASE_NAME konsolecolorscheme)
target_include_directories(konsolecolorscheme
PUBLIC ${CMAKE_CURRENT_BINARY_DIR}

@ -4,6 +4,8 @@ add_library(konsoledecoders
PlainTextDecoder.cpp
HTMLDecoder.cpp
)
set_target_properties(konsoledecoders PROPERTIES POSITION_INDEPENDENT_CODE ON)
generate_export_header(konsoledecoders BASE_NAME konsoledecoders)
target_include_directories(konsoledecoders
PUBLIC ${CMAKE_CURRENT_BINARY_DIR}

@ -6,6 +6,8 @@ add_library(keyboardtranslator
KeyboardTranslator.cpp
KeyboardTranslatorReader.cpp
)
# Needed to link this static lib to shared libs
set_target_properties(keyboardtranslator PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_link_libraries(
keyboardtranslator

@ -12,6 +12,8 @@ OBJECT
ProfileModel.cpp
${konsoleprofile_SRCS}
)
set_property(TARGET konsoleprofile PROPERTY POSITION_INDEPENDENT_CODE ON)
generate_export_header(konsoleprofile BASE_NAME konsoleprofile)
target_include_directories(konsoleprofile PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(

@ -30,6 +30,9 @@ add_library(konsolesession
OBJECT
${konsole_session_SRCS}
)
set_property(TARGET konsolesession PROPERTY POSITION_INDEPENDENT_CODE ON)
generate_export_header(konsolesession BASE_NAME konsolesession)
target_include_directories(konsolesession PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(

Loading…
Cancel
Save