From 21345d6b9ed8c9f8761dd422b5e4b95e73f8cf7a Mon Sep 17 00:00:00 2001 From: Megvii Engine Team Date: Fri, 10 Dec 2021 16:10:21 +0800 Subject: [PATCH] fix(cmake): only add -Werror=unused-parameter at CI env GitOrigin-RevId: 380f7f6ce9129ecf63f3cb0e92fdd6628fa4d07b --- scripts/cmake-build/cross_build_linux_arm_inference.sh | 10 ---------- toolchains/aarch64-linux-gnu.toolchain.cmake | 4 ++++ toolchains/aarch64-none-linux-gnu.toolchain.cmake | 8 ++++++-- toolchains/arm-linux-gnueabi.toolchain.cmake | 8 ++++++-- toolchains/arm-linux-gnueabihf.toolchain.cmake | 8 ++++++-- 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/scripts/cmake-build/cross_build_linux_arm_inference.sh b/scripts/cmake-build/cross_build_linux_arm_inference.sh index b0832df9f..c1008db1b 100755 --- a/scripts/cmake-build/cross_build_linux_arm_inference.sh +++ b/scripts/cmake-build/cross_build_linux_arm_inference.sh @@ -11,8 +11,6 @@ REMOVE_OLD_BUILD=false NINJA_VERBOSE=OFF NINJA_DRY_RUN=OFF SPECIFIED_TARGET="install/strip" -CMAKE_C_FLAGS="-Wno-psabi" -CMAKE_CXX_FLAGS="-Wno-psabi" READLINK=readlink OS=$(uname -s) @@ -140,12 +138,6 @@ if [ $MGE_WITH_CUDA = "ON" ] && [ ! $ARCH = "arm64-v8a" ];then exit -1 fi -if [ $MGE_WITH_CUDA = "OFF" ];then - echo "config -Werror=unused-parameter when cuda off for CI check" - CMAKE_C_FLAGS="-Werror=unused-parameter -Wno-psabi" - CMAKE_CXX_FLAGS="-Werror=unused-parameter -Wno-psabi" -fi - function cmake_build() { BUILD_DIR=$SRC_DIR/build_dir/gnu-linux/MGE_WITH_CUDA_$3/$1/$BUILD_TYPE/build INSTALL_DIR=$BUILD_DIR/../install @@ -163,8 +155,6 @@ function cmake_build() { mkdir -p $INSTALL_DIR cd_real_build_dir $BUILD_DIR bash -c "cmake -G Ninja \ - -DCMAKE_C_FLAGS=$CMAKE_C_FLAGS \ - -DCMAKE_CXX_FLAGS=$CMAKE_CXX_FLAGS \ -DCMAKE_TOOLCHAIN_FILE=$TOOLCHAIN \ -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ -DMGE_INFERENCE_ONLY=ON \ diff --git a/toolchains/aarch64-linux-gnu.toolchain.cmake b/toolchains/aarch64-linux-gnu.toolchain.cmake index dddd00917..525817b37 100644 --- a/toolchains/aarch64-linux-gnu.toolchain.cmake +++ b/toolchains/aarch64-linux-gnu.toolchain.cmake @@ -1,6 +1,10 @@ set(ARM_CROSS_BUILD_ARCH aarch64) set(CMAKE_C_COMPILER "aarch64-linux-gnu-gcc") set(CMAKE_CXX_COMPILER "aarch64-linux-gnu-g++") +if("$ENV{FORCE_CHECK_UNUSED_PARAMETER}" STREQUAL "true") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=unused-parameter") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=unused-parameter") +endif() set(CMAKE_STRIP "aarch64-linux-gnu-strip") set(CMAKE_SYSTEM_PROCESSOR aarch64) set(CMAKE_SYSTEM_NAME Linux) diff --git a/toolchains/aarch64-none-linux-gnu.toolchain.cmake b/toolchains/aarch64-none-linux-gnu.toolchain.cmake index 6e387ac1a..e16d3766f 100644 --- a/toolchains/aarch64-none-linux-gnu.toolchain.cmake +++ b/toolchains/aarch64-none-linux-gnu.toolchain.cmake @@ -1,8 +1,12 @@ set(ARM_CROSS_BUILD_ARCH aarch64) set(CMAKE_C_COMPILER "aarch64-none-linux-gnu-gcc") set(CMAKE_CXX_COMPILER "aarch64-none-linux-gnu-g++") -set(CMAKE_C_FLAGS "-Werror=unused-parameter -Wno-psabi") -set(CMAKE_CXX_FLAGS "-Werror=unused-parameter -Wno-psabi") +set(CMAKE_C_FLAGS "-Wno-psabi") +set(CMAKE_CXX_FLAGS "-Wno-psabi") +if("$ENV{FORCE_CHECK_UNUSED_PARAMETER}" STREQUAL "true") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=unused-parameter") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=unused-parameter") +endif() set(CMAKE_STRIP "aarch64-none-linux-gnu-strip") set(CMAKE_SYSTEM_PROCESSOR aarch64) set(CMAKE_SYSTEM_NAME Linux) diff --git a/toolchains/arm-linux-gnueabi.toolchain.cmake b/toolchains/arm-linux-gnueabi.toolchain.cmake index b80c35a40..471b78068 100644 --- a/toolchains/arm-linux-gnueabi.toolchain.cmake +++ b/toolchains/arm-linux-gnueabi.toolchain.cmake @@ -1,8 +1,12 @@ set(ARM_CROSS_BUILD_ARCH armv7) set(CMAKE_C_COMPILER "arm-linux-gnueabi-gcc") set(CMAKE_CXX_COMPILER "arm-linux-gnueabi-g++") -set(CMAKE_C_FLAGS "-mfloat-abi=softfp -mfpu=neon-vfpv4 -Werror=unused-parameter -Wno-psabi") -set(CMAKE_CXX_FLAGS "-mfloat-abi=softfp -mfpu=neon-vfpv4 -Werror=unused-parameter -Wno-psabi") +set(CMAKE_C_FLAGS "-mfloat-abi=softfp -mfpu=neon-vfpv4 -Wno-psabi") +set(CMAKE_CXX_FLAGS "-mfloat-abi=softfp -mfpu=neon-vfpv4 -Wno-psabi") +if("$ENV{FORCE_CHECK_UNUSED_PARAMETER}" STREQUAL "true") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=unused-parameter") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=unused-parameter") +endif() set(CMAKE_STRIP "arm-linux-gnueabi-strip") set(CMAKE_SYSTEM_PROCESSOR armv7) set(CMAKE_SYSTEM_NAME Linux) diff --git a/toolchains/arm-linux-gnueabihf.toolchain.cmake b/toolchains/arm-linux-gnueabihf.toolchain.cmake index deff624ac..b9e36412f 100644 --- a/toolchains/arm-linux-gnueabihf.toolchain.cmake +++ b/toolchains/arm-linux-gnueabihf.toolchain.cmake @@ -1,8 +1,12 @@ set(ARM_CROSS_BUILD_ARCH armv7) set(CMAKE_C_COMPILER "arm-linux-gnueabihf-gcc") set(CMAKE_CXX_COMPILER "arm-linux-gnueabihf-g++") -set(CMAKE_C_FLAGS "-mfloat-abi=hard -mfpu=neon-vfpv4 -Werror=unused-parameter -Wno-psabi") -set(CMAKE_CXX_FLAGS "-mfloat-abi=hard -mfpu=neon-vfpv4 -Werror=unused-parameter -Wno-psabi") +set(CMAKE_C_FLAGS "-mfloat-abi=hard -mfpu=neon-vfpv4 -Wno-psabi") +set(CMAKE_CXX_FLAGS "-mfloat-abi=hard -mfpu=neon-vfpv4 -Wno-psabi") +if("$ENV{FORCE_CHECK_UNUSED_PARAMETER}" STREQUAL "true") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=unused-parameter") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=unused-parameter") +endif() set(CMAKE_STRIP "arm-linux-gnueabihf-strip") set(CMAKE_SYSTEM_PROCESSOR armv7) set(CMAKE_SYSTEM_NAME Linux) -- GitLab