floooh / sokol-samples

Sample code for https://github.com/floooh/sokol
MIT License
624 stars 79 forks source link

build fails following Metal IOS instructions (mojave) #41

Closed olilarkin closed 5 years ago

olilarkin commented 5 years ago

pc-138-1:sokol-samples oli$ ./fips set config metal-ios-xcode-debug 'config' set to 'metal-ios-xcode-debug' in project 'sokol-samples' pc-138-1:sokol-samples oli$ ./fips set iosteam XXXXXXXXXX 'iosteam' set to 'xxxxx' in project 'sokol-samples' pc-138-1:sokol-samples oli$ ./fips gen === dependency: 'fips-cimgui': dir '/Users/oli/Dev/FrameworkTests/sokol/fips-cimgui' exists === dependency: 'sokol-tools-bin': dir '/Users/oli/Dev/FrameworkTests/sokol/sokol-tools-bin' exists === dependency: 'sokol': dir '/Users/oli/Dev/FrameworkTests/sokol/sokol' exists === dependency: 'fips-glfw': dir '/Users/oli/Dev/FrameworkTests/sokol/fips-glfw' exists === dependency: 'fips-libmodplug': dir '/Users/oli/Dev/FrameworkTests/sokol/fips-libmodplug' exists === dependency: 'fips-imgui': dir '/Users/oli/Dev/FrameworkTests/sokol/fips-imgui' exists === generating: metal-ios-xcode-debug config file: /Users/oli/Dev/FrameworkTests/sokol/sokol-samples/fips-files/configs/metal-ios-xcode-debug.yml Using Toolchain File: /Users/oli/Dev/FrameworkTests/sokol/fips/cmake-toolchains/ios.toolchain.cmake cmake -G "Xcode" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=/Users/oli/Dev/FrameworkTests/sokol/fips/cmake-toolchains/ios.toolchain.cmake -DFIPS_CONFIG=metal-ios-xcode-debug -DFIPS_IOS_USE_ARC=ON -DSOKOL_USE_METAL=ON -DFIPS_IOS_TEAMID=xxxxx -DFIPS_USE_CCACHE=OFF -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.4.sdk -DFIPS_AUTO_IMPORT=OFF -B/Users/oli/Dev/FrameworkTests/sokol/fips-build/sokol-samples/metal-ios-xcode-debug -H/Users/oli/Dev/FrameworkTests/sokol/sokol-samples -- The C compiler identification is AppleClang 10.0.1.10010046 -- The CXX compiler identification is AppleClang 10.0.1.10010046 System is unknown to cmake, create: Platform/iOS to use this system, please send your config file to cmake@www.cmake.org so it can be added to cmake -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang System is unknown to cmake, create: Platform/iOS to use this system, please send your config file to cmake@www.cmake.org so it can be added to cmake -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -- broken CMake Error at /usr/local/Cellar/cmake/3.12.3/share/cmake/Modules/CMakeTestCCompiler.cmake:52 (message): The C compiler

"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: /Users/oli/Dev/FrameworkTests/sokol/fips-build/sokol-samples/metal-ios-xcode-debug/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/xcodebuild" "-project" "CMAKE_TRY_COMPILE.xcodeproj" "build" "-target" "cmTC_b4ff1" "-configuration" "Debug"
Prepare build
note: Using legacy build system

=== BUILD TARGET cmTC_b4ff1 OF PROJECT CMAKE_TRY_COMPILE WITH CONFIGURATION Debug ===

Check dependencies
target specifies product type 'com.apple.product-type.tool', but there's no such product type for the 'iphoneos' platform
warning: The armv7 architecture is deprecated for your deployment target (iOS 12.4). You should update your ARCHS build setting to remove the armv7 architecture.

** BUILD FAILED **

The following build commands failed:
    Check dependencies
(1 failure)

CMake will not be able to correctly generate this project. Call Stack (most recent call first): CMakeLists.txt:5 (project)

-- Configuring incomplete, errors occurred! See also "/Users/oli/Dev/FrameworkTests/sokol/fips-build/sokol-samples/metal-ios-xcode-debug/CMakeFiles/CMakeOutput.log". See also "/Users/oli/Dev/FrameworkTests/sokol/fips-build/sokol-samples/metal-ios-xcode-debug/CMakeFiles/CMakeError.log". [ERROR] failed to generate build files for config 'metal-ios-xcode-debug' [ERROR] 1 out of 1 configs failed!

floooh commented 5 years ago

Hmm

target specifies product type 'com.apple.product-type.tool', but there's no such product type for the 'iphoneos' platform
warning: The armv7 architecture is deprecated for your deployment target (iOS 12.4). You should update your ARCHS build setting to remove the armv7 architecture.

I haven't seen this error yet.

Also this is strange:

System is unknown to cmake, create:
Platform/iOS to use this system, please send your config file to cmake@www.cmake.org so it can be added to cmake

What versions of cmake and Xcode are you using?

floooh commented 5 years ago

Ah, I'm getting 2 different errors though (I guess the iOS samples have rotted a bit):

/Users/floh/projects/sokol-samples/metal/osxentry.m:44:8: error: unknown type name 'NSWindow'; did you mean 'UIWindow'?
static NSWindow* window;
       ^~~~~~~~
       UIWindow
In file included from /Users/floh/projects/sokol-samples/metal/osxentry.m:6:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:9:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKitCore.h:424:
/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIWindowScene.h:15:18: note:
      'UIWindow' declared here
@class UIScreen, UIWindow, UIWindowSceneDelegate, UISceneDestructionRequestOptions, CKShareMetadata, UISceneSize...
                 ^
1 error generated.

Something seems wrong with the macOS vs iOS detection in osx_entry.m

In the meantime you could try the build config sapp-metal-ios-xcode-debug.

floooh commented 5 years ago

I committed a fix for the NSWindow vs UIWindow problem, everything compiles but later I'm getting an error when running in the simulator about mismatching Metal compiler versions (I haven't tested on real hardware).

This is definitely a problem in the last Xcode11 Beta though, I didn't have that problem before.

I couldn't test on real hardware right now, since I first need to update to the latest iOS Beta.

floooh commented 5 years ago

ok...updated to latest iOS Beta 13.0 matching my Xcode11 Beta5, and I can compile and run the sokol-app samples (in the sapp-directory) on hardware.

On the simulator I get a runtime error, shader creation fails with:

Compilation failed: 

error: PCH file built from a different branch ((metalfe-902.9.49)) than the compiler ((metalfe-902.9.52))

Compilation failed: 

error: PCH file built from a different branch ((metalfe-902.9.49)) than the compiler ((metalfe-902.9.52))

I don't know what's up with that, the simulator was working fine in the previous Xcode Beta (but Metal support in the simulator is very new, so I guess bugs like this are to be expected).

I haven't seen the cmake-related errors you are describing though.

My cmake version is: 3.15.2, and I'm on the XCode 11 Beta5, and latest macOS Catalina Beta.

olilarkin commented 5 years ago

i upgraded to the latest cmake and it fixed it. i had 3.12

floooh commented 5 years ago

Ah good to know. Usually I try to still support older tools versions, but I think in that case it's ok. Cmake had some useful additions for iOS support in recent versions, and on Mac it's easy to get the latest cmake versions (unlike some very conservative Unix distros, like Debian).