From 4821f16044529669c9b7ced22a0c3de0a07a17ad Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Sat, 25 Apr 2020 17:35:24 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B1=D0=B0=20=D1=81=D0=BE?= =?UTF-8?q?=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=B4=D0=BB=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D1=8B=20=D1=81=20=D0=BE=D1=82=D0=BB=D0=B0=D0=B4=D0=BE?= =?UTF-8?q?=D1=87=D0=BD=D0=BE=D0=B9=20=D0=B8=D0=BD=D1=84=D0=BE=D1=80=D0=BC?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMLibCommon.cmake | 1 + CMLibCommonTargetProperties.cmake | 9 +++++++++ CMLibDebugOutput.cmake | 13 +++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 CMLibDebugOutput.cmake diff --git a/CMLibCommon.cmake b/CMLibCommon.cmake index 4b2c50f..8e5ec18 100644 --- a/CMLibCommon.cmake +++ b/CMLibCommon.cmake @@ -30,6 +30,7 @@ include(CMLibCompilerFeaturesHPPGenerate) include(CMLibFlagRemove) include(CMLibCotire) include(CMLibBuildTypes) +include(CMLibDebugOutput) include(CMLibCommonTargetProperties) include(CMLibCommonLibraryTarget) include(CMLibPkgConfig) diff --git a/CMLibCommonTargetProperties.cmake b/CMLibCommonTargetProperties.cmake index e87e100..a77b987 100644 --- a/CMLibCommonTargetProperties.cmake +++ b/CMLibCommonTargetProperties.cmake @@ -37,6 +37,15 @@ function(common_target_properties target) if(_targetType STREQUAL "EXECUTABLE") target_compile_options(${target} PUBLIC "${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") endif() + if(NOT CMLIB_DEBUG_OUTPUT) + add_definitions(-DQT_NO_DEBUG_OUTPUT) + endif() + if(NOT CMLIB_INFO_OUTPUT) + add_definitions(-DQT_NO_INFO_OUTPUT) + endif() + if(NOT CMLIB_WARNING_OUTPUT) + add_definitions(-DQT_NO_WARNING_OUTPUT) + endif() endif() if(CMAKE_CXX_COMPILER_IS_GCC AND NOT APPLE) set_target_properties(${target} PROPERTIES LINK_FLAGS "-Wl,--no-as-needed") diff --git a/CMLibDebugOutput.cmake b/CMLibDebugOutput.cmake new file mode 100644 index 0000000..acaed72 --- /dev/null +++ b/CMLibDebugOutput.cmake @@ -0,0 +1,13 @@ +# По умолчанию отключена отладочная печать +# (если не включена явно программистом) +option(CMLIB_DEBUG_OUTPUT "Enable debug output" OFF) +option(CMLIB_INFO_OUTPUT "Enable info output" OFF) +option(CMLIB_WARNING_OUTPUT "Enable warning output" OFF) + +# Если сборка производится в режиме для отладки, +# то включаются флаги для разрешения отладочной печати +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(CMLIB_DEBUG_OUTPUT ON CACHE BOOL "" FORCE) + set(CMLIB_INFO_OUTPUT ON CACHE BOOL "" FORCE) + set(CMLIB_WARNING_OUTPUT ON CACHE BOOL "" FORCE) +endif()