Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove macros in FindSwiftXCTest.cmake #5

Merged
merged 1 commit into from
Mar 6, 2024
Merged
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
25 changes: 13 additions & 12 deletions cmake/modules/FindSwiftXCTest.cmake
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
find_package(XCTest)

# Adds the XCTest target.
macro(_FindSwiftXCTest_add_XCTest)
# This is a macro because it ultimately calls find_package, which
# will set variables inside the function scope from which it was
# called.
function(_FindSwiftXCTest_add_XCTest)
if(APPLE)
_FindSwiftXCTest_add_XCTest_apple()
elseif(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows")
_FindSwiftXCTest_add_XCTest_windows()
else()
_FindSwiftXCTest_add_XCTest_unknown_host()
endif()
endmacro()
endfunction()

# Uses the Apple-only support in FindXCTest to create the XCTest library.
macro(_FindSwiftXCTest_add_XCTest_apple)
# This is a macro because it calls find_package, which will set
# variables inside the function scope from which it was called.
find_package(XCTest REQUIRED)
message("XCTest was found? ${XCTest_FOUND}")
function(_FindSwiftXCTest_add_XCTest_apple)
if(NOT XCTest_FOUND)
message(FATAL_ERROR "XCTest is required, but was not found.")
endif()
add_library(XCTest INTERFACE) # the Objective-C XCTest module
target_link_libraries(XCTest INTERFACE ${XCTest_LIBRARIES})
endmacro()
endfunction()

# Adds the XCTest library using the same logic as Swift Package
# Manager uses.
Expand Down Expand Up @@ -175,7 +173,10 @@ function(add_swift_xctest test_target testee)
set(dependencies ${ARG_DEPENDENCIES})

if(APPLE)


if(NOT XCTest_FOUND)
message(FATAL_ERROR "XCTest is required, but was not found.")
endif()
xctest_add_bundle(${test_target} ${testee} ${sources})
target_link_libraries(${test_target} PRIVATE SwiftXCTest ${dependencies})
xctest_add_test(XCTest.${test_target} ${test_target})
Expand Down
Loading