2021-12-16 17:13:54 +01:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
#
|
|
|
|
# Copyright (c) 2021, Nordic Semiconductor ASA
|
|
|
|
|
|
|
|
# This CMake module will load all Zephyr CMake modules in correct order for
|
|
|
|
# default Zephyr build system.
|
|
|
|
#
|
|
|
|
# Outcome:
|
|
|
|
# See individual CMake module descriptions
|
|
|
|
|
|
|
|
include_guard(GLOBAL)
|
|
|
|
|
|
|
|
# The code line below defines the real minimum supported CMake version.
|
|
|
|
#
|
|
|
|
# Unfortunately CMake requires the toplevel CMakeLists.txt file to define the
|
|
|
|
# required version, not even invoking it from a CMake module is sufficient.
|
|
|
|
# It is however permitted to have multiple invocations of cmake_minimum_required.
|
|
|
|
cmake_minimum_required(VERSION 3.20.0)
|
|
|
|
|
|
|
|
message(STATUS "Application: ${APPLICATION_SOURCE_DIR}")
|
|
|
|
|
2022-12-22 05:28:07 +01:00
|
|
|
# Different CMake versions can have very subtle differences, for
|
|
|
|
# instance CMake 3.21 links object files in a different order compared
|
|
|
|
# to CMake 3.20; this produces different binaries.
|
|
|
|
message(STATUS "CMake version: ${CMAKE_VERSION}")
|
|
|
|
|
2023-07-24 00:46:02 +02:00
|
|
|
# Find and execute workspace build configuration
|
2021-12-16 17:13:54 +01:00
|
|
|
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
|
2023-07-24 00:46:02 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
# Find and execute application-specific build configuration
|
|
|
|
find_package(ZephyrAppConfiguration
|
|
|
|
QUIET NO_POLICY_SCOPE
|
|
|
|
NAMES ZephyrApp
|
|
|
|
PATHS ${APPLICATION_SOURCE_DIR}
|
|
|
|
NO_CMAKE_PATH
|
|
|
|
NO_CMAKE_ENVIRONMENT_PATH
|
|
|
|
NO_SYSTEM_ENVIRONMENT_PATH
|
|
|
|
NO_CMAKE_PACKAGE_REGISTRY
|
|
|
|
NO_CMAKE_SYSTEM_PATH
|
|
|
|
NO_CMAKE_SYSTEM_PACKAGE_REGISTRY
|
2021-12-16 17:13:54 +01:00
|
|
|
)
|
|
|
|
|
cmake: test CMake and issue error if using 3.22.1 / 3.22.2 from PyPI
Fixes: #43099
The CMake 3.22.1 / 3.22.2 PyPI version suffers a bug in the
`cmake_path(... PARENT_PATH)` implementation.
Therefore, when CMake version 3.22.1 / 3.22.2 is detected, test if the
CMake version is suffering from the bug, and in case the bug is present,
fail with an error regarding the issue.
The reason for failing, and not implementing work arounds is that Zephyr
already uses `cmake_path()` at two locations, and we cannot prevent
contributors from adding code which uses this function.
Secondly, Zephyr modules may also use `cmake_path()`, and thus be
affected by said bug.
It is impractical to implement work arounds at all possible locations
for something that is a CMake bug.
Therefore the safest solution is to test CMake itself, to check if the
version in use suffers said bug, and fail with a proper error message
if an affected CMake version is used.
See more here:
https://gitlab.kitware.com/cmake/cmake/-/issues/23187
https://github.com/scikit-build/cmake-python-distributions/issues/221
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-02-24 12:21:11 +01:00
|
|
|
# Test and error-out if we are affected by the PyPI CMake 3.22.1 / 3.22.2 bug
|
|
|
|
if(${CMAKE_VERSION} VERSION_EQUAL 3.22.1 OR ${CMAKE_VERSION} VERSION_EQUAL 3.22.2)
|
|
|
|
# It seems only pip-installed builds are affected so we test to see if we are affected
|
|
|
|
cmake_path(GET ZEPHYR_BASE PARENT_PATH test_cmake_path)
|
|
|
|
if(ZEPHYR_BASE STREQUAL test_cmake_path)
|
|
|
|
message(FATAL_ERROR "The CMake version ${CMAKE_VERSION} installed suffers"
|
|
|
|
" the \n 'cmake_path(... PARENT_PATH)' bug, see: \n"
|
|
|
|
"https://gitlab.kitware.com/cmake/cmake/-/issues/23187\n"
|
|
|
|
"https://github.com/scikit-build/cmake-python-distributions/issues/221\n"
|
|
|
|
"Please install another CMake version or use a build of CMake that"
|
|
|
|
" does not come from PyPI."
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2021-12-16 17:13:54 +01:00
|
|
|
# Prepare user cache
|
2022-02-03 12:10:53 +01:00
|
|
|
list(APPEND zephyr_cmake_modules python)
|
|
|
|
list(APPEND zephyr_cmake_modules user_cache)
|
2021-12-16 17:13:54 +01:00
|
|
|
|
|
|
|
# Load Zephyr extensions
|
2022-02-03 12:10:53 +01:00
|
|
|
list(APPEND zephyr_cmake_modules extensions)
|
|
|
|
list(APPEND zephyr_cmake_modules version)
|
2021-12-16 17:13:54 +01:00
|
|
|
|
2022-08-18 16:02:50 +02:00
|
|
|
# Load basic settings
|
|
|
|
list(APPEND zephyr_cmake_modules basic_settings)
|
|
|
|
|
2021-12-16 17:13:54 +01:00
|
|
|
#
|
|
|
|
# Find tools
|
|
|
|
#
|
|
|
|
|
2022-02-03 12:10:53 +01:00
|
|
|
list(APPEND zephyr_cmake_modules west)
|
|
|
|
list(APPEND zephyr_cmake_modules ccache)
|
2021-12-16 17:13:54 +01:00
|
|
|
|
|
|
|
# Load default root settings
|
2022-02-03 12:10:53 +01:00
|
|
|
list(APPEND zephyr_cmake_modules root)
|
2021-12-16 17:13:54 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Find Zephyr modules.
|
|
|
|
# Those may contain additional DTS, BOARD, SOC, ARCH ROOTs.
|
|
|
|
# Also create the Kconfig binary dir for generated Kconf files.
|
|
|
|
#
|
2022-02-03 12:10:53 +01:00
|
|
|
list(APPEND zephyr_cmake_modules zephyr_module)
|
2021-12-16 17:13:54 +01:00
|
|
|
|
2022-02-03 12:10:53 +01:00
|
|
|
list(APPEND zephyr_cmake_modules boards)
|
|
|
|
list(APPEND zephyr_cmake_modules shields)
|
2023-01-07 01:49:23 +01:00
|
|
|
list(APPEND zephyr_cmake_modules snippets)
|
2022-09-14 22:23:15 +02:00
|
|
|
list(APPEND zephyr_cmake_modules arch_v1)
|
|
|
|
list(APPEND zephyr_cmake_modules hwm_v2)
|
2022-02-03 12:10:53 +01:00
|
|
|
list(APPEND zephyr_cmake_modules configuration_files)
|
2023-02-27 23:27:28 +01:00
|
|
|
list(APPEND zephyr_cmake_modules generated_file_directories)
|
2021-12-16 17:13:54 +01:00
|
|
|
|
|
|
|
# Include board specific device-tree flags before parsing.
|
2022-02-03 12:10:53 +01:00
|
|
|
set(pre_dt_board "\${BOARD_DIR}/pre_dt_board.cmake" OPTIONAL)
|
|
|
|
list(APPEND zephyr_cmake_modules "\${pre_dt_board}")
|
2021-12-16 17:13:54 +01:00
|
|
|
|
|
|
|
# DTS should be close to kconfig because CONFIG_ variables from
|
|
|
|
# kconfig and dts should be available at the same time.
|
2022-02-03 12:10:53 +01:00
|
|
|
list(APPEND zephyr_cmake_modules dts)
|
|
|
|
list(APPEND zephyr_cmake_modules kconfig)
|
2022-09-14 22:23:15 +02:00
|
|
|
list(APPEND zephyr_cmake_modules arch_v2)
|
|
|
|
list(APPEND zephyr_cmake_modules soc_v1)
|
|
|
|
list(APPEND zephyr_cmake_modules soc_v2)
|
2022-02-03 12:10:53 +01:00
|
|
|
|
|
|
|
foreach(component ${SUB_COMPONENTS})
|
|
|
|
if(NOT ${component} IN_LIST zephyr_cmake_modules)
|
|
|
|
message(FATAL_ERROR
|
|
|
|
"Subcomponent '${component}' not default module for Zephyr CMake build system.\n"
|
|
|
|
"Please choose one or more valid components: ${zephyr_cmake_modules}"
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
foreach(module IN LISTS zephyr_cmake_modules)
|
|
|
|
# Ensures any module of type `${module}` are properly expanded to list before
|
|
|
|
# passed on the `include(${module})`.
|
|
|
|
# This is done twice to support cases where the content of `${module}` itself
|
|
|
|
# contains a variable, like `${BOARD_DIR}`.
|
|
|
|
string(CONFIGURE "${module}" module)
|
|
|
|
string(CONFIGURE "${module}" module)
|
|
|
|
include(${module})
|
|
|
|
|
|
|
|
list(REMOVE_ITEM SUB_COMPONENTS ${module})
|
|
|
|
if(DEFINED SUB_COMPONENTS AND NOT SUB_COMPONENTS)
|
|
|
|
# All requested Zephyr CMake modules have been loaded, so let's return.
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
2021-12-16 17:13:54 +01:00
|
|
|
include(kernel)
|