From af80d365be99d075bee35623c86deace69386871 Mon Sep 17 00:00:00 2001 From: Megvii Engine Team Date: Tue, 14 Sep 2021 11:18:59 +0800 Subject: [PATCH] fix(cmake/windows): fix cmake install failed on Windows GitOrigin-RevId: 2c6ba34dbd92c2def2b20a84f9f247db68852aa9 --- scripts/cmake-build/host_build.sh | 10 ++++++---- scripts/cmake-build/utils/utils.sh | 10 +++++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/scripts/cmake-build/host_build.sh b/scripts/cmake-build/host_build.sh index 6d4e12a6a..f63d8c695 100755 --- a/scripts/cmake-build/host_build.sh +++ b/scripts/cmake-build/host_build.sh @@ -33,8 +33,8 @@ BUILD_DEVELOP=ON NINJA_DRY_RUN=OFF SPECIFIED_TARGET="install/strip" if [[ $OS =~ "NT" ]]; then - echo "Windows do not support strip/install by defaut" - SPECIFIED_TARGET="" + echo "Windows no need strip, caused by pdb file always split with exe" + SPECIFIED_TARGET="install" fi echo "EXTRA_CMAKE_ARGS: ${EXTRA_CMAKE_ARGS}" @@ -248,7 +248,10 @@ function cmake_build_windows() { # windows do not support long path, so we cache the BUILD_DIR ASAP prepare_env_for_windows_build BUILD_DIR=$SRC_DIR/build_dir/host/build - INSTALL_DIR=$BUILD_DIR/../install + # ninja have compat issue with bash env, which fork from windows-git + # which will map C: to /c/c/ dir, which will lead to install file to /c/c/.. + # as a solution, we use relative path to INSTALL_DIR + INSTALL_DIR=../install MGE_WITH_CUDA=$1 MGE_INFERENCE_ONLY=$2 BUILD_TYPE=$3 @@ -261,7 +264,6 @@ function cmake_build_windows() { echo "create build dir" mkdir -p $BUILD_DIR - mkdir -p $INSTALL_DIR cd_real_build_dir $BUILD_DIR echo "now try build windows native with cmake/clang-ci/Ninja/Visual Studio ....." export CFLAGS=-$MGE_WINDOWS_BUILD_MARCH diff --git a/scripts/cmake-build/utils/utils.sh b/scripts/cmake-build/utils/utils.sh index e6977b098..40d2b0a8c 100755 --- a/scripts/cmake-build/utils/utils.sh +++ b/scripts/cmake-build/utils/utils.sh @@ -61,8 +61,16 @@ function try_remove_old_build() { if [ $REMOVE_OLD_BUILD = "true" ]; then echo "remove old build/install dir" - rm -rf ${BUILD_DIR} rm -rf ${INSTALL_DIR} + + # compat install is relative path for BUILD_DIR + if [ -d ${BUILD_DIR} ]; then + cd ${BUILD_DIR} + rm -rf ${INSTALL_DIR} + cd - + fi + + rm -rf ${BUILD_DIR} else echo "strip remove old build" fi -- GitLab