6
6
# See http://swift.org/LICENSE.txt for license information
7
7
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
8
8
9
- # Returns the os name in a variable
10
- #
11
- # Usage:
12
- # get_swift_host_os(result_var_name)
13
- #
14
- #
15
- # Sets ${result_var_name} with the converted OS name derived from
16
- # CMAKE_SYSTEM_NAME.
17
- function (get_swift_host_os result_var_name)
18
- set (${result_var_name} ${SWIFT_SYSTEM_NAME} PARENT_SCOPE)
19
- endfunction ()
20
-
21
- # Returns the path to the Swift Testing library installation directory
22
- #
23
- # Usage:
24
- # get_swift_testing_install_lib_dir(type result_var_name)
25
- #
26
- # Arguments:
27
- # type: The type of the library (STATIC_LIBRARY, SHARED_LIBRARY, or EXECUTABLE).
28
- # Typically, the value of the TYPE target property.
29
- # result_var_name: The name of the variable to set
30
- function (get_swift_testing_install_lib_dir type result_var_name)
31
- get_swift_host_os(swift_os)
32
- if (type STREQUAL STATIC_LIBRARY)
33
- set (swift swift_static)
34
- else ()
35
- set (swift swift)
36
- endif ()
37
-
38
- if (APPLE )
39
- set (${result_var_name} "lib/${swift} /${swift_os} /testing" PARENT_SCOPE)
40
- else ()
41
- set (${result_var_name} "lib/${swift} /${swift_os} " PARENT_SCOPE)
42
- endif ()
43
- endfunction ()
44
-
45
9
function (_swift_testing_install_target module)
46
- target_compile_options (${module} PRIVATE "-no-toolchain-stdlib-rpath" )
47
-
48
- if (APPLE )
49
- set_target_properties (${module} PROPERTIES
50
- INSTALL_RPATH "@loader_path/.."
51
- INSTALL_REMOVE_ENVIRONMENT_RPATH ON )
52
- else ()
53
- set_target_properties (${module} PROPERTIES
54
- INSTALL_RPATH "$ORIGIN"
55
- INSTALL_REMOVE_ENVIRONMENT_RPATH ON )
56
- endif ()
57
-
58
- get_target_property (type ${module} TYPE )
59
- get_swift_testing_install_lib_dir(${type} lib_destination_dir)
60
-
61
10
install (TARGETS ${module}
62
- ARCHIVE DESTINATION "${lib_destination_dir } "
63
- LIBRARY DESTINATION "${lib_destination_dir } "
11
+ ARCHIVE DESTINATION "${SwiftTesting_INSTALL_LIBDIR } "
12
+ LIBRARY DESTINATION "${SwiftTesting_INSTALL_LIBDIR } "
64
13
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
14
+
15
+ get_target_property (type ${module} TYPE )
65
16
if (type STREQUAL EXECUTABLE)
66
17
return ()
67
18
endif ()
@@ -71,23 +22,13 @@ function(_swift_testing_install_target module)
71
22
set (module_name ${module} )
72
23
endif ()
73
24
74
- if (NOT SwiftTesting_MODULE_TRIPLE)
75
- set (module_triple_command "${CMAKE_Swift_COMPILER} " -print-target -info)
76
- if (CMAKE_Swift_COMPILER_TARGET)
77
- list (APPEND module_triple_command -target ${CMAKE_Swift_COMPILER_TARGET} )
78
- endif ()
79
- execute_process (COMMAND ${module_triple_command} OUTPUT_VARIABLE target_info_json)
80
- string (JSON module_triple GET "${target_info_json} " "target" "moduleTriple" )
81
- set (SwiftTesting_MODULE_TRIPLE "${module_triple} " CACHE STRING "swift module triple used for installed swiftmodule and swiftinterface files" )
82
- mark_as_advanced (SwiftTesting_MODULE_TRIPLE)
83
- endif ()
25
+ set (module_dir ${SwiftTesting_INSTALL_SWIFTMODULEDIR} /${module_name} .swiftmodule)
84
26
85
- set (module_dir "${lib_destination_dir} /${module_name} .swiftmodule" )
86
27
install (FILES $<TARGET_PROPERTY:${module} ,Swift_MODULE_DIRECTORY>/${module_name} .swiftdoc
87
28
DESTINATION "${module_dir} "
88
29
RENAME ${SwiftTesting_MODULE_TRIPLE} .swiftdoc)
89
30
if (APPLE )
90
- # Only Darwin has stable ABI.
31
+ # Only Darwin has stable ABI.
91
32
install (FILES $<TARGET_PROPERTY:${module} ,Swift_MODULE_DIRECTORY>/${module_name} .swiftinterface
92
33
DESTINATION "${module_dir} "
93
34
RENAME ${SwiftTesting_MODULE_TRIPLE} .swiftinterface)
@@ -114,9 +55,6 @@ endfunction()
114
55
# swiftcrossimport_dir: The path to the source .swiftcrossimport directory
115
56
# which will be installed.
116
57
function (_swift_testing_install_swiftcrossimport module swiftcrossimport_dir)
117
- get_target_property (type ${module} TYPE )
118
- get_swift_testing_install_lib_dir(${type} lib_destination_dir)
119
-
120
58
install (DIRECTORY "${swiftcrossimport_dir} "
121
- DESTINATION "${lib_destination_dir } " )
59
+ DESTINATION "${SwiftTesting_INSTALL_SWIFTMODULEDIR } " )
122
60
endfunction ()
0 commit comments