feat: cmake build on ubuntu

This commit is contained in:
冉坤 2022-01-05 15:14:19 +08:00
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 }} ENV_QT_PATH: ${{ env.qt-install-path }}
run: | run: |
python ci/generate-version.py 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 # 例如 /home/barry/Qt5.9.6/5.9.6
echo ENV_QT_PATH $ENV_QT_PATH 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") cd $(dirname "$0")
# 启动参数声明 # 启动参数声明
build_mode=debug build_mode=RelWithDebInfo
echo echo
echo echo
echo --------------------------------------------------------------- echo ---------------------------------------------------------------
echo check build param[debug/release] echo check build param[Debug/Release/MinSizeRel/RelWithDebInfo]
echo --------------------------------------------------------------- echo ---------------------------------------------------------------
# 编译参数检查 # 编译参数检查
build_mode=$(echo $1 | tr '[:upper:]' '[:lower:]') 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" echo "error: unkonow build mode -- $1"
exit 1 exit 1
fi fi
@ -40,7 +40,7 @@ fi
echo current build mode: $build_mode echo current build mode: $build_mode
# 环境变量设置 # 环境变量设置
export PATH=$qt_gcc_path/bin:$PATH #export PATH=$qt_gcc_path/bin:$PATH
echo echo
echo echo
@ -49,35 +49,28 @@ echo begin qmake build
echo --------------------------------------------------------------- echo ---------------------------------------------------------------
# 删除输出目录 # 删除输出目录
output_path=$script_path../../output/linux/$build_mode output_path=$script_path../../output
if [ -d "$output_path" ]; then if [ -d "$output_path" ]; then
rm -rf $output_path rm -rf $output_path
fi fi
# 删除临时目录 # 删除临时目录
temp_path=$script_path/../temp build_path=$script_path/../build_temp
if [ -d "$temp_path" ]; then if [ -d "$build_path" ]; then
rm -rf $temp_path rm -rf $build_path
fi fi
mkdir $temp_path mkdir $build_path
cd $temp_path cd $build_path
qmake_params="-spec linux-g++" cmake_params="-DCMAKE_PREFIX_PATH=$qt_cmake_path -DCMAKE_BUILD_TYPE=$build_mode"
if [ $build_mode == "debug" ]; then cmake $cmake_params ../..
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
if [ $? -ne 0 ] ;then if [ $? -ne 0 ] ;then
echo "qmake failed" echo "cmake failed"
exit 1 exit 1
fi fi
make -j8 cmake --build . --config $build_mode -j8
if [ $? -ne 0 ] ;then if [ $? -ne 0 ] ;then
echo "make failed" echo "cmake build failed"
exit 1 exit 1
fi fi