forked from phoenix-engine/build-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xcode-build.cmake
48 lines (44 loc) · 1.42 KB
/
xcode-build.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
cmake_minimum_required(VERSION 3.13)
# ConfigureXcodeBuildCommand prepares an `xcodebuild` shell invocation
# to run the build. BUILD_MODE should be something like "Release" or
# "Debug". This macro supports an optional SDK parameter string.
#
# To use XCODE_BUILD_CMD, pass it as an argument to ExternalProject_add.
# See: https://cmake.org/cmake/help/latest/module/ExternalProject.html
#
# After this macro is invoked, the variables "XCODE_BUILD_CMD",
# "OBJ_ROOT", and "SYM_ROOT" are set.
#
# After the build is completed, the resulting binaries will be symlinked
# from the ${OBJ_ROOT} build path into ${SYM_ROOT}/artifacts.
macro(ConfigureXcodeBuildCommand
BUILD_MODE
BUILD_DIR
PROJECT
SCHEME
)
# Generate the build command. It will be appended to.
set(XCODE_BUILD_CMD
xcodebuild
-quiet
-project ${PROJECT}
-scheme ${SCHEME}
-configuration ${BUILD_MODE}
)
set(OBJ_ROOT ${BUILD_DIR}/obj)
set(SYM_ROOT ${BUILD_DIR}/artifacts)
# Configure external build for custom SDK if necessary.
if(${ARGC} GREATER 5)
message("Building with -sdk ${ARGV5}")
set(XCODE_BUILD_CMD ${XCODE_BUILD_CMD} -sdk ${ARGV5})
set(OBJ_ROOT ${BUILD_DIR}/${ARGV5}/obj)
set(SYM_ROOT ${BUILD_DIR}/${ARGV5}/artifacts)
endif()
# Append OBJROOT for intermediate objects and SYMROOT for symlinked
# final products.
set(XCODE_BUILD_CMD
${XCODE_BUILD_CMD}
OBJROOT=${OBJ_ROOT}
SYMROOT=${SYM_ROOT}
)
endmacro()