-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathGLTFPlatform.cmake
112 lines (90 loc) · 4.71 KB
/
GLTFPlatform.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
###############################################################################
# Sets the name of the platform in the variable named by 'outPlatform'
# Possible values are "iOS", "iOSSimulator", "iOSSimulator64", "appleTV", "appleTVSimulator"
# Android values are of the form "android_<ANDROID_ABI>".
# Possible values of ANDROID_ABIs are found here : https://developer.android.com/ndk/guides/abis
# TODO: Modify the Android and iOS logic to calculate outPlatform the same way we do on Windows.
###############################################################################
function (GetGLTFPlatform outPlatform)
if(ANDROID_OS_PLATFORM)
if(ANDROID_OS_PLATFORM STREQUAL "ANDROID")
if( (ANDROID_ABI STREQUAL "x86") OR
(ANDROID_ABI STREQUAL "x86_64") OR
(ANDROID_ABI STREQUAL "arm64-v8a") OR
(ANDROID_ABI STREQUAL "armeabi-v7a"))
set(${outPlatform} "android_${ANDROID_ABI}" PARENT_SCOPE)
else()
message(FATAL_ERROR "Invalid ANDROID_ABI: ${ANDROID_ABI}")
endif()
else()
message(FATAL_ERROR "Invalid ANDROID_OS_PLATFORM: ${ANDROID_OS_PLATFORM}")
endif()
elseif (IOS_PLATFORM)
if (IOS_PLATFORM STREQUAL "OS")
set(${outPlatform} iOS PARENT_SCOPE)
elseif (IOS_PLATFORM STREQUAL "SIMULATOR")
set(${outPlatform} iOSSimulator PARENT_SCOPE)
elseif (IOS_PLATFORM STREQUAL "SIMULATOR64")
set(${outPlatform} iOSSimulator64 PARENT_SCOPE)
elseif (IOS_PLATFORM STREQUAL "TVOS")
set(${outPlatform} appleTV PARENT_SCOPE)
elseif (IOS_PLATFORM STREQUAL "SIMULATOR_TVOS")
set(${outPlatform} appleTVSimulator PARENT_SCOPE)
else()
message(FATAL_ERROR "Invalid IOS_PLATFORM: ${IOS_PLATFORM}")
endif()
elseif (MSVC)
set(${outPlatform} "windows_${CMAKE_GENERATOR_PLATFORM}" PARENT_SCOPE)
elseif (UNIX AND NOT APPLE)
set(${outPlatform} "${CMAKE_SYSTEM_NAME}" PARENT_SCOPE)
else()
# MacOS
set(${outPlatform} macOS PARENT_SCOPE)
endif()
endfunction(GetGLTFPlatform)
###############################################################################
# Set the default install TARGETS (Built/Out/<Platform>/<Config>/<Project>)
# for the ARCHIVE, LIBRARY, RUNTIME, and BUNDLE folders
###############################################################################
function(CreateGLTFInstallTargets target platform)
install(TARGETS ${target}
ARCHIVE DESTINATION ${CMAKE_SOURCE_DIR}/Built/Out/${platform}/$<CONFIG>/${PROJECT_NAME}
LIBRARY DESTINATION ${CMAKE_SOURCE_DIR}/Built/Out/${platform}/$<CONFIG>/${PROJECT_NAME}
RUNTIME DESTINATION ${CMAKE_SOURCE_DIR}/Built/Out/${platform}/$<CONFIG>/${PROJECT_NAME}
BUNDLE DESTINATION ${CMAKE_SOURCE_DIR}/Built/Out/${platform}/$<CONFIG>/${PROJECT_NAME}
)
if (MSVC)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${PROJECT_NAME}.pdb DESTINATION ${CMAKE_SOURCE_DIR}/Built/Out/${platform}/$<CONFIG>/${PROJECT_NAME})
endif()
endfunction(CreateGLTFInstallTargets)
###############################################################################
# Add the required properties and libraries to create an iOS Application
# Assumes that the Info.plist is in the same folder as the caller
###############################################################################
function(AddGLTFIOSAppProperties target)
if(IOS_PLATFORM)
# Locate system libraries on iOS
find_library(UIKIT UIKit)
find_library(FOUNDATION Foundation)
find_library(MOBILECORESERVICES MobileCoreServices)
find_library(CFNETWORK CFNetwork)
find_library(SYSTEMCONFIGURATION SystemConfiguration)
# link the frameworks located above
target_link_libraries(${target} PRIVATE ${UIKIT})
target_link_libraries(${target} PRIVATE ${FOUNDATION})
target_link_libraries(${target} PRIVATE ${MOBILECORESERVICES})
target_link_libraries(${target} PRIVATE ${CFNETWORK})
target_link_libraries(${target} PRIVATE ${SYSTEMCONFIGURATION})
set_target_properties(${target} PROPERTIES
MACOSX_BUNDLE true
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_LIST_DIR}/Info.plist"
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES
XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 9.0
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
# This is a temporary value that is a personal team (kaokuda) to confirm that these settings are working
# When we get a real "Team" for development that we can all share then this should be changed.
# Change this locally to your personal Team to simplify the build process.
XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "BKXU2T37Q4"
)
endif()
endfunction(AddGLTFIOSAppProperties)