feat: cmake build on ubuntu

This commit is contained in:
冉坤 2022-01-05 15:14:19 +08:00
parent 459f70afe7
commit 3561af0058
2 changed files with 17 additions and 24 deletions

View file

@ -47,4 +47,4 @@ jobs:
ENV_QT_PATH: ${{ env.qt-install-path }}
run: |
python ci/generate-version.py
ci/linux/build_for_ubuntu.sh release
ci/linux/build_for_ubuntu.sh RelWithDebInfo

View file

@ -8,7 +8,7 @@ echo ---------------------------------------------------------------
# 从环境变量获取必要参数
# 例如 /home/barry/Qt5.9.6/5.9.6
echo ENV_QT_PATH $ENV_QT_PATH
qt_gcc_path=$ENV_QT_PATH/gcc_64
qt_cmake_path=$ENV_QT_PATH/gcc_64/lib/cmake/Qt5
# 获取绝对路径,保证其他目录执行此脚本依然正确
{
@ -21,17 +21,17 @@ old_cd=$(pwd)
cd $(dirname "$0")
# 启动参数声明
build_mode=debug
build_mode=RelWithDebInfo
echo
echo
echo ---------------------------------------------------------------
echo check build param[debug/release]
echo check build param[Debug/Release/MinSizeRel/RelWithDebInfo]
echo ---------------------------------------------------------------
# 编译参数检查
build_mode=$(echo $1 | tr '[:upper:]' '[:lower:]')
if [[ $build_mode != "release" && $build_mode != "debug" ]]; then
if [[ $build_mode != "Release" && $build_mode != "Debug" && $build_mode != "MinSizeRel" && $build_mode != "RelWithDebInfo" ]]; then
echo "error: unkonow build mode -- $1"
exit 1
fi
@ -40,7 +40,7 @@ fi
echo current build mode: $build_mode
# 环境变量设置
export PATH=$qt_gcc_path/bin:$PATH
#export PATH=$qt_gcc_path/bin:$PATH
echo
echo
@ -49,35 +49,28 @@ echo begin qmake build
echo ---------------------------------------------------------------
# 删除输出目录
output_path=$script_path../../output/linux/$build_mode
output_path=$script_path../../output
if [ -d "$output_path" ]; then
rm -rf $output_path
fi
# 删除临时目录
temp_path=$script_path/../temp
if [ -d "$temp_path" ]; then
rm -rf $temp_path
build_path=$script_path/../build_temp
if [ -d "$build_path" ]; then
rm -rf $build_path
fi
mkdir $temp_path
cd $temp_path
mkdir $build_path
cd $build_path
qmake_params="-spec linux-g++"
if [ $build_mode == "debug" ]; then
qmake_params="$qmake_params CONFIG+=debug CONFIG+=x86_64 CONFIG+=qml_debug"
else
qmake_params="$qmake_params CONFIG+=x86_64 CONFIG+=qtquickcompiler"
fi
# qmake ../../all.pro -spec linux-g++ CONFIG+=debug CONFIG+=x86_64 CONFIG+=qml_debug
qmake ../../all.pro $qmake_params
cmake_params="-DCMAKE_PREFIX_PATH=$qt_cmake_path -DCMAKE_BUILD_TYPE=$build_mode"
cmake $cmake_params ../..
if [ $? -ne 0 ] ;then
echo "qmake failed"
echo "cmake failed"
exit 1
fi
make -j8
cmake --build . --config $build_mode -j8
if [ $? -ne 0 ] ;then
echo "make failed"
echo "cmake build failed"
exit 1
fi