summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-02-11 13:19:52 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-02-11 13:20:03 (GMT)
commit8e39e0c3e383e226f0d4bc6f227816cc4acf9923 (patch)
tree69b396283c9c162d17623ea4304c5a2f6c45e5fc
parent783f4720f508405f0f4e30a1ba903d2851b41053 (diff)
parent5c2a92f44f4c653b9567f03f99385ab190c5fd88 (diff)
downloadCMake-8e39e0c3e383e226f0d4bc6f227816cc4acf9923.zip
CMake-8e39e0c3e383e226f0d4bc6f227816cc4acf9923.tar.gz
CMake-8e39e0c3e383e226f0d4bc6f227816cc4acf9923.tar.bz2
Merge topic 'swift-no-sdk-include' into release-3.17
5c2a92f44f Swift: Exclude SDK include paths Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4315
-rw-r--r--Modules/CMakeSwiftCompiler.cmake.in2
-rw-r--r--Modules/CMakeTestSwiftCompiler.cmake5
-rw-r--r--Modules/Platform/Darwin.cmake2
-rw-r--r--Tests/RunCMake/XcodeProject/RunCMakeTest.cmake21
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeRemoveExcessiveISystem.cmake52
-rw-r--r--Tests/RunCMake/XcodeProject/foo.swift2
-rw-r--r--Tests/RunCMake/XcodeProject/use_cmath.cpp6
7 files changed, 89 insertions, 1 deletions
diff --git a/Modules/CMakeSwiftCompiler.cmake.in b/Modules/CMakeSwiftCompiler.cmake.in
index 7c8d1c1..47ada38 100644
--- a/Modules/CMakeSwiftCompiler.cmake.in
+++ b/Modules/CMakeSwiftCompiler.cmake.in
@@ -12,3 +12,5 @@ set(CMAKE_Swift_COMPILER_ENV_VAR "SWIFTC")
set(CMAKE_Swift_COMPILER_ID_RUN 1)
set(CMAKE_Swift_SOURCE_FILE_EXTENSIONS swift)
+
+set(CMAKE_Swift_IMPLICIT_INCLUDE_DIRECTORIES "@CMAKE_Swift_IMPLICIT_INCLUDE_DIRECTORIES@")
diff --git a/Modules/CMakeTestSwiftCompiler.cmake b/Modules/CMakeTestSwiftCompiler.cmake
index 3e4ff95..d98dc9d 100644
--- a/Modules/CMakeTestSwiftCompiler.cmake
+++ b/Modules/CMakeTestSwiftCompiler.cmake
@@ -50,6 +50,11 @@ else()
"the following output:\n${__CMAKE_Swift_COMPILER_OUTPUT}\n\n")
endif()
+ # Unlike C and CXX we do not yet detect any information about the Swift ABI.
+ # However, one of the steps done for C and CXX as part of that detection is
+ # to initialize the implicit include directories. That is relevant here.
+ set(CMAKE_Swift_IMPLICIT_INCLUDE_DIRECTORIES "${_CMAKE_Swift_IMPLICIT_INCLUDE_DIRECTORIES_INIT}")
+
# Re-configure to save learned information.
configure_file(${CMAKE_ROOT}/Modules/CMakeSwiftCompiler.cmake.in
${CMAKE_PLATFORM_INFO_DIR}/CMakeSwiftCompiler.cmake @ONLY)
diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake
index e5a57b5..0a4d4e1 100644
--- a/Modules/Platform/Darwin.cmake
+++ b/Modules/Platform/Darwin.cmake
@@ -210,7 +210,7 @@ unset(_apps_paths)
include(Platform/UnixPaths)
if(_CMAKE_OSX_SYSROOT_PATH AND EXISTS ${_CMAKE_OSX_SYSROOT_PATH}/usr/include)
list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${_CMAKE_OSX_SYSROOT_PATH}/usr)
- foreach(lang C CXX OBJC OBJCXX)
+ foreach(lang C CXX OBJC OBJCXX Swift)
list(APPEND _CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES_INIT ${_CMAKE_OSX_SYSROOT_PATH}/usr/include)
endforeach()
endif()
diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
index f1dda54..342dbbc 100644
--- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
+++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
@@ -78,6 +78,15 @@ endfunction()
XcodeObjcxxFlags(XcodeObjcFlags)
XcodeObjcxxFlags(XcodeObjcxxFlags)
+function(XcodeRemoveExcessiveISystem)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeRemoveExcessiveISystem-build)
+ run_cmake(XcodeRemoveExcessiveISystem)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(XcodeRemoveExcessiveISystem-build ${CMAKE_COMMAND} --build .)
+endfunction()
+
+XcodeRemoveExcessiveISystem()
+
# Isolate device tests from host architecture selection.
unset(ENV{CMAKE_OSX_ARCHITECTURES})
@@ -297,4 +306,16 @@ if(XCODE_VERSION VERSION_GREATER_EQUAL 8)
xctest_lookup_test(tvOS appletvsimulator)
endif()
+if(XCODE_VERSION VERSION_GREATER_EQUAL 8)
+ function(XcodeRemoveExcessiveISystemSDK SDK)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeRemoveExcessiveISystemSDK-${SDK}-build)
+ set(RunCMake_TEST_OPTIONS "-DCMAKE_SYSTEM_NAME=iOS")
+ run_cmake(XcodeRemoveExcessiveISystem)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(XcodeRemoveExcessiveISystemSDK-${SDK}-build ${CMAKE_COMMAND} --build . -- -sdk ${SDK})
+ endfunction()
+
+ XcodeRemoveExcessiveISystemSDK(iphoneos)
+ XcodeRemoveExcessiveISystemSDK(iphonesimulator)
+endif()
# Please add macOS-only tests above before the device-specific tests.
diff --git a/Tests/RunCMake/XcodeProject/XcodeRemoveExcessiveISystem.cmake b/Tests/RunCMake/XcodeProject/XcodeRemoveExcessiveISystem.cmake
new file mode 100644
index 0000000..44052f0
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodeRemoveExcessiveISystem.cmake
@@ -0,0 +1,52 @@
+cmake_minimum_required (VERSION 3.14)
+
+if(NOT "$ENV{CMAKE_OSX_ARCHITECTURES}" MATCHES "[;$]")
+ set(USE_SWIFT 1)
+else()
+ set(USE_SWIFT 0)
+endif()
+
+if(IOS)
+ set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED NO)
+ set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
+ if(XCODE_VERSION VERSION_LESS 9)
+ set(USE_SWIFT 0)
+ endif()
+endif ()
+
+enable_language (CXX)
+
+if(USE_SWIFT)
+ enable_language (Swift)
+ if(NOT XCODE_VERSION VERSION_LESS 10.2)
+ set(CMAKE_Swift_LANGUAGE_VERSION 5.0)
+ elseif(NOT XCODE_VERSION VERSION_LESS 8.0)
+ set(CMAKE_Swift_LANGUAGE_VERSION 3.0)
+ endif()
+endif()
+
+# Try to find ZLIB in the SDK rather than in system locations.
+set(CMAKE_FIND_USE_PACKAGE_ROOT_PATH FALSE)
+set(CMAKE_FIND_USE_CMAKE_PATH FALSE)
+set(CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH FALSE)
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH FALSE)
+list(REMOVE_ITEM CMAKE_SYSTEM_PREFIX_PATH /usr/local /usr / /usr/X11R6 /usr/pkg /opt /sw /opt/local)
+
+find_package(ZLIB REQUIRED)
+add_library (framework_dependency STATIC)
+target_sources (framework_dependency PRIVATE use_cmath.cpp)
+target_link_libraries(framework_dependency INTERFACE ZLIB::ZLIB)
+
+add_library (framework_test SHARED use_cmath.cpp)
+if(USE_SWIFT)
+ target_sources(framework_test PRIVATE foo.swift)
+endif()
+target_link_libraries (framework_test PRIVATE framework_dependency)
+
+set_target_properties (framework_test PROPERTIES
+ FRAMEWORK TRUE
+ FRAMEWORK_VERSION A
+ MACOSX_FRAMEWORK_IDENTIFIER "framework.test"
+ VERSION "1.0"
+ SOVERSION 1.0
+ )
diff --git a/Tests/RunCMake/XcodeProject/foo.swift b/Tests/RunCMake/XcodeProject/foo.swift
new file mode 100644
index 0000000..fb2d3dc
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/foo.swift
@@ -0,0 +1,2 @@
+func foo() {
+}
diff --git a/Tests/RunCMake/XcodeProject/use_cmath.cpp b/Tests/RunCMake/XcodeProject/use_cmath.cpp
new file mode 100644
index 0000000..8a58af5
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/use_cmath.cpp
@@ -0,0 +1,6 @@
+#include <cmath>
+
+bool foo(double arg)
+{
+ return std::isfinite(arg);
+}