Skip to content

Commit 3e7da15

Browse files
committed
cmake: generalize the handling of the CLAR_TEST_OBJS list
A late-comer to the v2.49.0 party, `sk/unit-test-oid`, added yet another array item to `CLAR_TEST_OBJS`, causing the `win+VS build` job to fail with symptoms like this one: unit-tests-lib.lib(u-oid-array.obj) : error LNK2019: unresolved external symbol cl_parse_any_oid referenced in function fill_array This is a similar scenario to the one that forced me to write 8afda42 (cmake: generalize the handling of the `UNIT_TEST_OBJS` list, 2024-09-18): The hard-coded echo of `CLAR_TEST_OBJS` in `CMakeLists.txt` that recapitulates faithfully what was already hard-coded in `Makefile` would either have to be updated whack-a-mole style, or generalized. Just like I chose the latter option for `UNIT_TEST_OBJS`, I now do the same for `CLAR_TEST_OBJS`. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 1c6c7c2 commit 3e7da15

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

contrib/buildsystems/CMakeLists.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,10 +1030,14 @@ parse_makefile_for_sources(unit-test_SOURCES ${CMAKE_SOURCE_DIR}/Makefile "UNIT_
10301030
list(TRANSFORM unit-test_SOURCES REPLACE "\\$\\(UNIT_TEST_DIR\\)/" "${CMAKE_SOURCE_DIR}/t/unit-tests/")
10311031
add_library(unit-test-lib STATIC ${unit-test_SOURCES})
10321032

1033+
parse_makefile_for_sources(clar-test_SOURCES ${CMAKE_SOURCE_DIR}/Makefile "CLAR_TEST_OBJS")
1034+
list(TRANSFORM clar-test_SOURCES REPLACE "\\$\\(UNIT_TEST_DIR\\)/" "${CMAKE_SOURCE_DIR}/t/unit-tests/")
1035+
add_library(clar-test-lib STATIC ${clar-test_SOURCES})
1036+
10331037
parse_makefile_for_scripts(unit_test_PROGRAMS "UNIT_TEST_PROGRAMS" "")
10341038
foreach(unit_test ${unit_test_PROGRAMS})
10351039
add_executable("${unit_test}" "${CMAKE_SOURCE_DIR}/t/unit-tests/${unit_test}.c")
1036-
target_link_libraries("${unit_test}" unit-test-lib common-main)
1040+
target_link_libraries("${unit_test}" unit-test-lib clar-test-lib common-main)
10371041
set_target_properties("${unit_test}"
10381042
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/unit-tests/bin)
10391043
if(MSVC)
@@ -1075,13 +1079,13 @@ add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite"
10751079
VERBATIM)
10761080

10771081
add_library(unit-tests-lib ${clar_test_SUITES}
1078-
"${CMAKE_SOURCE_DIR}/t/unit-tests/clar/clar.c"
10791082
"${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h"
10801083
"${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite"
10811084
)
1085+
target_include_directories(clar-test-lib PUBLIC "${CMAKE_BINARY_DIR}/t/unit-tests")
10821086
target_include_directories(unit-tests-lib PUBLIC "${CMAKE_BINARY_DIR}/t/unit-tests")
1083-
add_executable(unit-tests "${CMAKE_SOURCE_DIR}/t/unit-tests/unit-test.c")
1084-
target_link_libraries(unit-tests unit-tests-lib common-main)
1087+
add_executable(unit-tests)
1088+
target_link_libraries(unit-tests unit-tests-lib clar-test-lib common-main)
10851089
set_target_properties(unit-tests
10861090
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/unit-tests/bin)
10871091
if(MSVC)

0 commit comments

Comments
 (0)