CMake: Add helper to swiftify imported properties from dependencies

Works around https://gitlab.kitware.com/cmake/cmake/-/issues/26195
This commit is contained in:
Andrew Kaster 2024-08-17 12:51:34 -06:00 committed by Andrew Kaster
parent 756ef2c722
commit 7f0044a721
Notes: github-actions[bot] 2024-08-17 23:45:30 +00:00
3 changed files with 19 additions and 0 deletions

View file

@ -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)

View file

@ -22,3 +22,16 @@ add_compile_options("SHELL:$<$<COMPILE_LANGUAGE:Swift>:-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 "$<$<COMPILE_LANGUAGE:C,CXX,ASM>:${property}>")
set(swift_property "SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xcc ${property}>")
list(APPEND munged_properties "${cxx_property}" "${swift_property}")
endforeach()
set_property(TARGET ${target_name} PROPERTY INTERFACE_COMPILE_OPTIONS ${munged_properties})
endfunction()

View file

@ -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()