From 48f97ecf463d642297f61ac8b2ce3748469b98b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B8e?= Date: Thu, 5 Sep 2019 17:34:10 +0200 Subject: [PATCH] cmake: Error-out when 'project' is invoked too early MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Error-out when 'project' is invoked before boilerplate.cmake is included. This is not supported and causes obscure errors. Signed-off-by: Sebastian Bøe --- cmake/app/boilerplate.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmake/app/boilerplate.cmake b/cmake/app/boilerplate.cmake index b0920b1d955..73e5cc48de8 100644 --- a/cmake/app/boilerplate.cmake +++ b/cmake/app/boilerplate.cmake @@ -28,6 +28,14 @@ cmake_policy(SET CMP0002 NEW) # CMP0079: "target_link_libraries() allows use with targets in other directories" cmake_policy(SET CMP0079 OLD) +# Error-out if 'project' has been invoked to avoid obscure user +# errors. +if(DEFINED CMAKE_PROJECT_NAME) + message(FATAL_ERROR + "'project()' was called before boilerplate.cmake was included, this is not supported." + ) +endif() + define_property(GLOBAL PROPERTY ZEPHYR_LIBS BRIEF_DOCS "Global list of all Zephyr CMake libs that should be linked in" FULL_DOCS "Global list of all Zephyr CMake libs that should be linked in.