jrouwe / JoltPhysics

A multi core friendly rigid body physics and collision detection library. Written in C++. Suitable for games and VR applications. Used by Horizon Forbidden West.
MIT License
6k stars 374 forks source link

No CMAKE_CXX_COMPILER could be found on MacOS #1124

Closed FireflyInTheDusk closed 1 month ago

FireflyInTheDusk commented 1 month ago

This is my first contact with cmake so I'm unsure if it's something that's cmake's fault or something that needs to be configured in Jolt, but trying to generate the Xcode project on latest (at the time of writing) Sonoma and Xcode fails with the following:

No CMAKE_CXX_COMPILER could be found

This happens both with cmake from homebrew (3.29.3) and with the official app.

At least in my case it was because cmake was generating an intermediary Xcode project with the aim of detecting the available compilers, but the project was unsigned and as a result it could not be built (I think).

To get it working I added this line in CMakeLists.txt:

set(id_code_sign_identity "-")

The projects were generated properly and I was able to build the library afterwards.

I noticed that this was an issue in a past cmake version, but it seems it still happens? Not sure, this is where I got the idea for the "fix" though: https://gitlab.kitware.com/cmake/cmake/-/issues/23609

Either way, maybe my findings will help other Mac users.

Thanks for the awesome lib :)

jrouwe commented 1 month ago

Thanks for reporting, I'll take a look.

jrouwe commented 1 month ago

I just tried to repro this on a M1 with macOS 14.4.1, XCode 15.3 and cmake 3.29.4. Running the build script cmake_xcode_macos.sh worked without any issues:

-- The CXX compiler identification is AppleClang 15.0.0.15000309
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (23.9s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/m1/JoltPhysics/Build/XCode_MacOS

It produced an XCode project that I could open, build and run. The iOS version worked without a hitch too.

(unfortunately I cannot easily switch to the absolute latest macOS 14.5 / XCode 15.4 version as it is a rented VM, but the versions tested are both from March)

FireflyInTheDusk commented 1 month ago

I tried it again w/ a clean clone and this time it worked without the change... I'm a bit confused, maybe it was something that was missing from my terminal session at the time.

I'll close this issue in this case.