Commit 7d9db24f authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'ios-xctest-lookup'

e9d128b7 Apple: Properly lookup XCTest for iOS and tvOS
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !3309
parents 9d48d3f6 e9d128b7
Pipeline #136936 passed with stage
in 0 seconds
......@@ -61,6 +61,22 @@ The following variables are set by including this module:
#]=======================================================================]
set(_PRESERVED_CMAKE_FIND_ROOT_PATH "${CMAKE_FIND_ROOT_PATH}")
if(CMAKE_EFFECTIVE_SYSTEM_NAME STREQUAL "Apple"
AND NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# Non-macos systems set the CMAKE_FIND_ROOT_PATH_MODE to "ONLY" which
# restricts the search paths too much to find XCTest.framework. In
# contrast to the regular system frameworks which reside within the
# SDK direectory the XCTest framework is located in the respective
# platform directory which is not added to the CMAKE_FIND_ROOT_PATH
# (only to CMAKE_SYSTEM_FRAMEWORK_PATH) and therefore not searched.
#
# Until this is properly addressed, temporaily add the platform
# directory to CMAKE_FIND_ROOT_PATH.
list(APPEND CMAKE_FIND_ROOT_PATH "${_CMAKE_OSX_SYSROOT_PATH}/../..")
endif()
find_path(XCTest_INCLUDE_DIR
NAMES "XCTest/XCTest.h"
DOC "XCTest include directory")
......@@ -71,6 +87,9 @@ find_library(XCTest_LIBRARY
DOC "XCTest Framework library")
mark_as_advanced(XCTest_LIBRARY)
set(CMAKE_FIND_ROOT_PATH "${_PRESERVED_CMAKE_FIND_ROOT_PATH}")
unset(_PRESERVED_CMAKE_FIND_ROOT_PATH)
execute_process(
COMMAND xcrun --find xctest
OUTPUT_VARIABLE _xcrun_out OUTPUT_STRIP_TRAILING_WHITESPACE
......
......@@ -256,4 +256,19 @@ if(XCODE_VERSION VERSION_GREATER_EQUAL 8)
deployment_target_test(watchOS watchsimulator)
endif()
if(XCODE_VERSION VERSION_GREATER_EQUAL 8)
function(xctest_lookup_test SystemName SDK)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XCTestLookup-${SDK}-build)
set(RunCMake_TEST_OPTIONS "-DCMAKE_SYSTEM_NAME=${SystemName}" "-DCMAKE_OSX_SYSROOT=${SDK}")
run_cmake(XCTestLookup)
endfunction()
xctest_lookup_test(Darwin macosx)
xctest_lookup_test(iOS iphoneos)
xctest_lookup_test(iOS iphonesimulator)
xctest_lookup_test(tvOS appletvos)
xctest_lookup_test(tvOS appletvsimulator)
endif()
# Please add macOS-only tests above before the device-specific tests.
enable_language(C)
find_package(XCTest REQUIRED)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment