cmake: doc: created a doc.cmake CMake module in Zephyr CMake modules dir

Creating a doc.cmake to the new Zephyr CMake modules dir.

This removes the need for `set(NO_BOILERPLATE TRUE)` before loading the
Zephyr CMake package.

It also removes the need within the doc/CMakeLists.txt file to manually
include individual parts of the Zephyr CMake files as this is now
controlled through a single Zephyr CMake doc module.

This aligns the way a Zephyr package is sourced with other places.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
Torsten Rasmussen 2021-12-17 13:15:42 +01:00 committed by Marti Bolivar
parent e4ccde3774
commit 604f705fda
2 changed files with 25 additions and 12 deletions

24
cmake/modules/doc.cmake Normal file
View file

@ -0,0 +1,24 @@
# SPDX-License-Identifier: Apache-2.0
#
# Copyright (c) 2021, Nordic Semiconductor ASA
# This CMake module will load all Zephyr CMake modules required for a
# documentation build.
#
# The following CMake modules will be loaded:
# - extensions
# - python
# - west
# - root
# - zephyr_module
#
# Outcome:
# The Zephyr package required for documentation build setup.
include_guard(GLOBAL)
include(extensions)
include(python)
include(west)
include(root)
include(zephyr_module)

View file

@ -3,8 +3,7 @@
cmake_minimum_required(VERSION 3.20.0)
project(Zephyr-Kernel-Doc LANGUAGES)
set(NO_BOILERPLATE TRUE)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE} ..)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE} .. COMPONENTS doc)
file(TO_CMAKE_PATH "${ZEPHYR_BASE}" ZEPHYR_BASE)
message(STATUS "Zephyr base: ${ZEPHYR_BASE}")
@ -37,11 +36,6 @@ if(NOT LATEX_PDFLATEX_FOUND OR NOT LATEXMK)
message(WARNING "LaTeX components not found. PDF build will not be available.")
endif()
include(${ZEPHYR_BASE}/cmake/python.cmake)
# Find west to (optionally) process modules for Kconfig
find_program(WEST west)
#-------------------------------------------------------------------------------
# Environment & Paths
@ -104,11 +98,6 @@ set_target_properties(
# kconfig
set(KCONFIG_BINARY_DIR ${CMAKE_BINARY_DIR}/Kconfig)
list(INSERT MODULE_EXT_ROOT 0 ${ZEPHYR_BASE})
file(MAKE_DIRECTORY ${KCONFIG_BINARY_DIR})
include(${ZEPHYR_BASE}/cmake/extensions.cmake)
include(${ZEPHYR_BASE}/cmake/zephyr_module.cmake)
foreach(module_name ${ZEPHYR_MODULE_NAMES})
zephyr_string(SANITIZE TOUPPER MODULE_NAME_UPPER ${module_name})