From 45f627029d2743b530e4b21fc19511fd57588b34 Mon Sep 17 00:00:00 2001 From: Yupeng Tang <85978465+yupengtang@users.noreply.github.com> Date: Tue, 22 Sep 2026 01:20:45 -0400 Subject: [PATCH] Let the tests configure alongside Highway's Highway derives its test target names from the file basename exactly as we do, and it is fetched before this block, so compress_test, dot_test and image_test were already taken and the configure step failed. Prefix ours when the name is taken; those three of our tests were never built through CMake as a result. threading_test includes gmock/gmock.h, whose headers come with the gmock target rather than with GTest::Main, so link it where it exists. --- CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a43a8c82..de917c3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -407,6 +407,12 @@ set(GEMMA_INTEGRATION_TEST_FILES foreach (TESTFILE IN LISTS GEMMA_TEST_FILES) # The TESTNAME is the name without the extension or directory. get_filename_component(TESTNAME ${TESTFILE} NAME_WE) + # Highway names its own test targets the same way, so a shared basename + # (compress_test, dot_test, image_test) collides and fails the configure + # step. Prefix ours only when the name is already taken. + if (TARGET ${TESTNAME}) + set(TESTNAME gemma_${TESTNAME}) + endif() add_executable(${TESTNAME} ${TESTFILE}) # Test all targets, not just the best/baseline. This changes the default # policy to all-attainable; note that setting -DHWY_COMPILE_* directly can @@ -415,6 +421,13 @@ foreach (TESTFILE IN LISTS GEMMA_TEST_FILES) target_compile_options(${TESTNAME} PRIVATE -DHWY_IS_TEST=1) target_link_libraries(${TESTNAME} PRIVATE libgemma GTest::Main hwy hwy_contrib hwy_test) + # threading_test includes gmock/gmock.h, whose headers come with the gmock + # target rather than with GTest::Main. + if (TARGET gmock) + target_link_libraries(${TESTNAME} PRIVATE gmock) + elseif (TARGET GTest::gmock) + target_link_libraries(${TESTNAME} PRIVATE GTest::gmock) + endif() # Run discovered tests from the repo root so tests using relative paths # (e.g. paligemma/image_test.cc reading paligemma/testdata/image.ppm) work.