Skip to content

Commit

Permalink
Merge pull request #5 from hylo-lang/camio-patch-1
Browse files Browse the repository at this point in the history
Remove macros in FindSwiftXCTest.cmake
  • Loading branch information
camio committed Mar 6, 2024
2 parents 8aa6d88 + b6fdf58 commit 5aac686
Showing 1 changed file with 13 additions and 12 deletions.
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

0 comments on commit 5aac686

Please sign in to comment.