File tree Expand file tree Collapse file tree 9 files changed +22
-28
lines changed Expand file tree Collapse file tree 9 files changed +22
-28
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,12 @@ if(POLICY CMP0054)
8
8
cmake_policy (SET CMP0054 NEW )
9
9
endif ()
10
10
11
+ # Enable the IN_LIST operator, as in:
12
+ # `if(<element_variable> IN_LIST <list_variable>)`
13
+ if (POLICY CMP0057 )
14
+ cmake_policy (SET CMP0057 NEW )
15
+ endif ()
16
+
11
17
# Add path for custom CMake modules.
12
18
list (APPEND CMAKE_MODULE_PATH
13
19
"${CMAKE_CURRENT_SOURCE_DIR} /cmake/modules" )
@@ -491,11 +497,10 @@ function(is_sdk_requested name result_var_name)
491
497
if ("${SWIFT_HOST_VARIANT_SDK} " STREQUAL "${name} " )
492
498
set ("${result_var_name} " "TRUE" PARENT_SCOPE )
493
499
else ()
494
- list (FIND SWIFT_SDKS "${name} " sdk_index )
495
- if (${sdk_index} EQUAL -1 )
496
- set ("${result_var_name} " "FALSE" PARENT_SCOPE )
497
- else ()
500
+ if ("${name} " IN_LIST SWIFT_SDKS )
498
501
set ("${result_var_name} " "TRUE" PARENT_SCOPE )
502
+ else ()
503
+ set ("${result_var_name} " "FALSE" PARENT_SCOPE )
499
504
endif ()
500
505
endif ()
501
506
endfunction ()
Original file line number Diff line number Diff line change @@ -67,8 +67,7 @@ endforeach()
67
67
file (GLOB SWIFT_API_NOTES_INPUT_FILES "${SWIFT_API_NOTES_PATH} /*.apinotes" )
68
68
foreach (file ${SWIFT_API_NOTES_INPUT_FILES} )
69
69
get_filename_component (name "${file} " NAME_WE )
70
- list (FIND SWIFT_API_NOTES_INPUTS "${name} " name_index )
71
- if (name_index EQUAL -1 )
70
+ if (NOT "${name} " IN_LIST SWIFT_API_NOTES_INPUTS )
72
71
message (SEND_ERROR "Found apinotes for ${name} ; please add to CMakeLists.txt" )
73
72
endif ()
74
73
endforeach ()
Original file line number Diff line number Diff line change @@ -618,8 +618,7 @@ function(_add_swift_library_single target name)
618
618
else ()
619
619
string (REPLACE swift "" module_name "${name} " )
620
620
endif ()
621
- list (FIND SWIFT_API_NOTES_INPUTS "${module_name} " overlay_index )
622
- if (NOT ${overlay_index} EQUAL -1 )
621
+ if ("${module_name} " IN_LIST SWIFT_API_NOTES_INPUTS )
623
622
set (SWIFTLIB_SINGLE_API_NOTES "${module_name} " )
624
623
endif ()
625
624
Original file line number Diff line number Diff line change @@ -60,8 +60,7 @@ function(add_swift_unittest test_dirname)
60
60
endif ()
61
61
62
62
if (SWIFT_RUNTIME_USE_SANITIZERS )
63
- list (FIND SWIFT_RUNTIME_USE_SANITIZERS "Thread" THREAD_INDEX )
64
- if (NOT THREAD_INDEX EQUAL -1 )
63
+ if ("Thread" IN_LIST SWIFT_RUNTIME_USE_SANITIZERS )
65
64
set_property (TARGET "${test_dirname} " APPEND_STRING PROPERTY COMPILE_FLAGS
66
65
" -fsanitize=thread" )
67
66
set_property (TARGET "${test_dirname} " APPEND_STRING PROPERTY
Original file line number Diff line number Diff line change @@ -16,11 +16,10 @@ include(SwiftUtils)
16
16
function (_make_acct_argument_list )
17
17
set (args )
18
18
foreach (k ${ARGN} )
19
- list (FIND options ${k} option_index )
20
- if (${option_index} EQUAL -1 )
21
- list (APPEND args ${${k}_keyword} ${ACCT_${k}} )
22
- else ()
19
+ if (${k} IN_LIST options )
23
20
list (APPEND args ${${k}_keyword} )
21
+ else ()
22
+ list (APPEND args ${${k}_keyword} ${ACCT_${k}} )
24
23
endif ()
25
24
endforeach ()
26
25
set (args ${args} PARENT_SCOPE )
Original file line number Diff line number Diff line change @@ -79,8 +79,7 @@ macro(swift_configure_components)
79
79
endforeach ()
80
80
81
81
foreach (component ${SWIFT_INSTALL_COMPONENTS} )
82
- list (FIND _SWIFT_DEFINED_COMPONENTS "${component} " index )
83
- if (${index} EQUAL -1 )
82
+ if (NOT "${component} " IN_LIST _SWIFT_DEFINED_COMPONENTS )
84
83
message (FATAL_ERROR "unknown install component: ${component} " )
85
84
endif ()
86
85
@@ -96,8 +95,7 @@ function(swift_is_installing_component component result_var_name)
96
95
if ("${component} " STREQUAL "never_install" )
97
96
set ("${result_var_name} " FALSE PARENT_SCOPE )
98
97
else ()
99
- list (FIND _SWIFT_DEFINED_COMPONENTS "${component} " index )
100
- if (${index} EQUAL -1 )
98
+ if (NOT "${component} " IN_LIST _SWIFT_DEFINED_COMPONENTS )
101
99
message (FATAL_ERROR "unknown install component: ${component} " )
102
100
endif ()
103
101
Original file line number Diff line number Diff line change @@ -3,8 +3,7 @@ include(SwiftUtils)
3
3
function (list_subtract lhs rhs result_var_name )
4
4
set (result )
5
5
foreach (item IN LISTS lhs )
6
- list (FIND rhs "${item} " index )
7
- if (${index} EQUAL -1 )
6
+ if (NOT "${item} " IN_LIST rhs )
8
7
list (APPEND result "${item} " )
9
8
endif ()
10
9
endforeach ()
@@ -14,8 +13,7 @@ endfunction()
14
13
function (list_intersect lhs rhs result_var_name )
15
14
set (result )
16
15
foreach (item IN LISTS lhs )
17
- list (FIND rhs "${item} " index )
18
- if (NOT ${index} EQUAL -1 )
16
+ if ("${item} " IN_LIST rhs )
19
17
list (APPEND result "${item} " )
20
18
endif ()
21
19
endforeach ()
@@ -25,8 +23,7 @@ endfunction()
25
23
function (list_union lhs rhs result_var_name )
26
24
set (result )
27
25
foreach (item IN LISTS lhs rhs )
28
- list (FIND result "${item} " index )
29
- if (${index} EQUAL -1 )
26
+ if (NOT "${item} " IN_LIST result )
30
27
list (APPEND result "${item} " )
31
28
endif ()
32
29
endforeach ()
Original file line number Diff line number Diff line change @@ -31,8 +31,7 @@ function(check_imported_target_has_imported_configuration target config)
31
31
message (FATAL_ERROR "No import configuration of ${target} specified?!" )
32
32
endif ()
33
33
34
- list (FIND IMPORTED_CONFIGS_LIST "${config} " FOUND_CONFIG )
35
- if (FOUND_CONFIG EQUAL -1 )
34
+ if (NOT "${config} " IN_LIST IMPORTED_CONFIGS_LIST )
36
35
message (FATAL_ERROR "${target} does not have imported config '${config} '?! Instead: ${IMPORTED_CONFIGS_LIST} " )
37
36
endif ()
38
37
endfunction ()
Original file line number Diff line number Diff line change @@ -7,8 +7,7 @@ set(SWIFT_RUNTIME_SWIFT_LINK_FLAGS)
7
7
8
8
if (SWIFT_RUNTIME_USE_SANITIZERS )
9
9
# TODO: Refactor this
10
- list (FIND SWIFT_RUNTIME_USE_SANITIZERS "Thread" THREAD_INDEX )
11
- if (NOT THREAD_INDEX EQUAL -1 )
10
+ if ("Thread" IN_LIST SWIFT_RUNTIME_USE_SANITIZERS )
12
11
list (APPEND SWIFT_RUNTIME_CXX_FLAGS "-fsanitize=thread" )
13
12
list (APPEND SWIFT_RUNTIME_LINK_FLAGS "-fsanitize=thread" )
14
13
list (APPEND SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS "-sanitize=thread" )
You can’t perform that action at this time.
0 commit comments