cmake: support ZephyrBuildConfiguration_ROOT for package location

Fixes: #35890

The current implementation of Zephyr build configuration CMake package
only allows the build configuration package to be placed inside a
Zephyr workspace.

This commit extends the usability by allowing users to locate the
Zephyr build configuration CMake package outside the Zephyr workspace
and then refer to the package using
`-DZephyrBuildConfiguration_ROOT=<path>`
`set(ZephyrBuildConfiguration_ROOT <path>)`

This allows users greater flexibility in their workspace layouts.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
Torsten Rasmussen 2021-06-03 10:20:03 +02:00 committed by Kumar Gala
parent fac1a5e09e
commit 489a69c092

View file

@ -128,7 +128,17 @@ if((NOT DEFINED ZEPHYR_BASE) AND (DEFINED ENV_ZEPHYR_BASE))
set(ZEPHYR_BASE ${ENV_ZEPHYR_BASE} CACHE PATH "Zephyr base")
endif()
find_package(ZephyrBuildConfiguration NAMES ZephyrBuild PATHS ${ZEPHYR_BASE}/../* QUIET NO_DEFAULT_PATH NO_POLICY_SCOPE)
find_package(ZephyrBuildConfiguration
QUIET NO_POLICY_SCOPE
NAMES ZephyrBuild
PATHS ${ZEPHYR_BASE}/../*
NO_CMAKE_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_PACKAGE_REGISTRY
NO_CMAKE_SYSTEM_PATH
NO_CMAKE_SYSTEM_PACKAGE_REGISTRY
)
# Note any later project() resets PROJECT_SOURCE_DIR
file(TO_CMAKE_PATH "${ZEPHYR_BASE}" PROJECT_SOURCE_DIR)