summaryrefslogtreecommitdiff
path: root/contrib/buildsystems
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2023-09-25 11:20:30 (GMT)
committerJunio C Hamano <gitster@pobox.com>2023-11-09 23:16:27 (GMT)
commita15d4465a9918911e0953e89276d563fdc8cceef (patch)
tree1bc23d277607c734b5deddac55274b9f8ccd2fa3 /contrib/buildsystems
parentd8f416bbb87c2218ee5e43ec44ab8574a93fe423 (diff)
downloadgit-a15d4465a9918911e0953e89276d563fdc8cceef.zip
git-a15d4465a9918911e0953e89276d563fdc8cceef.tar.gz
git-a15d4465a9918911e0953e89276d563fdc8cceef.tar.bz2
cmake: also build unit tests
A new, better way to run unit tests was just added to Git. This adds support for building those unit tests via CMake. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/buildsystems')
-rw-r--r--contrib/buildsystems/CMakeLists.txt18
1 files changed, 18 insertions, 0 deletions
diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index 2f6e019..ffeca1a 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -965,6 +965,24 @@ target_link_libraries(test-fake-ssh common-main)
parse_makefile_for_sources(test-reftable_SOURCES "REFTABLE_TEST_OBJS")
list(TRANSFORM test-reftable_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
+#unit-tests
+add_library(unit-test-lib OBJECT ${CMAKE_SOURCE_DIR}/t/unit-tests/test-lib.c)
+
+parse_makefile_for_scripts(unit_test_PROGRAMS "UNIT_TEST_PROGRAMS" "")
+foreach(unit_test ${unit_test_PROGRAMS})
+ add_executable("${unit_test}" "${CMAKE_SOURCE_DIR}/t/unit-tests/${unit_test}.c")
+ target_link_libraries("${unit_test}" unit-test-lib common-main)
+ set_target_properties("${unit_test}"
+ PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/unit-tests/bin)
+ if(MSVC)
+ set_target_properties("${unit_test}"
+ PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/t/unit-tests/bin)
+ set_target_properties("${unit_test}"
+ PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/unit-tests/bin)
+ endif()
+ list(APPEND PROGRAMS_BUILT "${unit_test}")
+endforeach()
+
#test-tool
parse_makefile_for_sources(test-tool_SOURCES "TEST_BUILTINS_OBJS")