Skip to content

Commit 9e2a0b1

Browse files
committed
[cmake] Fix Xcode build for Release LLVM + Debug Swift.
There were a couple of thinkos here that I had to fix. This passed on my machine. Lets see if the bots agree.
1 parent d65d5e3 commit 9e2a0b1

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

cmake/modules/SwiftXcodeSupport.cmake

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
function(get_effective_platform_for_triple triple output)
55
string(FIND "${triple}" "macos" IS_MACOS)
6-
if (IS_MACOS)
6+
if (NOT IS_MACOS EQUAL -1)
77
set(${output} "" PARENT_SCOPE)
88
return()
99
endif()
10-
message(FATAL_ERROR "Not supported")
10+
message(FATAL_ERROR "Can not create an effective platform name for triple: ${triple}")
1111
endfunction()
1212

1313
function(escape_path_for_xcode config path result_var_name)
@@ -27,35 +27,36 @@ endfunction()
2727

2828
function(check_imported_target_has_imported_configuration target config)
2929
get_target_property(IMPORTED_CONFIGS_LIST ${target} IMPORTED_CONFIGURATIONS)
30-
if ("${IMPORTED_CONFIGS_LIST}" STREQUAL "NOTFOUND")
30+
if ("${IMPORTED_CONFIGS_LIST}" STREQUAL "IMPORTED_CONFIGS_LIST-NOTFOUND")
3131
message(FATAL_ERROR "No import configuration of ${target} specified?!")
3232
endif()
3333

34-
list(FIND "${IMPORTED_CONFIGS_LIST}" "${config}" FOUND_CONFIG)
35-
if (NOT FOUND_CONFIG)
36-
message(FATAL_ERROR "${target} does not have imported config '${config}'?! \
37-
Instead: ${IMPORTED_CONFIGS_LIST}")
34+
list(FIND IMPORTED_CONFIGS_LIST "${config}" FOUND_CONFIG)
35+
if (FOUND_CONFIG EQUAL -1)
36+
message(FATAL_ERROR "${target} does not have imported config '${config}'?! Instead: ${IMPORTED_CONFIGS_LIST}")
3837
endif()
3938
endfunction()
4039

41-
function(fixup_imported_target_property_for_xcode target property real_build_type)
42-
set(FULL_PROP_NAME "${property}_${real_build_type}")
40+
function(fixup_imported_target_property_for_xcode target property llvm_build_type)
41+
set(FULL_PROP_NAME "${property}_${llvm_build_type}")
4342

4443
# First try to lookup the value associated with the "real build type".
4544
get_target_property(PROP_VALUE ${target} ${FULL_PROP_NAME})
4645

4746
# If the property is unspecified, return.
48-
if ("${PROP_VALUE}" STREQUAL "NOTFOUND")
47+
if ("${PROP_VALUE}" STREQUAL "PROP_VALUE-NOTFOUND")
4948
return()
5049
endif()
5150

5251
# Otherwise for each cmake configuration that is not real_build_type, hardcode
5352
# its value to be PROP_VALUE.
54-
foreach(c ${CMAKE_CONFIGURATION_TYPES})
55-
if ("${c}" STREQUAL "${real_build_type}")
53+
foreach(build_type ${CMAKE_CONFIGURATION_TYPES})
54+
string(TOUPPER "${build_type}" build_type_upper)
55+
if ("${build_type_upper}" STREQUAL "${llvm_build_type}")
5656
continue()
5757
endif()
58-
set_target_properties(${target} PROPERTIES "${property}_${c}" "${PROP_VALUE}")
58+
set(SWIFT_BUILD_PROPERTY_NAME "${property}_${build_type_upper}")
59+
set_target_properties(${target} PROPERTIES "${SWIFT_BUILD_PROPERTY_NAME}" "${PROP_VALUE}")
5960
endforeach()
6061
endfunction()
6162

@@ -69,6 +70,8 @@ endfunction()
6970
# compiled in, so we can grab the imported location for that configuration and
7071
# splat it across the other configurations as well.
7172
function(fix_imported_targets_for_xcode imported_targets)
73+
string(TOUPPER "${LLVM_BUILD_TYPE}" LLVM_BUILD_TYPE_UPPER)
74+
7275
# This is the set of configuration specific cmake properties that are
7376
# supported for imported targets in cmake 3.4.3. Sadly, beyond hacks, it seems
7477
# that there is no way to dynamically query the list of set properties of a
@@ -93,12 +96,12 @@ function(fix_imported_targets_for_xcode imported_targets)
9396

9497
# First check that we actually imported the configuration that LLVM said
9598
# that we did. This is just a sanity check.
96-
check_imported_target_has_imported_configuration(${target} ${LLVM_BUILD_TYPE})
99+
check_imported_target_has_imported_configuration(${target} ${LLVM_BUILD_TYPE_UPPER})
97100

98101
# Then loop through all of the imported properties and translate.
99-
foreach(property ${imported_properties})
102+
foreach(property ${imported_target_properties})
100103
fixup_imported_target_property_for_xcode(
101-
${target} ${property} ${LLVM_BUILD_TYPE})
104+
${target} ${property} ${LLVM_BUILD_TYPE_UPPER})
102105
endforeach()
103106
endforeach()
104107
endfunction()

0 commit comments

Comments
 (0)