2019-02-19 21:18:08 +08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2019-03-29 16:15:55 +08:00
|
|
|
number_of_build_workers=8
|
2021-01-22 00:36:00 +08:00
|
|
|
use_vcpkg=false
|
2019-07-23 21:59:02 +08:00
|
|
|
force_cpp_build=false
|
2021-01-22 00:36:00 +08:00
|
|
|
enable_cuda=false
|
2019-03-29 16:15:55 +08:00
|
|
|
|
2019-03-04 22:15:19 +08:00
|
|
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
2019-04-17 20:19:58 +08:00
|
|
|
vcpkg_triplet="x64-osx"
|
2019-04-09 15:06:58 +08:00
|
|
|
else
|
|
|
|
vcpkg_triplet="x64-linux"
|
2019-03-04 22:15:19 +08:00
|
|
|
fi
|
|
|
|
|
2021-01-22 00:36:00 +08:00
|
|
|
if [[ ! -z "${VCPKG_ROOT}" ]] && [ -d ${VCPKG_ROOT} ] && [ "$use_vcpkg" = true ]
|
2019-04-09 15:06:58 +08:00
|
|
|
then
|
|
|
|
vcpkg_path="${VCPKG_ROOT}"
|
|
|
|
vcpkg_triplet_define="-DVCPKG_TARGET_TRIPLET=$vcpkg_triplet"
|
|
|
|
echo "Found vcpkg in VCPKG_ROOT: ${vcpkg_path}"
|
2019-08-24 19:46:45 +08:00
|
|
|
additional_defines="-DBUILD_SHARED_LIBS=OFF"
|
2021-01-22 00:36:00 +08:00
|
|
|
elif [[ ! -z "${WORKSPACE}" ]] && [ -d ${WORKSPACE}/vcpkg ] && [ "$use_vcpkg" = true ]
|
2019-04-09 15:06:58 +08:00
|
|
|
then
|
2021-01-22 00:36:00 +08:00
|
|
|
export VCPKG_ROOT="${WORKSPACE}/vcpkg"
|
2019-04-09 15:06:58 +08:00
|
|
|
vcpkg_path="${WORKSPACE}/vcpkg"
|
|
|
|
vcpkg_triplet_define="-DVCPKG_TARGET_TRIPLET=$vcpkg_triplet"
|
|
|
|
echo "Found vcpkg in WORKSPACE/vcpkg: ${vcpkg_path}"
|
2019-08-24 19:46:45 +08:00
|
|
|
additional_defines="-DBUILD_SHARED_LIBS=OFF"
|
2021-01-22 00:36:00 +08:00
|
|
|
elif [ "$use_vcpkg" = true ]
|
2019-04-09 15:06:58 +08:00
|
|
|
then
|
|
|
|
(>&2 echo "darknet is unsupported without vcpkg, use at your own risk!")
|
2021-01-22 00:36:00 +08:00
|
|
|
else
|
|
|
|
additional_build_setup=${additional_build_setup}" -DENABLE_VCPKG_INTEGRATION:BOOL=FALSE"
|
2019-04-09 15:06:58 +08:00
|
|
|
fi
|
|
|
|
|
2019-07-23 21:59:02 +08:00
|
|
|
if [ "$force_cpp_build" = true ]
|
|
|
|
then
|
2021-01-22 00:36:00 +08:00
|
|
|
additional_build_setup=${additional_build_setup}" -DBUILD_AS_CPP:BOOL=TRUE"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$enable_cuda" = false ]
|
|
|
|
then
|
|
|
|
additional_build_setup=${additional_build_setup}" -DENABLE_CUDA:BOOL=FALSE"
|
2019-07-23 21:59:02 +08:00
|
|
|
fi
|
|
|
|
|
2019-04-11 00:20:55 +08:00
|
|
|
## DEBUG
|
|
|
|
#mkdir -p build_debug
|
|
|
|
#cd build_debug
|
|
|
|
#cmake .. -DCMAKE_BUILD_TYPE=Debug ${vcpkg_define} ${vcpkg_triplet_define} ${additional_defines} ${additional_build_setup}
|
2021-01-22 00:36:00 +08:00
|
|
|
#cmake --build . --target install --parallel ${number_of_build_workers}
|
2019-04-11 00:20:55 +08:00
|
|
|
#rm -f DarknetConfig.cmake
|
|
|
|
#rm -f DarknetConfigVersion.cmake
|
|
|
|
#cd ..
|
|
|
|
#cp cmake/Modules/*.cmake share/darknet/
|
|
|
|
|
2019-02-20 18:42:53 +08:00
|
|
|
# RELEASE
|
2019-02-19 21:18:08 +08:00
|
|
|
mkdir -p build_release
|
|
|
|
cd build_release
|
2019-04-09 15:06:58 +08:00
|
|
|
cmake .. -DCMAKE_BUILD_TYPE=Release ${vcpkg_define} ${vcpkg_triplet_define} ${additional_defines} ${additional_build_setup}
|
2021-01-22 00:36:00 +08:00
|
|
|
cmake --build . --target install --parallel ${number_of_build_workers}
|
2019-03-14 05:56:44 +08:00
|
|
|
rm -f DarknetConfig.cmake
|
|
|
|
rm -f DarknetConfigVersion.cmake
|
2019-02-19 21:18:08 +08:00
|
|
|
cd ..
|
2019-04-10 16:51:54 +08:00
|
|
|
cp cmake/Modules/*.cmake share/darknet/
|