CMake iOS Toolchain: Sample code in cmake-toolchains(7) does not work
This sample code
$ cmake -S. -B_builds -GXcode \
-DCMAKE_SYSTEM_NAME=iOS \
"-DCMAKE_OSX_ARCHITECTURES=armv7;armv7s;arm64;i386;x86_64" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=9.3 \
-DCMAKE_INSTALL_PREFIX=`pwd`/_install \
-DCMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH=NO \
-DCMAKE_IOS_INSTALL_COMBINED=YES
does not work if used in that form (tested on CMake 3.19.0 rc2, Xcode 12, MacOS 10.14.6). Specifically it will ignore variable settings and either fail at build stage or succeed but not build the desired product.
-
Variable types need to be declared.
-DCMAKE_SYSTEM_NAME=iOS
needs to be-DCMAKE_SYSTEM_NAME:STRING=iOS
. Similarly-DCMAKE_IOS_INSTALL_COMBINED=YES
needs to be-DCMAKE_IOS_INSTALL_COMBINED:BOOL=YES
. Same for all other variables in the sample code. If the variable types are not set, the configuration simply won't pick up the setting. -
Even if the variable types are declared correctly, if
CMAKE_IOS_INSTALL_COMBINED
isYES
the build will fail with an error message "unable to attach DB: error: accessing build database ... : database is locked". To solve it I had to do this https://stackoverflow.com/a/52386834/1232524. Seems like this was described in #21282 (closed) already.