diff --git a/CMakeLists.txt b/CMakeLists.txt index f75a353..88a3306 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,26 @@ if(NOT DEFINED PROJECT_VERSION) set(PROJECT_VERSION 1.0.0) endif() +# Check for and warn if running under Rosetta +if(APPLE) + execute_process( + COMMAND sysctl -in sysctl.proc_translated + OUTPUT_VARIABLE MACOS_TRANSLATED + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET + ) + + if(MACOS_TRANSLATED) + message( + WARNING + "CMake is running under Rosetta. " + "This may cause the project to be built for x86_64 instead of arm64. " + "Run CMake natively under Apple Silicon or explicitly pass " + "-DCMAKE_OSX_ARCHITECTURES=arm64" + ) + endif() +endif() + project(mcpp VERSION ${PROJECT_VERSION}) set(CMAKE_CXX_STANDARD 17) diff --git a/README.md b/README.md index 4f9b11a..af5e47f 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,11 @@ git clone https://github.com/rozukke/mcpp.git && cd mcpp cmake -B build && cd build sudo make install ``` + +On an M-series Mac, you may encounter: `found architecture 'x86_64', required architecture 'arm64'`. +This means `cmake` is running under Rosetta. You can fix this by adding `-DCMAKE_OSX_ARCHITECTURES=arm64` after `cmake -B build`. +But you should fix the root cause by ensuring your `cmake` or `brew` installs are not the intel x86 versions. + - After doing this, the library should be accessible via a `#include ` directive. - When compiling code using the library, use the flag `-lmcpp` for Makefiles or `target_link_libraries(your_executable mcpp)` for CMake.