Created
February 23, 2018 23:01
-
-
Save amroamroamro/de4ac4155f35451ebc6300f87cec1f06 to your computer and use it in GitHub Desktop.
MinGW patch for OpenCV 3.4.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 c68ef0b7e946e4e915f0972a3e5eb6bf6a425f59 Mon Sep 17 00:00:00 2001 | |
From: Amro <[email protected]> | |
Date: Fri, 23 Feb 2018 19:20:03 +0200 | |
Subject: [PATCH] fixes for MinGW | |
* fix mingw detection in cmake file. When test is true, it defines | |
a macro which instructs DShow header not to use secure string | |
replacements not found in mingw | |
* dont pass gcc flags to windres which doesnt understand them | |
(another workaround is to set ENABLE_PRECOMPILED_HEADERS=OFF) | |
References: | |
* 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/CMakeLists.txt | 2 +- | |
2 files changed, 10 insertions(+), 1 deletion(-) | |
diff --git a/cmake/OpenCVPCHSupport.cmake b/cmake/OpenCVPCHSupport.cmake | |
index 0e41130b0..b064892af 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/CMakeLists.txt b/modules/videoio/CMakeLists.txt | |
index 0ded292f0..e8f6d593b 100644 | |
--- a/modules/videoio/CMakeLists.txt | |
+++ b/modules/videoio/CMakeLists.txt | |
@@ -78,7 +78,7 @@ endif() | |
if (WIN32 AND HAVE_DSHOW) | |
list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_dshow.cpp) | |
list(APPEND videoio_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/cap_dshow.hpp) | |
- if (MINGW64) | |
+ if (MINGW) | |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSTRSAFE_NO_DEPRECATE") | |
endif() | |
endif() | |
-- | |
2.15.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment