aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorRaef Coles <raef.coles@arm.com>2020-09-28 10:44:06 +0100
committerTamas Ban <tamas.ban@arm.com>2020-10-07 14:58:20 +0000
commit6e8f83d0381a7561c38deb7bb4ef868d86ac10ea (patch)
treedca4a1989240472c823cf9bcba07508247d48385 /CMakeLists.txt
parentd9d63e1ba9b2db291306c0dca7e87d138c0808fc (diff)
downloadtrusted-firmware-m-6e8f83d0381a7561c38deb7bb4ef868d86ac10ea.tar.gz
Build: Add error when bad options are given
When either of the two required input paramters (CMAKE_TOOLCHAIN_FILE and TFM_PLATFORM) are given, validate that they are sane values and output a reasonable error message if they are not. Change-Id: Ie3a93ffed331e5ed66483f0b22c7875db469700c Signed-off-by: Raef Coles <raef.coles@arm.com>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt22
1 files changed, 14 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e00790a45..cd2d85f22 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,9 +10,22 @@ cmake_minimum_required(VERSION 3.13)
project("Trusted Firmware M" VERSION 1.1.0 LANGUAGES C ASM)
set(TFM_VERSION ${PROJECT_VERSION})
+if(NOT TFM_CMAKE_TOOLCHAIN_FILE_LOADED)
+ Message(FATAL_ERROR "Cmake toolchain file not set.")
+endif()
+
+if(NOT ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles" AND
+ NOT ${CMAKE_GENERATOR} STREQUAL "Ninja")
+ Message(FATAL_ERROR "Unsupported generator ${CMAKE_GENERATOR}. Hint: Try -G\"Unix Makefiles\"")
+endif()
+
# Some compiler flags depend on the CPU / platform config. This include should
# be run before anything else so the compiler can be configured properly.
-include(platform/ext/target/${TFM_PLATFORM}/preload.cmake)
+if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/preload.cmake)
+ Message(FATAL_ERROR "Unsupported TFM_PLATFORM ${TFM_PLATFORM}")
+else()
+ include(platform/ext/target/${TFM_PLATFORM}/preload.cmake)
+endif()
# The default build type is release. If debug symbols are needed then
# -DCMAKE_BUILD_TYPE=debug should be used (likewise with other build types)
@@ -20,13 +33,6 @@ if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type: [Debug, Release, RelWithDebInfo, MinSizeRel]" FORCE)
endif()
-if(
- NOT ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles" AND
- NOT ${CMAKE_GENERATOR} STREQUAL "Ninja"
-)
- Message(FATAL_ERROR "unsupported generator ${CMAKE_GENERATOR}. Hint: Try -G\"Unix Makefiles\"")
-endif()
-
############################ CONFIGURATION #####################################
# First load defaults.