cmake: Relocating Zephyr Unittest CMake package.
Fixes: #23872
Relocating Zephyr Unittest CMake package to ensure that
HINTS ${ZEPHYR_BASE} in
find_package(ZephyrUnittest HINTS ${ZEPHYR_BASE}) works correctly when
the package has not been exported to CMake user package registry.
This ensure that the new package functionality is fully backwards
compatible on systems where the package is not exported and ZEPHYR_BASE
is set.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
diff --git a/scripts/west_commands/export.py b/scripts/west_commands/export.py
index fa753d8..f4f8367 100644
--- a/scripts/west_commands/export.py
+++ b/scripts/west_commands/export.py
@@ -47,7 +47,7 @@
lines = run_cmake(cmake_args, capture_output=True)
# Let's clean up, as Zephyr has now been exported, and we no longer
- # need the generated files.
+ # need the generated files.
cmake_args = ['--build', f'{zephyr_config_package_path}',
'--target', 'pristine']
run_cmake(cmake_args, capture_output=True)
@@ -56,3 +56,21 @@
# the important information.
msg = [line for line in lines if not line.startswith('-- ')]
print('\n'.join(msg))
+
+ zephyr_unittest_config_package_path = PurePath(__file__).parents[2] \
+ / 'share' / 'zephyrunittest-package' / 'cmake'
+
+ cmake_args = ['-S', f'{zephyr_unittest_config_package_path}',
+ '-B', f'{zephyr_unittest_config_package_path}']
+ lines = run_cmake(cmake_args, capture_output=True)
+
+ # Let's clean up, as Zephyr has now been exported, and we no longer
+ # need the generated files.
+ cmake_args = ['--build', f'{zephyr_unittest_config_package_path}',
+ '--target', 'pristine']
+ run_cmake(cmake_args, capture_output=True)
+
+ # Let's ignore the normal CMake printing and instead only print
+ # the important information.
+ msg = [line for line in lines if not line.startswith('-- ')]
+ print('\n'.join(msg))