forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSwiftComponents.cmake
52 lines (44 loc) · 1.77 KB
/
SwiftComponents.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function(swift_is_installing_component component result_var_name)
precondition(component MESSAGE "Component name is required")
if("${component}" STREQUAL "never_install")
set("${result_var_name}" FALSE PARENT_SCOPE)
else()
list(FIND _SWIFT_KNOWN_INSTALL_COMPONENTS "${component}" index)
if(${index} EQUAL -1)
message(FATAL_ERROR "unknown install component: ${component}")
endif()
string(TOUPPER "${component}" var_name_piece)
string(REPLACE "-" "_" var_name_piece "${var_name_piece}")
set("${result_var_name}" "${SWIFT_INSTALL_${var_name_piece}}" PARENT_SCOPE)
endif()
endfunction()
# swift_install_in_component(<COMPONENT NAME>
# <same parameters as install()>)
#
# Executes the specified installation actions if the named component is
# requested to be installed.
#
# This function accepts the same parameters as install().
function(swift_install_in_component component)
precondition(component MESSAGE "Component name is required")
swift_is_installing_component("${component}" is_installing)
if(is_installing)
install(${ARGN})
endif()
endfunction()
macro(swift_configure_install_components install_components)
foreach(component ${_SWIFT_KNOWN_INSTALL_COMPONENTS})
string(TOUPPER "${component}" var_name_piece)
string(REPLACE "-" "_" var_name_piece "${var_name_piece}")
set(SWIFT_INSTALL_${var_name_piece} FALSE)
endforeach()
foreach(component ${install_components})
list(FIND _SWIFT_KNOWN_INSTALL_COMPONENTS "${component}" index)
if(${index} EQUAL -1)
message(FATAL_ERROR "unknown install component: ${component}")
endif()
string(TOUPPER "${component}" var_name_piece)
string(REPLACE "-" "_" var_name_piece "${var_name_piece}")
set(SWIFT_INSTALL_${var_name_piece} TRUE)
endforeach()
endmacro()