@@ -90,19 +90,8 @@ function(is_darwin_based_sdk sdk_name out_var)
9090endfunction ()
9191
9292# Usage:
93- # _add_host_variant_c_compile_link_flags(
94- # RESULT_VAR_NAME result_var_name
95- # )
96- function (_add_host_variant_c_compile_link_flags)
97- set (oneValueArgs RESULT_VAR_NAME)
98- cmake_parse_arguments (CFLAGS
99- ""
100- "${oneValueArgs} "
101- ""
102- ${ARGN} )
103-
104- set (result ${${CFLAGS_RESULT_VAR_NAME} })
105-
93+ # _add_host_variant_c_compile_link_flags(name)
94+ function (_add_host_variant_c_compile_link_flags name )
10695 is_darwin_based_sdk("${SWIFT_HOST_VARIANT_SDK} " IS_DARWIN)
10796 if (IS_DARWIN)
10897 set (DEPLOYMENT_VERSION "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _DEPLOYMENT_VERSION}" )
@@ -113,49 +102,45 @@ function(_add_host_variant_c_compile_link_flags)
113102 get_target_triple(target target_variant "${SWIFT_HOST_VARIANT_SDK} " "${SWIFT_HOST_VARIANT_ARCH} "
114103 MACCATALYST_BUILD_FLAVOR ""
115104 DEPLOYMENT_VERSION "${DEPLOYMENT_VERSION} " )
116- list ( APPEND result " -target" " ${target} " )
105+ target_compile_options ( ${name} PRIVATE -target ; ${target} )
117106 endif ()
118107
119108 set (_sysroot
120109 "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _ARCH_${SWIFT_HOST_VARIANT_ARCH} _PATH}" )
121110 if (IS_DARWIN)
122- list ( APPEND result " -isysroot" " ${_sysroot} " )
111+ target_compile_options ( ${name} PRIVATE -isysroot; ${_sysroot} )
123112 elseif (NOT SWIFT_COMPILER_IS_MSVC_LIKE AND NOT "${_sysroot} " STREQUAL "/" )
124- list ( APPEND result " --sysroot=${_sysroot} " )
113+ target_compile_options ( ${name} PRIVATE --sysroot=${_sysroot} )
125114 endif ()
126115
127116 if (SWIFT_HOST_VARIANT_SDK STREQUAL ANDROID)
128117 # lld can handle targeting the android build. However, if lld is not
129118 # enabled, then fallback to the linker included in the android NDK.
130119 if (NOT SWIFT_ENABLE_LLD_LINKER)
131120 swift_android_tools_path(${SWIFT_HOST_VARIANT_ARCH} tools_path)
132- list ( APPEND result "-B" " ${tools_path} " )
121+ target_compile_options ( ${name} PRIVATE -B ${tools_path} )
133122 endif ()
134123 endif ()
135124
136125 if (IS_DARWIN)
137126 # We collate -F with the framework path to avoid unwanted deduplication
138127 # of options by target_compile_options -- this way no undesired
139128 # side effects are introduced should a new search path be added.
140- list ( APPEND result
141- " -arch" " ${SWIFT_HOST_VARIANT_ARCH} "
129+ target_compile_options ( ${name} PRIVATE
130+ -arch ${SWIFT_HOST_VARIANT_ARCH}
142131 "-F${SWIFT_SDK_${SWIFT_HOST_VARIANT_ARCH} _PATH}/../../../Developer/Library/Frameworks"
143132 "-m${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _VERSION_MIN_NAME}-version-min=${DEPLOYMENT_VERSION} " )
144133 endif ()
145134
146135 _compute_lto_flag("${SWIFT_TOOLS_ENABLE_LTO} " _lto_flag_out)
147136 if (_lto_flag_out)
148- list ( APPEND result " ${_lto_flag_out} " )
137+ target_compile_options ( ${name} PRIVATE ${_lto_flag_out} )
149138 endif ()
150-
151- set ("${CFLAGS_RESULT_VAR_NAME} " "${result} " PARENT_SCOPE)
152139endfunction ()
153140
154141
155142function (_add_host_variant_c_compile_flags target )
156- _add_host_variant_c_compile_link_flags(RESULT_VAR_NAME result)
157- target_compile_options (${target} PRIVATE
158- ${result} )
143+ _add_host_variant_c_compile_link_flags(${target} )
159144
160145 is_build_type_optimized("${CMAKE_BUILD_TYPE} " optimized)
161146 if (optimized)
@@ -318,9 +303,7 @@ function(_add_host_variant_c_compile_flags target)
318303endfunction ()
319304
320305function (_add_host_variant_link_flags target )
321- _add_host_variant_c_compile_link_flags(RESULT_VAR_NAME result)
322- target_link_options (${target} PRIVATE
323- ${result} )
306+ _add_host_variant_c_compile_link_flags(${target} )
324307
325308 if (SWIFT_HOST_VARIANT_SDK STREQUAL LINUX)
326309 target_link_libraries (${target} PRIVATE
0 commit comments