How do I build cmake from source as universal(arm64 and x86_64) binary on Mac?

as title:

I try with CFLAGS and CXXFLAGS, but not successful.
./configure CFLAGS="-mmacosx-version-min=11.0 -arch x86_64 -arch arm64" CXXFLAGS="-mmacosx-version-min=11.0 -arch x86_64 -arch arm64" --prefix=/some/place/cmake-3.23.2


You need to tell CMake what is going on "-DCMAKE_OSX_ARCHITECTURES=x86_64;arm64". Just doing it as flags makes CMake unaware that multi-arch binaries are being made and confuses some things.

@ben.boeckel thank you for reply.
sorry! english is not my mother language and maybe my question is not clear.
I want to ask,
How do I build cmake command as universal binary from source(cmake source)?

thank you.

AFAIK, passing that -D in when configuring should be enough. You can also set CMAKE_OSX_DEPLOYMENT_TARGET to manage the -mmacosx-version-min= flag.

@ben.boeckel thanks

I know so far have 2 ways(configure and bootstrap) to compile cmake from cmake source.

You mentioned -DCMAKE_OSX_ARCHITECTURES=x86_64;arm64 option.

I also try ./bootstrap -- -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" --prefix=/some/place/cmake-3.23.2 but failed.

CMake Error: Unknown argument --prefix=/some/place/cmake-3.23.2

How do I apply it with configure and bootstrap?
Could you give me an example?


I would guess that --prefix= goes before the -- for bootstrap.

@ben.boeckel thanks
It works.