FindSwiftTesting.cmake 1.0 KB

123456789101112131415161718192021222324
  1. # Finds the swift-testing library
  2. # On Apple platforms, this is a framework included in the Xcode release
  3. find_library(SWIFT_TESTING NAMES Testing
  4. PATHS ${SWIFT_LIBRARY_SEARCH_PATHS}
  5. )
  6. if (SWIFT_TESTING)
  7. if (NOT TARGET SwiftTesting::SwiftTesting)
  8. add_library(SwiftTesting::SwiftTesting IMPORTED UNKNOWN)
  9. message(STATUS "Found SwiftTesting: ${SWIFT_TESTING}")
  10. cmake_path(GET SWIFT_TESTING PARENT_PATH _SWIFT_TESTING_DIR)
  11. set_target_properties(SwiftTesting::SwiftTesting PROPERTIES
  12. IMPORTED_LOCATION "${SWIFT_TESTING}"
  13. INTERFACE_LINK_DIRECTORIES "${_SWIFT_TESTING_DIR}"
  14. )
  15. if (UNIX AND NOT APPLE)
  16. cmake_path(GET _SWIFT_TESTING_DIR PARENT_PATH _SWIFT_TESTING_TARGETLESS_DIR)
  17. set_target_properties(SwiftTesting::SwiftTesting PROPERTIES
  18. INTERFACE_COMPILE_OPTIONS "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-load-plugin-library ${_SWIFT_TESTING_TARGETLESS_DIR}/host/plugins/libTestingMacros.so>"
  19. )
  20. endif()
  21. endif()
  22. set(SwiftTesting_FOUND TRUE)
  23. endif()