cmake: Populate var CMAKE_GCOV

For each compiler, also set a CMAKE_GCOV var referencing the appropriate
gcov tool.

Tested with gcc and host-gcc on the ChromeOS codebase.

Signed-off-by: Jeremy Bettis <jbettis@chromium.org>
This commit is contained in:
Jeremy Bettis 2021-08-27 16:57:15 -06:00 committed by Anas Nashif
commit 1fee4849bc
5 changed files with 7 additions and 0 deletions

View file

@ -19,6 +19,8 @@ if(NOT CMAKE_DTS_PREPROCESSOR)
endif()
find_program(CMAKE_C_COMPILER ${CROSS_COMPILE}ccac PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
find_program(CMAKE_LLVM_COV ${CROSS_COMPILE}llvm-cov PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
set(CMAKE_GCOV "${CMAKE_LLVM_COV} gcov")
if(CMAKE_C_COMPILER STREQUAL CMAKE_C_COMPILER-NOTFOUND)
message(FATAL_ERROR "Zephyr was unable to find the Metaware compiler")

View file

@ -5,4 +5,6 @@ if(DEFINED TOOLCHAIN_HOME)
endif()
find_program(CMAKE_C_COMPILER clang ${find_program_clang_args})
find_program(CMAKE_LLVM_COV llvm-cov ${find_program_clang_args})
set(CMAKE_GCOV "${CMAKE_LLVM_COV} gcov")

View file

@ -3,6 +3,7 @@
set_ifndef(CC gcc)
find_program(CMAKE_C_COMPILER ${CROSS_COMPILE}${CC} PATHS ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
find_program(CMAKE_GCOV ${CROSS_COMPILE}gcov PATHS ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
if(CMAKE_C_COMPILER STREQUAL CMAKE_C_COMPILER-NOTFOUND)
message(FATAL_ERROR "Zephyr was unable to find the toolchain. Is the environment misconfigured?

View file

@ -3,3 +3,4 @@
# Configures CMake for using GCC
find_program(CMAKE_C_COMPILER gcc)
find_program(CMAKE_GCOV gcov)

View file

@ -3,6 +3,7 @@
set_ifndef(CC gcc)
find_program(CMAKE_C_COMPILER ${CROSS_COMPILE}${CC} PATHS ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
find_program(CMAKE_GCOV ${CROSS_COMPILE}gcov PATHS ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
if(CMAKE_C_COMPILER STREQUAL CMAKE_C_COMPILER-NOTFOUND)
message(FATAL_ERROR "Zephyr was unable to find the toolchain. Is the environment misconfigured?