mirror of
https://github.com/SFML/SFML.git
synced 2024-11-24 20:31:05 +08:00
Use built-in CMake support for iOS
* Use built-in iOS support for cmake and expand tests to cover more configurations * Adjust CI builds * Update examples version --------- Co-authored-by: Chris Thrasher <chrisjthrasher@gmail.com>
This commit is contained in:
parent
92e5a1e4e6
commit
741fe219da
16
.github/workflows/ci.yml
vendored
16
.github/workflows/ci.yml
vendored
@ -21,6 +21,8 @@ jobs:
|
|||||||
- { name: Linux Clang, os: ubuntu-latest, flags: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DSFML_RUN_DISPLAY_TESTS=ON -GNinja , gcovr_options: '--gcov-executable="llvm-cov-$CLANG_VERSION gcov"' }
|
- { name: Linux Clang, os: ubuntu-latest, flags: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DSFML_RUN_DISPLAY_TESTS=ON -GNinja , gcovr_options: '--gcov-executable="llvm-cov-$CLANG_VERSION gcov"' }
|
||||||
- { name: MacOS, os: macos-11, flags: -GNinja }
|
- { name: MacOS, os: macos-11, flags: -GNinja }
|
||||||
- { name: MacOS Xcode, os: macos-11, flags: -GXcode }
|
- { name: MacOS Xcode, os: macos-11, flags: -GXcode }
|
||||||
|
- { name: iOS, os: macos-11, flags: -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_ARCHITECTURES=arm64 }
|
||||||
|
- { name: iOS Xcode, os: macos-11, suffix: -- CODE_SIGNING_ALLOWED=NO, flags: -DCMAKE_SYSTEM_NAME=iOS -GXcode }
|
||||||
config:
|
config:
|
||||||
- { name: Shared, flags: -DBUILD_SHARED_LIBS=TRUE }
|
- { name: Shared, flags: -DBUILD_SHARED_LIBS=TRUE }
|
||||||
- { name: Static, flags: -DBUILD_SHARED_LIBS=FALSE }
|
- { name: Static, flags: -DBUILD_SHARED_LIBS=FALSE }
|
||||||
@ -28,6 +30,12 @@ jobs:
|
|||||||
- { name: Release }
|
- { name: Release }
|
||||||
- { name: Debug, flags: -DCMAKE_BUILD_TYPE=Debug -DSFML_ENABLE_COVERAGE=TRUE }
|
- { name: Debug, flags: -DCMAKE_BUILD_TYPE=Debug -DSFML_ENABLE_COVERAGE=TRUE }
|
||||||
|
|
||||||
|
exclude:
|
||||||
|
- platform: { name: iOS }
|
||||||
|
config: { name: Shared }
|
||||||
|
- platform: { name: iOS Xcode }
|
||||||
|
config: { name: Shared }
|
||||||
|
|
||||||
include:
|
include:
|
||||||
- platform: { name: Windows VS2022, os: windows-2022 }
|
- platform: { name: Windows VS2022, os: windows-2022 }
|
||||||
config: { name: Unity, flags: -DBUILD_SHARED_LIBS=TRUE -DCMAKE_UNITY_BUILD=ON }
|
config: { name: Unity, flags: -DBUILD_SHARED_LIBS=TRUE -DCMAKE_UNITY_BUILD=ON }
|
||||||
@ -37,8 +45,6 @@ jobs:
|
|||||||
type: { name: Debug, flags: -DCMAKE_BUILD_TYPE=Debug -DSFML_ENABLE_COVERAGE=TRUE }
|
type: { name: Debug, flags: -DCMAKE_BUILD_TYPE=Debug -DSFML_ENABLE_COVERAGE=TRUE }
|
||||||
- platform: { name: MacOS, os: macos-11 }
|
- platform: { name: MacOS, os: macos-11 }
|
||||||
config: { name: Frameworks, flags: -GNinja -DSFML_BUILD_FRAMEWORKS=TRUE -DBUILD_SHARED_LIBS=TRUE }
|
config: { name: Frameworks, flags: -GNinja -DSFML_BUILD_FRAMEWORKS=TRUE -DBUILD_SHARED_LIBS=TRUE }
|
||||||
- platform: { name: MacOS, os: macos-11 }
|
|
||||||
config: { name: iOS, flags: -DCMAKE_TOOLCHAIN_FILE=$GITHUB_WORKSPACE/cmake/toolchains/iOS.toolchain.cmake -DIOS_PLATFORM=SIMULATOR }
|
|
||||||
- platform: { name: Android, os: ubuntu-latest }
|
- platform: { name: Android, os: ubuntu-latest }
|
||||||
config: { name: x86, flags: -GNinja -DCMAKE_ANDROID_ARCH_ABI=x86 -DCMAKE_SYSTEM_NAME=Android -DSFML_BUILD_TEST_SUITE=FALSE -DCMAKE_ANDROID_NDK=$GITHUB_WORKSPACE/android-ndk-r23b -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang -DCMAKE_ANDROID_STL_TYPE=c++_shared -DCMAKE_ANDROID_API=26 }
|
config: { name: x86, flags: -GNinja -DCMAKE_ANDROID_ARCH_ABI=x86 -DCMAKE_SYSTEM_NAME=Android -DSFML_BUILD_TEST_SUITE=FALSE -DCMAKE_ANDROID_NDK=$GITHUB_WORKSPACE/android-ndk-r23b -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang -DCMAKE_ANDROID_STL_TYPE=c++_shared -DCMAKE_ANDROID_API=26 }
|
||||||
- platform: { name: Android, os: ubuntu-latest }
|
- platform: { name: Android, os: ubuntu-latest }
|
||||||
@ -94,7 +100,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
shell: bash
|
shell: bash
|
||||||
run: cmake --build $GITHUB_WORKSPACE/build --config ${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }} --target install
|
run: cmake --build $GITHUB_WORKSPACE/build --config ${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }} --target install ${{matrix.platform.suffix}}
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
uses: nick-fields/retry@v2
|
uses: nick-fields/retry@v2
|
||||||
@ -154,11 +160,11 @@ jobs:
|
|||||||
./${{ env.CODECOV_BINARY }} -n "${{ matrix.platform.name }} ${{ matrix.config.name }} ${{ matrix.type.name }}" -Z -f ./build/coverage.out $COMMIT_OVERRIDE -s ./build -e GITHUB_ACTION,GITHUB_RUN_ID,GITHUB_REF,GITHUB_REPOSITORY,GITHUB_SHA,GITHUB_HEAD_REF
|
./${{ env.CODECOV_BINARY }} -n "${{ matrix.platform.name }} ${{ matrix.config.name }} ${{ matrix.type.name }}" -Z -f ./build/coverage.out $COMMIT_OVERRIDE -s ./build -e GITHUB_ACTION,GITHUB_RUN_ID,GITHUB_REF,GITHUB_REPOSITORY,GITHUB_SHA,GITHUB_HEAD_REF
|
||||||
|
|
||||||
- name: Test Install Interface
|
- name: Test Install Interface
|
||||||
if: matrix.platform.name != 'Android' && matrix.config.name != 'iOS'
|
if: matrix.platform.name != 'Android'
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
cmake -S $GITHUB_WORKSPACE/test/install -B $GITHUB_WORKSPACE/test/install/build -DSFML_ROOT=$GITHUB_WORKSPACE/install -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }} ${{matrix.platform.flags}} ${{matrix.config.flags}} ${{matrix.type.flags}}
|
cmake -S $GITHUB_WORKSPACE/test/install -B $GITHUB_WORKSPACE/test/install/build -DSFML_ROOT=$GITHUB_WORKSPACE/install -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }} ${{matrix.platform.flags}} ${{matrix.config.flags}} ${{matrix.type.flags}}
|
||||||
cmake --build $GITHUB_WORKSPACE/test/install/build --config ${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }}
|
cmake --build $GITHUB_WORKSPACE/test/install/build --config ${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }} ${{matrix.platform.suffix}}
|
||||||
|
|
||||||
format:
|
format:
|
||||||
name: Formatting with clang-format-${{ matrix.version }}
|
name: Formatting with clang-format-${{ matrix.version }}
|
||||||
|
@ -12,15 +12,7 @@ endmacro()
|
|||||||
|
|
||||||
# determine whether to create a debug or release build
|
# determine whether to create a debug or release build
|
||||||
sfml_set_option(CMAKE_BUILD_TYPE Release STRING "Choose the type of build (Debug or Release)")
|
sfml_set_option(CMAKE_BUILD_TYPE Release STRING "Choose the type of build (Debug or Release)")
|
||||||
|
sfml_set_option(CMAKE_OSX_DEPLOYMENT_TARGET "13.0" STRING "The minimal iOS version that will be able to run the built binaries. Cannot be lower than 13.0")
|
||||||
if(NOT CMAKE_OSX_SYSROOT)
|
|
||||||
# query the path to the default SDK, will fail on non-macOS, but it's okay.
|
|
||||||
execute_process(COMMAND xcodebuild -sdk macosx -version Path
|
|
||||||
COMMAND head -n 1
|
|
||||||
COMMAND tr -d '\n'
|
|
||||||
OUTPUT_VARIABLE CMAKE_OSX_SYSROOT
|
|
||||||
ERROR_QUIET)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# project name
|
# project name
|
||||||
project(SFML VERSION 3.0.0)
|
project(SFML VERSION 3.0.0)
|
||||||
@ -43,15 +35,11 @@ include(cmake/Config.cmake)
|
|||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
# add an option for choosing the build type (shared or static)
|
# add an option for choosing the build type (shared or static)
|
||||||
if(NOT (SFML_OS_IOS OR SFML_OS_ANDROID))
|
if(NOT SFML_OS_ANDROID)
|
||||||
sfml_set_option(BUILD_SHARED_LIBS TRUE BOOL "TRUE to build SFML as shared libraries, FALSE to build it as static libraries")
|
sfml_set_option(BUILD_SHARED_LIBS TRUE BOOL "TRUE to build SFML as shared libraries, FALSE to build it as static libraries")
|
||||||
else()
|
else()
|
||||||
if(SFML_OS_IOS)
|
|
||||||
set(BUILD_SHARED_LIBS FALSE)
|
|
||||||
elseif(SFML_OS_ANDROID)
|
|
||||||
set(BUILD_SHARED_LIBS TRUE)
|
set(BUILD_SHARED_LIBS TRUE)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
|
||||||
|
|
||||||
# add options to select which modules to build
|
# add options to select which modules to build
|
||||||
sfml_set_option(SFML_BUILD_WINDOW TRUE BOOL "TRUE to build SFML's Window module. This setting is ignored, if the graphics module is built.")
|
sfml_set_option(SFML_BUILD_WINDOW TRUE BOOL "TRUE to build SFML's Window module. This setting is ignored, if the graphics module is built.")
|
||||||
@ -70,20 +58,16 @@ if(SFML_BUILD_WINDOW)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# macOS specific options
|
# macOS specific options
|
||||||
if(SFML_OS_MACOSX)
|
if(SFML_OS_MACOSX OR SFML_OS_IOS)
|
||||||
# add an option to build frameworks instead of dylibs (release only)
|
# add an option to build frameworks instead of dylibs (release only)
|
||||||
sfml_set_option(SFML_BUILD_FRAMEWORKS FALSE BOOL "TRUE to build SFML as frameworks libraries (release only), FALSE to build according to BUILD_SHARED_LIBS")
|
sfml_set_option(SFML_BUILD_FRAMEWORKS FALSE BOOL "TRUE to build SFML as frameworks libraries (release only), FALSE to build according to BUILD_SHARED_LIBS")
|
||||||
|
|
||||||
# add an option to automatically install Xcode templates
|
if (SFML_OS_IOS AND NOT SFML_BUILD_FRAMEWORKS AND BUILD_SHARED_LIBS)
|
||||||
sfml_set_option(SFML_INSTALL_XCODE_TEMPLATES FALSE BOOL "TRUE to automatically install the Xcode templates, FALSE to do nothing about it. The templates are compatible with Xcode 4 and 5.")
|
message(FATAL_ERROR "Naked dynamic libs not supported for iOS, build static or frameworks instead")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# iOS specific options
|
# add an option to automatically install Xcode templates
|
||||||
if(SFML_OS_IOS)
|
sfml_set_option(SFML_INSTALL_XCODE_TEMPLATES FALSE BOOL "TRUE to automatically install the Xcode templates, FALSE to do nothing about it. The templates are compatible with Xcode 4 and 5.")
|
||||||
# At the moment the minimal deployement target version is 10.2 only because the externals for iOS were built with that requirement.
|
|
||||||
sfml_set_option(SFML_IOS_DEPLOYMENT_TARGET "13.0" STRING "The minimal iOS version that will be able to run the built binaries. Cannot be lower than 10.2.")
|
|
||||||
|
|
||||||
sfml_set_option(SFML_CODE_SIGN_IDENTITY "iPhone Developer" STRING "The code signing identity to use when building for a real device")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Android options
|
# Android options
|
||||||
@ -282,6 +266,10 @@ else()
|
|||||||
# find only "root" headers
|
# find only "root" headers
|
||||||
file(GLOB SFML_HEADERS RELATIVE ${PROJECT_SOURCE_DIR} "include/SFML/*")
|
file(GLOB SFML_HEADERS RELATIVE ${PROJECT_SOURCE_DIR} "include/SFML/*")
|
||||||
|
|
||||||
|
# Because we use generator expressions in the post build scripts we need to
|
||||||
|
# suppress the generation of "EFFECTIVE_PLATFORM_NAME" as it will fail
|
||||||
|
set_property(GLOBAL PROPERTY XCODE_EMIT_EFFECTIVE_PLATFORM_NAME OFF)
|
||||||
|
|
||||||
# in fact we have to fool cmake to copy all the headers in subdirectories
|
# in fact we have to fool cmake to copy all the headers in subdirectories
|
||||||
# to do that we have to add the "root" headers to the PUBLIC_HEADER
|
# to do that we have to add the "root" headers to the PUBLIC_HEADER
|
||||||
# then we can run a post script to copy the remaining headers
|
# then we can run a post script to copy the remaining headers
|
||||||
@ -448,9 +436,6 @@ elseif(SFML_OS_MACOSX)
|
|||||||
|
|
||||||
elseif(SFML_OS_IOS)
|
elseif(SFML_OS_IOS)
|
||||||
|
|
||||||
# fix CMake install rules broken for iOS (see http://public.kitware.com/Bug/view.php?id=12506)
|
|
||||||
install(DIRECTORY "${PROJECT_BINARY_DIR}/lib/\$ENV{CONFIGURATION}/" DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
|
||||||
|
|
||||||
if(NOT SFML_USE_SYSTEM_DEPS)
|
if(NOT SFML_USE_SYSTEM_DEPS)
|
||||||
# since the iOS libraries are built as static, we must install the SFML dependencies
|
# since the iOS libraries are built as static, we must install the SFML dependencies
|
||||||
# too so that the end user can easily link them to its final application
|
# too so that the end user can easily link them to its final application
|
||||||
|
@ -39,21 +39,22 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "^NetBSD$")
|
|||||||
set(SFML_OS_NETBSD 1)
|
set(SFML_OS_NETBSD 1)
|
||||||
# don't use the OpenGL ES implementation on NetBSD
|
# don't use the OpenGL ES implementation on NetBSD
|
||||||
set(OPENGL_ES 0)
|
set(OPENGL_ES 0)
|
||||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
|
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
|
||||||
if(IOS)
|
|
||||||
set(SFML_OS_IOS 1)
|
set(SFML_OS_IOS 1)
|
||||||
|
# As we want to find packages in our extlibs folder too
|
||||||
|
# we need to tell CMake we want to search there instead
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE NEVER)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||||
# use the OpenGL ES implementation on iOS
|
# use the OpenGL ES implementation on iOS
|
||||||
set(OPENGL_ES 1)
|
set(OPENGL_ES 1)
|
||||||
else()
|
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
|
||||||
set(SFML_OS_MACOSX 1)
|
set(SFML_OS_MACOSX 1)
|
||||||
|
|
||||||
# don't use the OpenGL ES implementation on Mac OS X
|
# don't use the OpenGL ES implementation on Mac OS X
|
||||||
set(OPENGL_ES 0)
|
set(OPENGL_ES 0)
|
||||||
endif()
|
|
||||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Android")
|
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Android")
|
||||||
set(SFML_OS_ANDROID 1)
|
set(SFML_OS_ANDROID 1)
|
||||||
|
|
||||||
# use the OpenGL ES implementation on Android
|
# use the OpenGL ES implementation on Android
|
||||||
set(OPENGL_ES 1)
|
set(OPENGL_ES 1)
|
||||||
# comparing CMAKE_SYSTEM_NAME with "CYGWIN" generates a false warning depending on the CMake version
|
# comparing CMAKE_SYSTEM_NAME with "CYGWIN" generates a false warning depending on the CMake version
|
||||||
|
@ -193,7 +193,7 @@ macro(sfml_add_library module)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# build frameworks or dylibs
|
# build frameworks or dylibs
|
||||||
if(SFML_OS_MACOSX AND BUILD_SHARED_LIBS AND NOT THIS_STATIC)
|
if((SFML_OS_MACOSX OR SFML_OS_IOS) AND BUILD_SHARED_LIBS AND NOT THIS_STATIC)
|
||||||
if(SFML_BUILD_FRAMEWORKS)
|
if(SFML_BUILD_FRAMEWORKS)
|
||||||
# adapt target to build frameworks instead of dylibs
|
# adapt target to build frameworks instead of dylibs
|
||||||
set_target_properties(${target} PROPERTIES
|
set_target_properties(${target} PROPERTIES
|
||||||
@ -432,11 +432,7 @@ function(sfml_find_package)
|
|||||||
message(FATAL_ERROR "Unknown arguments when calling sfml_find_package: ${THIS_UNPARSED_ARGUMENTS}")
|
message(FATAL_ERROR "Unknown arguments when calling sfml_find_package: ${THIS_UNPARSED_ARGUMENTS}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(SFML_OS_IOS)
|
|
||||||
find_host_package(${target} REQUIRED)
|
|
||||||
else()
|
|
||||||
find_package(${target} REQUIRED)
|
find_package(${target} REQUIRED)
|
||||||
endif()
|
|
||||||
|
|
||||||
# Make sure to interpret the items in INCLUDE and LINK parameters. sfml_add_external()
|
# Make sure to interpret the items in INCLUDE and LINK parameters. sfml_add_external()
|
||||||
# does not interpret given items in order to also accept parameters that must not be interpreted
|
# does not interpret given items in order to also accept parameters that must not be interpreted
|
||||||
|
@ -13,13 +13,11 @@ if(SFML_STATIC_LIBRARIES)
|
|||||||
endif()
|
endif()
|
||||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||||
set(FIND_SFML_OS_FREEBSD 1)
|
set(FIND_SFML_OS_FREEBSD 1)
|
||||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "iOS")
|
||||||
if(DEFINED IOS)
|
|
||||||
set(FIND_SFML_OS_IOS 1)
|
set(FIND_SFML_OS_IOS 1)
|
||||||
else()
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||||
set(FIND_SFML_OS_MACOSX 1)
|
set(FIND_SFML_OS_MACOSX 1)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
|
||||||
|
|
||||||
# start with an empty list
|
# start with an empty list
|
||||||
set(FIND_SFML_DEPENDENCIES_NOTFOUND)
|
set(FIND_SFML_DEPENDENCIES_NOTFOUND)
|
||||||
|
@ -1,188 +0,0 @@
|
|||||||
# Copyright (c) 2016, Bogdan Cristea <cristeab@gmail.com>
|
|
||||||
# All rights reserved.
|
|
||||||
#
|
|
||||||
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
||||||
#
|
|
||||||
# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
||||||
#
|
|
||||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
||||||
#
|
|
||||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
||||||
#
|
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
# This file is based off of the Platform/Darwin.cmake and Platform/UnixPaths.cmake
|
|
||||||
# files which are included with CMake 2.8.4
|
|
||||||
# It has been altered for iOS development
|
|
||||||
|
|
||||||
# Options:
|
|
||||||
#
|
|
||||||
# IOS_PLATFORM = OS (default) or SIMULATOR
|
|
||||||
# This decides if SDKS will be selected from the iPhoneOS.platform or iPhoneSimulator.platform folders
|
|
||||||
# OS - the default, used to build for iPhone and iPad physical devices, which have an arm arch.
|
|
||||||
# SIMULATOR - used to build for the Simulator platforms, which have an x86_64 arch.
|
|
||||||
#
|
|
||||||
# IOS_DEVELOPER_ROOT = automatic(default) or /path/to/platform/Developer folder
|
|
||||||
# By default this location is automatcially chosen based on the IOS_PLATFORM value above.
|
|
||||||
# If set manually, it will override the default location and force the user of a particular Developer Platform
|
|
||||||
#
|
|
||||||
# IOS_SDK_ROOT = automatic(default) or /path/to/platform/Developer/SDKs/SDK folder
|
|
||||||
# By default this location is automatcially chosen based on the IOS_DEVELOPER_ROOT value.
|
|
||||||
# In this case it will always be the most up-to-date SDK found in the IOS_DEVELOPER_ROOT path.
|
|
||||||
# If set manually, this will force the use of a specific SDK version
|
|
||||||
|
|
||||||
# Macros:
|
|
||||||
#
|
|
||||||
# set_xcode_property(TARGET XCODE_PROPERTY XCODE_VALUE)
|
|
||||||
# A convenience macro for setting xcode specific properties on targets
|
|
||||||
# example: set_xcode_property(myioslib IPHONEOS_DEPLOYMENT_TARGET "3.1")
|
|
||||||
#
|
|
||||||
# find_host_package(PROGRAM ARGS)
|
|
||||||
# A macro used to find executable programs on the host system, not within the iOS environment.
|
|
||||||
# Thanks to the android-cmake project for providing the command
|
|
||||||
|
|
||||||
# Standard settings
|
|
||||||
set(CMAKE_SYSTEM_NAME Darwin)
|
|
||||||
set(CMAKE_SYSTEM_VERSION 1)
|
|
||||||
set(UNIX True)
|
|
||||||
set(APPLE True)
|
|
||||||
set(IOS True)
|
|
||||||
|
|
||||||
# Required as of cmake 2.8.10
|
|
||||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING "Force unset of the deployment target for iOS" FORCE)
|
|
||||||
|
|
||||||
# Determine the cmake host system version so we know where to find the iOS SDKs
|
|
||||||
find_program(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin)
|
|
||||||
if(CMAKE_UNAME)
|
|
||||||
exec_program(uname ARGS -r OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION)
|
|
||||||
string(REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1" DARWIN_MAJOR_VERSION "${CMAKE_HOST_SYSTEM_VERSION}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(CMAKE_C_COMPILER /usr/bin/clang CACHE FILEPATH "" FORCE)
|
|
||||||
set(CMAKE_CXX_COMPILER /usr/bin/clang++ CACHE FILEPATH "" FORCE)
|
|
||||||
set(CMAKE_AR ar CACHE FILEPATH "" FORCE)
|
|
||||||
|
|
||||||
# Skip the platform compiler checks for cross compiling
|
|
||||||
set(CMAKE_CXX_COMPILER_WORKS TRUE)
|
|
||||||
set(CMAKE_C_COMPILER_WORKS TRUE)
|
|
||||||
|
|
||||||
# All iOS/Darwin specific settings - some may be redundant
|
|
||||||
set(CMAKE_SHARED_LIBRARY_PREFIX "lib")
|
|
||||||
set(CMAKE_SHARED_LIBRARY_SUFFIX ".dylib")
|
|
||||||
set(CMAKE_SHARED_MODULE_PREFIX "lib")
|
|
||||||
set(CMAKE_SHARED_MODULE_SUFFIX ".so")
|
|
||||||
set(CMAKE_MODULE_EXISTS 1)
|
|
||||||
set(CMAKE_DL_LIBS "")
|
|
||||||
|
|
||||||
set(CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
|
|
||||||
set(CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ")
|
|
||||||
set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
|
|
||||||
set(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")
|
|
||||||
|
|
||||||
# Hidden visibilty is required for cxx on iOS
|
|
||||||
set(CMAKE_C_FLAGS_INIT "")
|
|
||||||
set(CMAKE_CXX_FLAGS_INIT "-fvisibility=hidden -fvisibility-inlines-hidden")
|
|
||||||
|
|
||||||
set(CMAKE_C_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}")
|
|
||||||
set(CMAKE_CXX_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}")
|
|
||||||
|
|
||||||
set(CMAKE_PLATFORM_HAS_INSTALLNAME 1)
|
|
||||||
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -headerpad_max_install_names")
|
|
||||||
set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -headerpad_max_install_names")
|
|
||||||
set(CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,")
|
|
||||||
set(CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,")
|
|
||||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a")
|
|
||||||
|
|
||||||
# hack: if a new cmake (which uses CMAKE_INSTALL_NAME_TOOL) runs on an old build tree
|
|
||||||
# (where install_name_tool was hardcoded) and where CMAKE_INSTALL_NAME_TOOL isn't in the cache
|
|
||||||
# and still cmake didn't fail in CMakeFindBinUtils.cmake (because it isn't rerun)
|
|
||||||
# hardcode CMAKE_INSTALL_NAME_TOOL here to install_name_tool, so it behaves as it did before, Alex
|
|
||||||
if(NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
|
|
||||||
find_program(CMAKE_INSTALL_NAME_TOOL install_name_tool)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Setup iOS platform unless specified manually with IOS_PLATFORM
|
|
||||||
if(NOT DEFINED IOS_PLATFORM)
|
|
||||||
set(IOS_PLATFORM "OS")
|
|
||||||
endif()
|
|
||||||
set(IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING "Type of iOS Platform: OS or SIMULATOR")
|
|
||||||
|
|
||||||
# Check the platform selection and setup for developer root
|
|
||||||
if(IOS_PLATFORM STREQUAL OS)
|
|
||||||
set(IOS_PLATFORM_LOCATION "iPhoneOS.platform")
|
|
||||||
|
|
||||||
# This causes the installers to properly locate the output libraries
|
|
||||||
set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos")
|
|
||||||
elseif(IOS_PLATFORM STREQUAL SIMULATOR)
|
|
||||||
set(IOS_PLATFORM_LOCATION "iPhoneSimulator.platform")
|
|
||||||
|
|
||||||
# This causes the installers to properly locate the output libraries
|
|
||||||
set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator")
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "Unsupported IOS_PLATFORM value '${IOS_PLATFORM}' selected. Please choose OS or SIMULATOR")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Setup iOS developer location unless specified manually with IOS_DEVELOPER_ROOT
|
|
||||||
exec_program(/usr/bin/xcode-select ARGS -print-path OUTPUT_VARIABLE XCODE_DEVELOPER_DIR)
|
|
||||||
set(IOS_DEVELOPER_ROOT "${XCODE_DEVELOPER_DIR}/Platforms/${IOS_PLATFORM_LOCATION}/Developer" CACHE PATH "Location of iOS Platform")
|
|
||||||
|
|
||||||
# Find and use the most recent iOS sdk unless specified manually with IOS_SDK_ROOT
|
|
||||||
if(NOT DEFINED IOS_SDK_ROOT)
|
|
||||||
file(GLOB _IOS_SDKS "${IOS_DEVELOPER_ROOT}/SDKs/*")
|
|
||||||
if(_IOS_SDKS)
|
|
||||||
list(SORT _IOS_SDKS)
|
|
||||||
list(REVERSE _IOS_SDKS)
|
|
||||||
list(GET _IOS_SDKS 0 IOS_SDK_ROOT)
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "No iOS SDK's found in default search path ${IOS_DEVELOPER_ROOT}. Manually set IOS_SDK_ROOT or install the iOS SDK.")
|
|
||||||
endif()
|
|
||||||
message(STATUS "Toolchain using default iOS SDK: ${IOS_SDK_ROOT}")
|
|
||||||
endif()
|
|
||||||
set(IOS_SDK_ROOT ${IOS_SDK_ROOT} CACHE PATH "Location of the selected iOS SDK")
|
|
||||||
|
|
||||||
# Set the sysroot default to the most recent SDK
|
|
||||||
set(CMAKE_OSX_SYSROOT ${IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS support")
|
|
||||||
|
|
||||||
# set the architecture for iOS
|
|
||||||
if(${IOS_PLATFORM} STREQUAL OS)
|
|
||||||
set(OSX_UNIVERSAL true)
|
|
||||||
set(IOS_ARCH arm64)
|
|
||||||
elseif(${IOS_PLATFORM} STREQUAL SIMULATOR)
|
|
||||||
set(IOS_ARCH x86_64)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE STRING "Build architecture for iOS" FORCE)
|
|
||||||
|
|
||||||
# Set the find root to the iOS developer roots and to user defined paths
|
|
||||||
set(CMAKE_FIND_ROOT_PATH ${IOS_DEVELOPER_ROOT} ${IOS_SDK_ROOT} ${CMAKE_PREFIX_PATH} CACHE STRING "iOS find search path root")
|
|
||||||
|
|
||||||
# default to searching for frameworks first
|
|
||||||
set(CMAKE_FIND_FRAMEWORK FIRST)
|
|
||||||
|
|
||||||
# set up the default search directories for frameworks
|
|
||||||
set(CMAKE_SYSTEM_FRAMEWORK_PATH
|
|
||||||
${IOS_SDK_ROOT}/System/Library/Frameworks
|
|
||||||
${IOS_SDK_ROOT}/System/Library/PrivateFrameworks
|
|
||||||
${IOS_SDK_ROOT}/Developer/Library/Frameworks
|
|
||||||
)
|
|
||||||
|
|
||||||
# only search the iOS sdks, not the remainder of the host filesystem
|
|
||||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
|
|
||||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
|
||||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
|
||||||
|
|
||||||
|
|
||||||
# This macro lets you find executable programs on the host system
|
|
||||||
macro(find_host_package)
|
|
||||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
|
||||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
|
|
||||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
|
|
||||||
set(IOS FALSE)
|
|
||||||
|
|
||||||
find_package(${ARGN})
|
|
||||||
|
|
||||||
set(IOS TRUE)
|
|
||||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
|
|
||||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
|
||||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
|
||||||
endmacro(find_host_package)
|
|
@ -17,17 +17,17 @@
|
|||||||
<key>CFBundleInfoDictionaryVersion</key>
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
<string>6.0</string>
|
<string>6.0</string>
|
||||||
<key>CFBundleLongVersionString</key>
|
<key>CFBundleLongVersionString</key>
|
||||||
<string>2.5.1</string>
|
<string>3.0.0</string>
|
||||||
<key>CFBundleName</key>
|
<key>CFBundleName</key>
|
||||||
<string>$(EXECUTABLE_NAME)</string>
|
<string>$(EXECUTABLE_NAME)</string>
|
||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string></string>
|
<string>3.0.0</string>
|
||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>????</string>
|
<string>????</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string></string>
|
<string>3.0.0</string>
|
||||||
<key>CSResourcesFileMapped</key>
|
<key>CSResourcesFileMapped</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSHumanReadableCopyright</key>
|
<key>NSHumanReadableCopyright</key>
|
||||||
|
@ -311,9 +311,7 @@ if(NOT OpenGL_GL_PREFERENCE)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(SFML_OS_IOS)
|
if(SFML_OS_IOS)
|
||||||
sfml_add_external(GLES LINK "-framework OpenGLES")
|
target_link_libraries(sfml-window PRIVATE "-framework OpenGLES")
|
||||||
|
|
||||||
target_link_libraries(sfml-window PRIVATE GLES)
|
|
||||||
elseif(SFML_OS_ANDROID)
|
elseif(SFML_OS_ANDROID)
|
||||||
sfml_find_package(GLES INCLUDE "GLES_INCLUDE_DIR" LINK "GLES_LIBRARY")
|
sfml_find_package(GLES INCLUDE "GLES_INCLUDE_DIR" LINK "GLES_LIBRARY")
|
||||||
sfml_find_package(EGL INCLUDE "EGL_INCLUDE_DIR" LINK "EGL_LIBRARY")
|
sfml_find_package(EGL INCLUDE "EGL_INCLUDE_DIR" LINK "EGL_LIBRARY")
|
||||||
@ -342,7 +340,7 @@ elseif(SFML_OS_FREEBSD)
|
|||||||
elseif(SFML_OS_MACOSX)
|
elseif(SFML_OS_MACOSX)
|
||||||
target_link_libraries(sfml-window PRIVATE "-framework Foundation" "-framework AppKit" "-framework IOKit" "-framework Carbon")
|
target_link_libraries(sfml-window PRIVATE "-framework Foundation" "-framework AppKit" "-framework IOKit" "-framework Carbon")
|
||||||
elseif(SFML_OS_IOS)
|
elseif(SFML_OS_IOS)
|
||||||
target_link_libraries(sfml-window PRIVATE "-framework Foundation" "-framework UIKit" "-framework CoreGraphics" "-framework QuartzCore" "-framework CoreMotion")
|
target_link_libraries(sfml-window PUBLIC "-framework Foundation" "-framework UIKit" "-framework CoreGraphics" "-framework QuartzCore" "-framework CoreMotion")
|
||||||
elseif(SFML_OS_ANDROID)
|
elseif(SFML_OS_ANDROID)
|
||||||
target_link_libraries(sfml-window PRIVATE android)
|
target_link_libraries(sfml-window PRIVATE android)
|
||||||
endif()
|
endif()
|
||||||
|
@ -8,6 +8,13 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
|||||||
if(NOT BUILD_SHARED_LIBS)
|
if(NOT BUILD_SHARED_LIBS)
|
||||||
set(SFML_STATIC_LIBRARIES TRUE)
|
set(SFML_STATIC_LIBRARIES TRUE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# cmake by default will only search inside the iOS SDK for packages/libraries, so we need to tell it to look elsewhere
|
||||||
|
if(IOS)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
|
||||||
|
endif()
|
||||||
|
|
||||||
find_package(SFML 3.0.0 EXACT CONFIG REQUIRED COMPONENTS Graphics Network Audio)
|
find_package(SFML 3.0.0 EXACT CONFIG REQUIRED COMPONENTS Graphics Network Audio)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user