1# SPDX-License-Identifier: Apache-2.0
2
3# Purpose of this CMake file is to install a ZephyrUnittestConfig package reference in:
4# Unix/Linux/MacOS: ~/.cmake/packages/ZephyrUnittest
5# Windows         : HKEY_CURRENT_USER
6#
7# Having ZephyrUnittestConfig package allows for find_package(ZephyrUnittest) to work when ZEPHYR_BASE is not defined.
8#
9# Create the reference by running `cmake -P zephyr_export.cmake` in this directory.
10
11string(MD5 MD5_SUM ${CMAKE_CURRENT_LIST_DIR})
12if(WIN32)
13  execute_process(COMMAND ${CMAKE_COMMAND}
14                  -E  write_regv
15                 "HKEY_CURRENT_USER\\Software\\Kitware\\CMake\\Packages\\ZephyrUnittest\;${MD5_SUM}" "${CMAKE_CURRENT_LIST_DIR}"
16)
17else()
18  file(WRITE $ENV{HOME}/.cmake/packages/ZephyrUnittest/${MD5_SUM} ${CMAKE_CURRENT_LIST_DIR})
19endif()
20
21message("ZephyrUnittest (${CMAKE_CURRENT_LIST_DIR})")
22message("has been added to the user package registry in:")
23if(WIN32)
24  message("HKEY_CURRENT_USER\\Software\\Kitware\\CMake\\Packages\\ZephyrUnittest\n")
25else()
26  message("~/.cmake/packages/ZephyrUnittest\n")
27endif()
28
29file(REMOVE ${CMAKE_CURRENT_LIST_DIR}/${MD5_INFILE})
30