# How to name package based on target architecture on macOS?

**URL:** https://discourse.cmake.org/t/how-to-name-package-based-on-target-architecture-on-macos/8560
**Category:** Code
**Tags:** os:macos
**Created:** [July 20, 2023, 12:52pm UTC](https://discourse.cmake.org/t/how-to-name-package-based-on-target-architecture-on-macos/8560 "2023-07-20T12:52:17Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jpfeuffer](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jpfeuffer/32/1529_2.png) [@jpfeuffer](https://discourse.cmake.org/u/jpfeuffer)
#### Post date: [July 20, 2023, 12:52pm UTC](https://discourse.cmake.org/t/how-to-name-package-based-on-target-architecture-on-macos/8560/1 "2023-07-20T12:52:18Z")

</div>

Hi!

I want to name my macOS package according to the target architecture(s) that CMake is going to build.  
How do I do that? Which variables do I need to query? E.g. CMAKE\_OSX\_ARCHITECTURES might not necessarily be set, right?

The outcome I want to have is:  
x86\_64 → Intel  
aarch64 → Silicon  
x86\_64, aarch64 → Universal

Thanks a lot for any hints!

---

<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: [July 20, 2023, 5:12pm UTC](https://discourse.cmake.org/t/how-to-name-package-based-on-target-architecture-on-macos/8560/2 "2023-07-20T17:12:59Z")

</div>

`CMAKE_OSX_ARCHITECTURES` is the first place I’d look. Other than that, I think `CMAKE_SYSTEM_PROCESSOR` is likely to be useful.

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [July 21, 2023, 12:47am UTC](https://discourse.cmake.org/t/how-to-name-package-based-on-target-architecture-on-macos/8560/3 "2023-07-21T00:47:15Z")

</div>

> [@ben.boeckel](#):
>
> CMAKE\_SYSTEM\_PROCESSOR

I don’t tend to trust `CMAKE_SYSTEM_PROCESSOR` for anything important unless I know that the project I’m using it with explicitly sets it. There’s no standard set of values for it, and the toolchain file the developer uses can set it to any arbitrary value. The `CMAKE_OSX_ARCHITECTURES` variable should be more reliable and I think better reflects the information you are trying to capture.

---

<div class="post-metadata">

### Author: ![jpfeuffer](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jpfeuffer/32/1529_2.png) [@jpfeuffer](https://discourse.cmake.org/u/jpfeuffer)
#### Post date: [July 21, 2023, 8:35am UTC](https://discourse.cmake.org/t/how-to-name-package-based-on-target-architecture-on-macos/8560/4 "2023-07-21T08:35:58Z")

</div>

Thank you! The problem that I have with `CMAKE_OSX_ARCHITECTURES` is that it does not need to be set, right (i.e. it’s optional)?  
How would I get its defaults (i.e. probably the host architecture in the same format, right?) in case it is not set.

---

<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: [July 21, 2023, 12:00pm UTC](https://discourse.cmake.org/t/how-to-name-package-based-on-target-architecture-on-macos/8560/5 "2023-07-21T12:00:40Z")

</div>

> [@jpfeuffer](#):
>
> How would I get its defaults (i.e. probably the host architecture in the same format, right?) in case it is not set.

I think [`cmake_host_system_information`](https://cmake.org/cmake/help/latest/command/cmake_host_system_information.html) may be useful here.
