From 377dc1af24d5803aac11fa70e369eae9c40e8b7f Mon Sep 17 00:00:00 2001
From: "R. van twisk" <ries.van.twisk@ing.com>
Date: Sat, 30 Nov 2019 12:22:16 +0100
Subject: OSX Build fixes

---
 cmake/opentrack-platform.cmake        | 8 +++++---
 options/globals.cpp                   | 2 +-
 proto-iokit-foohid/CMakeLists.txt     | 2 +-
 proto-iokit-foohid/foohidjoystick.cpp | 8 ++++----
 proto-iokit-foohid/foohidjoystick.h   | 2 ++
 proto-iokit-foohid/iokitprotocol.cpp  | 4 ++--
 qxt-mini/CMakeLists.txt               | 4 +++-
 7 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/cmake/opentrack-platform.cmake b/cmake/opentrack-platform.cmake
index 02c1b2f8..0ebe53a7 100644
--- a/cmake/opentrack-platform.cmake
+++ b/cmake/opentrack-platform.cmake
@@ -156,11 +156,13 @@ if(MSVC)
 endif()
 
 if(APPLE)
-    add_compile_definitions(-stdlib=libc++)
+    # Removed because of Macro error
+    # add_compile_definitions(-stdlib=libc++)
     add_link_options(-stdlib=libc++)
 
-    add_link_options(-framework Cocoa -framework CoreFoundation -framework Carbon)
-    link_libraries(objc z)
+    # Build failure cannot link to frameworks
+    #add_link_options(-framework Cocoa -framework CoreFoundation -framework Carbon)
+    #link_libraries(objc z)
 endif()
 
 if(NOT MSVC)
diff --git a/options/globals.cpp b/options/globals.cpp
index 099a7208..386ef56d 100644
--- a/options/globals.cpp
+++ b/options/globals.cpp
@@ -154,8 +154,8 @@ fail:   constexpr const char* subdir = "ini";
         QString dir = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation).value(0, QString());
         if (dir.isEmpty())
             goto fail;
-#if !defined _WIN32 && !defined __APPLE__
         const QString fmt = QStringLiteral("%1/%2");
+#if !defined _WIN32 && !defined __APPLE__
         if (!QFile::exists(fmt.arg(dir, OPENTRACK_ORG)))
         {
             dir = QStandardPaths::standardLocations(QStandardPaths::ConfigLocation).value(0, QString());
diff --git a/proto-iokit-foohid/CMakeLists.txt b/proto-iokit-foohid/CMakeLists.txt
index 31d3dcdc..6a4bf89a 100644
--- a/proto-iokit-foohid/CMakeLists.txt
+++ b/proto-iokit-foohid/CMakeLists.txt
@@ -1,4 +1,4 @@
-if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
+if(APPLE)
     otr_module(proto-iokit-foohid)
     target_link_options(${self} PRIVATE -framework IOKit)
 endif()
diff --git a/proto-iokit-foohid/foohidjoystick.cpp b/proto-iokit-foohid/foohidjoystick.cpp
index 0b305d08..898db2f4 100644
--- a/proto-iokit-foohid/foohidjoystick.cpp
+++ b/proto-iokit-foohid/foohidjoystick.cpp
@@ -51,7 +51,7 @@ static bool connectToService(io_connect_t *connection, QString *errorMessage)
                                                      IOServiceMatching(FOOHID_SERVICE_NAME),
                                                      &iterator);
     if (ret != KERN_SUCCESS) {
-        *errorMessage = otr_tr("Unable to find FooHID IOService.");
+        *errorMessage = QObject::tr("Unable to find FooHID IOService.");
         return false;
     }
     // Iterate over services and try to open connection
@@ -66,7 +66,7 @@ static bool connectToService(io_connect_t *connection, QString *errorMessage)
     }
     IOObjectRelease(iterator);
     if (!found) {
-        *errorMessage = otr_tr("Unable to connect to FooHID IOService.");
+        *errorMessage = QObject::tr("Unable to connect to FooHID IOService.");
         return false;
     }
     return true;
@@ -89,7 +89,7 @@ FooHIDJoystick::FooHIDJoystick(const QByteArray &name, const QByteArray &serialN
         deviceCreated = createDevice();
         _hasError = !deviceCreated;
         if (!deviceCreated)
-            _errorMessage = otr_tr("Failed to create virtual joystick");
+            _errorMessage = tr("Failed to create virtual joystick");
     }
 }
 
@@ -116,7 +116,7 @@ void FooHIDJoystick::setValue(JoystickValues newValues)
     values = newValues;
     if (!sendToDevice()) {
         _hasError = true;
-        _errorMessage = otr_tr("Failed to send values to virtual joystick");
+        _errorMessage = tr("Failed to send values to virtual joystick");
     }
 }
 
diff --git a/proto-iokit-foohid/foohidjoystick.h b/proto-iokit-foohid/foohidjoystick.h
index a1f74304..e987c229 100644
--- a/proto-iokit-foohid/foohidjoystick.h
+++ b/proto-iokit-foohid/foohidjoystick.h
@@ -9,6 +9,7 @@
 
 #include <QByteArray>
 #include <QString>
+#include <QCoreApplication>
 
 #include <IOKit/IOKitLib.h>
 
@@ -23,6 +24,7 @@ struct JoystickValues {
 
 class FooHIDJoystick
 {
+    Q_DECLARE_TR_FUNCTIONS(FooHIDJoystick)
 public:
     FooHIDJoystick(const QByteArray &name, const QByteArray &serialNumber);
     ~FooHIDJoystick();
diff --git a/proto-iokit-foohid/iokitprotocol.cpp b/proto-iokit-foohid/iokitprotocol.cpp
index 6f163d8f..abc43a60 100644
--- a/proto-iokit-foohid/iokitprotocol.cpp
+++ b/proto-iokit-foohid/iokitprotocol.cpp
@@ -25,14 +25,14 @@ IOKitProtocol::IOKitProtocol()
 module_status IOKitProtocol::initialize()
 {
     if (!joystick)
-        return otr_tr("Load failure");
+        return tr("Load failure");
 
     if (joystick->hasError())
     {
         QString msg = joystick->errorMessage();
 
         if (msg.isEmpty())
-            msg = otr_tr("Unknown error");
+            msg = tr("Unknown error");
 
         return error(msg);
     }
diff --git a/qxt-mini/CMakeLists.txt b/qxt-mini/CMakeLists.txt
index 21b2b160..1b2496f6 100644
--- a/qxt-mini/CMakeLists.txt
+++ b/qxt-mini/CMakeLists.txt
@@ -3,7 +3,9 @@ if(UNIX OR APPLE)
     include_directories(SYSTEM ${Qt5Gui_PRIVATE_INCLUDE_DIRS})
     otr_module(qxt-mini NO-COMPAT BIN)
     if(APPLE)
-        target_link_options(${self} PUBLIC -framework Carbon -framework CoreFoundation)
+        find_library(CoreFoundation CoreFoundation)
+        find_library(Carbon Carbon)
+        target_link_options(${self} PUBLIC -framework Carbon -I ${CoreFoundation})
     else()
         otr_pkgconfig(${self} x11 xcb xproto)
     endif()
-- 
cgit v1.2.3