@@ -90,19 +90,8 @@ function(is_darwin_based_sdk sdk_name out_var)
90
90
endfunction ()
91
91
92
92
# 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 )
106
95
is_darwin_based_sdk ("${SWIFT_HOST_VARIANT_SDK} " IS_DARWIN )
107
96
if (IS_DARWIN )
108
97
set (DEPLOYMENT_VERSION "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _DEPLOYMENT_VERSION}" )
@@ -113,49 +102,45 @@ function(_add_host_variant_c_compile_link_flags)
113
102
get_target_triple (target target_variant "${SWIFT_HOST_VARIANT_SDK} " "${SWIFT_HOST_VARIANT_ARCH} "
114
103
MACCATALYST_BUILD_FLAVOR ""
115
104
DEPLOYMENT_VERSION "${DEPLOYMENT_VERSION} " )
116
- list ( APPEND result " -target" " ${target} " )
105
+ target_compile_options ( ${name} PRIVATE -target; ${target} )
117
106
endif ()
118
107
119
108
set (_sysroot
120
109
"${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _ARCH_${SWIFT_HOST_VARIANT_ARCH} _PATH}" )
121
110
if (IS_DARWIN )
122
- list ( APPEND result " -isysroot" " ${_sysroot} " )
111
+ target_compile_options ( ${name} PRIVATE -isysroot; ${_sysroot} )
123
112
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} )
125
114
endif ()
126
115
127
116
if (SWIFT_HOST_VARIANT_SDK STREQUAL ANDROID )
128
117
# lld can handle targeting the android build. However, if lld is not
129
118
# enabled, then fallback to the linker included in the android NDK.
130
119
if (NOT SWIFT_ENABLE_LLD_LINKER )
131
120
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} )
133
122
endif ()
134
123
endif ()
135
124
136
125
if (IS_DARWIN )
137
126
# We collate -F with the framework path to avoid unwanted deduplication
138
127
# of options by target_compile_options -- this way no undesired
139
128
# 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}
142
131
"-F${SWIFT_SDK_${SWIFT_HOST_VARIANT_ARCH} _PATH}/../../../Developer/Library/Frameworks"
143
132
"-m${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _VERSION_MIN_NAME}-version-min=${DEPLOYMENT_VERSION} " )
144
133
endif ()
145
134
146
135
_compute_lto_flag ("${SWIFT_TOOLS_ENABLE_LTO} " _lto_flag_out )
147
136
if (_lto_flag_out )
148
- list ( APPEND result " ${_lto_flag_out} " )
137
+ target_compile_options ( ${name} PRIVATE ${_lto_flag_out} )
149
138
endif ()
150
-
151
- set ("${CFLAGS_RESULT_VAR_NAME} " "${result} " PARENT_SCOPE )
152
139
endfunction ()
153
140
154
141
155
142
function (_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} )
159
144
160
145
is_build_type_optimized ("${CMAKE_BUILD_TYPE} " optimized )
161
146
if (optimized )
@@ -318,9 +303,7 @@ function(_add_host_variant_c_compile_flags target)
318
303
endfunction ()
319
304
320
305
function (_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} )
324
307
325
308
if (SWIFT_HOST_VARIANT_SDK STREQUAL LINUX )
326
309
target_link_libraries (${target} PRIVATE
0 commit comments