From 7f0044a721b1a974163cbc46b15ad19521d45d3b Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Sat, 17 Aug 2024 12:51:34 -0600 Subject: [PATCH] CMake: Add helper to swiftify imported properties from dependencies Works around https://gitlab.kitware.com/cmake/cmake/-/issues/26195 --- AK/CMakeLists.txt | 1 + Meta/CMake/Swift/swift-settings.cmake | 13 +++++++++++++ Meta/CMake/utils.cmake | 5 +++++ 3 files changed, 19 insertions(+) diff --git a/AK/CMakeLists.txt b/AK/CMakeLists.txt index cc501d46fe9..02cc2c9d422 100644 --- a/AK/CMakeLists.txt +++ b/AK/CMakeLists.txt @@ -58,6 +58,7 @@ else() endif() find_package(simdutf REQUIRED) +swizzle_target_properties_for_swift(simdutf::simdutf) target_link_libraries(AK PRIVATE simdutf::simdutf) if (ENABLE_SWIFT) diff --git a/Meta/CMake/Swift/swift-settings.cmake b/Meta/CMake/Swift/swift-settings.cmake index 7aa3eabc59b..cda16f540b9 100644 --- a/Meta/CMake/Swift/swift-settings.cmake +++ b/Meta/CMake/Swift/swift-settings.cmake @@ -22,3 +22,16 @@ add_compile_options("SHELL:$<$:-Xcc -std=c++23 -cxx-inte if (APPLE) set(CMAKE_Swift_COMPILER_TARGET "${CMAKE_SYSTEM_PROCESSOR}-apple-macosx${CMAKE_OSX_DEPLOYMENT_TARGET}") endif() + +# FIXME: https://gitlab.kitware.com/cmake/cmake/-/issues/26195 +# For now, we'll just manually massage the flags. +function(swizzle_target_properties_for_swift target_name) + get_property(compile_options TARGET ${target_name} PROPERTY INTERFACE_COMPILE_OPTIONS) + set(munged_properties "") + foreach(property IN LISTS compile_options) + set(cxx_property "$<$:${property}>") + set(swift_property "SHELL:$<$:-Xcc ${property}>") + list(APPEND munged_properties "${cxx_property}" "${swift_property}") + endforeach() + set_property(TARGET ${target_name} PROPERTY INTERFACE_COMPILE_OPTIONS ${munged_properties}) +endfunction() diff --git a/Meta/CMake/utils.cmake b/Meta/CMake/utils.cmake index 506ec783c90..079659b9d59 100644 --- a/Meta/CMake/utils.cmake +++ b/Meta/CMake/utils.cmake @@ -252,3 +252,8 @@ function(add_lagom_library_install_rules target_name) INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) endfunction() + +if (NOT COMMAND swizzle_target_properties_for_swift) + function(swizzle_target_properties_for_swift target) + endfunction() +endif()