Skip to content

Commit 33f5a9f

Browse files
committed
Include additional core headers conditionally
1 parent af5d857 commit 33f5a9f

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

src_cpp/core.hpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
#include "ocvrs_common.hpp"
22
#include <opencv2/core/affine.hpp>
3-
#include <opencv2/core/directx.hpp>
4-
#include <opencv2/core/ocl.hpp>
5-
#include <opencv2/core/va_intel.hpp>
6-
#include <opencv2/core/cuda.hpp>
7-
#include <opencv2/core/opengl.hpp>
8-
#include <opencv2/core/directx.hpp>
3+
#ifdef HAVE_OPENCL
4+
#include <opencv2/core/ocl.hpp>
5+
// opengl.hpp, va_intel.hpp and directx.hpp unconditionally include ocl.hpp thus it needs to be within ifdef HAVE_OPENCL
6+
#ifdef HAVE_OPENGL
7+
#include <opencv2/core/opengl.hpp>
8+
#endif
9+
#include <opencv2/core/va_intel.hpp>
10+
#include <opencv2/core/directx.hpp>
11+
#endif
12+
#ifdef HAVE_CUDA
13+
#include <opencv2/core/cuda.hpp>
14+
#endif
915
#if (CV_VERSION_MAJOR == 3 && CV_VERSION_MINOR == 4 && CV_VERSION_REVISION >= 4) /* 3.4.4+ */ \
1016
|| (CV_VERSION_MAJOR == 4) /* 4.0+ */ \
1117
|| (CV_VERSION_MAJOR == 5) /* 5.0+ */

src_cpp/ocvrs_common.hpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#ifndef __OCVRS_COMMON_HPP__
22
#define __OCVRS_COMMON_HPP__
33

4-
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(__TOS_WIN__) || defined(__WINDOWS__) \
5-
|| defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__)
6-
#define OCVRS_TARGET_OS_WINDOWS
7-
#endif
4+
#include <memory>
5+
#include <opencv2/cvconfig.h>
6+
// defining HAVE_VA starts to rely on <va/va.h> for VADisplay and VASurfaceID instead of OpenCV stubs, and we stop generating
7+
// bindings for the functions that use them
8+
#undef HAVE_VA
89

910
#define CV_COLLECT_IMPL_DATA
1011
#ifdef OCVRS_PARSING_HEADERS
@@ -15,9 +16,13 @@
1516
#define OCVRS_FFI_EXPORT_SUFFIX
1617
#endif
1718

18-
#include <memory>
1919
#include <opencv2/core.hpp>
2020

21+
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(__TOS_WIN__) || defined(__WINDOWS__) \
22+
|| defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__)
23+
#define OCVRS_TARGET_OS_WINDOWS
24+
#endif
25+
2126
#define OCVRS_ONLY_DEPENDENT_TYPES
2227

2328
#define OCVRS_HANDLE(code, msg, return_name) Err(code, msg, return_name)

0 commit comments

Comments
 (0)