cmake: Added possibility to disable the printing of version

When ZephyrConfig package is being version checked, then
ZephyrConfigVersion.cmake loads version.cmake.

This causes a print message, such as the following to happen:
-- Zephyr version: 2.2.0

Now, in case a user has multiple Zephyr installations, this could
result in something similar to:
-- Zephyr version: 2.2.0
-- Zephyr version: 2.x.0
-- Zephyr version: 3.x.0
being printed.

This commit add the possibility to disable version printing.

With new Zephyr base find_package, printing of ZEPHYR_BASE is added
after the version, in order to make it easy for users to see which
Zephyr is used.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>

suggested change: print ZEPHYR_BASE
This commit is contained in:
Torsten Rasmussen 2020-02-14 14:16:06 +01:00 committed by Carles Cufí
commit 3dd96d8927
2 changed files with 7 additions and 1 deletions

View file

@ -61,7 +61,9 @@ endif()
set(PROJECT_VERSION_STR ${PROJECT_VERSION}${PROJECT_VERSION_EXTRA_STR})
message(STATUS "Zephyr version: ${PROJECT_VERSION_STR}")
if (NOT NO_PRINT_VERSION)
message(STATUS "Zephyr version: ${PROJECT_VERSION_STR} (${ZEPHYR_BASE})")
endif()
set(MAJOR ${PROJECT_VERSION_MAJOR}) # Temporary convenience variable
set(MINOR ${PROJECT_VERSION_MINOR}) # Temporary convenience variable

View file

@ -29,6 +29,10 @@ endif()
# Temporary set local Zephyr base to allow using version.cmake to find this Zephyr tree current version
set(ZEPHYR_BASE ${CMAKE_CURRENT_LIST_DIR}/../../..)
# Tell version.cmake to not print as printing version for all Zephyr installations being tested
# will lead to confusion on which is being used.
set(NO_PRINT_VERSION True)
include(${ZEPHYR_BASE}/cmake/version.cmake)
set(ZEPHYR_BASE)