Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,5 @@ endif()
include(AvailabilityDefinitions)
include(CompilerSettings)
add_subdirectory(_TestingInternals)
add_subdirectory(Overlays)
add_subdirectory(Testing)
9 changes: 9 additions & 0 deletions Sources/Overlays/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2024 Apple Inc. and the Swift project authors
# Licensed under Apache License v2.0 with Runtime Library Exception
#
# See http://swift.org/LICENSE.txt for license information
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors

add_subdirectory(_Testing_Foundation)
39 changes: 39 additions & 0 deletions Sources/Overlays/_Testing_Foundation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2024 Apple Inc. and the Swift project authors
# Licensed under Apache License v2.0 with Runtime Library Exception
#
# See http://swift.org/LICENSE.txt for license information
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors

add_library(_Testing_Foundation
Attachments/EncodingFormat.swift
Attachments/Attachment+URL.swift
Attachments/Attachable+NSSecureCoding.swift
Attachments/Data+Attachable.swift
Attachments/Attachable+Encodable+NSSecureCoding.swift
Attachments/Attachable+Encodable.swift
Events/Clock+Date.swift
ReexportTesting.swift)

target_link_libraries(_Testing_Foundation PUBLIC
Testing)

# Although this library links Foundation on all platforms, it only does so using
# `target_link_libraries()` when building for non-Apple platforms. This is
# because that command uses the `-lFoundation` linker flag, but on Apple
# platforms Foundation is a .framework and requires a different flag. However,
# we don't need to explicitly pass any linker flag since it's handled
# automatically on Apple platforms via auto-linking.
if(NOT APPLE)
target_link_libraries(_Testing_Foundation PUBLIC
Foundation)
endif()

# Note: This does not enable Library Evolution, despite emitting a module
# interface, because Foundation does not have Library Evolution enabled for all
# platforms.
target_compile_options(_Testing_Foundation PRIVATE
-emit-module-interface -emit-module-interface-path $<TARGET_PROPERTY:_Testing_Foundation,Swift_MODULE_DIRECTORY>/_Testing_Foundation.swiftinterface)

_swift_testing_install_target(_Testing_Foundation)
4 changes: 4 additions & 0 deletions Sources/Testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,7 @@ target_compile_options(Testing PRIVATE
-emit-module-interface -emit-module-interface-path $<TARGET_PROPERTY:Testing,Swift_MODULE_DIRECTORY>/Testing.swiftinterface)

_swift_testing_install_target(Testing)

# Install the Swift cross-import overlay directory.
_swift_testing_install_swiftcrossimport(Testing
Testing.swiftcrossimport)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version: 1
modules:
- name: _Testing_Foundation
20 changes: 20 additions & 0 deletions cmake/modules/SwiftModuleInstallation.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,23 @@ function(_swift_testing_install_target module)
RENAME ${SwiftTesting_MODULE_TRIPLE}.swiftinterface)
endif()
endfunction()

# Install the specified .swiftcrossimport directory for the specified declaring
# module.
#
# Usage:
# _swift_testing_install_swiftcrossimport(module swiftcrossimport_dir)
#
# Arguments:
# module: The name of the declaring module. This is used to determine where
# the .swiftcrossimport directory should be installed, since it must be
# adjacent to the declaring module's .swiftmodule directory.
# swiftcrossimport_dir: The path to the source .swiftcrossimport directory
# which will be installed.
function(_swift_testing_install_swiftcrossimport module swiftcrossimport_dir)
get_target_property(type ${module} TYPE)
get_swift_testing_install_lib_dir(${type} lib_destination_dir)

install(DIRECTORY "${swiftcrossimport_dir}"
DESTINATION "${lib_destination_dir}")
endfunction()