From a8b96a014024e2771e7d578d2b0e6f513a47c3e2 Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Fri, 9 Dec 2022 10:09:54 +0100 Subject: [PATCH] mygui: add darwin support --- pkgs/development/libraries/mygui/default.nix | 56 ++++++++++++++++--- .../libraries/mygui/disable-framework.patch | 19 +++++++ pkgs/top-level/all-packages.nix | 1 + 3 files changed, 68 insertions(+), 8 deletions(-) create mode 100644 pkgs/development/libraries/mygui/disable-framework.patch diff --git a/pkgs/development/libraries/mygui/default.nix b/pkgs/development/libraries/mygui/default.nix index 740c1fec8834..b49f9ca6e2de 100644 --- a/pkgs/development/libraries/mygui/default.nix +++ b/pkgs/development/libraries/mygui/default.nix @@ -1,9 +1,24 @@ -{ lib, stdenv, fetchFromGitHub, libX11, cmake, ois, freetype, libuuid, - boost, pkg-config, withOgre ? false, ogre ? null, libGL, libGLU ? null } : +{ lib +, stdenv +, fetchFromGitHub +, cmake +, pkg-config +, boost +, freetype +, libuuid +, ois +, withOgre ? false +, ogre +, libGL +, libGLU +, libX11 +, Cocoa +}: let renderSystem = if withOgre then "3" else "4"; -in stdenv.mkDerivation rec { +in +stdenv.mkDerivation rec { pname = "mygui"; version = "3.4.0"; @@ -14,17 +29,42 @@ in stdenv.mkDerivation rec { sha256 = "0a4zi8w18pjj813n7kmxldl1d9r1jp0iyhkw7pbqgl8f7qaq994w"; }; - nativeBuildInputs = [ cmake pkg-config ]; - buildInputs = [ libX11 ois freetype libuuid boost ] - ++ (if withOgre then [ ogre ] else [ libGL libGLU ]); + patches = [ + ./disable-framework.patch + ]; + + nativeBuildInputs = [ + cmake + pkg-config + ]; + + buildInputs = [ + boost + freetype + libuuid + ois + ] ++ lib.optionals withOgre [ + ogre + ] ++ lib.optionals (!withOgre && stdenv.isLinux) [ + libGL + libGLU + ] ++ lib.optionals stdenv.isLinux [ + libX11 + ] ++ lib.optionals stdenv.isDarwin [ + Cocoa + ]; # Tools are disabled due to compilation failures. - cmakeFlags = [ "-DMYGUI_BUILD_TOOLS=OFF" "-DMYGUI_BUILD_DEMOS=OFF" "-DMYGUI_RENDERSYSTEM=${renderSystem}" ]; + cmakeFlags = [ + "-DMYGUI_BUILD_TOOLS=OFF" + "-DMYGUI_BUILD_DEMOS=OFF" + "-DMYGUI_RENDERSYSTEM=${renderSystem}" + ]; meta = with lib; { homepage = "http://mygui.info/"; description = "Library for creating GUIs for games and 3D applications"; license = licenses.lgpl3Plus; - platforms = platforms.linux; + platforms = platforms.unix; }; } diff --git a/pkgs/development/libraries/mygui/disable-framework.patch b/pkgs/development/libraries/mygui/disable-framework.patch new file mode 100644 index 000000000000..502e58ac3625 --- /dev/null +++ b/pkgs/development/libraries/mygui/disable-framework.patch @@ -0,0 +1,19 @@ +diff --git a/CMake/Utils/MyGUIConfigTargets.cmake b/CMake/Utils/MyGUIConfigTargets.cmake +index bba3f91..8f4f351 100644 +--- a/CMake/Utils/MyGUIConfigTargets.cmake ++++ b/CMake/Utils/MyGUIConfigTargets.cmake +@@ -477,14 +477,6 @@ function(mygui_config_lib PROJECTNAME) + if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") + # add GCC visibility flags to shared library build + set_target_properties(${PROJECTNAME} PROPERTIES COMPILE_FLAGS "${MYGUI_GCC_VISIBILITY_FLAGS}") +- if (APPLE) +- # deal with Mac OS X's framework system +- set_target_properties(${PROJECTNAME} PROPERTIES FRAMEWORK TRUE) +- set_target_properties(${PROJECTNAME} PROPERTIES PUBLIC_HEADER "${${PROJECTNAME}_HEADERS}") +- set_target_properties(${PROJECTNAME} PROPERTIES OUTPUT_NAME ${PROJECTNAME}) +- set_target_properties(${PROJECTNAME} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE) +- set_target_properties(${PROJECTNAME} PROPERTIES INSTALL_NAME_DIR "@executable_path/../Frameworks") +- endif (APPLE) + endif () + endif (MYGUI_STATIC) + mygui_install_target(${PROJECTNAME} "") diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 172ba6fd737b..77d92a36ee6e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -21645,6 +21645,7 @@ with pkgs; mygpoclient = with python3.pkgs; toPythonApplication mygpoclient; mygui = callPackage ../development/libraries/mygui { + inherit (darwin.apple_sdk.frameworks) Cocoa; ogre = ogre1_9; };