All mobile-compatible examples now successfully link
This commit is contained in:
parent
b516a3ae2b
commit
82c2f4c05e
@ -84,7 +84,7 @@ if(SFML_BUILD_WINDOW)
|
||||
sfml_set_option(SFML_OPENGL_ES ${OPENGL_ES} BOOL "TRUE to use an OpenGL ES implementation, FALSE to use a desktop OpenGL implementation")
|
||||
endif()
|
||||
|
||||
# Mac OS X specific options
|
||||
# macOS specific options
|
||||
if(SFML_OS_MACOSX)
|
||||
# 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")
|
||||
@ -99,6 +99,14 @@ else()
|
||||
sfml_set_option(SFML_DEPENDENCIES_INSTALL_PREFIX "." PATH "External libraries (FLAC, Freetype, Vorbis, ...) installation directory")
|
||||
endif()
|
||||
|
||||
# iOS specific options
|
||||
if(SFML_OS_IOS)
|
||||
# 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 "10.2" 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()
|
||||
|
||||
# Android options
|
||||
if(SFML_OS_ANDROID)
|
||||
# make sure there's the android library available
|
||||
@ -489,7 +497,7 @@ elseif(SFML_OS_IOS)
|
||||
endif()
|
||||
|
||||
if(SFML_BUILD_AUDIO)
|
||||
install(FILES extlibs/libs-ios/libflac.a
|
||||
install(FILES extlibs/libs-ios/libflac.a
|
||||
extlibs/libs-ios/libvorbis.a
|
||||
extlibs/libs-ios/libogg.a
|
||||
DESTINATION lib)
|
||||
|
@ -27,6 +27,23 @@ function(sfml_set_stdlib target)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(sfml_set_common_ios_properties target)
|
||||
# enable automatic reference counting on iOS
|
||||
sfml_set_xcode_property(${target} CLANG_ENABLE_OBJC_ARC YES)
|
||||
sfml_set_xcode_property(${target} IPHONEOS_DEPLOYMENT_TARGET "${SFML_IOS_DEPLOYMENT_TARGET}")
|
||||
sfml_set_xcode_property(${target} CODE_SIGN_IDENTITY "${SFML_CODE_SIGN_IDENTITY}")
|
||||
|
||||
get_target_property(target_type ${target} TYPE)
|
||||
if (target_type STREQUAL "EXECUTABLE")
|
||||
set_target_properties(${target} PROPERTIES
|
||||
MACOSX_BUNDLE TRUE # Bare executables are not usable on iOS, only bundle applications
|
||||
MACOSX_BUNDLE_GUI_IDENTIFIER "org.sfml-dev.${target}" # If missing, trying to launch an example in simulator will make Xcode < 9.3 crash
|
||||
MACOSX_BUNDLE_BUNDLE_NAME "${target}"
|
||||
MACOSX_BUNDLE_LONG_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# add a new target which is a SFML library
|
||||
# example: sfml_add_library(sfml-graphics
|
||||
# SOURCES sprite.cpp image.cpp ...
|
||||
@ -140,9 +157,8 @@ macro(sfml_add_library target)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# enable automatic reference counting on iOS
|
||||
if (SFML_OS_IOS)
|
||||
set_target_properties(${target} PROPERTIES XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES)
|
||||
sfml_set_common_ios_properties(${target})
|
||||
endif()
|
||||
|
||||
# sfml-activity library is our bootstrap activity and must not depend on stlport_shared
|
||||
@ -241,6 +257,10 @@ macro(sfml_add_example target)
|
||||
INSTALL_RPATH "$ORIGIN/${rel_lib_dir}")
|
||||
endif()
|
||||
|
||||
if (SFML_OS_IOS)
|
||||
sfml_set_common_ios_properties(${target})
|
||||
endif()
|
||||
|
||||
# add the install rule
|
||||
install(TARGETS ${target}
|
||||
RUNTIME DESTINATION ${target_install_dir} COMPONENT examples
|
||||
@ -266,12 +286,13 @@ macro(sfml_add_example target)
|
||||
endmacro()
|
||||
|
||||
|
||||
# Find the requested package and make an INTERFACE library from it
|
||||
# Usage: sfml_find_package(wanted_target_name
|
||||
# [INCLUDE "OPENGL_INCLUDE_DIR"]
|
||||
# [LINK "OPENGL_gl_LIBRARY"])
|
||||
function(sfml_find_package)
|
||||
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/Modules/")
|
||||
# Create an interface library for an external dependency. This virtual target can provide
|
||||
# link specifications and include directories to be used by dependees.
|
||||
# The created INTERFACE library is tagged for export to be part of the generated SFMLConfig
|
||||
# Usage: sfml_add_external(target_name
|
||||
# [INCLUDE "extlibs/include"]
|
||||
# [LINK "extlibs/libfoo/libfoo.a"])
|
||||
function(sfml_add_external)
|
||||
list(GET ARGN 0 target)
|
||||
list(REMOVE_AT ARGN 0)
|
||||
|
||||
@ -284,16 +305,10 @@ function(sfml_find_package)
|
||||
message(FATAL_ERROR "Unknown arguments when calling sfml_import_library: ${THIS_UNPARSED_ARGUMENTS}")
|
||||
endif()
|
||||
|
||||
if (SFML_OS_IOS)
|
||||
find_host_package(${target} REQUIRED)
|
||||
else()
|
||||
find_package(${target} REQUIRED)
|
||||
endif()
|
||||
|
||||
add_library(${target} INTERFACE)
|
||||
|
||||
if (THIS_INCLUDE)
|
||||
foreach(include_dir IN LISTS "${THIS_INCLUDE}")
|
||||
foreach(include_dir IN LISTS THIS_INCLUDE)
|
||||
if (NOT include_dir)
|
||||
message(FATAL_ERROR "No path given for include dir ${THIS_INCLUDE}")
|
||||
endif()
|
||||
@ -302,16 +317,61 @@ function(sfml_find_package)
|
||||
endif()
|
||||
|
||||
if (THIS_LINK)
|
||||
foreach(link_item IN LISTS ${THIS_LINK})
|
||||
foreach(link_item IN LISTS THIS_LINK)
|
||||
if (NOT link_item)
|
||||
message(FATAL_ERROR "Missing item in ${THIS_LINK}")
|
||||
endif()
|
||||
target_link_libraries(${target} INTERFACE "$<BUILD_INTERFACE:${link_item}>")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
install(TARGETS ${target} EXPORT SFMLConfigExport)
|
||||
endfunction()
|
||||
|
||||
# Find the requested package and make an INTERFACE library from it
|
||||
# The created INTERFACE library is tagged for export to be part of the generated SFMLConfig
|
||||
# Usage: sfml_find_package(wanted_target_name
|
||||
# [INCLUDE "OPENGL_INCLUDE_DIR"]
|
||||
# [LINK "OPENGL_gl_LIBRARY"])
|
||||
function(sfml_find_package)
|
||||
list(GET ARGN 0 target)
|
||||
list(REMOVE_AT ARGN 0)
|
||||
|
||||
if (TARGET ${target})
|
||||
message(FATAL_ERROR "Target '${target}' is already defined")
|
||||
endif()
|
||||
|
||||
cmake_parse_arguments(THIS "" "" "INCLUDE;LINK" ${ARGN})
|
||||
if (THIS_UNPARSED_ARGUMENTS)
|
||||
message(FATAL_ERROR "Unknown arguments when calling sfml_import_library: ${THIS_UNPARSED_ARGUMENTS}")
|
||||
endif()
|
||||
|
||||
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/Modules/")
|
||||
if (SFML_OS_IOS)
|
||||
find_host_package(${target} REQUIRED)
|
||||
else()
|
||||
find_package(${target} REQUIRED)
|
||||
endif()
|
||||
|
||||
# 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
|
||||
set(LINK_LIST "")
|
||||
if (THIS_LINK)
|
||||
foreach(link_item IN LISTS THIS_LINK)
|
||||
list(APPEND LINK_LIST "${${link_item}}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
set(INCLUDE_LIST "")
|
||||
if (THIS_INCLUDE)
|
||||
foreach(include_dir IN LISTS THIS_INCLUDE)
|
||||
list(APPEND INCLUDE_LIST "${${include_dir}}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
sfml_add_external(${target} INCLUDE ${INCLUDE_LIST} LINK ${LINK_LIST})
|
||||
endfunction()
|
||||
|
||||
# Generate a SFMLConfig.cmake file (and associated files) from the targets registered against
|
||||
# the EXPORT name "SFMLConfigExport" (EXPORT parameter of install(TARGETS))
|
||||
function(sfml_export_targets)
|
||||
|
@ -1,10 +1,7 @@
|
||||
|
||||
# iOS Demo
|
||||
if(SFML_OS_IOS)
|
||||
add_subdirectory(iOS)
|
||||
else(SFML_OS_IOS)
|
||||
|
||||
# add the examples subdirectories
|
||||
# CLI based examples
|
||||
if (NOT SFML_OS_IOS)
|
||||
if(SFML_BUILD_NETWORK)
|
||||
add_subdirectory(ftp)
|
||||
add_subdirectory(sockets)
|
||||
@ -16,23 +13,33 @@ else(SFML_OS_IOS)
|
||||
add_subdirectory(sound)
|
||||
add_subdirectory(sound_capture)
|
||||
endif()
|
||||
if(SFML_BUILD_WINDOW)
|
||||
add_subdirectory(window)
|
||||
endif()
|
||||
if(SFML_BUILD_GRAPHICS)
|
||||
endif()
|
||||
|
||||
# GUI based examples
|
||||
if(SFML_BUILD_WINDOW)
|
||||
add_subdirectory(window)
|
||||
endif()
|
||||
|
||||
if(SFML_BUILD_GRAPHICS)
|
||||
add_subdirectory(opengl)
|
||||
if (NOT SFML_OS_IOS)
|
||||
add_subdirectory(joystick)
|
||||
add_subdirectory(opengl)
|
||||
add_subdirectory(shader)
|
||||
add_subdirectory(island)
|
||||
if(SFML_OS_WINDOWS)
|
||||
add_subdirectory(win32)
|
||||
elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD)
|
||||
add_subdirectory(X11)
|
||||
elseif(SFML_OS_MACOSX)
|
||||
add_subdirectory(cocoa)
|
||||
endif()
|
||||
endif()
|
||||
if(SFML_BUILD_GRAPHICS AND SFML_BUILD_AUDIO)
|
||||
add_subdirectory(pong)
|
||||
add_subdirectory(island)
|
||||
if(SFML_OS_WINDOWS)
|
||||
add_subdirectory(win32)
|
||||
elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD)
|
||||
add_subdirectory(X11)
|
||||
elseif(SFML_OS_MACOSX)
|
||||
add_subdirectory(cocoa)
|
||||
endif()
|
||||
endif(SFML_OS_IOS)
|
||||
endif()
|
||||
if(SFML_BUILD_GRAPHICS AND SFML_BUILD_AUDIO)
|
||||
add_subdirectory(pong)
|
||||
endif()
|
||||
|
||||
# Mobile specific examples
|
||||
if(SFML_OS_IOS)
|
||||
add_subdirectory(iOS)
|
||||
endif()
|
||||
|
@ -5,6 +5,15 @@
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include <SFML/OpenGL.hpp>
|
||||
|
||||
#ifdef SFML_SYSTEM_IOS
|
||||
#include <SFML/Main.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef SFML_OPENGL_ES
|
||||
#define glClearDepth glClearDepthf
|
||||
#define glFrustum glFrustumf
|
||||
#endif
|
||||
|
||||
#ifndef GL_SRGB8_ALPHA8
|
||||
#define GL_SRGB8_ALPHA8 0x8C43
|
||||
#endif
|
||||
|
@ -4,6 +4,14 @@
|
||||
#include <SFML/Window.hpp>
|
||||
#include <SFML/OpenGL.hpp>
|
||||
|
||||
#ifdef SFML_SYSTEM_IOS
|
||||
#include <SFML/Main.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef SFML_OPENGL_ES
|
||||
#define glClearDepth glClearDepthf
|
||||
#define glFrustum glFrustumf
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Entry point of application
|
||||
|
@ -132,6 +132,8 @@ endif()
|
||||
|
||||
if(SFML_OS_ANDROID)
|
||||
target_link_libraries(sfml-graphics PRIVATE z EGL GLESv1_CM)
|
||||
elseif(SFML_OS_IOS)
|
||||
target_link_libraries(sfml-graphics PRIVATE z bz2)
|
||||
endif()
|
||||
|
||||
sfml_find_package(Freetype INCLUDE "FREETYPE_INCLUDE_DIRS" LINK "FREETYPE_LIBRARY")
|
||||
|
@ -251,14 +251,14 @@ endif()
|
||||
|
||||
if(SFML_OPENGL_ES)
|
||||
if(SFML_OS_IOS)
|
||||
target_link_libraries(sfml-window PRIVATE "-framework OpenGLES")
|
||||
sfml_add_external(OpenGL LINK "-framework OpenGLES")
|
||||
elseif(SFML_OS_ANDROID)
|
||||
target_link_libraries(sfml-window PRIVATE EGL GLESv1_CM)
|
||||
sfml_add_external(OpenGL LINK "EGL" "GLESv1_CM")
|
||||
endif()
|
||||
else()
|
||||
sfml_find_package(OpenGL INCLUDE "OPENGL_INCLUDE_DIR" LINK "OPENGL_LIBRARIES")
|
||||
target_link_libraries(sfml-window PRIVATE OpenGL)
|
||||
sfml_find_package(OpenGL INCLUDE "OPENGL_INCLUDE_DIR" LINK "OPENGL_gl_LIBRARY")
|
||||
endif()
|
||||
target_link_libraries(sfml-window PRIVATE OpenGL)
|
||||
|
||||
if(SFML_OS_WINDOWS AND NOT SFML_COMPILER_MSVC)
|
||||
include(CheckIncludeFile)
|
||||
|
Loading…
Reference in New Issue
Block a user