ogre-next: add darwin support (#501202)
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
stdenv,
|
||||
fetchFromGitHub,
|
||||
fetchpatch2,
|
||||
testers,
|
||||
|
||||
cmake,
|
||||
ninja,
|
||||
@@ -21,6 +22,7 @@
|
||||
openvr,
|
||||
rapidjson,
|
||||
zziplib,
|
||||
apple-sdk_15,
|
||||
}:
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "ogre-next";
|
||||
@@ -41,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
|
||||
@@ -53,7 +84,6 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
zziplib
|
||||
zlib
|
||||
tinyxml
|
||||
openvr
|
||||
rapidjson
|
||||
]
|
||||
++ lib.optionals stdenv.hostPlatform.isLinux [
|
||||
@@ -63,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
|
||||
|
||||
@@ -73,18 +107,39 @@ 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 {
|
||||
package = finalAttrs.finalPackage;
|
||||
versionCheck = true;
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "3D Object-Oriented Graphics Rendering Engine";
|
||||
homepage = "https://www.ogre3d.org/";
|
||||
maintainers = with lib.maintainers; [
|
||||
marcin-serwin
|
||||
];
|
||||
platforms = lib.platforms.linux;
|
||||
pkgConfigModules = [
|
||||
"OGRE"
|
||||
"OGRE-Hlms"
|
||||
"OGRE-MeshLodGenerator"
|
||||
"OGRE-Overlay"
|
||||
];
|
||||
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