CMake: Clean up TFM_LVL configuration

Details:
 - Configure TFM_LVL only in CommonConfig.cmake

Change-Id: I4374e15556af1d4b277b8e88279e47ecafbcfc66
Signed-off-by: Tamas Ban <tamas.ban@arm.com>
diff --git a/CommonConfig.cmake b/CommonConfig.cmake
index b70ad71..4a198ef 100755
--- a/CommonConfig.cmake
+++ b/CommonConfig.cmake
@@ -104,6 +104,9 @@
 # Option to demonstrate usage of secure-only peripheral
 set (SECURE_UART1 OFF)
 
+# TF-M isolation level: 1..3, default is 1
+set (TFM_LVL 1)
+
 if (REGRESSION)
 	set(SERVICES_TEST_ENABLED ON)
 else()
@@ -121,6 +124,7 @@
 if (CORE_TEST)
 	set(CORE_TEST_POSITIVE ON)
 	set(CORE_TEST_INTERACTIVE OFF)
+	set(TFM_LVL 3)
 endif()
 
 if (CORE_TEST_INTERACTIVE)
diff --git a/secure_fw/CMakeLists.txt b/secure_fw/CMakeLists.txt
index ddb9a26..9645b80 100644
--- a/secure_fw/CMakeLists.txt
+++ b/secure_fw/CMakeLists.txt
@@ -23,10 +23,8 @@
 set(TEST_DIR      "${TFM_ROOT_DIR}/test")
 set(INTERFACE_DIR "${TFM_ROOT_DIR}/interface")
 
-if(CORE_TEST)
-	set(TFM_LVL 3)
-else()
-	set(TFM_LVL 1)
+if (NOT DEFINED TFM_LVL)
+	message(FATAL_ERROR "Incomplete build configuration: TFM_LVL is undefined. ")
 endif()
 
 include(${SECURE_FW_DIR}/spm/CMakeLists.inc)
diff --git a/secure_fw/services/audit_logging/CMakeLists.txt b/secure_fw/services/audit_logging/CMakeLists.txt
index 7bdf17d..d864d47 100644
--- a/secure_fw/services/audit_logging/CMakeLists.txt
+++ b/secure_fw/services/audit_logging/CMakeLists.txt
@@ -34,11 +34,8 @@
 set (ENABLE_AUDIT_LOGGING ON)
 include(CMakeLists.inc)
 
-###Configure how we build our target
-if(DEFINED CORE_TEST)
-	set (TFM_LVL 3)
-else()
-	set (TFM_LVL 1)
+if (NOT DEFINED TFM_LVL)
+	message(FATAL_ERROR "Incomplete build configuration: TFM_LVL is undefined. ")
 endif()
 
 #Set build type for mbedtls libraries
diff --git a/secure_fw/services/secure_storage/CMakeLists.txt b/secure_fw/services/secure_storage/CMakeLists.txt
index 1db9482..dafeea6 100644
--- a/secure_fw/services/secure_storage/CMakeLists.txt
+++ b/secure_fw/services/secure_storage/CMakeLists.txt
@@ -34,11 +34,8 @@
 set (ENABLE_SECURE_STORAGE ON)
 include(CMakeLists.inc)
 
-###Configure how we build our target
-if(DEFINED CORE_TEST)
-	set (TFM_LVL 3)
-else()
-	set (TFM_LVL 1)
+if (NOT DEFINED TFM_LVL)
+	message(FATAL_ERROR "Incomplete build configuration: TFM_LVL is undefined. ")
 endif()
 
 #Set build type for mbedtls libraries
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 5202ef8..27a50d8 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -25,14 +25,16 @@
 	message(FATAL_ERROR "Incomplete build configuration: SERVICES_TEST_ENABLED is undefined. ")
 endif()
 
-if (NOT DEFINED CORE_TEST)
-	message(FATAL_ERROR "Incomplete build configuration: CORE_TEST is undefined. ")
+if (NOT DEFINED CORE_TEST_INTERACTIVE)
+	message(FATAL_ERROR "Incomplete build configuration: CORE_TEST_INTERACTIVE is undefined. ")
 endif()
 
-if(CORE_TEST)
-	set (TFM_LVL 3)
-else()
-	set (TFM_LVL 1)
+if (NOT DEFINED CORE_TEST_POSITIVE)
+	message(FATAL_ERROR "Incomplete build configuration: CORE_TEST_POSITIVE is undefined. ")
+endif()
+
+if (NOT DEFINED TFM_LVL)
+	message(FATAL_ERROR "Incomplete build configuration: TFM_LVL is undefined. ")
 endif()
 
 #Configure our options as needed.
@@ -84,6 +86,5 @@
 		DESTINATION export/tfm/test/lib
 		PUBLIC_HEADER DESTINATION export/tfm/test/inc)
 
-
 embedded_project_end(tfm_non_secure_tests)
 embedded_project_end(tfm_secure_tests)