Skip to content

Commit 8829e82

Browse files
tejlmandcarlescufi
authored andcommitted
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>
1 parent caf596e commit 8829e82

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

share/zephyr-package/cmake/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ if(NOT (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_LIST_DIR))
1515
message(WARNING "\$\{CMAKE_BINARY_DIR\} is different from \$\{CMAKE_CURRENT_LIST_DIR\}, Zephyr config package may not work as expected.")
1616
endif()
1717

18-
message("Zephyr (${CMAKE_CURRENT_LIST_DIR})")
18+
message("Zephyr and ZephyrUnitTest (${CMAKE_CURRENT_LIST_DIR})")
1919
message("has been added to the user package registry in:")
2020
if(WIN32)
2121
message("HKEY_CURRENT_USER\\Software\\Kitware\\CMake\\Packages\\Zephyr")
22+
message("HKEY_CURRENT_USER\\Software\\Kitware\\CMake\\Packages\\ZephyrUnitTest")
2223
else()
2324
message("~/.cmake/packages/Zephyr")
25+
message("~/.cmake/packages/ZephyrUnitTest")
2426
endif()
2527

2628
export(PACKAGE Zephyr)

share/zephyr-package/cmake/ZephyrConfig.cmake

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,17 @@
1313
include(${CMAKE_CURRENT_LIST_DIR}/zephyr_package_search.cmake)
1414

1515
macro(include_boilerplate location)
16-
set(Zephyr_FOUND True)
16+
if(ZEPHYR_UNITTEST)
17+
set(ZephyrUnittest_FOUND True)
18+
set(BOILERPLATE_FILE ${ZEPHYR_BASE}/subsys/testsuite/unittest.cmake)
19+
else()
20+
set(Zephyr_FOUND True)
21+
set(BOILERPLATE_FILE ${ZEPHYR_BASE}/cmake/app/boilerplate.cmake)
22+
endif()
23+
1724
if(NOT NO_BOILERPLATE)
18-
message("Including boilerplate (${location}): ${ZEPHYR_BASE}/cmake/app/boilerplate.cmake")
19-
include(${ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
25+
message("Including boilerplate (${location}): ${BOILERPLATE_FILE}")
26+
include(${BOILERPLATE_FILE} NO_POLICY_SCOPE)
2027
endif()
2128
endmacro()
2229

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
set(ZEPHYR_UNITTEST TRUE)
4+
include(${CMAKE_CURRENT_LIST_DIR}/ZephyrConfig.cmake)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
include(${CMAKE_CURRENT_LIST_DIR}/ZephyrConfigVersion.cmake)

0 commit comments

Comments
 (0)