From 3c77b378e6bff4a760124743939d157f0b32bb44 Mon Sep 17 00:00:00 2001 From: Florian Albrechtskirchinger Date: Sat, 24 Sep 2022 13:17:31 +0200 Subject: [PATCH] Print valgrind command with options in feature summary --- cmake/json_opts.cmake | 1 + cmake/json_summary.cmake | 3 ++- cmake/json_test.cmake | 14 +++++++------- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/cmake/json_opts.cmake b/cmake/json_opts.cmake index ac0b2043b..f5769d4cb 100644 --- a/cmake/json_opts.cmake +++ b/cmake/json_opts.cmake @@ -16,6 +16,7 @@ set(JSON_32bitTest AUTO CACHE STRING "Enable the 32bit unit test (ON/OFF/AUTO/ON cmake_dependent_option(JSON_FastTests "Skip expensive/slow tests." OFF "JSON_BuildTests" OFF) set(JSON_TestDataDirectory "$ENV{JSON_TEST_DATA_DIRECTORY}" CACHE FILEPATH "Test data directory for the unit tests (will be downloaded if not specified).") cmake_dependent_option(JSON_Valgrind "Execute test suite with Valgrind." OFF "JSON_BuildTests" OFF) +set(JSON_MEMORYCHECK_COMMAND_OPTIONS "--error-exitcode=1;--leak-check=full" CACHE STRING "Options passed to the memory check command (valgrind).") set(JSON_TestStandards "" CACHE STRING "The list of standards to test explicitly.") diff --git a/cmake/json_summary.cmake b/cmake/json_summary.cmake index 758dda535..cef785b8b 100644 --- a/cmake/json_summary.cmake +++ b/cmake/json_summary.cmake @@ -60,7 +60,8 @@ if(JSON_BuildTests) json_feature(JSON_Valgrind "Execute test suite with Valgrind?") if(JSON_Valgrind) - message(" Valgrind command: ${CMAKE_MEMORYCHECK_COMMAND}" ${CMAKE_MEMORYCHECK_COMMAND_OPTIONS}) + string (REPLACE ";" " " memcheck_command "${JSON_MEMORYCHECK_COMMAND};${JSON_MEMORYCHECK_COMMAND_OPTIONS}") + message(" Valgrind command: ${memcheck_command}") endif() set(test_cxx_standards "") diff --git a/cmake/json_test.cmake b/cmake/json_test.cmake index 6ece47d59..d64affdca 100644 --- a/cmake/json_test.cmake +++ b/cmake/json_test.cmake @@ -26,12 +26,11 @@ add_test(NAME "download_test_data" COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINA ) set_tests_properties(download_test_data PROPERTIES FIXTURES_SETUP TEST_DATA) -if(JSON_Valgrind) - find_program(CMAKE_MEMORYCHECK_COMMAND valgrind) - message(STATUS "Executing test suite with Valgrind (${CMAKE_MEMORYCHECK_COMMAND})") - set(memcheck_command "${CMAKE_MEMORYCHECK_COMMAND} ${CMAKE_MEMORYCHECK_COMMAND_OPTIONS} --error-exitcode=1 --leak-check=full") - separate_arguments(memcheck_command) -endif() +############################################################################# +# locate memory check command +############################################################################# + +find_program(JSON_MEMORYCHECK_COMMAND valgrind) ############################################################################# # detect standard support @@ -189,7 +188,8 @@ function(_json_test_add_test test_name file main cxx_standard) if(JSON_Valgrind) add_test(NAME ${test_target}_valgrind - COMMAND ${memcheck_command} $ ${DOCTEST_TEST_FILTER} + COMMAND ${JSON_MEMORYCHECK_COMMAND} ${JSON_MEMORYCHECK_COMMAND_OPTIONS} + -- $ ${DOCTEST_TEST_FILTER} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ) set_tests_properties(${test_target}_valgrind PROPERTIES