ogre-next
ogre-next copied to clipboard
Static builds fail on macOS when attempting to use Metal backend
System Information
- Ogre Version: v2.2
- Operating System / Platform: macOS 10.15.5
- RenderSystem: Metal
- GPU: Radeon Pro 5500M
Detailled description
When using #include <OgreMetalRenderSystem.h>, compile fails on macOS with the following messages:
Unknown type name 'NSString'
In file included from /Users/main/Documents/engine-cmake/src/OgreStatics.cpp:1:
In file included from /Users/main/Documents/engine-cmake/include/engine/OgreStatics.hpp:3:
In file included from /Users/main/Documents/engine-cmake/deps/ogre-next/OgreMain/include/OgreSceneManager.h:34:
In file included from /Users/main/Documents/engine-cmake/deps/ogre-next/OgreMain/include/OgrePrerequisites.h:30:
/Users/main/Documents/engine-cmake/deps/ogre-next/OgreMain/include/OgrePlatform.h:316:16: warning: Ogre can't tell whether this is a debug build. If it is, please add _DEBUG to the preprocessor definitions. Otherwise, you can set OGRE_IGNORE_UNKNOWN_DEBUG to suppress this warning. Ogre will assume this is not a debug build by default. To add _DEBUG with g++, invoke g++ with the argument -D_DEBUG. To add it in CMake, include set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG=1 -D_DEBUG=1" ) at the top of your CMakeLists.txt file. IDEs usually provide the possibility to add preprocessor definitions in the build settings. You can also manually set OGRE_DEBUG_MODE to either 1 or 0 instead of adding _DEBUG. [-W#pragma-messages]
# pragma message (\
^
In file included from /Users/main/Documents/engine-cmake/src/OgreStatics.cpp:4:
In file included from /Users/main/Documents/engine-cmake/deps/ogre-next/RenderSystems/Metal/include/OgreMetalRenderSystem.h:34:
In file included from /Users/main/Documents/engine-cmake/deps/ogre-next/RenderSystems/Metal/include/OgreMetalRenderPassDescriptor.h:36:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLRenderPass.h:8:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:8:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:492:1: error: expected unqualified-id
@class NSString, Protocol;
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:494:9: error: unknown type name 'NSString'
typedef NSString * NSExceptionName NS_EXTENSIBLE_STRING_ENUM;
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:495:9: error: unknown type name 'NSString'
typedef NSString * NSRunLoopMode NS_EXTENSIBLE_STRING_ENUM;
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:497:19: error: unknown type name 'NSString'
FOUNDATION_EXPORT NSString *NSStringFromSelector(SEL aSelector);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:498:44: error: unknown type name 'NSString'
FOUNDATION_EXPORT SEL NSSelectorFromString(NSString *aSelectorName);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:500:19: error: unknown type name 'NSString'
FOUNDATION_EXPORT NSString *NSStringFromClass(Class aClass);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:501:53: error: unknown type name 'NSString'
FOUNDATION_EXPORT Class _Nullable NSClassFromString(NSString *aClassName);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:503: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/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:503: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/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:504: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/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:504: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/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:508: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/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:508: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/MacOSX10.15.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/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:509: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/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:509: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/MacOSX10.15.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/main/Documents/engine-cmake/src/OgreStatics.cpp:4:
In file included from /Users/main/Documents/engine-cmake/deps/ogre-next/RenderSystems/Metal/include/OgreMetalRenderSystem.h:34:
In file included from /Users/main/Documents/engine-cmake/deps/ogre-next/RenderSystems/Metal/include/OgreMetalRenderPassDescriptor.h:36:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLRenderPass.h:8:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:10:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSArray.h:5:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:8:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSZone.h:9:1: error: expected unqualified-id
@class NSString;
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.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/MacOSX10.15.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/main/Documents/engine-cmake/src/OgreStatics.cpp:4:
In file included from /Users/main/Documents/engine-cmake/deps/ogre-next/RenderSystems/Metal/include/OgreMetalRenderSystem.h:34:
In file included from /Users/main/Documents/engine-cmake/deps/ogre-next/RenderSystems/Metal/include/OgreMetalRenderPassDescriptor.h:36:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLRenderPass.h:8:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:10:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSArray.h:5:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:10:1: error: expected unqualified-id
@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
1 warning and 20 errors generated.
Ogre is configured as static in my CMakeLists.txt like this:
# ...
set(OGRE_ROOT "${DEPS_DIR}/ogre-next/")
set(OGRE_USE_BOOST OFF CACHE INTERNAL "")
set(OGRE_CONFIG_THREAD_PROVIDER OFF CACHE INTERNAL "")
set(OGRE_BUILD_COMPONENT_SCENE_FORMAT ON CACHE INTERNAL "")
set(OGRE_BUILD_SAMPLES2 OFF CACHE INTERNAL "")
set(OGRE_BUILD_TESTS OFF CACHE INTERNAL "")
set(OGRE_DEPENDENCIES_DIR "${OGRE_ROOT}/Dependencies/" CACHE INTERNAL "")
set(OGRE_STATIC ON CACHE INTERNAL "")
set(OGRE_BUILD_LIBS_AS_FRAMEWORKS OFF CACHE INTERNAL "")
ProcessorCount(OGRE_CONFIG_THREADS)
set(CMAKE_CXX_STANDARD 14)
if(APPLE)
set(OGRE_BUILD_RENDERSYSTEM_GL3PLUS OFF CACHE INTERNAL "") # disable OpenGL on Mac
elseif(WIN32)
endif()
add_subdirectory("${OGRE_ROOT}")
# ...
include_directories("${OGRE_ROOT}/OgreMain/include/")
include_directories("${OGRE_ROOT}/include/")
include_directories("${OGRE_ROOT}/Components/Hlms/Common/include")
include_directories("${OGRE_ROOT}/Components/Hlms/Pbs/include")
include_directories("${OGRE_ROOT}/Components/Unlit/Pbs/include")
include_directories("${OGRE_ROOT}/Components/Hlms/Unlit/include")
include_directories("${OGRE_ROOT}/Components/Hlms/UnlitMobile/include")
include_directories("${OGRE_ROOT}/RenderSystems/Direct3D11/include")
include_directories("${OGRE_ROOT}/RenderSystems/Metal/include")
include_directories("${OGRE_ROOT}/RenderSystems/GLES/include")
include_directories("${OGRE_ROOT}/RenderSystems/GL3Plus/include")
include_directories("${OGRE_ROOT}/RenderSystems/NULL/include")
include_directories("${OGRE_ROOT}/build/Release/include")
# ...
target_link_libraries("${PROJECT_NAME}" "OgreHlmsUnlit")
target_link_libraries("${PROJECT_NAME}" "OgreMain")
target_link_libraries("${PROJECT_NAME}" "OgreHlmsPbs")
if(WIN32)
target_link_libraries("${PROJECT_NAME}" "RenderSystem_Direct3D11")
#target_link_libraries("${PROJECT_NAME}" "RenderSystem_Direct3D9")
elseif(APPLE)
target_link_libraries("${PROJECT_NAME}" "RenderSystem_Metal")
endif()
if(NOT APPLE)
target_link_libraries("${PROJECT_NAME}" "RenderSystem_GL3Plus")
endif()
#target_link_libraries("${PROJECT_NAME}" "RenderSystem_GLES2")
target_link_libraries("${PROJECT_NAME}" "RenderSystem_NULL")
Ogre.log
N/A
Callstack
N/A