From b98f09fcbfc5f2309b64d63d613fe3516a15ac1a Mon Sep 17 00:00:00 2001 From: kevg Date: Sun, 20 Nov 2016 22:17:35 +0300 Subject: [PATCH] Scripts: Three modes of warning printing. WARN_MODE=early print warnings at compilation stage WARN_MODE=late print warnings at build finish stage WARN_MODE=both print both at early and at later stages --- BUILD/capture_warnings.sh | 8 +++++--- cmake/print_warnings.cmake | 18 ++++++++++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/BUILD/capture_warnings.sh b/BUILD/capture_warnings.sh index c101493a09e..c469d2f1991 100755 --- a/BUILD/capture_warnings.sh +++ b/BUILD/capture_warnings.sh @@ -1,7 +1,8 @@ #!/bin/bash - warn_path=$1 -shift +warn_mode=$2 +shift 2 + warn_file="$warn_path/compile.warnings" suppress_file="$warn_path/suppress.warnings" @@ -10,7 +11,8 @@ cmderr=$("$@" 2>&1 1>&3) error=$? if [[ -n "$cmderr" ]]; then - echo "$cmderr" >&2 + [[ "$warn_mode" == "both" ]] && + echo "$cmderr" >&2 [[ "$cmderr" =~ warning:(.+)$ ]] && echo -n "$cmderr" >> "$warn_file" fi diff --git a/cmake/print_warnings.cmake b/cmake/print_warnings.cmake index a697e1bd11f..ea61085b5cc 100644 --- a/cmake/print_warnings.cmake +++ b/cmake/print_warnings.cmake @@ -1,6 +1,20 @@ -IF (NOT DEFINED WITHOUT_REPRINT AND CMAKE_BUILD_TYPE MATCHES "Debug") +IF(NOT DEFINED WARN_MODE) + IF(CMAKE_BUILD_TYPE MATCHES "Debug") + SET(WARN_MODE "late") + ELSE() + SET(WARN_MODE "early") + ENDIF() +ENDIF() + +IF(NOT WARN_MODE STREQUAL "early" AND + NOT WARN_MODE STREQUAL "late" AND + NOT WARN_MODE STREQUAL "both") + MESSAGE(FATAL_ERROR "Unknown WARN_MODE: expected 'early', 'late' or 'both'") +ENDIF() + +IF(NOT WARN_MODE MATCHES "early") SET_DIRECTORY_PROPERTIES(PROPERTIES RULE_LAUNCH_COMPILE - "bash ${CMAKE_SOURCE_DIR}/BUILD/capture_warnings.sh ${CMAKE_BINARY_DIR}") + "bash ${CMAKE_SOURCE_DIR}/BUILD/capture_warnings.sh ${CMAKE_BINARY_DIR} ${WARN_MODE}") SET_DIRECTORY_PROPERTIES(PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_BINARY_DIR}/compile.warnings") ADD_CUSTOM_TARGET(rm_compile.warnings ALL