Skip to content

Commit 8073ef9

Browse files
Merge pull request #1042 from yupengtang:cmake-tests-highway-collision
PiperOrigin-RevId: 990329917
2 parents 3806ff7 + 53ff3f8 commit 8073ef9

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎CMakeLists.txt‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,12 @@ set(GEMMA_INTEGRATION_TEST_FILES
407407
foreach (TESTFILE IN LISTS GEMMA_TEST_FILES)
408408
# The TESTNAME is the name without the extension or directory.
409409
get_filename_component(TESTNAME ${TESTFILE} NAME_WE)
410+
# Highway names its own test targets the same way, so a shared basename
411+
# (compress_test, dot_test, image_test) collides and fails the configure
412+
# step. Prefix ours only when the name is already taken.
413+
if (TARGET ${TESTNAME})
414+
set(TESTNAME gemma_${TESTNAME})
415+
endif()
410416
add_executable(${TESTNAME} ${TESTFILE})
411417
# Test all targets, not just the best/baseline. This changes the default
412418
# policy to all-attainable; note that setting -DHWY_COMPILE_* directly can
@@ -415,6 +421,13 @@ foreach (TESTFILE IN LISTS GEMMA_TEST_FILES)
415421
target_compile_options(${TESTNAME} PRIVATE -DHWY_IS_TEST=1)
416422

417423
target_link_libraries(${TESTNAME} PRIVATE libgemma GTest::Main hwy hwy_contrib hwy_test)
424+
# threading_test includes gmock/gmock.h, whose headers come with the gmock
425+
# target rather than with GTest::Main.
426+
if (TARGET gmock)
427+
target_link_libraries(${TESTNAME} PRIVATE gmock)
428+
elseif (TARGET GTest::gmock)
429+
target_link_libraries(${TESTNAME} PRIVATE GTest::gmock)
430+
endif()
418431

419432
# Run discovered tests from the repo root so tests using relative paths
420433
# (e.g. paligemma/image_test.cc reading paligemma/testdata/image.ppm) work.

0 commit comments

Comments
 (0)