ogre-next: add darwin support
- Add apple-sdk_15 for Metal/Cocoa/OpenGL frameworks on macOS - Move openvr to Linux-only (broken on darwin) - Disable framework bundle output on darwin (incompatible with Nix store) - Guard Xcode-style POST_BUILD commands behind OGRE_BUILD_LIBS_AS_FRAMEWORKS to fix ninja "bad $-escape" error from $(PLATFORM_NAME)/$(CONFIGURATION) - Remove Xcode-centric CMAKE_OSX_SYSROOT overrides (Nix stdenv handles this) - Disable GL3Plus on darwin (missing Khronos headers; Metal is the primary render system on macOS) - Disable both NEON and SSE2 SIMD on aarch64 (fixes build failures) - Extend platforms from linux to unix Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
da048a16af
commit
68101fd57b
@@ -22,6 +22,7 @@
|
||||
openvr,
|
||||
rapidjson,
|
||||
zziplib,
|
||||
apple-sdk_15,
|
||||
}:
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "ogre-next";
|
||||
@@ -42,6 +43,35 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
})
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
# OgreMain/CMakeLists.txt has a macOS post-build block that uses `ditto`
|
||||
# (a macOS system tool unavailable in the Nix sandbox) to copy headers
|
||||
# into an Ogre.framework bundle. This block runs unconditionally on
|
||||
# non-iOS macOS — it is not gated by OGRE_BUILD_LIBS_AS_FRAMEWORKS.
|
||||
# Wrap it in a framework guard so it is skipped when frameworks are
|
||||
# disabled, avoiding the missing `ditto` and the unnecessary framework
|
||||
# directory structure.
|
||||
substituteInPlace OgreMain/CMakeLists.txt \
|
||||
--replace-fail \
|
||||
'set(OGRE_OSX_BUILD_CONFIGURATION "$(PLATFORM_NAME)/$(CONFIGURATION)")' \
|
||||
'if (OGRE_BUILD_LIBS_AS_FRAMEWORKS)
|
||||
set(OGRE_OSX_BUILD_CONFIGURATION "$(PLATFORM_NAME)/$(CONFIGURATION)")' \
|
||||
--replace-fail \
|
||||
'ogre_config_framework(''${OGRE_NEXT}Main)' \
|
||||
'endif ()
|
||||
ogre_config_framework(''${OGRE_NEXT}Main)'
|
||||
|
||||
# Remove Xcode-centric CMAKE_OSX_SYSROOT and CMAKE_OSX_ARCHITECTURES overrides.
|
||||
# Nix stdenv already sets these correctly via apple-sdk.
|
||||
substituteInPlace CMakeLists.txt \
|
||||
--replace-fail 'set(XCODE_ATTRIBUTE_SDKROOT macosx)' "" \
|
||||
--replace-fail 'set(CMAKE_OSX_SYSROOT macosx)' "" \
|
||||
--replace-fail \
|
||||
'execute_process(COMMAND xcodebuild -version -sdk "''${XCODE_ATTRIBUTE_SDKROOT}" Path | head -n 1 OUTPUT_VARIABLE CMAKE_OSX_SYSROOT)' "" \
|
||||
--replace-fail \
|
||||
'string(REGEX REPLACE "(\r?\n)+$" "" CMAKE_OSX_SYSROOT "''${CMAKE_OSX_SYSROOT}")' ""
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [
|
||||
cmake
|
||||
pkg-config
|
||||
@@ -54,7 +84,6 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
zziplib
|
||||
zlib
|
||||
tinyxml
|
||||
openvr
|
||||
rapidjson
|
||||
]
|
||||
++ lib.optionals stdenv.hostPlatform.isLinux [
|
||||
@@ -64,7 +93,11 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
libxrandr
|
||||
libxt
|
||||
libxcb
|
||||
];
|
||||
# openvr is broken on darwin
|
||||
openvr
|
||||
]
|
||||
# apple-sdk_15 provides Metal, Cocoa, and OpenGL frameworks
|
||||
++ lib.optional stdenv.hostPlatform.isDarwin apple-sdk_15;
|
||||
|
||||
# TODO: Figure out Vulkan plugin deps
|
||||
|
||||
@@ -74,6 +107,19 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
# Use STB instead of freeimage since the latter is marked as insecure
|
||||
(lib.cmakeBool "OGRE_CONFIG_ENABLE_FREEIMAGE" false)
|
||||
(lib.cmakeBool "OGRE_CONFIG_ENABLE_STBI" true)
|
||||
|
||||
# Framework bundles are incompatible with the Nix store
|
||||
(lib.cmakeBool "OGRE_BUILD_LIBS_AS_FRAMEWORKS" false)
|
||||
]
|
||||
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
||||
# GL3Plus requires Khronos headers not available on darwin; Metal is the
|
||||
# primary render system on macOS
|
||||
(lib.cmakeBool "OGRE_BUILD_RENDERSYSTEM_GL3PLUS" false)
|
||||
]
|
||||
# Both NEON and SSE2 SIMD cause build failures on aarch64
|
||||
++ lib.optionals stdenv.hostPlatform.isAarch64 [
|
||||
(lib.cmakeBool "OGRE_SIMD_NEON" false)
|
||||
(lib.cmakeBool "OGRE_SIMD_SSE2" false)
|
||||
];
|
||||
|
||||
passthru.tests.pkg-config = testers.hasPkgConfigModules {
|
||||
@@ -93,10 +139,7 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
"OGRE-MeshLodGenerator"
|
||||
"OGRE-Overlay"
|
||||
];
|
||||
platforms = lib.platforms.linux;
|
||||
platforms = lib.platforms.linux ++ lib.platforms.darwin;
|
||||
license = lib.licenses.mit;
|
||||
|
||||
# build problems around NEON intrinsics
|
||||
broken = stdenv.hostPlatform.isAarch64;
|
||||
};
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user