Created
August 18, 2017 15:54
-
-
Save amroamroamro/a568eb73de00ef9b92f326778666df85 to your computer and use it in GitHub Desktop.
MinGW patch for OpenCV 3.3.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 37163b5ad31d1a7dffa3d4fdf65ce9a357d12054 Mon Sep 17 00:00:00 2001 | |
From: Amro <amroamroamro@gmail.com> | |
Date: Fri, 18 Aug 2017 16:19:26 +0300 | |
Subject: [PATCH] fixes for MinGW | |
- add a define before including DShow header, | |
to not use secure string replacements not defined by mingw | |
- dont pass gcc flags to windres which doesnt understand them | |
(another workaround is to set ENABLE_PRECOMPILED_HEADERS=OFF) | |
References: | |
- DShow fix: https://trac.ffmpeg.org/ticket/999 | |
- windres fix: https://github.com/mxe/mxe/pull/1485 | |
- https://wiki.qt.io/How_to_setup_Qt_and_openCV_on_Windows#OpenCV | |
--- | |
cmake/OpenCVPCHSupport.cmake | 9 +++++++++ | |
modules/videoio/src/cap_dshow.cpp | 1 + | |
2 files changed, 10 insertions(+) | |
diff --git a/cmake/OpenCVPCHSupport.cmake b/cmake/OpenCVPCHSupport.cmake | |
index 12e804d90..373f01ad9 100644 | |
--- a/cmake/OpenCVPCHSupport.cmake | |
+++ b/cmake/OpenCVPCHSupport.cmake | |
@@ -31,6 +31,15 @@ ELSE() | |
SET(PCHSupport_FOUND FALSE) | |
ENDIF() | |
+IF(CMAKE_COMPILER_IS_GNUCXX AND MINGW) | |
+ # in case of MinGW, we drop <FLAGS> because windres doesnt understand the | |
+ # various GCC flags like -Winvalid-pch or -include | |
+ # (it only accepts the -D and -I flags, i.e <DEFINES> and <INCLUDES>) | |
+ # https://github.com/Kitware/CMake/blob/master/Modules/Platform/Windows-windres.cmake | |
+ # https://sourceware.org/binutils/docs-2.28/binutils/windres.html | |
+ set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -O coff <DEFINES> <INCLUDES> <SOURCE> <OBJECT>") | |
+ENDIF() | |
+ | |
MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags) | |
STRING(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" _flags_var_name) | |
diff --git a/modules/videoio/src/cap_dshow.cpp b/modules/videoio/src/cap_dshow.cpp | |
index d8a9e8441..2b9c1c0b2 100644 | |
--- a/modules/videoio/src/cap_dshow.cpp | |
+++ b/modules/videoio/src/cap_dshow.cpp | |
@@ -108,6 +108,7 @@ Thanks to: | |
#include <vector> | |
//Include Directshow stuff here so we don't worry about needing all the h files. | |
+#define NO_DSHOW_STRSAFE | |
#include "DShow.h" | |
#include "strmif.h" | |
#include "Aviriff.h" | |
-- | |
2.14.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment