Where are default compile flags set?

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 but I don’t understand how to clear these out yet.

It seems like you’ve got x86_64 dependencies? You can use CMAKE_OSX_ARCHITECTURES to target it instead of your (I assume) native arm64 that is being detected.

1 Like

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. :grinning:

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.