|
| 1 | +# Test if the Swift compiler returns success for supplied compiler arguments.... |
| 2 | +function(swift_supports_compiler_arguments out_var) |
| 3 | + file(WRITE "${CMAKE_BINARY_DIR}/tmp/dummy.swift" "") |
| 4 | + execute_process( |
| 5 | + COMMAND "${CMAKE_Swift_COMPILER}" -parse ${ARGN} - |
| 6 | + INPUT_FILE "${CMAKE_BINARY_DIR}/tmp/dummy.swift" |
| 7 | + OUTPUT_QUIET ERROR_QUIET |
| 8 | + RESULT_VARIABLE result |
| 9 | + ) |
| 10 | + if(NOT result) |
| 11 | + set("${out_var}" "TRUE" PARENT_SCOPE) |
| 12 | + else() |
| 13 | + set("${out_var}" "FALSE" PARENT_SCOPE) |
| 14 | + endif() |
| 15 | +endfunction() |
| 16 | + |
| 17 | +# Test if the Swift compiler supports -disable-implicit-<module>-module-import. |
| 18 | +macro(swift_supports_implicit_module module_name out_var) |
| 19 | + swift_supports_compiler_arguments(${out_var} |
| 20 | + -Xfrontend -disable-implicit-${module_name}-module-import |
| 21 | + ) |
| 22 | +endmacro() |
| 23 | + |
| 24 | +# Get "package cross-module-optimization" compiler arguments suitable for the compiler. |
| 25 | +function(swift_get_package_cmo_support out_var) |
| 26 | + # > 6.0 : Fixed feature. |
| 27 | + swift_supports_compiler_arguments(result |
| 28 | + -package-name my-package |
| 29 | + -Xfrontend -package-cmo |
| 30 | + -Xfrontend -allow-non-resilient-access |
| 31 | + ) |
| 32 | + if(result) |
| 33 | + set(${out_var} IMPLEMENTED PARENT_SCOPE) |
| 34 | + return() |
| 35 | + endif() |
| 36 | + |
| 37 | + # == 6.0 : Experimental. |
| 38 | + swift_supports_compiler_arguments(result |
| 39 | + -package-name my-package |
| 40 | + -Xfrontend -experimental-package-cmo |
| 41 | + -Xfrontend -experimental-allow-non-resilient-access |
| 42 | + -Xfrontend -experimental-package-bypass-resilience |
| 43 | + ) |
| 44 | + if(result) |
| 45 | + set(${out_var} EXPERIMENTAL PARENT_SCOPE) |
| 46 | + return() |
| 47 | + endif() |
| 48 | + |
| 49 | + # < 6.0 : Not supported. |
| 50 | + set(${out_var} NO PARENT_SCOPE) |
| 51 | +endfunction() |
0 commit comments