Commit 28b0d321 authored by Ahmad Samir's avatar Ahmad Samir Committed by Tomaz Canabrava
Browse files

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.
parent 7b89ba17
Pipeline #184140 passed with stage
in 2 minutes and 17 seconds
......@@ -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(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment