aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>2021-07-21 15:24:11 +0100
committerAlex Richardson <arichardson.kde@gmail.com>2021-10-02 15:02:35 +0000
commit5f6a21d56404ad34aa01deca48ff41aae50d4613 (patch)
tree1a4dac93d6ae5d04400990dc38d2dcf4d2236fd6
parent63bec5521d245e3a1ea50109b86a2b716966938e (diff)
downloadextra-cmake-modules-5f6a21d56404ad34aa01deca48ff41aae50d4613.tar.gz
extra-cmake-modules-5f6a21d56404ad34aa01deca48ff41aae50d4613.tar.bz2
ecm_add_test: add -DQT_FORCE_ASSERTS to compile flags by default
While debugging a failing test (KProcessTest in KCoreAddons), I noticed that the Q_ASSERT() statements inside that test weren't being executed because RelWithDebInfo builds default to passing -DQT_NO_DEBUG. With this change the test I was debugging now asserts early instead of failing a QCOMPARE later on.
-rw-r--r--modules/ECMAddTests.cmake4
1 files changed, 4 insertions, 0 deletions
diff --git a/modules/ECMAddTests.cmake b/modules/ECMAddTests.cmake
index de965f06..58c78d05 100644
--- a/modules/ECMAddTests.cmake
+++ b/modules/ECMAddTests.cmake
@@ -34,6 +34,9 @@ of CMAKE_WIN32_EXECUTABLE or CMAKE_MACOSX_BUNDLE). Be aware that this changes
the executable entry point on Windows (although some frameworks, such as Qt,
abstract this difference away).
+The tests will be build with -DQT_FORCE_ASSERTS to enable assertions in the
+test executable even for release builds.
+
The TARGET_NAMES_VAR and TEST_NAMES_VAR arguments, if given, should specify a
variable name to receive the list of generated target and test names,
respectively. This makes it convenient to apply properties to them as a
@@ -92,6 +95,7 @@ function(ecm_add_test)
endif()
add_test(NAME ${_testname} COMMAND ${_targetname})
target_link_libraries(${_targetname} ${ARG_LINK_LIBRARIES})
+ target_compile_definitions(${_targetname} PRIVATE -DQT_FORCE_ASSERTS)
ecm_mark_as_test(${_targetname})
if (CMAKE_LIBRARY_OUTPUT_DIRECTORY)
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")