# Where are default compile flags set?

**URL:** https://discourse.cmake.org/t/where-are-default-compile-flags-set/6754
**Category:** Usage
**Tags:** os:macos, gen:ninja
**Created:** [October 29, 2022, 1:20am UTC](https://discourse.cmake.org/t/where-are-default-compile-flags-set/6754 "2022-10-29T01:20:57Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Andrew\_Beers](https://discourse.cmake.org/user_avatar/discourse.cmake.org/andrew_beers/32/2887_2.png) [@Andrew\_Beers](https://discourse.cmake.org/u/Andrew_Beers)
#### Post date: [October 29, 2022, 1:20am UTC](https://discourse.cmake.org/t/where-are-default-compile-flags-set/6754/1 "2022-10-29T01:20:57Z")

</div>

I’ve inherited a c++ project that had a custom build script written in JavaScript. I’m looking to convert this build script into a CMake build script so I can debug the project in CLion. This custom build script does not include any -arch compile flags and works fine. When I create a hello world project in CLion I see the build.ninja file have the following flags:

`FLAGS = -g -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -fcolor-diagnostics -std=gnu++17`

my builds fail because `ld: symbol(s) not found for architecture arm64`

I’ve tried to set `CMAKE_CXX_FLAGS` to something to try to clear out these defaults, but it just appends to this list. When I print out `CMAKE_CXX_FLAGS` it shows an empty string. Where do these ‘default’ flags come from? How do I clear them out?

this looks reasonably similar to : [Compilation option flags settings and default](https://discourse.cmake.org/t/compilation-option-flags-settings-and-default/3393) but I don’t understand how to clear these out yet.

---

<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: [October 29, 2022, 1:57pm UTC](https://discourse.cmake.org/t/where-are-default-compile-flags-set/6754/2 "2022-10-29T13:57:44Z")

</div>

It seems like you’ve got x86\_64 dependencies? You can use [`CMAKE_OSX_ARCHITECTURES`](https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_ARCHITECTURES.html) to target it instead of your (I assume) native arm64 that is being detected.

---

<div class="post-metadata">

### Author: ![Andrew\_Beers](https://discourse.cmake.org/user_avatar/discourse.cmake.org/andrew_beers/32/2887_2.png) [@Andrew\_Beers](https://discourse.cmake.org/u/Andrew_Beers)
#### Post date: [October 30, 2022, 1:37am UTC](https://discourse.cmake.org/t/where-are-default-compile-flags-set/6754/3 "2022-10-30T01:37:39Z")

</div>

Thanks for the response, setting this to x86\_64 was what I needed to do. I was getting so confused because the JavaScript compile commands did not include any -arch compile options at all, and somehow they ended up being compiled as x86\_64 where if I ran the command directly in the terminal myself without the -arch compile command, it would compile as arm64. Still not clear why that happened but your advice has helped me conquer my first true cpp compile issue, can’t thank you enough, this was like a week of confusion and now I can sleep comfortably! On to the next issue. 😀

---

<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: [October 30, 2022, 3:42pm UTC](https://discourse.cmake.org/t/where-are-default-compile-flags-set/6754/4 "2022-10-30T15:42:37Z")

</div>

> [@Andrew\_Beers](#):
>
> somehow they ended up being compiled as x86\_64 where if I ran the command directly in the terminal myself without the -arch compile command

The compilers, tools, or some such are probably x86\_64-only. Rosetta 2 hides arm64 support when it runs, so x86\_64 processes only launch the x86\_64 “half” of anything they run and when they self-detect, they’ll do x86\_64 as well.
