Closed Angluca closed 10 months ago
//cmakelist.txt
...
fips_setup()
include_directories("../sokol")
add_subdirectory(src)
//src
fips_begin_app(hello cmdline)
fips_frameworks_osx(Cocoa QuartzCore OpenGL)
fips_files(hello.c)
fips_end_app()
=== building: osx-make-release
=== generating: osx-make-release
config file: /Users/hehe/SDK/Sokols/fips/configs/osx-make-release.yml
Preset CMake variables:
CMAKE_BUILD_TYPE="Release"
CMAKE_EXPORT_COMPILE_COMMANDS="ON"
CMAKE_OSX_SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk"
FIPS_AUTO_IMPORT="ON"
FIPS_CONFIG="osx-make-release"
FIPS_LOCAL_BUILD="OFF"
-- The C compiler identification is AppleClang 13.0.0.13000029
-- The CXX compiler identification is AppleClang 13.0.0.13000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- 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/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMAKE_BUILD_TYPE: Release
FIPS_ROOT_DIR: /Users/hehe/SDK/Sokols/fips
FIPS_PROJECT_DIR: /Users/hehe/SDK/Sokols/hello
FIPS_BUILD_DIR: /Users/hehe/SDK/Sokols/fips-build
FIPS_DEPLOY_DIR: /Users/hehe/SDK/Sokols/fips-deploy
FIPS_PROJECT_NAME: hello
FIPS_AUTO_IMPORT: ON
FIPS_CONFIG: osx-make-release
FIPS_PROJECT_BUILD_DIR: /Users/hehe/SDK/Sokols/fips-build/hello/osx-make-release
FIPS_PROJECT_DEPLOY_DIR: /Users/hehe/SDK/Sokols/fips-deploy/hello/osx-make-release
Host system: OSX
CMAKE_CXX_COMPILER_ID: AppleClang
FIPS_CLANG: 1
FIPS_APPLE_CLANG: 1
FIPS_PLATFORM: OSX
FIPS_PLATFORM_NAME: osx
-- Found Python: /usr/local/Frameworks/Python.framework/Versions/3.12/bin/python3.12 (found version "3.12.1") found components: Interpreter
-- Configuring done (4.8s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/hehe/SDK/Sokols/fips-build/hello/osx-make-release
cmake --build . --parallel 6 --config Release --
[ 50%] Building C object src/CMakeFiles/hello.dir/hello.c.o
In file included from /Users/hehe/SDK/Sokols/hello/src/hello.c:4:
In file included from /Users/hehe/SDK/Sokols/hello/../sokol/sokol_app.h:2006:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:8:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:523:1: error: expected identifier or '('
@class NSString, Protocol;
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:525:9: error: unknown type name 'NSString'
typedef NSString * NSExceptionName NS_TYPED_EXTENSIBLE_ENUM;
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:526:9: error: unknown type name 'NSString'
typedef NSString * NSRunLoopMode NS_TYPED_EXTENSIBLE_ENUM;
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:528:19: error: unknown type name 'NSString'
FOUNDATION_EXPORT NSString *NSStringFromSelector(SEL aSelector);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:529:44: error: unknown type name 'NSString'
FOUNDATION_EXPORT SEL NSSelectorFromString(NSString *aSelectorName);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:531:19: error: unknown type name 'NSString'
FOUNDATION_EXPORT NSString *NSStringFromClass(Class aClass);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:532:53: error: unknown type name 'NSString'
FOUNDATION_EXPORT Class _Nullable NSClassFromString(NSString *aClassName);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:534:19: error: unknown type name 'NSString'
FOUNDATION_EXPORT NSString *NSStringFromProtocol(Protocol *proto) API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0));
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:534:50: error: unknown type name 'Protocol'
FOUNDATION_EXPORT NSString *NSStringFromProtocol(Protocol *proto) API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0));
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:535:19: error: unknown type name 'Protocol'
FOUNDATION_EXPORT Protocol * _Nullable NSProtocolFromString(NSString *namestr) API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0));
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:535:61: error: unknown type name 'NSString'
FOUNDATION_EXPORT Protocol * _Nullable NSProtocolFromString(NSString *namestr) API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0));
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:539:30: error: unknown type name 'NSString'
FOUNDATION_EXPORT void NSLog(NSString *format, ...) NS_FORMAT_FUNCTION(1,2) NS_NO_TAIL_CALL;
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:539:53: error: format argument not an NSString
FOUNDATION_EXPORT void NSLog(NSString *format, ...) NS_FORMAT_FUNCTION(1,2) NS_NO_TAIL_CALL;
~~~~~~~~~~~~~~~~ ^ ~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:94:49: note: expanded from macro 'NS_FORMAT_FUNCTION'
#define NS_FORMAT_FUNCTION(F,A) __attribute__((format(__NSString__, F, A)))
^ ~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:540:31: error: unknown type name 'NSString'
FOUNDATION_EXPORT void NSLogv(NSString *format, va_list args) NS_FORMAT_FUNCTION(1,0) NS_NO_TAIL_CALL;
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:540:63: error: format argument not an NSString
FOUNDATION_EXPORT void NSLogv(NSString *format, va_list args) NS_FORMAT_FUNCTION(1,0) NS_NO_TAIL_CALL;
~~~~~~~~~~~~~~~~ ^ ~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:94:49: note: expanded from macro 'NS_FORMAT_FUNCTION'
#define NS_FORMAT_FUNCTION(F,A) __attribute__((format(__NSString__, F, A)))
^ ~
In file included from /Users/hehe/SDK/Sokols/hello/src/hello.c:4:
In file included from /Users/hehe/SDK/Sokols/hello/../sokol/sokol_app.h:2006:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:10:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSArray.h:5:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:8:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSZone.h:9:1: error: expected identifier or '('
@class NSString;
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSZone.h:19:63: error: unknown type name 'NSString'
FOUNDATION_EXPORT void NSSetZoneName(NSZone * _Nullable zone, NSString *name)NS_SWIFT_UNAVAILABLE("Zone-based memory management is unavailable");
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSZone.h:20:19: error: unknown type name 'NSString'
FOUNDATION_EXPORT NSString *NSZoneName(NSZone * _Nullable zone) NS_SWIFT_UNAVAILABLE("Zone-based memory management is unavailable");
^
In file included from /Users/hehe/SDK/Sokols/hello/src/hello.c:4:
In file included from /Users/hehe/SDK/Sokols/hello/../sokol/sokol_app.h:2006:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:10:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSArray.h:5:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:10:1: error: expected identifier or '('
@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [src/CMakeFiles/hello.dir/hello.c.o] Error 1
make[1]: *** [src/CMakeFiles/hello.dir/all] Error 2
make: *** [all] Error 2
[ERROR] Failed to build config 'osx-make-release' of project 'hello'
hello.m
!!!How to build success when filename is hello.c
... T_T
Yes it's because on macOS the sokol headers must be compiled as Objective-C.
You can force that with target_compile_option
in the CMakeLists.txt file like this:
fips_begin_app(hello cmdline)
fips_frameworks_osx(Cocoa QuartzCore OpenGL)
fips_files(hello.c)
target_compile_option(hello PRIVATE -x objective-c)
fips_end_app()
...make sure to use an uptodate fips version though, the ability to put the target_compile_option inside fips_begin/end is somewhat new (ok not that new, Dec-2022).
I've update fips ./fips update fips
But It always fips 0.0.1 version
So add target_compile_option(hello PRIVATE -x objective-c)
always error T_T
Well, I'm glad it compile success now
...you can also check the CMakeLists.txt file here for reference:
https://github.com/floooh/cimgui-sokol-starterkit
...this builds the sokol headers into a library, but it demonstrates how to force compiling .c files as ObjC.
Yeah, I copy sokol.c and change cmakelists.txt build hello.c use opengl ok now I 'm lazy so add sokol.h include sokol heads, Very well :)
# hello/cmakelists.txt
...
fips_setup()
include_directories("../sokol")
add_subdirectory(src)
# src/cmakelists.txt
fips_begin_app(hello cmdline)
add_library(sokol STATIC sokol.c)
target_compile_options(sokol PRIVATE -x objective-c)
target_link_libraries(sokol PUBLIC
"-framework QuartzCore"
"-framework Cocoa"
"-framework Opengl")
#"-framework MetalKit"
#"-framework Metal")
fips_deps(sokol)
fips_files(hello.c)
fips_end_app()
// sokol.c
// sokol implementation library on non-Apple platforms
#define SOKOL_IMPL
#if defined(_WIN32)
#define SOKOL_D3D11
#elif defined(__EMSCRIPTEN__)
#define SOKOL_GLES3
#elif defined(__APPLE__)
// NOTE: on macOS, sokol.c is compiled explicitely as ObjC
//#define SOKOL_METAL
#define SOKOL_GLCORE33
#else
#define SOKOL_GLCORE33
#endif
#include "sokol.h"
// sokol.h
#include "sokol_app.h"
#include "sokol_gfx.h"
#include "sokol_log.h"
#include "sokol_glue.h"
// hello.c
#include "sokol.h"
sg_pass_action pass_action;
void init(void) {
...
I build sokol-examples all ok
./fips build sapp-osx-vscode|xcode-release
But I create a project use sokol build error
./fips build osx-make-release