diff options
-rw-r--r-- | Source/cmComputeLinkInformation.cxx | 19 | ||||
-rw-r--r-- | Tests/RunCMake/AppleTextStubs/LibraryWithOutputs.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/AppleTextStubs/RunCMakeTest.cmake | 7 |
3 files changed, 26 insertions, 3 deletions
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 5d44a6a..b80b3cb 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1175,7 +1175,14 @@ void cmComputeLinkInformation::AddItem(LinkEntry const& entry) LinkEntry libEntry{ entry }; libEntry.Item = lib; this->AddTargetItem(libEntry); - this->AddLibraryRuntimeInfo(lib.Value, tgt); + if (tgt->IsApple() && tgt->HasImportLibrary(config)) { + // Use the library rather than the tbd file for runpath computation + this->AddLibraryRuntimeInfo( + tgt->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact, true), + tgt); + } else { + this->AddLibraryRuntimeInfo(lib.Value, tgt); + } if (tgt && tgt->GetType() == cmStateEnums::SHARED_LIBRARY && this->Target->IsDLLPlatform()) { this->AddRuntimeDLL(tgt); @@ -1261,7 +1268,15 @@ void cmComputeLinkInformation::AddSharedDepItem(LinkEntry const& entry) ? cmStateEnums::ImportLibraryArtifact : cmStateEnums::RuntimeBinaryArtifact; lib = tgt->GetFullPath(this->Config, artifact); - this->AddLibraryRuntimeInfo(lib, tgt); + if (tgt->IsApple() && tgt->HasImportLibrary(this->Config)) { + // Use the library rather than the tbd file for runpath computation + this->AddLibraryRuntimeInfo( + tgt->GetFullPath(this->Config, cmStateEnums::RuntimeBinaryArtifact, + true), + tgt); + } else { + this->AddLibraryRuntimeInfo(lib, tgt); + } } else { lib = item.Value; this->AddLibraryRuntimeInfo(lib); diff --git a/Tests/RunCMake/AppleTextStubs/LibraryWithOutputs.cmake b/Tests/RunCMake/AppleTextStubs/LibraryWithOutputs.cmake index f61c8f2..9c7107a 100644 --- a/Tests/RunCMake/AppleTextStubs/LibraryWithOutputs.cmake +++ b/Tests/RunCMake/AppleTextStubs/LibraryWithOutputs.cmake @@ -7,6 +7,9 @@ set_property(TARGET foo PROPERTY ARCHIVE_OUTPUT_NAME "tbd") add_executable(main main.c) target_link_libraries(main PRIVATE foo) +set_property(TARGET main PROPERTY RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/$<CONFIG>") + +add_custom_target(run COMMAND "$<TARGET_FILE:main>") set (GENERATE_CONTENT "if (\"${CMAKE_TAPI}\") diff --git a/Tests/RunCMake/AppleTextStubs/RunCMakeTest.cmake b/Tests/RunCMake/AppleTextStubs/RunCMakeTest.cmake index 9ccd685..7687106 100644 --- a/Tests/RunCMake/AppleTextStubs/RunCMakeTest.cmake +++ b/Tests/RunCMake/AppleTextStubs/RunCMakeTest.cmake @@ -19,7 +19,12 @@ endfunction() build_project(Simple) build_project(Framework) -build_project(LibraryWithOutputs) + +function(LibraryWithOutputs-run) + run_cmake_command(${test}-run ${CMAKE_COMMAND} --build . --target run --config Release) +endfunction() + +build_project(LibraryWithOutputs LibraryWithOutputs-run) function(LibraryWithVersions-install) |