cmake: ZephyrUnittestConfig.cmake added

Adding ZephyrUnittestConfig.cmake and ZephyrUnittestConfigVersion.cmake
to allow unittest projects to use find_package to locate ZephyrUnittest.

This means that it will be possible to allow users to run CMake without
the need to source zephyr-env.sh or run zephyr-env.cmd.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
Torsten Rasmussen 2020-02-26 14:28:09 +01:00 committed by Carles Cufí
commit 8829e8237a
4 changed files with 20 additions and 4 deletions

View file

@ -15,12 +15,14 @@ if(NOT (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_LIST_DIR))
message(WARNING "\$\{CMAKE_BINARY_DIR\} is different from \$\{CMAKE_CURRENT_LIST_DIR\}, Zephyr config package may not work as expected.")
endif()
message("Zephyr (${CMAKE_CURRENT_LIST_DIR})")
message("Zephyr and ZephyrUnitTest (${CMAKE_CURRENT_LIST_DIR})")
message("has been added to the user package registry in:")
if(WIN32)
message("HKEY_CURRENT_USER\\Software\\Kitware\\CMake\\Packages\\Zephyr")
message("HKEY_CURRENT_USER\\Software\\Kitware\\CMake\\Packages\\ZephyrUnitTest")
else()
message("~/.cmake/packages/Zephyr")
message("~/.cmake/packages/ZephyrUnitTest")
endif()
export(PACKAGE Zephyr)

View file

@ -13,10 +13,17 @@
include(${CMAKE_CURRENT_LIST_DIR}/zephyr_package_search.cmake)
macro(include_boilerplate location)
set(Zephyr_FOUND True)
if(ZEPHYR_UNITTEST)
set(ZephyrUnittest_FOUND True)
set(BOILERPLATE_FILE ${ZEPHYR_BASE}/subsys/testsuite/unittest.cmake)
else()
set(Zephyr_FOUND True)
set(BOILERPLATE_FILE ${ZEPHYR_BASE}/cmake/app/boilerplate.cmake)
endif()
if(NOT NO_BOILERPLATE)
message("Including boilerplate (${location}): ${ZEPHYR_BASE}/cmake/app/boilerplate.cmake")
include(${ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
message("Including boilerplate (${location}): ${BOILERPLATE_FILE}")
include(${BOILERPLATE_FILE} NO_POLICY_SCOPE)
endif()
endmacro()

View file

@ -0,0 +1,4 @@
# SPDX-License-Identifier: Apache-2.0
set(ZEPHYR_UNITTEST TRUE)
include(${CMAKE_CURRENT_LIST_DIR}/ZephyrConfig.cmake)

View file

@ -0,0 +1,3 @@
# SPDX-License-Identifier: Apache-2.0
include(${CMAKE_CURRENT_LIST_DIR}/ZephyrConfigVersion.cmake)