From 929c8a7860344b0b2edeefaf09be1ef0b09f4b23 Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Fri, 14 May 2021 11:42:34 +0200 Subject: INTERFACE_POSITION_INDEPENDENT_CODE must be transitive for OBJECT library Fixes: #22174 --- Source/cmLocalGenerator.cxx | 7 ------- Tests/PositionIndependentTargets/interface/CMakeLists.txt | 3 +++ 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) -- cgit v0.12