diff --git a/CMakeLists.txt b/CMakeLists.txt index 62b22af84d..6c59d13120 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,6 +74,10 @@ else() endif() FetchContent_MakeAvailable(SwiftFoundationICU SwiftFoundation) +include(CheckLinkerFlag) + +check_linker_flag(C "LINKER:--build-id=sha1" LINKER_SUPPORTS_BUILD_ID) + # Precompute module triple for installation if(NOT SwiftFoundation_MODULE_TRIPLE) set(module_triple_command "${CMAKE_Swift_COMPILER}" -print-target-info) diff --git a/Sources/Foundation/CMakeLists.txt b/Sources/Foundation/CMakeLists.txt index b591310cda..d382f15c94 100644 --- a/Sources/Foundation/CMakeLists.txt +++ b/Sources/Foundation/CMakeLists.txt @@ -171,5 +171,9 @@ set_target_properties(Foundation PROPERTIES target_link_libraries(Foundation PUBLIC swiftDispatch) +if(LINKER_SUPPORTS_BUILD_ID) + target_link_options(Foundation PRIVATE "LINKER:--build-id=sha1") +endif() + set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS Foundation) _foundation_install_target(Foundation) diff --git a/Sources/FoundationNetworking/CMakeLists.txt b/Sources/FoundationNetworking/CMakeLists.txt index 33d6872ae7..75c8505060 100644 --- a/Sources/FoundationNetworking/CMakeLists.txt +++ b/Sources/FoundationNetworking/CMakeLists.txt @@ -71,5 +71,9 @@ target_link_options(FoundationNetworking PRIVATE set_target_properties(FoundationNetworking PROPERTIES INSTALL_RPATH "$ORIGIN") +if(LINKER_SUPPORTS_BUILD_ID) + target_link_options(FoundationNetworking PRIVATE "LINKER:--build-id=sha1") +endif() + set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS FoundationNetworking) _foundation_install_target(FoundationNetworking) diff --git a/Sources/FoundationXML/CMakeLists.txt b/Sources/FoundationXML/CMakeLists.txt index e27bd67308..9640298a71 100644 --- a/Sources/FoundationXML/CMakeLists.txt +++ b/Sources/FoundationXML/CMakeLists.txt @@ -46,5 +46,9 @@ target_link_options(FoundationXML PRIVATE set_target_properties(FoundationXML PROPERTIES INSTALL_RPATH "$ORIGIN") +if(LINKER_SUPPORTS_BUILD_ID) + target_link_options(FoundationXML PRIVATE "LINKER:--build-id=sha1") +endif() + set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS FoundationXML) _foundation_install_target(FoundationXML)