-
Notifications
You must be signed in to change notification settings - Fork 22
/
Makefile.win
227 lines (208 loc) · 8.34 KB
/
Makefile.win
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
!IFNDEF MIX_APP_PATH
MIX_APP_PATH=$(MAKEDIR)
!ENDIF
PRIV_DIR = $(MIX_APP_PATH)/priv
EVISION_SO = $(PRIV_DIR)/evision.dll
WINDOWS_FIX_SO = $(PRIV_DIR)/windows_fix.dll
SRC = $(MAKEDIR)\src
C_SRC = $(MAKEDIR)\c_src
PY_SRC = $(MAKEDIR)\py_src
LIB_SRC = $(MAKEDIR)\lib
GLEAM_SRC = $(MAKEDIR)\gleam_src
PATCHES_DIR = $(MAKEDIR)\patches
!IFDEF CMAKE_TOOLCHAIN_FILE
CMAKE_CONFIGURE_FLAGS=-D CMAKE_TOOLCHAIN_FILE="$(CMAKE_TOOLCHAIN_FILE)"
!ENDIF
# OpenCV
!IFNDEF OPENCV_USE_GIT_HEAD
OPENCV_USE_GIT_HEAD=false
!ENDIF
!IFNDEF OPENCV_GIT_REPO
OPENCV_GIT_REPO="https://github.com/opencv/opencv.git"
!ENDIF
!IFNDEF OPENCV_VER
OPENCV_VER=4.10.0
!ENDIF
!IFNDEF OPENCV_CONTRIB_VER
OPENCV_CONTRIB_VER=4.10.0
!ENDIF
!IF "$(OPENCV_USE_GIT_HEAD)" == "true"
OPENCV_VER=$(OPENCV_USE_GIT_BRANCH)
!ENDIF
OPENCV_CACHE_DIR = $(MAKEDIR)\3rd_party\cache
OPENCV_SOURCE_URL = "https://github.com/opencv/opencv/archive/$(OPENCV_VER).zip"
OPENCV_SOURCE_ZIP = $(OPENCV_CACHE_DIR)\opencv-$(OPENCV_VER).zip
OPENCV_ROOT_DIR = $(MAKEDIR)\3rd_party\opencv
OPENCV_DIR = $(OPENCV_ROOT_DIR)\opencv-$(OPENCV_VER)
OPENCV_CONTRIB_DIR = $(OPENCV_ROOT_DIR)\opencv_contrib-$(OPENCV_CONTRIB_VER)
OPENCV_CONFIGURATION_PRIVATE_HPP = $(OPENCV_DIR)\modules\core\include\opencv2\core\utils\configuration.private.hpp
CMAKE_OPENCV_BUILD_DIR = $(MIX_APP_PATH)/cmake_opencv_$(OPENCV_VER)
!IFNDEF CMAKE_OPENCV_MODULE_SELECTION
CMAKE_OPENCV_MODULE_SELECTION = -D BUILD_opencv_python2=OFF -D BUILD_opencv_python3=OFF -D BUILD_opencv_gapi=OFF
!ENDIF
!IFNDEF CMAKE_OPENCV_IMG_CODER_SELECTION
CMAKE_OPENCV_IMG_CODER_SELECTION = -D BUILD_PNG=ON -D BUILD_JPEG=ON -D BUILD_TIFF=ON -D BUILD_WEBP=ON -D BUILD_OPENJPEG=ON -D BUILD_JASPER=ON -D BUILD_OPENEXR=ON
!ENDIF
!IFNDEF CMAKE_OPENCV_OPTIONS
CMAKE_OPENCV_OPTIONS = ""
!ENDIF
!IFNDEF CMAKE_OPTIONS
CMAKE_OPTIONS = $(CMAKE_OPENCV_MODULE_SELECTION) $(CMAKE_OPENCV_IMG_CODER_SELECTION)
!ENDIF
CMAKE_WIN_FINAL_OPTIONS = $(CMAKE_OPTIONS) $(CMAKE_CONFIGURE_FLAGS) $(CMAKE_OPENCV_OPTIONS)
!IFNDEF ENABLED_CV_MODULES
ENABLED_CV_MODULES = ""
!ENDIF
# evision
OPENCV_HEADERS_TXT="$(CMAKE_OPENCV_BUILD_DIR)/modules/python_bindings_generator/headers.txt"
CONFIGURATION_PRIVATE_HPP = $(C_SRC)\configuration.private.hpp
GENERATED_ELIXIR_SRC_DIR = $(LIB_SRC)\generated
GENERATED_ERLANG_SRC_DIR = $(SRC)\generated
GENERATED_GLEAM_SRC_DIR = $(GLEAM_SRC)
CMAKE_EVISION_BUILD_DIR = $(MIX_APP_PATH)/cmake_evision
!IFNDEF GLEAM_EVISION
GLEAM_EVISION = "false"
!ENDIF
!IFNDEF EVISION_PREFER_PRECOMPILED
EVISION_PREFER_PRECOMPILED = "false"
!ENDIF
!IFNDEF EVISION_ENABLE_CONTRIB
EVISION_ENABLE_CONTRIB = "true"
!ENDIF
!IFNDEF EVISION_PRECOMPILED_CACHE_DIR
EVISION_PRECOMPILED_CACHE_DIR = $(MAKEDIR)\.cache
!ENDIF
!IFNDEF EVISION_GENERATE_LANG
!IF "$(EVISION_COMPILE_WITH_REBAR)" == "true"
EVISION_GENERATE_LANG = elixir,erlang
!ELSE
EVISION_GENERATE_LANG = elixir
!ENDIF
!ENDIF
!IFNDEF CMAKE_GENERATOR_TYPE
!IFNDEF MSBUILD_PLATFORM
!IF "$(HAVE_NINJA)" == "true"
CMAKE_GENERATOR_TYPE=Ninja
!ELSE
CMAKE_GENERATOR_TYPE=NMake Makefiles
!ENDIF
!ENDIF
!ENDIF
!IFNDEF CMAKE_BUILD_TYPE
CMAKE_BUILD_TYPE=Release
!ENDIF
!IF "$(EVISION_ENABLE_CONTRIB)" == "true"
CMAKE_WIN_FINAL_OPTIONS_DEFINITIVE_EDITION = $(CMAKE_WIN_FINAL_OPTIONS) -DOPENCV_EXTRA_MODULES_PATH="$(OPENCV_CONTRIB_DIR)\modules" -D BUILD_opencv_hdf=OFF -D BUILD_opencv_freetype=OFF
C_SRC_HEADER_TXT="$(C_SRC)/headers-contrib.txt"
HEADERS_TXT="$(CMAKE_OPENCV_BUILD_DIR)/modules/python_bindings_generator/headers-contrib.txt"
!ELSE
CMAKE_WIN_FINAL_OPTIONS_DEFINITIVE_EDITION = $(CMAKE_WIN_FINAL_OPTIONS)
C_SRC_HEADER_TXT="$(C_SRC)/headers.txt"
HEADERS_TXT="$(CMAKE_OPENCV_BUILD_DIR)/modules/python_bindings_generator/headers.txt"
!ENDIF
!IFDEF CMAKE_TOOLCHAIN_FILE
CMAKE_WIN_FINAL_OPTIONS_DEFINITIVE_EDITION_V2 = -G "$(CMAKE_GENERATOR_TYPE)" -A "$(MSBUILD_PLATFORM)" $(CMAKE_WIN_FINAL_OPTIONS_DEFINITIVE_EDITION) -D CMAKE_TOOLCHAIN_FILE="$(CMAKE_TOOLCHAIN_FILE)"
!ELSE
CMAKE_WIN_FINAL_OPTIONS_DEFINITIVE_EDITION_V2 = -G "$(CMAKE_GENERATOR_TYPE)" $(CMAKE_WIN_FINAL_OPTIONS_DEFINITIVE_EDITION)
!ENDIF
!IFDEF MSBUILD_PLATFORM
!IF "$(CMAKE_GENERATOR_TYPE)" == "Ninja"
CMAKE_BUILD_PARAMETER= --config "$(CMAKE_BUILD_TYPE)"
!ELSE
CMAKE_BUILD_PARAMETER= --config "$(CMAKE_BUILD_TYPE)" -- /p:Platform=$(MSBUILD_PLATFORM)
!ENDIF
!ELSE
CMAKE_BUILD_PARAMETER= --config "$(CMAKE_BUILD_TYPE)"
!ENDIF
!IF "$(MSBUILD_PLATFORM)" == "ARM64"
# todo: we have disabled SIMD for now, but we should enable it for ARM64 when we have a proper solution
CMAKE_WIN_FINAL_OPTIONS_DEFINITIVE_EDITION_V2 = $(CMAKE_WIN_FINAL_OPTIONS_DEFINITIVE_EDITION_V2) -D ENABLE_LIBJPEG_TURBO_SIMD=OFF -D ENABLE_NEON=OFF -D ENABLE_VFPV3=OFF -D WITH_FFMPEG=OFF -D HAVE_FFMPEG=OFF
!ENDIF
!IF "$(EVISION_DO_OPENCV_COMPILE)" == "false"
EVISION_DO_OPENCV_COMPILE=false
!ELSE
EVISION_DO_OPENCV_COMPILE=true
!ENDIF
!IFNDEF EVISION_KEEP_OCV_BUILD_DIR
EVISION_KEEP_OCV_BUILD_DIR="true"
!ENDIF
build: $(EVISION_SO)
download_opencv_contrib:
!IF "$(EVISION_ENABLE_CONTRIB)" == "true"
@ powershell scripts/download_opencv_contrib.ps1 "$(OPENCV_VER)" "$(OPENCV_CACHE_DIR)" "$(OPENCV_ROOT_DIR)"
!ENDIF
$(CONFIGURATION_PRIVATE_HPP): download_opencv_contrib
!IF "$(EVISION_PREFER_PRECOMPILED)" != "true"
@ powershell scripts/download_opencv.ps1 "$(OPENCV_VER)" "$(OPENCV_CACHE_DIR)" "$(OPENCV_ROOT_DIR)"
@ if not exist "$(CONFIGURATION_PRIVATE_HPP)" copy "$(OPENCV_CONFIGURATION_PRIVATE_HPP)" "$(CONFIGURATION_PRIVATE_HPP)"
!ENDIF
$(HEADERS_TXT): $(CONFIGURATION_PRIVATE_HPP)
!IF "$(EVISION_PREFER_PRECOMPILED)" != "true"
@ if not exist "$(CMAKE_OPENCV_BUILD_DIR)" mkdir "$(CMAKE_OPENCV_BUILD_DIR)"
@ if not exist "$(HEADERS_TXT)" if "$(EVISION_DO_OPENCV_COMPILE)" == "true" ( \
python3 "$(PATCHES_DIR)\apply_patch.py" "$(OPENCV_DIR)" "$(OPENCV_VER)" || \
python "$(PATCHES_DIR)\apply_patch.py" "$(OPENCV_DIR)" "$(OPENCV_VER)" \
)
@ if not exist "$(HEADERS_TXT)" if "$(EVISION_DO_OPENCV_COMPILE)" == "true" ( \
cd "$(CMAKE_OPENCV_BUILD_DIR)" && \
cmake -D CMAKE_BUILD_TYPE="$(CMAKE_BUILD_TYPE)" \
-D CMAKE_INSTALL_PREFIX="$(PRIV_DIR)" \
-D PYTHON3_EXECUTABLE="$(PYTHON3_EXECUTABLE)" \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D INSTALL_C_EXAMPLES=OFF \
-D BUILD_EXAMPLES=OFF \
-D BUILD_TESTS=OFF \
-D BUILD_PERF_TESTS=OFF \
-D OPENCV_ENABLE_NONFREE=OFF \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D OPENCV_PC_FILE_NAME=opencv4.pc \
-D BUILD_ZLIB=ON \
-D BUILD_opencv_gapi=OFF \
-D BUILD_opencv_apps=OFF \
$(CMAKE_WIN_FINAL_OPTIONS_DEFINITIVE_EDITION_V2) "$(OPENCV_DIR)" && \
cmake --build . $(CMAKE_BUILD_PARAMETER) \
)
@ if "$(EVISION_DO_OPENCV_COMPILE)" == "true" ( \
if not exist "$(EVISION_SO)" ( \
cd "$(CMAKE_OPENCV_BUILD_DIR)" && cmake --install . --config "$(CMAKE_BUILD_TYPE)" && \
if "$(OPENCV_HEADERS_TXT)" NEQ "$(HEADERS_TXT)" ( \
powershell -command Copy-Item "$(OPENCV_HEADERS_TXT)" -Destination "$(HEADERS_TXT)" -force \
) \
) \
) && \
powershell -command Copy-Item "$(HEADERS_TXT)" -Destination "$(C_SRC_HEADER_TXT)" -force
@ if "$(EVISION_KEEP_OCV_BUILD_DIR)" == "false" ( \
powershell -command Remove-Item "$(CMAKE_OPENCV_BUILD_DIR)" -Recurse -force \
)
!ENDIF
$(C_SRC_HEADER_TXT): $(HEADERS_TXT)
opencv: $(C_SRC_HEADER_TXT)
$(EVISION_SO): opencv
@ if not exist "$(PRIV_DIR)" mkdir "$(PRIV_DIR)"
!IF "$(EVISION_PREFER_PRECOMPILED)" != "true"
@ if not exist "$(CMAKE_EVISION_BUILD_DIR)" mkdir "$(CMAKE_EVISION_BUILD_DIR)"
@ if not exist "$(GENERATED_ELIXIR_SRC_DIR)" mkdir "$(GENERATED_ELIXIR_SRC_DIR)"
@ if not exist "$(GENERATED_ERLANG_SRC_DIR)" mkdir "$(GENERATED_ERLANG_SRC_DIR)"
@ if not exist "$(EVISION_SO)" ( \
cd "$(CMAKE_EVISION_BUILD_DIR)" && \
cmake -G "$(CMAKE_GENERATOR_TYPE)" \
--no-warn-unused-cli \
-D CMAKE_BUILD_TYPE="$(CMAKE_BUILD_TYPE)" \
-D C_SRC="$(C_SRC)" \
-D GENERATED_ELIXIR_SRC_DIR="$(GENERATED_ELIXIR_SRC_DIR)" \
-D GENERATED_ERLANG_SRC_DIR="$(GENERATED_ERLANG_SRC_DIR)" \
-D GENERATED_GELAM_SRC_DIR="$(GENERATED_GELAM_SRC_DIR)" \
-D PY_SRC="$(PY_SRC)" \
-D MIX_APP_PATH="$(MIX_APP_PATH)" \
-D PRIV_DIR="$(PRIV_DIR)" \
-D ERTS_INCLUDE_DIR="$(ERTS_INCLUDE_DIR)" \
-D ENABLED_CV_MODULES=$(ENABLED_CV_MODULES) \
-D EVISION_GENERATE_LANG="$(EVISION_GENERATE_LANG)" \
-D EVISION_ENABLE_CONTRIB="$(EVISION_ENABLE_CONTRIB)" \
-D EVISION_ENABLE_CUDA="$(EVISION_ENABLE_CUDA)" \
-D GLEAM_EVISION="$(GLEAM_EVISION)" \
$(CMAKE_CONFIGURE_FLAGS) "$(MAKEDIR)" && \
cmake --build . $(CMAKE_BUILD_PARAMETER) && \
cmake --install . --config "$(CMAKE_BUILD_TYPE)" \
)
!ENDIF