Проба создания правил для работы с отладочной информацией

This commit is contained in:
Andrei Astafev 2020-04-25 17:35:24 +03:00
parent 2ea38c32c8
commit 4821f16044
3 changed files with 23 additions and 0 deletions

View File

@ -30,6 +30,7 @@ include(CMLibCompilerFeaturesHPPGenerate)
include(CMLibFlagRemove) include(CMLibFlagRemove)
include(CMLibCotire) include(CMLibCotire)
include(CMLibBuildTypes) include(CMLibBuildTypes)
include(CMLibDebugOutput)
include(CMLibCommonTargetProperties) include(CMLibCommonTargetProperties)
include(CMLibCommonLibraryTarget) include(CMLibCommonLibraryTarget)
include(CMLibPkgConfig) include(CMLibPkgConfig)

View File

@ -37,6 +37,15 @@ function(common_target_properties target)
if(_targetType STREQUAL "EXECUTABLE") if(_targetType STREQUAL "EXECUTABLE")
target_compile_options(${target} PUBLIC "${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") target_compile_options(${target} PUBLIC "${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
endif() 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() endif()
if(CMAKE_CXX_COMPILER_IS_GCC AND NOT APPLE) if(CMAKE_CXX_COMPILER_IS_GCC AND NOT APPLE)
set_target_properties(${target} PROPERTIES LINK_FLAGS "-Wl,--no-as-needed") set_target_properties(${target} PROPERTIES LINK_FLAGS "-Wl,--no-as-needed")

13
CMLibDebugOutput.cmake Normal file
View File

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