summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
authorGregor Jasny <gjasny@googlemail.com>2017-11-04 14:27:48 (GMT)
committerGregor Jasny <gjasny@googlemail.com>2017-12-22 20:56:53 (GMT)
commit4017bf40de512e977d59c12f4e3f6c91f5dd953d (patch)
tree4ef1e4b8d4b325e5a746273c1d036d29215a82b4 /Tests/RunCMake
parent8f4663ffb265b6216cc9da9019e6169e27f0d8ec (diff)
downloadCMake-4017bf40de512e977d59c12f4e3f6c91f5dd953d.zip
CMake-4017bf40de512e977d59c12f4e3f6c91f5dd953d.tar.gz
CMake-4017bf40de512e977d59c12f4e3f6c91f5dd953d.tar.bz2
Darwin: Emit deployment target that matches the SDK
Closes: #17431
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/XcodeProject/DeploymentTarget.c26
-rw-r--r--Tests/RunCMake/XcodeProject/DeploymentTarget.cmake32
-rw-r--r--Tests/RunCMake/XcodeProject/RunCMakeTest.cmake18
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeBundles.cmake3
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake3
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake3
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake3
7 files changed, 88 insertions, 0 deletions
diff --git a/Tests/RunCMake/XcodeProject/DeploymentTarget.c b/Tests/RunCMake/XcodeProject/DeploymentTarget.c
new file mode 100644
index 0000000..51af046
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/DeploymentTarget.c
@@ -0,0 +1,26 @@
+#include <Availability.h>
+#include <TargetConditionals.h>
+
+#if TARGET_OS_OSX
+#if __MAC_OS_X_VERSION_MIN_REQUIRED != __MAC_10_11
+#error macOS deployment version mismatch
+#endif
+#elif TARGET_OS_IOS
+#if __IPHONE_OS_VERSION_MIN_REQUIRED != __IPHONE_9_1
+#error iOS deployment version mismatch
+#endif
+#elif TARGET_OS_WATCH
+#if __WATCH_OS_VERSION_MIN_REQUIRED != __WATCHOS_2_0
+#error watchOS deployment version mismatch
+#endif
+#elif TARGET_OS_TV
+#if __TV_OS_VERSION_MIN_REQUIRED != __TVOS_9_0
+#error tvOS deployment version mismatch
+#endif
+#else
+#error unknown OS
+#endif
+
+void foo()
+{
+}
diff --git a/Tests/RunCMake/XcodeProject/DeploymentTarget.cmake b/Tests/RunCMake/XcodeProject/DeploymentTarget.cmake
new file mode 100644
index 0000000..6281352
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/DeploymentTarget.cmake
@@ -0,0 +1,32 @@
+cmake_minimum_required(VERSION 3.10)
+project(DeploymentTarget C)
+
+# using Xcode 7.1 SDK versions for deployment targets
+
+if(SDK MATCHES iphone)
+ set(CMAKE_OSX_SYSROOT ${SDK})
+ set(CMAKE_OSX_ARCHITECTURES "armv7;x86_64")
+ set(CMAKE_OSX_DEPLOYMENT_TARGET "9.1")
+ set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
+ set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO")
+elseif(SDK MATCHES watch)
+ set(CMAKE_OSX_SYSROOT ${SDK})
+ set(CMAKE_OSX_ARCHITECTURES "armv7k;i386")
+ set(CMAKE_OSX_DEPLOYMENT_TARGET "2.0")
+ set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
+ set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "")
+ set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES")
+elseif(SDK MATCHES appletv)
+ set(CMAKE_OSX_SYSROOT ${SDK})
+ set(CMAKE_OSX_DEPLOYMENT_TARGET "9.0")
+ set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
+ set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
+ set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "")
+ set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES")
+else()
+ set(CMAKE_OSX_SYSROOT ${SDK})
+ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.11")
+endif()
+
+add_library(myFramework STATIC DeploymentTarget.c)
+set_target_properties(myFramework PROPERTIES FRAMEWORK TRUE)
diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
index 7eb624c..1313cb5 100644
--- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
+++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
@@ -216,3 +216,21 @@ endfunction()
if(NOT XCODE_VERSION VERSION_LESS 7)
XcodeSchemaGeneration()
endif()
+
+if(XCODE_VERSION VERSION_GREATER_EQUAL 8)
+ function(deploymeny_target_test SDK)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/DeploymentTarget-${SDK}-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ set(RunCMake_TEST_OPTIONS "-DSDK=${SDK}")
+
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+
+ run_cmake(DeploymentTarget)
+ run_cmake_command(DeploymentTarget-${SDK} ${CMAKE_COMMAND} --build .)
+ endfunction()
+
+ foreach(SDK macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator)
+ deploymeny_target_test(${SDK})
+ endforeach()
+endif()
diff --git a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake
index 0b854d8..5d19ee8 100644
--- a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake
+++ b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake
@@ -3,6 +3,9 @@
cmake_minimum_required(VERSION 3.3)
enable_language(C)
+# due to lack of toolchain file it might point to running macOS version
+unset(CMAKE_OSX_DEPLOYMENT_TARGET CACHE)
+
if(TEST_IOS)
set(CMAKE_OSX_SYSROOT iphoneos)
set(CMAKE_OSX_ARCHITECTURES "armv7")
diff --git a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake
index fc830b1..d7f3920 100644
--- a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake
+++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake
@@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.3)
project(IOSInstallCombined CXX)
+# due to lack of toolchain file it might point to running macOS version
+unset(CMAKE_OSX_DEPLOYMENT_TARGET CACHE)
+
set(CMAKE_OSX_SYSROOT iphoneos)
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf")
diff --git a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake
index b47d3a5..28ab883 100644
--- a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake
+++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake
@@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.3)
project(XcodeIOSInstallCombinedPrune CXX)
+# due to lack of toolchain file it might point to running macOS version
+unset(CMAKE_OSX_DEPLOYMENT_TARGET CACHE)
+
set(CMAKE_OSX_SYSROOT iphoneos)
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf")
diff --git a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake
index 4b5e7ce..5e7961a 100644
--- a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake
+++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake
@@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.3)
project(XcodeIOSInstallCombinedSingleArch CXX)
+# due to lack of toolchain file it might point to running macOS version
+unset(CMAKE_OSX_DEPLOYMENT_TARGET CACHE)
+
set(CMAKE_OSX_SYSROOT iphoneos)
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf")