-
Notifications
You must be signed in to change notification settings - Fork 3
99 Customize your build script
MaverickTse edited this page Oct 28, 2015
·
1 revision
- Add your own build script
Take any bld_*.sh
as reference. Each bld_*.sh
builds a single package (or with dependencies).
A typical Git repo with Cmake build system looks like:
if [ ! -d ~/opencv ]; then
git clone --recursive https://github.com/Itseez/opencv.git #DL the repo source if not done yet
else
cd opencv
git pull
fi
cd ~
if [ ! -d ~/ocvcontrib ]; then
git clone --recursive https://github.com/Itseez/opencv_contrib.git ocvcontrib #DL dependencies
else
cd ocvcontrib
git pull # update before ./configure or make or cmake
fi
cd ~
if [ ! -d ~/ocv32d ]; then
mkdir ~/ocv32d
fi
cd ~/ocv32d
if [ -f Makefile ]; then
make clean
fi
cd ~/opencv
cp ~/patches/mingw-w64-opencv/*.patch ./ #applies patch if necessary. The MSYS2 PKGBUILD files can be used as reference
patch -Np1 -i "mingw-w64-cmake.patch"
patch -Np1 -i "solve_deg3-underflow.patch"
#patch -Np1 -i "issue-4107.patch" # note that some patches in MSYS2 repo is outdated
#4107 should have been fixed in master branch
patch -Np1 -i "remove-bindings-generation-DetectionBasedTracker.patch"
patch -Np1 -i "generate-proper-pkg-config-file.patch"
patch -Np1 -i "opencv-support-python-3.5.patch"
cd ~/ocv32d # go into the output directory
PATH=${PATH}:${CUDA_PATH} # adjust PATH, PKG_CONFIG_PATH if necessary
cmake \
-G"MSYS Makefiles" \ # Must be MSYS Makefiles. Others will not work
-DCMAKE_C_FLAGS=" -m32 -DSTRSAFE_NO_DEPRECATE " \
-DCMAKE_CXX_FLAGS=" -m32 -DSTRSAFE_NO_DEPRECATE " \
-DCMAKE_EXE_LINKER_FLAGS=" -m32" \ # For 32-bit builds, the -m32 switch is required for TDM
-DCMAKE_BUILD_TYPE=Debug \ #Debug build or Release
-DPKG_CONFIG_WITHOUT_PREFIX=ON \
-DBUILD_SHARED_LIBS=ON \ #There can be subtle difference in meaning among packages. Check documentation.
-DWITH_CUDA=OFF \ # Mingw-w64 cannot build CUDA stuff
-DWITH_VTK=OFF \
-DWITH_GTK=OFF \
-DWITH_OPENCL=ON \
-DWITH_OPENGL=ON \
-DCMAKE_SKIP_RPATH=ON \
-DENABLE_PRECOMPILED_HEADERS=OFF \
-DCPACK_BINARY_7Z=ON \
-DCPACK_BINARY_NSIS=OFF \
-DOPENCV_EXTRA_MODULES_PATH=../ocvcontrib/modules \
-DBUILD_opencv_text=OFF \
-Wno-dev \
~/opencv \ #The source directory, where you git cloned to
make -j$(nproc) && make package # nproc returns the max available threads on your system. To disable parallel build, remove the whole -j switch.