summaryrefslogtreecommitdiffstats
path: root/cmake/modules/AddTest.cmake
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:54:46 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:54:46 +0000
commitcd7b005519ade8ab6c97fcb21590b71b7d1be6e3 (patch)
treec611a8d0cd5e8f68f41b8c2d16ba580e0f40a38d /cmake/modules/AddTest.cmake
parentInitial commit. (diff)
downloadlibrtr-cd7b005519ade8ab6c97fcb21590b71b7d1be6e3.tar.xz
librtr-cd7b005519ade8ab6c97fcb21590b71b7d1be6e3.zip
Adding upstream version 0.8.0.upstream/0.8.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--cmake/modules/AddTest.cmake31
1 files changed, 31 insertions, 0 deletions
diff --git a/cmake/modules/AddTest.cmake b/cmake/modules/AddTest.cmake
new file mode 100644
index 0000000..10da459
--- /dev/null
+++ b/cmake/modules/AddTest.cmake
@@ -0,0 +1,31 @@
+enable_testing()
+include(CTest)
+
+function (ADD_RTR_TEST _testName _testSource)
+ add_executable(${_testName} ${_testSource})
+ target_link_libraries(${_testName} ${ARGN})
+ add_test(${_testName} ${CMAKE_CURRENT_BINARY_DIR}/${_testName})
+endfunction (ADD_RTR_TEST)
+
+
+function (ADD_RTR_UNIT_TEST _testName _testSource)
+ add_rtr_test(${_testName} ${_testSource} ${ARGN})
+ add_coverage(${_testName})
+endfunction (ADD_RTR_UNIT_TEST)
+
+
+function (WRAP_FUNCTIONS _testName)
+ set(template " -Wl,--wrap=")
+ set(linkopts "")
+ foreach(f ${ARGN})
+ string(CONCAT linkopts ${linkopts} ${template} ${f})
+ endforeach()
+
+ get_target_property(temp ${_testName} COMPILE_FLAGS)
+ if (temp)
+ string(CONCAT linkopts ${temp} ${linkopts})
+ endif()
+ set_target_properties(${_testName}
+ PROPERTIES
+ LINK_FLAGS ${linkopts})
+endfunction (WRAP_FUNCTIONS)