From 7a0fcb907430590a227271fd54dd77334fab7cb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Rodr=C3=ADguez=20Troiti=C3=B1o?= Date: Tue, 18 Jun 2019 15:49:41 -0700 Subject: [PATCH] [cmake] Allow cross-compilation of add_swift_executable targets. Add an explicit TARGET for executable targets, to allow cross compilation and fix plutil to import Glibc also in Android. --- CMakeLists.txt | 6 ++++++ Tools/plutil/main.swift | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d320555a9c..7def02e5e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -386,6 +386,8 @@ endif() add_swift_executable(plutil SOURCES Tools/plutil/main.swift + TARGET + ${CMAKE_C_COMPILER_TARGET} CFLAGS -F${CMAKE_CURRENT_BINARY_DIR} LINK_FLAGS @@ -409,6 +411,8 @@ add_swift_executable(plutil if(ENABLE_TESTING) add_swift_executable(xdgTestHelper + TARGET + ${CMAKE_C_COMPILER_TARGET} CFLAGS -F${CMAKE_CURRENT_BINARY_DIR} LINK_FLAGS @@ -528,6 +532,8 @@ if(ENABLE_TESTING) TestFoundation/TestUUID.swift TestFoundation/TestXMLDocument.swift TestFoundation/TestXMLParser.swift + TARGET + ${CMAKE_C_COMPILER_TARGET} CFLAGS -F${CMAKE_CURRENT_BINARY_DIR} LINK_FLAGS diff --git a/Tools/plutil/main.swift b/Tools/plutil/main.swift index 5c00d93139..8a0dd01220 100644 --- a/Tools/plutil/main.swift +++ b/Tools/plutil/main.swift @@ -6,13 +6,13 @@ // See http://swift.org/LICENSE.txt for license information // See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // -#if os(macOS) || os(iOS) +#if canImport(Darwin) import Darwin import SwiftFoundation -#elseif os(Linux) +#elseif canImport(Glibc) import Foundation import Glibc -#elseif os(Windows) +#elseif canImport(MSVCRT) import Foundation import MSVCRT #endif