Files
CMake/Tests/RunCMake/ObjectLibrary/LinkObjLHSShared.cmake
Brad King 1c15eb39d2 Tests: Suppress failures on macOS arm64 due to separate Xcode signing phase
Some tests fail because Xcode runs `POST_BUILD` commands before signing
the binaries they run.  Tell the linker to perform ad-hoc codesign even
though Xcode normally tells it not to.

Other tests fail because `install_name_tool` does not revise ad-hoc
signatures without the codesign `linker-signed` flag.  Add that flag
ourselves where needed by our tests.

For now these changes help our test suite pass so we can use it to cover
everything else.  Both of these cases may need further investigation to
update CMake to help projects in general.

Issue: #21845, #21854
2021-02-22 15:47:13 -08:00

22 lines
963 B
CMake

project(LinkObjLHSShared C)
# Create a versioned shared library that does not build as part of "all".
add_library(OtherLib SHARED a.c)
target_compile_definitions(OtherLib INTERFACE REQUIRED PRIVATE COMPILE_FOR_SHARED_LIB)
set_target_properties(OtherLib PROPERTIES SOVERSION 0 VERSION 0.0.0 EXCLUDE_FROM_ALL ON)
add_library(AnObjLib OBJECT requires.c)
target_link_libraries(AnObjLib PUBLIC OtherLib)
add_executable(LinkObjLHSShared LinkObjLHSShared.c)
target_link_libraries(LinkObjLHSShared AnObjLib)
# Verify that our dependency on OtherLib generated its versioning symlinks.
if(CMAKE_GENERATOR STREQUAL "Xcode" AND
"${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Darwin;arm64")
# Xcode runs POST_BUILD before signing, so let the linker use ad-hoc signing.
# See CMake Issue 21845.
target_link_options(LinkObjLHSShared PRIVATE LINKER:-adhoc_codesign)
endif()
add_custom_command(TARGET LinkObjLHSShared POST_BUILD COMMAND LinkObjLHSShared)