summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-05-13 10:37:21 -0400
committerBrad King <brad.king@kitware.com>2019-05-13 10:37:21 -0400
commit620e7b1c39848ab0c37ac643a9f1595fc1e0ba97 (patch)
treef3665a326b022086ac68c84ac15c894abf708707
parent6ced0b97d5fbcaf94f88a5f3062beeb0ad75f186 (diff)
parente9d128b789f91c3f8d22e366500f58e6c7f6abc6 (diff)
downloadcmake-620e7b1c39848ab0c37ac643a9f1595fc1e0ba97.tar.gz
Merge branch 'ios-xctest-lookup' into release-3.14
Merge-request: !3309
-rw-r--r--Modules/FindXCTest.cmake19
-rw-r--r--Tests/RunCMake/XcodeProject/RunCMakeTest.cmake15
-rw-r--r--Tests/RunCMake/XcodeProject/XCTestLookup.cmake3
3 files changed, 37 insertions, 0 deletions
diff --git a/Modules/FindXCTest.cmake b/Modules/FindXCTest.cmake
index 849733661e..15721e1849 100644
--- a/Modules/FindXCTest.cmake
+++ b/Modules/FindXCTest.cmake
@@ -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
diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
index 4918f7ca48..191f56dd7a 100644
--- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
+++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
@@ -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.
diff --git a/Tests/RunCMake/XcodeProject/XCTestLookup.cmake b/Tests/RunCMake/XcodeProject/XCTestLookup.cmake
new file mode 100644
index 0000000000..77676e5bde
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XCTestLookup.cmake
@@ -0,0 +1,3 @@
+enable_language(C)
+
+find_package(XCTest REQUIRED)