From 9973dd3e5d390728e003c6b1fc927a4540f30655 Mon Sep 17 00:00:00 2001
From: Jon Evans <jon@craftyjon.com>
Date: Tue, 19 Sep 2023 20:30:57 -0400
Subject: [PATCH] Fix sentry compile issues on macOS

---
 CMakeLists.txt                                                | 4 +++-
 common/pgm_base.cpp                                           | 4 ++++
 thirdparty/sentry-native/CMakeLists.txt                       | 2 +-
 .../sentry-native/external/crashpad/handler/CMakeLists.txt    | 2 +-
 4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index cb671e7bc4..ec62cbf753 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -997,7 +997,9 @@ if( KICAD_USE_SENTRY )
         message( FATAL_ERROR "Sentry DSN must be configured with KICAD_USE_SENTRY" )
     endif()
 
-    set( CRASHPAD_WER_ENABLED ON )
+    if( WIN32 )
+        set( CRASHPAD_WER_ENABLED ON )
+    endif()
     add_subdirectory( thirdparty/sentry-native )
     add_compile_definitions( KICAD_USE_SENTRY )
 endif()
diff --git a/common/pgm_base.cpp b/common/pgm_base.cpp
index 9a868fa428..526567247e 100644
--- a/common/pgm_base.cpp
+++ b/common/pgm_base.cpp
@@ -338,7 +338,11 @@ void PGM_BASE::sentryInit()
         tmp.AssignDir( PATHS::GetUserCachePath() );
         tmp.AppendDir( "sentry" );
 
+#ifdef __WINDOWS__
         sentry_options_set_database_pathw( options, tmp.GetPathWithSep().wc_str() );
+#else
+        sentry_options_set_database_path( options, tmp.GetPathWithSep().c_str() );
+#endif
         sentry_options_set_symbolize_stacktraces( options, true );
         sentry_options_set_auto_session_tracking( options, false );
 
diff --git a/thirdparty/sentry-native/CMakeLists.txt b/thirdparty/sentry-native/CMakeLists.txt
index 8c56eb355f..4e00a28def 100644
--- a/thirdparty/sentry-native/CMakeLists.txt
+++ b/thirdparty/sentry-native/CMakeLists.txt
@@ -482,7 +482,7 @@ if(SENTRY_BACKEND_CRASHPAD)
 		endif()
 	endif()
 	add_dependencies(sentry crashpad::handler)
-	if(CRASHPAD_WER_ENABLED)
+	if(WIN32 AND CRASHPAD_WER_ENABLED)
 		add_dependencies(sentry crashpad::wer)
 	endif()
 elseif(SENTRY_BACKEND_BREAKPAD)
diff --git a/thirdparty/sentry-native/external/crashpad/handler/CMakeLists.txt b/thirdparty/sentry-native/external/crashpad/handler/CMakeLists.txt
index 0e5851c099..949b627e22 100644
--- a/thirdparty/sentry-native/external/crashpad/handler/CMakeLists.txt
+++ b/thirdparty/sentry-native/external/crashpad/handler/CMakeLists.txt
@@ -123,7 +123,7 @@ if(NOT IOS)
     )
 endif()
 
-if(CRASHPAD_WER_ENABLED)
+if(WIN32 AND CRASHPAD_WER_ENABLED)
     add_library(crashpad_wer SHARED
         win/wer/crashpad_wer.cc
         win/wer/crashpad_wer.h