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()