cmake: Small improvements to AddCMockaTest
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Этот коммит содержится в:
родитель
f99e6766d6
Коммит
baa434ebed
@ -1,7 +1,7 @@
|
|||||||
# - ADD_CHECK_TEST(test_name test_source linklib1 ... linklibN)
|
# - add_cmocka_test(test_name test_source linklib1 ... linklibN)
|
||||||
|
|
||||||
# Copyright (c) 2007 Daniel Gollub <dgollub@suse.de>
|
# Copyright (c) 2007 Daniel Gollub <dgollub@suse.de>
|
||||||
# Copyright (c) 2007-2010 Andreas Schneider <asn@cryptomilk.org>
|
# Copyright (c) 2007-2018 Andreas Schneider <asn@cryptomilk.org>
|
||||||
#
|
#
|
||||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||||
@ -9,19 +9,19 @@
|
|||||||
enable_testing()
|
enable_testing()
|
||||||
include(CTest)
|
include(CTest)
|
||||||
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCC AND NOT MINGW)
|
if((CMAKE_C_COMPILER_ID MATCHES "(GNU|Clang)") AND NOT MINGW)
|
||||||
# Profiling
|
# Activate with: -DCMAKE_BUILD_TYPE=Profiling
|
||||||
set(CMAKE_C_FLAGS_PROFILING "-g -O0 -Wall -W -Wshadow -Wunused-variable -Wunused-parameter -Wunused-function -Wunused -Wno-system-headers -Wwrite-strings -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Compiler Flags")
|
set(CMAKE_C_FLAGS_PROFILING "-g -O0 -fprofile-arcs -ftest-coverage")
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS_PROFILING " -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Linker Flags")
|
set(CMAKE_SHARED_LINKER_FLAGS_PROFILING "-fprofile-arcs -ftest-coverage")
|
||||||
set(CMAKE_MODULE_LINKER_FLAGS_PROFILING " -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Linker Flags")
|
set(CMAKE_MODULE_LINKER_FLAGS_PROFILING "-fprofile-arcs -ftest-coverage")
|
||||||
set(CMAKE_EXEC_LINKER_FLAGS_PROFILING " -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Linker Flags")
|
set(CMAKE_EXEC_LINKER_FLAGS_PROFILING "-fprofile-arcs -ftest-coverage")
|
||||||
|
|
||||||
# Address Sanitizer
|
# Activate with: -DCMAKE_BUILD_TYPE=AddressSanitizer
|
||||||
set(CMAKE_C_FLAGS_ADDRESSSANITIZER "-g -O1 -fsanitize=address -fno-omit-frame-pointer" CACHE STRING "Address sanitizer compiler flags")
|
set(CMAKE_C_FLAGS_ADDRESSSANITIZER "-g -O1 -fsanitize=address -fno-omit-frame-pointer")
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS_ADDRESSSANITIZER "-fsanitize=address" CACHE STRING "Address sanitizer shared linker flags")
|
set(CMAKE_SHARED_LINKER_FLAGS_ADDRESSSANITIZER "-fsanitize=address")
|
||||||
set(CMAKE_MODULE_LINKER_FLAGS_ADDRESSSANITIZER "-fsanitize=address" CACHE STRING "Address sanitizer module linker flags")
|
set(CMAKE_MODULE_LINKER_FLAGS_ADDRESSSANITIZER "-fsanitize=address")
|
||||||
set(CMAKE_EXEC_LINKER_FLAGS_ADDRESSSANITIZER "-fsanitize=address" CACHE STRING "Address sanitizer executable linker flags")
|
set(CMAKE_EXEC_LINKER_FLAGS_ADDRESSSANITIZER "-fsanitize=address")
|
||||||
endif(CMAKE_COMPILER_IS_GNUCC AND NOT MINGW)
|
endif()
|
||||||
|
|
||||||
if (CMAKE_CROSSCOMPILING)
|
if (CMAKE_CROSSCOMPILING)
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
@ -31,8 +31,10 @@ if (CMAKE_CROSSCOMPILING)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
function (ADD_CMOCKA_TEST _testName _testSource)
|
function(ADD_CMOCKA_TEST _testName _testSource)
|
||||||
add_executable(${_testName} ${_testSource})
|
add_executable(${_testName} ${_testSource})
|
||||||
|
|
||||||
target_link_libraries(${_testName} ${ARGN})
|
target_link_libraries(${_testName} ${ARGN})
|
||||||
|
|
||||||
add_test(${_testName} ${TARGET_SYSTEM_EMULATOR} ${CMAKE_CURRENT_BINARY_DIR}/${_testName}${CMAKE_EXECUTABLE_SUFFIX})
|
add_test(${_testName} ${TARGET_SYSTEM_EMULATOR} ${CMAKE_CURRENT_BINARY_DIR}/${_testName}${CMAKE_EXECUTABLE_SUFFIX})
|
||||||
endfunction (ADD_CMOCKA_TEST)
|
endfunction (ADD_CMOCKA_TEST)
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user