From bb6a6e8fcca039f95d5aa0113b258e285c7504f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B8e?= Date: Fri, 27 Sep 2019 14:05:53 +0200 Subject: [PATCH] cmake: Move the invocation of 'project' earlier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The CMake documentation for 'project' states "Call the project() command near the top of the top-level CMakeLists.txt". Meaning, it should be run as early as possible. An obscure internal error was observed when 'project' was located in zephyr/CMakeLists.txt and was observed to be fixed after moving 'project' earlier, hence this patch that moves it earlier. Invoking project depends on knowing information about the toolchain so it is placed after target_toolchain.cmake. Signed-off-by: Sebastian Bøe --- CMakeLists.txt | 2 -- cmake/app/boilerplate.cmake | 9 +++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index be0c0fa5c3d..6fbd2f38dd8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,8 +35,6 @@ endif() # For Zephyr more specifically this breaks (at least) # -fmacro-prefix-map=${ZEPHYR_BASE}= -project(Zephyr-Kernel VERSION ${PROJECT_VERSION}) -enable_language(C CXX ASM) # Verify that the toolchain can compile a dummy file, if it is not we # won't be able to test for compatibility with certain C flags. diff --git a/cmake/app/boilerplate.cmake b/cmake/app/boilerplate.cmake index e044e9be61c..b4fbc1182f1 100644 --- a/cmake/app/boilerplate.cmake +++ b/cmake/app/boilerplate.cmake @@ -470,6 +470,15 @@ endif() include(${ZEPHYR_BASE}/cmake/target_toolchain.cmake) +project(Zephyr-Kernel VERSION ${PROJECT_VERSION}) +enable_language(C CXX ASM) + +# 'project' sets PROJECT_BINARY_DIR to ${CMAKE_CURRENT_BINARY_DIR}, +# but for legacy reasons we need it to be set to +# ${CMAKE_CURRENT_BINARY_DIR}/zephyr +set(PROJECT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/zephyr) +set(PROJECT_SOURCE_DIR ${ZEPHYR_BASE}) + set(KERNEL_NAME ${CONFIG_KERNEL_BIN_NAME}) set(KERNEL_ELF_NAME ${KERNEL_NAME}.elf)