@@ -18,28 +18,44 @@ function(get_swift_host_os result_var_name)
1818 set (${result_var_name} ${SWIFT_SYSTEM_NAME} PARENT_SCOPE)
1919endfunction ()
2020
21- function (_swift_testing_install_target module)
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)
2231 get_swift_host_os(swift_os)
23- get_target_property (type ${module} TYPE )
24-
2532 if (type STREQUAL STATIC_LIBRARY)
2633 set (swift swift_static)
2734 else ()
2835 set (swift swift)
2936 endif ()
3037
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+ function (_swift_testing_install_target module)
3146 target_compile_options (Testing PRIVATE "-no-toolchain-stdlib-rpath" )
3247
33- if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" )
34- set (lib_destination_dir "lib/${swift} /${swift_os} /testing" )
48+ if (APPLE )
3549 set_property (TARGET ${module} PROPERTY
3650 INSTALL_RPATH "@loader_path/.." )
3751 else ()
38- set (lib_destination_dir "lib/${swift} /${swift_os} " )
3952 set_property (TARGET ${module} PROPERTY
4053 INSTALL_RPATH "$ORIGIN" )
4154 endif ()
4255
56+ get_target_property (type ${module} TYPE )
57+ get_swift_testing_install_lib_dir(${type} lib_destination_dir)
58+
4359 install (TARGETS ${module}
4460 ARCHIVE DESTINATION "${lib_destination_dir} "
4561 LIBRARY DESTINATION "${lib_destination_dir} "
@@ -71,7 +87,7 @@ function(_swift_testing_install_target module)
7187 install (FILES $<TARGET_PROPERTY:${module} ,Swift_MODULE_DIRECTORY>/${module_name} .swiftmodule
7288 DESTINATION "${module_dir} "
7389 RENAME ${SwiftTesting_MODULE_TRIPLE} .swiftmodule)
74- if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" )
90+ if (APPLE )
7591 # Only Darwin has stable ABI.
7692 install (FILES $<TARGET_PROPERTY:${module} ,Swift_MODULE_DIRECTORY>/${module_name} .swiftinterface
7793 DESTINATION "${module_dir} "
0 commit comments