From b2bf0a002b58bb0615c7abf5b54ed718739ed086 Mon Sep 17 00:00:00 2001 From: Martchus Date: Sun, 13 Jan 2019 22:14:42 +0100 Subject: [PATCH] Allow to add default cppunit test application To get rid of the boilderplate file "cppunit.cpp" in each project using cppunit for tests. --- cmake/modules/TestTarget.cmake | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmake/modules/TestTarget.cmake b/cmake/modules/TestTarget.cmake index a142803..98c0e91 100644 --- a/cmake/modules/TestTarget.cmake +++ b/cmake/modules/TestTarget.cmake @@ -50,6 +50,17 @@ if(NOT META_NO_CPP_UNIT) endif() endif() +# add default cppunit test application if requested +if(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION) + if(META_NO_CPP_UNIT) + message(FATAL_ERROR "Project ${META_PROJECT_NAME} has META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION and META_NO_CPP_UNIT enabled at the same time.") + endif() + + set(DEFAULT_CPP_UNIT_TEST_APPLICATION_SRC "${CMAKE_CURRENT_BINARY_DIR}/cppunit.cpp") + file(WRITE "${DEFAULT_CPP_UNIT_TEST_APPLICATION_SRC}" "#include ") + list(APPEND TEST_SRC_FILES "${DEFAULT_CPP_UNIT_TEST_APPLICATION_SRC}") +endif() + # always link test applications against c++utilities list(APPEND TEST_LIBRARIES ${CPP_UTILITIES_LIB})