MethanePowered / MethaneAsteroids

:ringed_planet: Asteroids sample demonstrating multi-threaded rendering of large number random-generated asteroids with Methane Kit framework using DirectX 12, Vulkan and Metal
https://github.com/MethanePowered/MethaneKit
Apache License 2.0
16 stars 1 forks source link

Clean build fails on macOS #14

Closed CrushedPixel closed 4 months ago

CrushedPixel commented 4 months ago

16-inch 2021 MacBook Pro, M1 Max macOS Sonoma 14.5 cmake version 3.29.6

I'm building from console using the commands provided in the README.

OUTPUT_DIR=Build/Output/XCode/macOS
cmake -S . -B $OUTPUT_DIR/Build -G Xcode -DCMAKE_OSX_ARCHITECTURES="[arm64|x86_64]" -DCMAKE_OSX_ARCHITECTURES="[arm64|x86_64]" -DCMAKE_INSTALL_PREFIX="$(pwd)/$OUTPUT_DIR/Install"
cmake --build $OUTPUT_DIR/Build --config Release --target install

The build script fails because a folder hasn't yet been created:

WriteAuxiliaryFile /Users/marius/Documents/Gamedev/MethaneAsteroids/Build/Output/XCode/macOS/Build/build/MethaneAsteroids.build/Release/Script-032561A0B7652221BF209A44.sh (in target 'MethaneAsteroids' from project 'METHANE_ASTEROIDS')
    cd /Users/marius/Documents/Gamedev/MethaneAsteroids
    write-file /Users/marius/Documents/Gamedev/MethaneAsteroids/Build/Output/XCode/macOS/Build/build/MethaneAsteroids.build/Release/Script-032561A0B7652221BF209A44.sh

PhaseScriptExecution CMake\ PostBuild\ Rules /Users/marius/Documents/Gamedev/MethaneAsteroids/Build/Output/XCode/macOS/Build/build/MethaneAsteroids.build/Release/Script-032561A0B7652221BF209A44.sh (in target 'MethaneAsteroids' from project 'METHANE_ASTEROIDS')
    cd /Users/marius/Documents/Gamedev/MethaneAsteroids
    /bin/sh -c /Users/marius/Documents/Gamedev/MethaneAsteroids/Build/Output/XCode/macOS/Build/build/MethaneAsteroids.build/Release/Script-032561A0B7652221BF209A44.sh
Error: Target (for copy_if_different command) "/Users/marius/Documents/Gamedev/MethaneAsteroids/Build/Output/XCode/macOS/Build/App/Release/MethaneAsteroids.app/Contents/MacOS/../Resources" is not a directory.
Command PhaseScriptExecution failed with a nonzero exit code

Full log: build_log.txt

egorodet commented 4 months ago

Hello @CrushedPixel , your cmake command line contains mistake in the argument -DCMAKE_OSX_ARCHITECTURES="[arm64|x86_64]". Syntax[...|...] means that you have to choose specific build architecture - either arm64 or x86_64, but not both, which is clearly noted in the Build/README.md:

Note that starting with XCode 12 and Clang 12 build architectures have to be specified explicitly using CMake generator command line option -DCMAKE_OSX_ARCHITECTURES="[arm64|x86_64]" (multiple architecture are not supported by Asteroids sample) to build the fat binary.

I was able to successfully build repository with this command line on my M1 MacBook with latest MacOS, Xcode and CMake versions:

OUTPUT_DIR=Build/Output/XCode/macOS
cmake -S . -B $OUTPUT_DIR/Build -G Xcode -DCMAKE_OSX_ARCHITECTURES="arm64" -DCMAKE_INSTALL_PREFIX="$(pwd)/$OUTPUT_DIR/Install"
cmake --build $OUTPUT_DIR/Build --config Release --target install

Also I've updated referenced Methane Kit version in Externals/MethaneKit.cmake to the latest hot-fix commit from the master branch, so that CI Build workflow now runs successfully in GitHub Actions.