Files
swift-mirror/test/cmake/modules/SwiftTestUtils.cmake
Daniel Rodríguez Troitiño c869cbf6b9 [test] Move utility functions into reusable CMake file.
Some pieces of the main CMakeLists.txt file are useful to future
CMakeLists.txt. In order to avoid duplication, move those pieces into a
new SwiftTestsUtils.cmake to be able to include the functions from other
files.

This should not modify anything in the behaviour of the build.
2020-11-24 14:54:30 -08:00

49 lines
1.6 KiB
CMake

# SwiftTestUtils.cmake
#
# Utility functions for Swift testing targets
# Get the possible build flavors for testing
function(get_swift_test_build_flavors build_flavors_out_var sdk)
set(build_flavors "default")
if(SWIFT_ENABLE_MACCATALYST AND "${sdk}" STREQUAL "OSX")
list(APPEND build_flavors "ios-like")
endif()
set(${build_flavors_out_var} ${build_flavors} PARENT_SCOPE)
endfunction()
# Get the variant suffix for test targets and folders
function(get_swift_test_variant_suffix variant_suffix_out_var sdk arch build_flavor)
if(build_flavor STREQUAL "ios-like")
set(variant_suffix "-${SWIFT_SDK_${sdk}_LIB_SUBDIR}-maccatalyst-${arch}")
else()
set(variant_suffix "-${SWIFT_SDK_${sdk}_LIB_SUBDIR}-${arch}")
endif()
set(${variant_suffix_out_var} "${variant_suffix}" PARENT_SCOPE)
endfunction()
# Get the variant triple for test targets
function(get_swift_test_versioned_target_triple variant_triple_out_var sdk arch build_flavor)
if(build_flavor STREQUAL "ios-like")
# Use the macCatalyst target triple and compiler resources for the iOS-like build flavor.
set(variant_triple "${arch}-apple-ios13.0-macabi")
else()
get_versioned_target_triple(variant_triple ${sdk} ${arch} "${SWIFT_SDK_${sdk}_DEPLOYMENT_VERSION}")
endif()
set(${variant_triple_out_var} "${variant_triple}" PARENT_SCOPE)
endfunction()
# Get the default OSX variant suffix for test targets
function(get_swift_test_default_osx_variant_suffix suffix_out_var original_variant_suffix build_flavor)
set(suffix "")
if(build_flavor STREQUAL "ios-like")
set(suffix "${variant_suffix}")
endif()
set(${suffix_out_var} "${suffix}" PARENT_SCOPE)
endfunction()