# problems following the CMake library & cross compiling tutorial

**URL:** https://discourse.cmake.org/t/problems-following-the-cmake-library-cross-compiling-tutorial/2601
**Category:** Usage
**Created:** [January 22, 2021, 8:58am UTC](https://discourse.cmake.org/t/problems-following-the-cmake-library-cross-compiling-tutorial/2601 "2021-01-22T08:58:33Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![w461](https://discourse.cmake.org/user_avatar/discourse.cmake.org/w461/32/1125_2.png) [@w461](https://discourse.cmake.org/u/w461)
#### Post date: [January 22, 2021, 8:58am UTC](https://discourse.cmake.org/t/problems-following-the-cmake-library-cross-compiling-tutorial/2601/1 "2021-01-22T08:58:33Z")

</div>

Hi, I am tying to combine the CMake library tutorial and Cross Compiling ([https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-ios-tvos-or-watchos](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-ios-tvos-or-watchos)) with the Dart C interoperability tutorial ([https://dart.dev/guides/libraries/c-interop](https://dart.dev/guides/libraries/c-interop)). Applying this to a mobile app build appears to cause some different outcomes that with a terminal app and I am struggling to understand the intend or meaning of some of the CMake steps.

(1) To install the fat 5 architectures the following command is stated:  
$ 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

However, DCMAKE\_OSX\_ARCHITECTURES is in hyphens. Removing this causes an error, also when selecting only a single architecture:

```
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.3.sdk;/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.3.sdk;/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.3.sdk;/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk;/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk

  is not the same length as CMAKE_OSX_ARCHITECTURES:

    armv7s

```

and

-DCMAKE\_OSX\_DEPLOYMENT\_TARGET=9.3: command not found

(2) Then, when I try to run the install command  
$ cmake --build \_builds --config Release --target install

I receive the error

xcodebuild: error: The project ‘primitives\_library.xcodeproj’ does not contain a target named ‘install’.

**What am I doing wrong?**

I am using macOS 11.1 and CMake 3.19.3

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [January 22, 2021, 2:13pm UTC](https://discourse.cmake.org/t/problems-following-the-cmake-library-cross-compiling-tutorial/2601/2 "2021-01-22T14:13:44Z")

</div>

> [@w461](#):
>
> However, DCMAKE\_OSX\_ARCHITECTURES is in hyphens

Do you mean quotes? It needs to be quoted because the `;` in the value of the variable is interpreted as “end this command here” by the shell otherwise.

> [@w461](#):
>
> Removing this causes an error, also when selecting only a single architecture:

I think this is from the `CMAKE_OSX_SDK` variable. That variable and `CMAKE_OSX_ARCHITECTURES` must be the same length and match up in order (I believe).

> [@w461](#):
>
> -DCMAKE\_OSX\_DEPLOYMENT\_TARGET=9.3: command not found

This is a side effect of removing the quotes.

Cc: @gjasny

---

<div class="post-metadata">

### Author: ![w461](https://discourse.cmake.org/user_avatar/discourse.cmake.org/w461/32/1125_2.png) [@w461](https://discourse.cmake.org/u/w461)
#### Post date: [January 22, 2021, 3:01pm UTC](https://discourse.cmake.org/t/problems-following-the-cmake-library-cross-compiling-tutorial/2601/3 "2021-01-22T15:01:27Z")

</div>

Cheers, this indeed removes the related errors. My assumption was that this is avoiding the errors because the part in quotes is ignored. Good to know that this is for the semicolons.

My question on `xcodebuild: error: The project ‘primitives_library.xcodeproj’ does not contain a target named ‘install’.` remains

Also, shouldn’t `-DCMAKE_INSTALL_PREFIX=../_install` leave some file in …/\_install? The folder remains empty.

I am having a few issues in this area and unfortunately it is hard to tell for me, whether it is caused by those cmake commands or by the CMakeLists.txt or elsewhere in the toolchain. With the example of Dart’s C interoperability I am also missing any .dylib file, which I was able to create with another example.

Some feedback on the CMake examples, if you don’t mind: While I can follow the steps, it is hard for me as a CMake beginner to understand what is being done and why - just as with those quotes. Also it appears that you use the same name for different things such as MathFunctions or Tutorial, which (if I understand this correctly) is once an executable and once a subdirectory. The examples themselves are very relevant, though.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [January 22, 2021, 3:22pm UTC](https://discourse.cmake.org/t/problems-following-the-cmake-library-cross-compiling-tutorial/2601/4 "2021-01-22T15:22:21Z")

</div>

> [@w461](#):
>
> Also, shouldn’t `-DCMAKE_INSTALL_PREFIX=../_install` leave some file in …/\_install? The folder remains empty.

Not until the install step is run. The lack of an `install` target probably means that there are no `install()` commands in the CMake code itself.

> [@w461](#):
>
> Some feedback on the CMake examples, if you don’t mind: While I can follow the steps, it is hard for me as a CMake beginner to understand what is being done and why - just as with those quotes. Also it appears that you use the same name for different things such as MathFunctions or Tutorial, which (if I understand this correctly) is once an executable and once a subdirectory. The examples themselves are very relevant, though.

@betsy.mcphail
