Skip to content

fix(tests): link glm into test_chat_types - #108

Merged
Kelsidavis merged 1 commit into
Kelsidavis:masterfrom
Fuitad:fix/test-chat-types-glm-link
Aug 5, 2026
Merged

fix(tests): link glm into test_chat_types#108
Kelsidavis merged 1 commit into
Kelsidavis:masterfrom
Fuitad:fix/test-chat-types-glm-link

Conversation

@Fuitad

@Fuitad Fuitad commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

What

Adds the glm link block to the test_chat_types target in tests/CMakeLists.txt, matching the pattern already used by test_hill_climbing, test_spline, test_transport_path_repo, and test_taxi_packets.

if(TARGET glm::glm-header-only)
    target_link_libraries(test_chat_types PRIVATE glm::glm-header-only)
elseif(TARGET glm::glm)
    target_link_libraries(test_chat_types PRIVATE glm::glm)
endif()

Why

test_chat_types does not build on macOS. It fails at the preprocessor:

In file included from tests/test_chat_types.cpp:3:
In file included from include/game/world_packets.hpp:6:
In file included from include/game/entity.hpp:16:
include/math/spline.hpp:5:10: fatal error: 'glm/glm.hpp' file not found
    5 | #include <glm/glm.hpp>
      |          ^~~~~~~~~~~~~
1 error generated.

The include chain is test_chat_types.cpp to game/world_packets.hpp to game/entity.hpp:16 to math/spline.hpp:5 to <glm/glm.hpp>. The target linked only catch2_main, so it never received glm's include path.

glm is not vendored in extern/. It comes from find_package(glm), and its include directory arrives with the imported target rather than through TEST_INCLUDE_DIRS or TEST_SYSTEM_INCLUDE_DIRS. The comment above test_hill_climbing at tests/CMakeLists.txt:50 already records this, from the previous time it bit:

glm is not vendored, it comes from find_package(glm), and its include path arrives with the imported target rather than through any directory this file lists.

test_taxi_packets, added in the same commit as test_chat_types (3ed9330), already carries the block. test_chat_types was the one that missed it.

Why CI did not catch it

.github/workflows/build.yml runs on ubuntu-24.04 and ubuntu-24.04-arm only. There, libglm-dev installs the headers into /usr/include, which the compiler searches by default, so the missing link target makes no difference and the build is green. macOS puts glm under the Homebrew prefix, which is not on the default search path, so it is the only platform that reports the error. macOS appears in release.yml (macos-15), which runs on release rather than on pull requests.

This is a build-configuration bug with a platform-dependent symptom, not a behaviour change. The compiled test itself is untouched.

Scope

I audited the rest of the test suite rather than fixing only the reported failure. Running each target's exact compile line from compile_commands.json with -fsyntax-only: of 55 test translation units, 27 build without glm's include path, and all 27 are clean. None of them reach entity.hpp, so test_chat_types was the only affected target.

The three other targets added recently (test_equipment_set_packets, test_achievement_criteria, test_packed_time) include only network/packet.hpp, game/achievement_criteria.hpp, and game/packed_time.hpp respectively, and are correct as they stand. I left them alone rather than adding a block they do not currently need.

Effect on Linux

None. On Linux, glm::glm (or glm::glm-header-only) resolves to the same headers already found via /usr/include, and the if(TARGET ...) guard makes the block a no-op where neither imported target exists.

Verification

cmake --build build --parallel 12 exits 0 on macOS 15 (arm64, Homebrew glm 1.0), and ctest reports 55 of 55 tests passing, including chat_types.

Possible follow-up, not included here

Adding a macos-15 job to the build.yml matrix would let CI catch this class of error on pull requests instead of at release time or on a contributor's machine. That is a separate change and I have kept it out of this PR.

Summary:
- Add the glm::glm-header-only / glm::glm link block to the
  test_chat_types target, matching the pattern already used by
  test_hill_climbing, test_spline, and test_taxi_packets.

Rationale:
- test_chat_types.cpp includes game/world_packets.hpp, which pulls in
  game/entity.hpp, which includes math/spline.hpp and therefore
  <glm/glm.hpp>. The target linked only catch2_main, so it never
  received glm's include path.
- glm is not vendored. It comes from find_package(glm) and its headers
  arrive with the imported target rather than through TEST_INCLUDE_DIRS
  or TEST_SYSTEM_INCLUDE_DIRS, as the comment above test_hill_climbing
  already records.
- On Linux libglm-dev installs into /usr/include, so the target compiles
  regardless. On macOS glm lives under the Homebrew prefix, which the
  compiler does not search by default, and the build fails with
  "'glm/glm.hpp' file not found". CI only covers ubuntu-24.04 and
  ubuntu-24.04-arm, so the platform that reports this is not built on
  pull requests.
- test_taxi_packets, added in the same commit, already carries the
  block. test_chat_types was the only target missing it: the other test
  targets that compile without glm's include path do not reach
  entity.hpp.

Tests:
- cmake --build build --parallel 12 (exit 0, full project)
- ctest --test-dir build (55/55 passed)
@Kelsidavis
Kelsidavis merged commit 095128d into Kelsidavis:master Aug 5, 2026
8 checks passed
Kelsidavis added a commit that referenced this pull request Aug 5, 2026
macOS CI has been failing on test_chat_types for want of glm's include path.
#108 fixed that target, and it was the thirtieth copy of the same four-line
block — added because CI broke, which is how the twenty-nine before it were
added too.

glm is not vendored: it comes from find_package and its include path arrives
with the imported target rather than through any directory the tests file
lists. A test that reaches <glm/glm.hpp> through a chain of headers and does
not name glm compiles anyway on Linux, where there is a system copy under
/usr/include, and fails on macOS, where there is not. So every one of these
was found the same way — by breaking one platform's CI — and the next header
that starts including spline.hpp would have found the thirty-first.

One PUBLIC link on catch2_main instead. Every one of the 55 test targets
links catch2_main, checked rather than assumed, so all of them get the
include path transitively and a new test cannot be written without it.

It also fixes a fault none of them had hit yet: twenty-six of the thirty
checked only glm::glm, with no branch for the glm::glm-header-only target
GLM 1.0 exposes when it builds glm::glm as a real library. On such a system
those tests would have failed exactly the way macOS is failing now.
@Fuitad
Fuitad deleted the fix/test-chat-types-glm-link branch August 5, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants