forked from qt-creator/qt-creator
Add option to build QtCreator with sanitizer
Fixes: QTCREATORBUG-26318 Change-Id: I44589b5bb39958eda2329b444e4857e8f61823bf Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
committed by
Cristian Adam
parent
9e8b838080
commit
efdaeaba43
@@ -33,6 +33,10 @@ option(WITH_TESTS "Build Tests" OFF)
|
||||
add_feature_info("Build tests" ${WITH_TESTS} "")
|
||||
option(WITH_DEBUG_CMAKE "Enabled CMake project debugging functionality (e.g. source file disk checking)" OFF)
|
||||
option(SHOW_BUILD_DATE "Show build date in about dialog" OFF)
|
||||
option(WITH_SANITIZE "Build with sanitizer enabled" OFF)
|
||||
set(SANITIZE_FLAGS "" CACHE STRING "Sets flags for sanitizer compilation flags used in Debug builds")
|
||||
add_feature_info("Build with sanitize" ${WITH_SANITIZE} "SANITIZE_FLAGS='${SANITIZE_FLAGS}'")
|
||||
|
||||
|
||||
# merge binary directories of sub projects into top level
|
||||
set(QTC_MERGE_BINARY_DIR ON)
|
||||
|
@@ -299,6 +299,10 @@ function(add_qtc_library name)
|
||||
|
||||
qtc_enable_separate_debug_info(${name} "${IDE_LIBRARY_PATH}")
|
||||
|
||||
if (WITH_SANITIZE)
|
||||
qtc_enable_sanitize(${SANITIZE_FLAGS})
|
||||
endif()
|
||||
|
||||
if (NAMELINK_OPTION)
|
||||
install(TARGETS ${name}
|
||||
LIBRARY
|
||||
@@ -457,6 +461,10 @@ function(add_qtc_plugin target_name)
|
||||
set(TEST_DEFINES WITH_TESTS SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
endif()
|
||||
|
||||
if (WITH_SANITIZE)
|
||||
qtc_enable_sanitize(${SANITIZE_FLAGS})
|
||||
endif()
|
||||
|
||||
extend_qtc_target(${target_name}
|
||||
INCLUDES ${_arg_INCLUDES}
|
||||
PUBLIC_INCLUDES ${_arg_PUBLIC_INCLUDES}
|
||||
|
@@ -154,6 +154,13 @@ function(qtc_enable_release_for_debug_configuration)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(qtc_enable_sanitize _sanitize_flags)
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=${_sanitize_flags}")
|
||||
endif()
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(append_extra_translations target_name)
|
||||
if(NOT ARGN)
|
||||
return()
|
||||
|
@@ -109,6 +109,9 @@ def get_arguments():
|
||||
parser.add_argument('--zip-threads', help='Sets number of threads to use for 7z. Use "+" for turning threads on '
|
||||
'without a specific number of threads. This is directly passed to the "-mmt" option of 7z.',
|
||||
default='2')
|
||||
parser.add_argument('--add-sanitize-flags', help="Sets flags for sanitizer compilation flags used in Debug builds",
|
||||
action='append', dest='sanitize_flags', default=[] )
|
||||
|
||||
args = parser.parse_args()
|
||||
args.with_debug_info = args.build_type == 'RelWithDebInfo'
|
||||
|
||||
@@ -185,6 +188,10 @@ def build_qtcreator(args, paths):
|
||||
'-DIDE_REVISION_STR=' + ide_revision[:10],
|
||||
'-DIDE_REVISION_URL=https://code.qt.io/cgit/qt-creator/qt-creator.git/log/?id=' + ide_revision]
|
||||
|
||||
if not args.build_type.lower() == 'release' and args.sanitize_flags:
|
||||
cmake_args += ['-DWITH_SANITIZE=ON',
|
||||
'-DSANITIZE_FLAGS=' + ",".join(args.sanitize_flags)]
|
||||
|
||||
cmake_args += args.config_args
|
||||
|
||||
common.check_print_call(cmake_args + [paths.src], paths.build)
|
||||
|
@@ -56,6 +56,8 @@ def get_arguments():
|
||||
action='append', dest='config_args', default=[])
|
||||
parser.add_argument('--with-docs', help='Build and install documentation.',
|
||||
action='store_true', default=False)
|
||||
parser.add_argument('--add-sanitize-flags', help="Sets flags for sanitizer compilation flags used in Debug builds",
|
||||
action='append', dest='sanitize_flags', default=[] )
|
||||
parser.add_argument('--deploy', help='Installs the "Dependencies" component of the plugin.',
|
||||
action='store_true', default=False)
|
||||
parser.add_argument('--build-type', help='Build type to pass to CMake (defaults to RelWithDebInfo)',
|
||||
@@ -110,6 +112,10 @@ def build(args, paths):
|
||||
with open(os.path.join(paths.result, args.name + '.7z.git_sha'), 'w') as f:
|
||||
f.write(ide_revision)
|
||||
|
||||
if not args.build_type.lower() == 'release' and args.sanitize_flags:
|
||||
cmake_args += ['-DWITH_SANITIZE=ON',
|
||||
'-DSANITIZE_FLAGS=' + ",".join(args.sanitize_flags)]
|
||||
|
||||
cmake_args += args.config_args
|
||||
common.check_print_call(cmake_args + [paths.src], paths.build)
|
||||
build_args = ['cmake', '--build', '.']
|
||||
|
Reference in New Issue
Block a user