From 03c2593c50eddbe3c7910d389046037cdc8a58de Mon Sep 17 00:00:00 2001
From: Sergey Fedorov <vital.had@gmail.com>
Date: Mon, 22 Apr 2024 05:58:13 +0800
Subject: [PATCH] Do not force Cocoa build

---
 CMakeLists.txt       | 10 +++++++---
 rtgui/CMakeLists.txt |  2 +-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git CMakeLists.txt CMakeLists.txt
index 7b7c797d9..eecffe531 100644
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -79,6 +79,10 @@ set(CACHE_NAME_SUFFIX
     ""
     CACHE STRING "RawTherapee's cache folder suffix")
 
+if(APPLE)
+    option(MACOS_NATIVE "Use macOS Cocoa backend" ON)
+endif()
+
 # For macOS only, OSX_DEV_BUILD option allows using relative paths instead of absolute
 # paths. Consequently, for development builds, application can be launching without
 # being bundled. However, file access can be restricted for some folder.
@@ -248,7 +252,7 @@ set(TCMALLOC_LIB_DIR
     CACHE PATH "Custom path for the tcmalloc library")
 
 # Set installation directories:
-if(WIN32 OR APPLE)
+if(WIN32 OR (APPLE AND MACOS_NATIVE))
     if(BUILD_BUNDLE)
         message(
             STATUS
@@ -399,7 +403,7 @@ else()
     set(LENSFUNDBDIR "${LENSFUNDBDIR}")
 endif()
 
-if(APPLE)
+if(APPLE AND MACOS_NATIVE)
     if("${CODESIGNID}")
         set(CODESIGNID
             "${CODESIGNID}"
index 592b816a0..40108eca0 100644
--- rtgui/CMakeLists.txt
+++ rtgui/CMakeLists.txt
@@ -177,7 +177,7 @@ set(NONCLISOURCEFILES
 
 include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
 
-if(APPLE)
+if(APPLE AND MACOS_NATIVE)
     find_package(MacIntegration REQUIRED)
     # At the time of writing CMake has no module finder for gtkmacintegration so here we have it hard-coded, if installed via macports it should be in /opt/local/...
     set(EXTRA_LIB_RTGUI "${MacIntegration_LIBRARIES}")
