This file is part of MXE. See LICENSE.md for licensing information.

Contains ad hoc patches for cross building.

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20L=C3=B6ffler?= <st.loeffler@gmail.com>
Date: Sun, 5 Nov 2017 20:53:42 +0100
Subject: [PATCH 1/4] Only check for Type1 fonts in custom directory if path is
 non-NULL

Otherwise, programs using poppler may crash
Proposed upstream at https://bugs.freedesktop.org/show_bug.cgi?id=49037

diff --git a/poppler/GlobalParamsWin.cc b/poppler/GlobalParamsWin.cc
index 1111111..2222222 100644
--- a/poppler/GlobalParamsWin.cc
+++ b/poppler/GlobalParamsWin.cc
@@ -382,7 +382,7 @@ void GlobalParams::setupBaseFonts(const char *dir)
 
         GooString *fontName = new GooString(displayFontTab[i].name);
 
-        if (dir) {
+        if (dir && displayFontTab[i].t1FileName) {
             GooString *fontPath = appendToPath(new GooString(dir), displayFontTab[i].t1FileName);
             if (FileExists(fontPath->c_str()) || FileExists(replaceSuffix(fontPath, ".pfb", ".pfa")->c_str())) {
                 addFontFile(fontName, fontPath);

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: darealshinji <djcj@gmx.de>
Date: Thu, 14 Jul 2016 13:21:26 +0200
Subject: [PATCH 2/4] enable cross-building DLLs


diff --git a/cpp/poppler-global.h b/cpp/poppler-global.h
index 1111111..2222222 100644
--- a/cpp/poppler-global.h
+++ b/cpp/poppler-global.h
@@ -22,7 +22,7 @@
 #ifndef POPPLER_GLOBAL_H
 #define POPPLER_GLOBAL_H
 
-#if defined(_WIN32)
+#if defined(_WIN32) && defined(DLL_EXPORT)
 #    define LIB_EXPORT __declspec(dllexport)
 #    define LIB_IMPORT __declspec(dllimport)
 #else
diff --git a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc
index 1111111..2222222 100644
--- a/poppler/GlobalParams.cc
+++ b/poppler/GlobalParams.cc
@@ -104,6 +104,7 @@ std::unique_ptr<GlobalParams> globalParams;
 
 static HMODULE hmodule;
 
+#ifdef DLL_EXPORT
 extern "C" {
 /* Provide declaration to squelch -Wmissing-declarations warning */
 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
@@ -119,6 +120,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
     return TRUE;
 }
 }
+#endif
 
 static const char *get_poppler_datadir(void)
 {
diff --git a/qt5/src/poppler-export.h b/qt5/src/poppler-export.h
index 1111111..2222222 100644
--- a/qt5/src/poppler-export.h
+++ b/qt5/src/poppler-export.h
@@ -2,7 +2,7 @@
  * This file is used to set the poppler_qt5_EXPORT macros right.
  * This is needed for setting the visibility on windows, it will have no effect on other platforms.
  */
-#if defined(_WIN32)
+#if defined(_WIN32) && defined(DLL_EXPORT)
 #    define _POPPLER_QT5_LIB_EXPORT __declspec(dllexport)
 #    define _POPPLER_QT5_LIB_IMPORT __declspec(dllimport)
 #elif defined(__GNUC__)

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Boris Nagaev <bnagaev@gmail.com>
Date: Wed, 27 Jul 2016 10:29:52 +0200
Subject: [PATCH 3/4] do not try to use mman.h (package mman-win32)

fix https://github.com/mxe/mxe/issues/1455

diff --git a/poppler/CairoFontEngine.cc b/poppler/CairoFontEngine.cc
index 1111111..2222222 100644
--- a/poppler/CairoFontEngine.cc
+++ b/poppler/CairoFontEngine.cc
@@ -51,13 +51,6 @@
 #include "Gfx.h"
 #include "Page.h"
 
-#if defined(HAVE_FCNTL_H) && defined(HAVE_SYS_MMAN_H) && defined(HAVE_SYS_STAT_H)
-#    include <fcntl.h>
-#    include <sys/stat.h>
-#    include <sys/mman.h>
-#    define CAN_CHECK_OPEN_FACES 1
-#endif
-
 //------------------------------------------------------------------------
 // CairoFont
 //------------------------------------------------------------------------

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20L=C3=B6ffler?= <st.loeffler@gmail.com>
Date: Sat, 2 Mar 2019 12:42:53 +0100
Subject: [PATCH 4/4] Add the possibility to disable tests


diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1111111..2222222 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -48,10 +48,11 @@ set (CMAKE_CXX_EXTENSIONS OFF)
 
 # command line switches
 option(ENABLE_UNSTABLE_API_ABI_HEADERS "Install API/ABI unstable xpdf headers." OFF)
-option(BUILD_GTK_TESTS "Whether to compile the GTK+ test programs." ON)
-option(BUILD_QT5_TESTS "Whether to compile the Qt5 test programs." ON)
-option(BUILD_QT6_TESTS "Whether to compile the Qt6 test programs." ON)
-option(BUILD_CPP_TESTS "Whether to compile the CPP test programs." ON)
+option(ENABLE_TESTS "Whether compile tests." ON)
+option(BUILD_GTK_TESTS "Whether to compile the GTK+ test programs." ${ENABLE_TESTS})
+option(BUILD_QT5_TESTS "Whether to compile the Qt5 test programs." ${ENABLE_TESTS})
+option(BUILD_QT6_TESTS "Whether to compile the Qt6 test programs." ${ENABLE_TESTS})
+option(BUILD_CPP_TESTS "Whether to compile the CPP test programs." ${ENABLE_TESTS})
 option(ENABLE_SPLASH "Build the Splash graphics backend." ON)
 option(ENABLE_UTILS "Compile poppler command line utils." ON)
 option(ENABLE_CPP "Compile poppler cpp wrapper." ON)
@@ -727,7 +728,9 @@ endif()
 if(ENABLE_GLIB)
   add_subdirectory(glib)
 endif()
-add_subdirectory(test)
+if(ENABLE_TESTS)
+  add_subdirectory(test)
+endif()
 if(ENABLE_QT5)
   add_subdirectory(qt5)
 endif()
