Skip to content

Commit cbb5b53

Browse files
committed
Merge branch 'jc/cmake-unit-test-updates'
CMake adjustments for recent changes around unit tests. * jc/cmake-unit-test-updates: cmake: generalize the handling of the `UNIT_TEST_OBJS` list cmake: stop looking for `REFTABLE_TEST_OBJS` in the Makefile cmake: rename clar-related variables to avoid confusion
2 parents 7644bb0 + 8afda42 commit cbb5b53

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

contrib/buildsystems/CMakeLists.txt

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -970,18 +970,15 @@ if(BUILD_TESTING)
970970
add_executable(test-fake-ssh ${CMAKE_SOURCE_DIR}/t/helper/test-fake-ssh.c)
971971
target_link_libraries(test-fake-ssh common-main)
972972

973-
#reftable-tests
974-
parse_makefile_for_sources(test-reftable_SOURCES "REFTABLE_TEST_OBJS")
975-
list(TRANSFORM test-reftable_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
976-
977973
#unit-tests
978-
add_library(unit-test-lib OBJECT ${CMAKE_SOURCE_DIR}/t/unit-tests/test-lib.c)
979-
add_library(unit-test-lib-oid OBJECT ${CMAKE_SOURCE_DIR}/t/unit-tests/lib-oid.c)
974+
parse_makefile_for_sources(unit-test_SOURCES "UNIT_TEST_OBJS")
975+
list(TRANSFORM unit-test_SOURCES REPLACE "\\$\\(UNIT_TEST_DIR\\)/" "${CMAKE_SOURCE_DIR}/t/unit-tests/")
976+
add_library(unit-test-lib STATIC ${unit-test_SOURCES})
980977

981978
parse_makefile_for_scripts(unit_test_PROGRAMS "UNIT_TEST_PROGRAMS" "")
982979
foreach(unit_test ${unit_test_PROGRAMS})
983980
add_executable("${unit_test}" "${CMAKE_SOURCE_DIR}/t/unit-tests/${unit_test}.c")
984-
target_link_libraries("${unit_test}" unit-test-lib unit-test-lib-oid common-main)
981+
target_link_libraries("${unit_test}" unit-test-lib common-main)
985982
set_target_properties("${unit_test}"
986983
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/unit-tests/bin)
987984
if(MSVC)
@@ -1004,14 +1001,14 @@ foreach(unit_test ${unit_test_PROGRAMS})
10041001
endif()
10051002
endforeach()
10061003

1007-
parse_makefile_for_scripts(unit_tests_SUITES "UNIT_TESTS_SUITES" "")
1004+
parse_makefile_for_scripts(clar_test_SUITES "CLAR_TEST_SUITES" "")
10081005

10091006
set(clar_decls "")
10101007
set(clar_cbs "")
10111008
set(clar_cbs_count 0)
10121009
set(clar_suites "static struct clar_suite _clar_suites[] = {\n")
1013-
list(LENGTH unit_tests_SUITES clar_suites_count)
1014-
foreach(suite ${unit_tests_SUITES})
1010+
list(LENGTH clar_test_SUITES clar_suites_count)
1011+
foreach(suite ${clar_test_SUITES})
10151012
file(STRINGS "${CMAKE_SOURCE_DIR}/t/unit-tests/${suite}.c" decls
10161013
REGEX "^void test_${suite}__[a-zA-Z_0-9][a-zA-Z_0-9]*\\(void\\)$")
10171014

@@ -1042,9 +1039,9 @@ string(APPEND clar_suites
10421039
file(WRITE "${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h" "${clar_decls}")
10431040
file(WRITE "${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite" "${clar_decls}" "${clar_cbs}" "${clar_suites}")
10441041

1045-
list(TRANSFORM unit_tests_SUITES PREPEND "${CMAKE_SOURCE_DIR}/t/unit-tests/")
1046-
list(TRANSFORM unit_tests_SUITES APPEND ".c")
1047-
add_library(unit-tests-lib ${unit_tests_SUITES} "${CMAKE_SOURCE_DIR}/t/unit-tests/clar/clar.c")
1042+
list(TRANSFORM clar_test_SUITES PREPEND "${CMAKE_SOURCE_DIR}/t/unit-tests/")
1043+
list(TRANSFORM clar_test_SUITES APPEND ".c")
1044+
add_library(unit-tests-lib ${clar_test_SUITES} "${CMAKE_SOURCE_DIR}/t/unit-tests/clar/clar.c")
10481045
target_include_directories(unit-tests-lib PRIVATE "${CMAKE_SOURCE_DIR}/t/unit-tests")
10491046
add_executable(unit-tests "${CMAKE_SOURCE_DIR}/t/unit-tests/unit-test.c")
10501047
target_link_libraries(unit-tests unit-tests-lib common-main)
@@ -1062,7 +1059,7 @@ parse_makefile_for_sources(test-tool_SOURCES "TEST_BUILTINS_OBJS")
10621059
add_library(test-lib OBJECT ${CMAKE_SOURCE_DIR}/t/unit-tests/test-lib.c)
10631060

10641061
list(TRANSFORM test-tool_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/t/helper/")
1065-
add_executable(test-tool ${CMAKE_SOURCE_DIR}/t/helper/test-tool.c ${test-tool_SOURCES} ${test-reftable_SOURCES})
1062+
add_executable(test-tool ${CMAKE_SOURCE_DIR}/t/helper/test-tool.c ${test-tool_SOURCES})
10661063
target_link_libraries(test-tool test-lib common-main)
10671064

10681065
set_target_properties(test-fake-ssh test-tool

0 commit comments

Comments
 (0)