@@ -77,19 +77,8 @@ function(is_darwin_based_sdk sdk_name out_var)
77
77
endfunction ()
78
78
79
79
# Usage:
80
- # _add_host_variant_c_compile_link_flags(
81
- # RESULT_VAR_NAME result_var_name
82
- # )
83
- function (_add_host_variant_c_compile_link_flags )
84
- set (oneValueArgs RESULT_VAR_NAME )
85
- cmake_parse_arguments (CFLAGS
86
- ""
87
- "${oneValueArgs} "
88
- ""
89
- ${ARGN} )
90
-
91
- set (result ${${CFLAGS_RESULT_VAR_NAME}} )
92
-
80
+ # _add_host_variant_c_compile_link_flags(name)
81
+ function (_add_host_variant_c_compile_link_flags name )
93
82
is_darwin_based_sdk ("${SWIFT_HOST_VARIANT_SDK} " IS_DARWIN )
94
83
if (IS_DARWIN )
95
84
set (DEPLOYMENT_VERSION "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _DEPLOYMENT_VERSION}" )
@@ -100,49 +89,45 @@ function(_add_host_variant_c_compile_link_flags)
100
89
get_target_triple (target target_variant "${SWIFT_HOST_VARIANT_SDK} " "${SWIFT_HOST_VARIANT_ARCH} "
101
90
MACCATALYST_BUILD_FLAVOR ""
102
91
DEPLOYMENT_VERSION "${DEPLOYMENT_VERSION} " )
103
- list ( APPEND result " -target" " ${target} " )
92
+ target_compile_options ( ${name} PRIVATE -target; ${target} )
104
93
endif ()
105
94
106
95
set (_sysroot
107
96
"${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _ARCH_${SWIFT_HOST_VARIANT_ARCH} _PATH}" )
108
97
if (IS_DARWIN )
109
- list ( APPEND result " -isysroot" " ${_sysroot} " )
98
+ target_compile_options ( ${name} PRIVATE -isysroot; ${_sysroot} )
110
99
elseif (NOT SWIFT_COMPILER_IS_MSVC_LIKE AND NOT "${_sysroot} " STREQUAL "/" )
111
- list ( APPEND result " --sysroot=${_sysroot} " )
100
+ target_compile_options ( ${name} PRIVATE --sysroot=${_sysroot} )
112
101
endif ()
113
102
114
103
if (SWIFT_HOST_VARIANT_SDK STREQUAL ANDROID )
115
104
# lld can handle targeting the android build. However, if lld is not
116
105
# enabled, then fallback to the linker included in the android NDK.
117
106
if (NOT SWIFT_ENABLE_LLD_LINKER )
118
107
swift_android_tools_path (${SWIFT_HOST_VARIANT_ARCH} tools_path )
119
- list ( APPEND result "-B" " ${tools_path} " )
108
+ target_compile_options ( ${name} PRIVATE -B ${tools_path} )
120
109
endif ()
121
110
endif ()
122
111
123
112
if (IS_DARWIN )
124
113
# We collate -F with the framework path to avoid unwanted deduplication
125
114
# of options by target_compile_options -- this way no undesired
126
115
# side effects are introduced should a new search path be added.
127
- list ( APPEND result
128
- " -arch" " ${SWIFT_HOST_VARIANT_ARCH} "
116
+ target_compile_options ( ${name} PRIVATE
117
+ -arch ${SWIFT_HOST_VARIANT_ARCH}
129
118
"-F${SWIFT_SDK_${SWIFT_HOST_VARIANT_ARCH} _PATH}/../../../Developer/Library/Frameworks"
130
119
"-m${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _VERSION_MIN_NAME}-version-min=${DEPLOYMENT_VERSION} " )
131
120
endif ()
132
121
133
122
_compute_lto_flag ("${SWIFT_TOOLS_ENABLE_LTO} " _lto_flag_out )
134
123
if (_lto_flag_out )
135
- list ( APPEND result " ${_lto_flag_out} " )
124
+ target_compile_options ( ${name} PRIVATE ${_lto_flag_out} )
136
125
endif ()
137
-
138
- set ("${CFLAGS_RESULT_VAR_NAME} " "${result} " PARENT_SCOPE )
139
126
endfunction ()
140
127
141
128
142
129
function (_add_host_variant_c_compile_flags target )
143
- _add_host_variant_c_compile_link_flags (RESULT_VAR_NAME result )
144
- target_compile_options (${target} PRIVATE
145
- ${result} )
130
+ _add_host_variant_c_compile_link_flags (${target} )
146
131
147
132
is_build_type_optimized ("${CMAKE_BUILD_TYPE} " optimized )
148
133
if (optimized )
@@ -305,9 +290,7 @@ function(_add_host_variant_c_compile_flags target)
305
290
endfunction ()
306
291
307
292
function (_add_host_variant_link_flags target )
308
- _add_host_variant_c_compile_link_flags (RESULT_VAR_NAME result )
309
- target_link_options (${target} PRIVATE
310
- ${result} )
293
+ _add_host_variant_c_compile_link_flags (${target} )
311
294
312
295
if (SWIFT_HOST_VARIANT_SDK STREQUAL LINUX )
313
296
target_link_libraries (${target} PRIVATE
0 commit comments