Skip to content

Conversation

@thorsten-klein
Copy link

Summary

This PR introduces minimal changes required to successfully build and run GoogleTest on Zephyr.
It is based on PR #4692 and it includes a cherry-picked commit from @anobli (Thank you!).

I open this PR to gather feedback from googletest maintainers. Maybe you prefer this more minimal solution for the start?
Otherwise please feel free to close this PR if #4692 will be merged.

Notes

These changes only contain the changes that are really necessary to build successful for Zephyr.
All further additional Zephyr-specific integration files can be maintained in downstream Zephyr projects, so there is no hard need to add them to googletest.

Usage Instructions (for Zephyr projects)

  1. Add googletest to your west.yml manifest, for example under lib/googletest:

    - name: googletest
      url: https://github.com/google/googletest.git
      revision: v1.17.0
      path: lib/googletest
  2. Create the module integration files within your project:

    • modules/googletest/CMakeLists.txt
    • modules/googletest/Kconfig

    Refer to PR Add support of Zephyr OS #4692 how they can look like. In CMake, you can locate the googletest sources with:

    set(ZEPHYR_GOOGLETEST_SRC_DIR ${ZEPHYR_BASE}/../lib/googletest)
    
  3. Include the module’s Kconfig in your project’s Zephyr module Kconfig:

    rsource "modules/googletest/Kconfig"
    
  4. Add the module directory in your project’s Zephyr module CMakeLists.txt:

    add_subdirectory(modules/googletest)
    

anobli and others added 2 commits December 12, 2025 22:37
Although Zephyr has it own test suite, it doesn't work well with C++.
gtest and gmock seem more adapted.
This adds support of Zephyr OS in order to test C++ libraries and
applications.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
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