2019-04-06 21:08:09 +08:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2019-02-05 17:36:22 +08:00
|
|
|
# This cmake file provides functionality to import additional out-of-tree, OoT
|
|
|
|
# CMakeLists.txt and Kconfig files into Zephyr build system.
|
|
|
|
# It uses -DZEPHYR_MODULES=<oot-path-to-module>[;<additional-oot-module(s)>]
|
|
|
|
# given to CMake for a list of folders to search.
|
|
|
|
# It looks for: <oot-module>/zephyr/module.yml or
|
|
|
|
# <oot-module>/zephyr/CMakeLists.txt
|
|
|
|
# to load the oot-module into Zephyr build system.
|
|
|
|
# If west is available, it uses `west list` to obtain a list of projects to
|
|
|
|
# search for zephyr/module.yml
|
|
|
|
|
|
|
|
if(ZEPHYR_MODULES)
|
2019-03-19 17:38:18 +08:00
|
|
|
set(ZEPHYR_MODULES_ARG "--modules" ${ZEPHYR_MODULES})
|
2019-02-05 17:36:22 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ZEPHYR_EXTRA_MODULES)
|
2019-03-19 17:38:18 +08:00
|
|
|
set(ZEPHYR_EXTRA_MODULES_ARG "--extra-modules" ${ZEPHYR_EXTRA_MODULES})
|
2019-02-05 17:36:22 +08:00
|
|
|
endif()
|
|
|
|
|
2019-03-30 14:35:12 +08:00
|
|
|
set(KCONFIG_MODULES_FILE ${CMAKE_BINARY_DIR}/Kconfig.modules)
|
|
|
|
|
2019-04-25 18:27:17 +08:00
|
|
|
if(WEST)
|
2020-02-19 19:01:39 +08:00
|
|
|
set(WEST_ARG "--west-path" ${WEST} "--zephyr-base" ${ZEPHYR_BASE})
|
2019-04-25 18:27:17 +08:00
|
|
|
endif()
|
|
|
|
|
2019-03-19 17:38:18 +08:00
|
|
|
if(WEST OR ZEPHYR_MODULES)
|
|
|
|
# Zephyr module uses west, so only call it if west is installed or
|
|
|
|
# ZEPHYR_MODULES was provided as argument to CMake.
|
|
|
|
execute_process(
|
|
|
|
COMMAND
|
|
|
|
${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/zephyr_module.py
|
2019-04-25 18:27:17 +08:00
|
|
|
${WEST_ARG}
|
2019-03-19 17:38:18 +08:00
|
|
|
${ZEPHYR_MODULES_ARG}
|
|
|
|
${ZEPHYR_EXTRA_MODULES_ARG}
|
2019-03-30 14:35:12 +08:00
|
|
|
--kconfig-out ${KCONFIG_MODULES_FILE}
|
2019-03-19 17:38:18 +08:00
|
|
|
--cmake-out ${CMAKE_BINARY_DIR}/zephyr_modules.txt
|
|
|
|
ERROR_VARIABLE
|
|
|
|
zephyr_module_error_text
|
|
|
|
RESULT_VARIABLE
|
|
|
|
zephyr_module_return
|
2019-02-05 17:36:22 +08:00
|
|
|
)
|
|
|
|
|
2019-03-19 17:38:18 +08:00
|
|
|
if(${zephyr_module_return})
|
|
|
|
message(FATAL_ERROR "${zephyr_module_error_text}")
|
2019-02-05 17:36:22 +08:00
|
|
|
endif()
|
2019-03-30 14:35:12 +08:00
|
|
|
|
|
|
|
else()
|
|
|
|
|
|
|
|
file(WRITE ${KCONFIG_MODULES_FILE}
|
|
|
|
"# No west and no modules\n"
|
|
|
|
)
|
|
|
|
|
2019-03-19 17:38:18 +08:00
|
|
|
endif()
|