aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorRaef Coles <raef.coles@arm.com>2020-10-19 14:14:14 +0100
committerSoby Mathew <soby.mathew@arm.com>2020-11-03 10:26:38 +0000
commit698173275839bbe1f724e3f8c580578fdf3371d3 (patch)
treee78e879cf9d8b9760c1c4d4ebb6cb9a36b1b35c8 /CMakeLists.txt
parent940ac5111a7d7bcba94dbe5e977206b8643b0dad (diff)
downloadtrusted-firmware-m-698173275839bbe1f724e3f8c580578fdf3371d3.tar.gz
Build: Refactor toolchain files
Change from a CMAKE toolchain file to a TFM toolchain file, avoiding some abuses of the CMAKE_TOOLCHAIN_FILE that were used as a workaround for compiler setup. Also add the CROSS_COMPILE variable. Bump cmake required version to 3.15. Change-Id: I0948033045e2d2f34beffa807925fc7375098335 Signed-off-by: Raef Coles <raef.coles@arm.com>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt65
1 files changed, 39 insertions, 26 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fdd84469e..5368f8eb7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,33 +5,9 @@
#
#-------------------------------------------------------------------------------
-cmake_minimum_required(VERSION 3.13)
+cmake_minimum_required(VERSION 3.15)
-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.
-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)
-if (NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type: [Debug, Release, RelWithDebInfo, MinSizeRel]" FORCE)
-endif()
+set(TFM_VERSION 1.1.0)
############################ CONFIGURATION #####################################
@@ -77,6 +53,43 @@ endif()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
+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()
+
+# The default build type is release. If debug symbols are needed then
+# -DCMAKE_BUILD_TYPE=debug should be used (likewise with other build types)
+if (NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type: [Debug, Release, RelWithDebInfo, MinSizeRel]" FORCE)
+endif()
+
+list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
+
+############################### Compiler configuration #########################
+
+# Some compiler flags depend on the CPU / platform config. This include should
+# be run before the toolchain file so the compiler can be configured properly.
+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()
+
+#Legacy compat option - load CMAKE_TOOLCHAIN_FILE as a TFM_TOOLCHAIN_FILE
+if (CMAKE_TOOLCHAIN_FILE)
+ message(DEPRECATION "SETTING CMAKE_TOOLCHAIN_FILE is deprecated. It has been replaced with TFM_TOOLCHAIN_FILE.")
+ message(DEPRECATION "INTERPRETING -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} as -DTFM_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
+ set(TFM_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE})
+ unset(CMAKE_TOOLCHAIN_FILE)
+endif()
+
+include(${TFM_TOOLCHAIN_FILE})
+set(CMAKE_PROJECT_INCLUDE_BEFORE ${CMAKE_SOURCE_DIR}/cmake/disable_compiler_detection.cmake)
+
+project("Trusted Firmware M" VERSION ${TFM_VERSION} LANGUAGES C ASM)
+tfm_toolchain_reload_compiler()
+
################################################################################
add_subdirectory(lib/ext)