diff --git a/cmake/CompileFlags.cmake b/cmake/CompileFlags.cmake
index 5b7711a880..e147c36c2a 100644
--- a/cmake/CompileFlags.cmake
+++ b/cmake/CompileFlags.cmake
@@ -193,4 +193,9 @@ macro(compile_flags)
# rdynamic is used to get useful stack traces from crash reports.
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic")
endif()
+
+ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+ # workaround for MacOS 10.13 and below which does not support std::variant, etc
+ add_definitions(-D_LIBCPP_DISABLE_AVAILABILITY)
+ endif()
endmacro()
diff --git a/src/os/macosx/CMakeLists.txt b/src/os/macosx/CMakeLists.txt
index 645a057c7d..0b6264d294 100644
--- a/src/os/macosx/CMakeLists.txt
+++ b/src/os/macosx/CMakeLists.txt
@@ -4,6 +4,7 @@ add_files(
font_osx.h
macos.h
macos.mm
+ misc_osx.cpp
osx_stdafx.h
string_osx.cpp
string_osx.h
diff --git a/src/os/macosx/misc_osx.cpp b/src/os/macosx/misc_osx.cpp
new file mode 100644
index 0000000000..499c92b0e7
--- /dev/null
+++ b/src/os/macosx/misc_osx.cpp
@@ -0,0 +1,19 @@
+/*
+ * This file is part of OpenTTD.
+ * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
+ * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see .
+ */
+
+/** @file misc_osx.cpp OS X misc functionality */
+
+#include "../../stdafx.h"
+
+#include "../../safeguards.h"
+
+#include
+
+/* See: https://stackoverflow.com/questions/52310835/xcode-10-call-to-unavailable-function-stdvisit/53868971#53868971 */
+const char* std::bad_variant_access::what() const noexcept {
+ return "bad_variant_access";
+}