Create Zephyr external module

This update googletest to use it as Zephyr OS external module.
This allows downloading, configure and building googltest using
Zephyr west build system, without any user manipulation.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
This commit is contained in:
Alexandre Bailon 2025-01-08 11:27:27 +01:00
parent ab83f0365c
commit 8e3886acac
4 changed files with 43 additions and 0 deletions

View file

@ -0,0 +1,17 @@
zephyr_library()
# Disable use of pthreads in GoogleTest
set(gtest_disable_pthreads ON CACHE BOOL "Build GoogleTest without Pthread")
zephyr_include_directories_ifdef(CONFIG_GTEST ${ZEPHYR_GOOGLETEST_MODULE_DIR}/googletest/)
zephyr_include_directories_ifdef(CONFIG_GTEST ${ZEPHYR_GOOGLETEST_MODULE_DIR}/googletest/include/)
zephyr_library_sources_ifdef(CONFIG_GTEST
${ZEPHYR_GOOGLETEST_MODULE_DIR}/googletest/src/gtest-all.cc
)
target_sources_ifdef(CONFIG_GTEST app PRIVATE
${ZEPHYR_GOOGLETEST_MODULE_DIR}/googletest/src/gtest_main.cc
)
zephyr_include_directories_ifdef(CONFIG_GMOCK ${ZEPHYR_GOOGLETEST_MODULE_DIR}/googlemock/)
zephyr_include_directories_ifdef(CONFIG_GMOCK ${ZEPHYR_GOOGLETEST_MODULE_DIR}/googlemock/include/)
zephyr_library_sources_ifdef(CONFIG_GMOCK ${ZEPHYR_GOOGLETEST_MODULE_DIR}/googlemock/src/gmock-all.cc)

View file

@ -0,0 +1,18 @@
config GTEST
bool "GoogleTest test framework"
select TEST
select CPP
select REQUIRES_FULL_LIBCPP
select FPU
config GMOCK
bool "GoogleMock mocking framework"
select GTEST
choice STD_CPP
default STD_CPP14 if GTEST
endchoice
choice LIBC_IMPLEMENTATION
default NEWLIB_LIBC if GTEST
endchoice

2
modules/modules.cmake Normal file
View file

@ -0,0 +1,2 @@
set(ZEPHYR_GOOGLETEST_CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR}/googletest)
set(ZEPHYR_GOOGLETEST_KCONFIG ${CMAKE_CURRENT_LIST_DIR}/googletest/Kconfig)

6
zephyr/module.yml Normal file
View file

@ -0,0 +1,6 @@
name: googletest
build:
cmake-ext: true
kconfig-ext: true
settings:
module_ext_root: .