64 lines
2.3 KiB
Bash
Executable File
64 lines
2.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
INVOCATION_ABS_DIR=`pwd`
|
|
BUILD_TYPE="None"
|
|
CMD_LINE_ARGS=""
|
|
|
|
#-------------------------------------------------------------------
|
|
# Part 1: Check for and handle command-line arguments
|
|
#-------------------------------------------------------------------
|
|
for ARGI; do
|
|
if [ "${ARGI}" = "--help" -o "${ARGI}" = "-h" ] ; then
|
|
printf "%s [SWITCHES] \n" $0
|
|
printf "Switches: \n"
|
|
printf " --help, -h \n"
|
|
printf " --debug, -d \n"
|
|
printf " --release, -r \n"
|
|
printf "Notes: \n"
|
|
printf " (1) All other command line args will be passed as args \n"
|
|
printf " to \"make\" when it is eventually invoked. \n"
|
|
printf " (2) For example -k will continue making when/if a failure \n"
|
|
printf " is encountered in building one of the subdirectories. \n"
|
|
printf " (3) For example -j2 will utilize a 2nd core in the build \n"
|
|
printf " if your machine has two cores. -j4 etc for quad core. \n"
|
|
exit 0;
|
|
elif [ "${ARGI}" = "--debug" -o "${ARGI}" = "-d" ] ; then
|
|
BUILD_TYPE="Debug"
|
|
elif [ "${ARGI}" = "--release" -o "${ARGI}" = "-r" ] ; then
|
|
BUILD_TYPE="Release"
|
|
else
|
|
CMD_LINE_ARGS=$CMD_LINE_ARGS" "$ARGI
|
|
fi
|
|
done
|
|
|
|
#-------------------------------------------------------------------
|
|
# Part 2: Invoke the call to make in the build directory
|
|
#-------------------------------------------------------------------
|
|
|
|
mkdir -p build
|
|
cd build
|
|
|
|
# 修复: PATH 中包含了 Windows Anaconda(/mnt/d/Software/Anaconda),
|
|
# 其下的 GTest 是 Windows .lib, 无法被 Linux 链接器使用。
|
|
# 因此显式指定 Linux 平台的 GTest 配置, 覆盖 CMake 从 PATH 探测到的不正确路径。
|
|
CMAKE_ARGS="-DCMAKE_BUILD_TYPE=${BUILD_TYPE}"
|
|
if [ -z "${GTest_DIR}" ]; then
|
|
for GTEST_CONFIG in \
|
|
/usr/lib/x86_64-linux-gnu/cmake/GTest/GTestConfig.cmake \
|
|
/usr/lib/cmake/GTest/GTestConfig.cmake \
|
|
/usr/local/lib/cmake/GTest/GTestConfig.cmake \
|
|
"${HOME}/miniconda/lib/cmake/GTest/GTestConfig.cmake"; do
|
|
if [ -f "${GTEST_CONFIG}" ]; then
|
|
CMAKE_ARGS="${CMAKE_ARGS} -DGTest_DIR=$(dirname "${GTEST_CONFIG}")"
|
|
break
|
|
fi
|
|
done
|
|
fi
|
|
|
|
cmake ${CMAKE_ARGS} ../
|
|
|
|
make ${CMD_LINE_ARGS}
|
|
cd ${INVOCATION_ABS_DIR}
|
|
|
|
|