summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2021-05-14 09:42:34 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2021-05-14 14:40:53 (GMT)
commit929c8a7860344b0b2edeefaf09be1ef0b09f4b23 (patch)
treea5933ca4e2f27e618240e73af10972a35bf0cf5b
parent21da0f83a21794bdd283210608ca7c127db084ec (diff)
downloadCMake-929c8a7860344b0b2edeefaf09be1ef0b09f4b23.zip
CMake-929c8a7860344b0b2edeefaf09be1ef0b09f4b23.tar.gz
CMake-929c8a7860344b0b2edeefaf09be1ef0b09f4b23.tar.bz2
INTERFACE_POSITION_INDEPENDENT_CODE must be transitive for OBJECT library
Fixes: #22174
-rw-r--r--Source/cmLocalGenerator.cxx7
-rw-r--r--Tests/PositionIndependentTargets/interface/CMakeLists.txt3
2 files changed, 3 insertions, 7 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index ced535d..c101ff3 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -2306,13 +2306,6 @@ void cmLocalGenerator::AddCMP0018Flags(std::string& flags,
if (this->GetShouldUseOldFlags(shared, lang)) {
this->AddSharedFlags(flags, lang, shared);
} else {
- if (target->GetType() == cmStateEnums::OBJECT_LIBRARY) {
- if (target->GetPropertyAsBool("POSITION_INDEPENDENT_CODE")) {
- this->AddPositionIndependentFlags(flags, lang, targetType);
- }
- return;
- }
-
if (target->GetLinkInterfaceDependentBoolProperty(
"POSITION_INDEPENDENT_CODE", config)) {
this->AddPositionIndependentFlags(flags, lang, targetType);
diff --git a/Tests/PositionIndependentTargets/interface/CMakeLists.txt b/Tests/PositionIndependentTargets/interface/CMakeLists.txt
index 65f3b76..90186a3 100644
--- a/Tests/PositionIndependentTargets/interface/CMakeLists.txt
+++ b/Tests/PositionIndependentTargets/interface/CMakeLists.txt
@@ -12,6 +12,9 @@ set_property(TARGET sharedlib PROPERTY DEFINE_SYMBOL PIC_TEST_BUILD_DLL)
add_executable(test_iface_via_shared "${CMAKE_CURRENT_SOURCE_DIR}/../pic_main.cpp")
target_link_libraries(test_iface_via_shared sharedlib)
+add_library(objectlib OBJECT "${CMAKE_CURRENT_SOURCE_DIR}/../pic_lib.cpp")
+target_link_libraries(objectlib piciface)
+
add_library(sharedlibpic SHARED "${CMAKE_CURRENT_SOURCE_DIR}/../pic_lib.cpp")
set_property(TARGET sharedlibpic PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE ON)
set_property(TARGET sharedlibpic PROPERTY DEFINE_SYMBOL PIC_TEST_BUILD_DLL)