Split cmsis_startup into _startup and _system

In order to get better control of the cmsis startup build for secure and
nonsecure worlds, the cmsis_startup OBJECT library is split up into two
INTERFACE libraries that can be configured and built per executable.

Change-Id: I21b6f6af75f9c23e920525ce6c23677f0607745c
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fcb9605..9d20c14 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,15 +38,6 @@
 set(CORE_SOFTWARE_RTOS "None" CACHE STRING "Select RTOS to include. (None, MbedOS, FreeRTOS, Zephyr)")
 string(TOLOWER ${CORE_SOFTWARE_RTOS} CORE_SOFTWARE_RTOS_LOWER)
 
-# Set trustzone options
-set(TRUSTZONE_BUILD OFF CACHE BOOL "Enable TrustZone build")
-if (TRUSTZONE_BUILD)
-    set(TRUSTZONE_SIDE "secure" CACHE STRING "Select secure or nonsecure")
-    set_property(CACHE TRUSTZONE_SIDE PROPERTY STRINGS secure nonsecure)
-    set(TRUSTZONE_PARTITION_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" CACHE
-        FILEPATH "Path to CMSIS partion header for device")
-endif()
-
 #
 # Build
 #
diff --git a/cmsis.cmake b/cmsis.cmake
index 9322240..b5b6726 100644
--- a/cmsis.cmake
+++ b/cmsis.cmake
@@ -43,43 +43,24 @@
 # CMSIS device
 add_library(cmsis_device INTERFACE)
 target_include_directories(cmsis_device INTERFACE ${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Include)
-if (TRUSTZONE_BUILD)
-    # Use Cortex-M Secure Extension when compiling
-    target_compile_options(cmsis_device INTERFACE -mcmse)
-    target_compile_definitions(cmsis_device INTERFACE TRUSTZONE_BUILD)
-    if (TRUSTZONE_SIDE STREQUAL secure)
-        target_compile_definitions(cmsis_device INTERFACE TRUSTZONE_SECURE)
-    else()
-        target_compile_definitions(cmsis_device INTERFACE TRUSTZONE_NONSECURE)
-    endif()
-endif()
+
 target_compile_options(cmsis_device INTERFACE -include${ARM_CPU}${ARM_FEATURES}.h)
 target_link_libraries(cmsis_device INTERFACE cmsis_core)
 
 # CMSIS startup
-add_library(cmsis_startup STATIC)
-if (TRUSTZONE_BUILD)
-    if (TRUSTZONE_SIDE STREQUAL secure)
-        target_sources(cmsis_startup PRIVATE
-            ${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Source/startup_${ARM_CPU}.c
-            ${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Source/system_${ARM_CPU}.c)
-        # Bring in the partion header
-        target_include_directories(cmsis_startup PRIVATE ${TRUSTZONE_PARTITION_DIRECTORY})
-    elseif(TRUSTZONE_SIDE STREQUAL nonsecure)
-        target_sources(cmsis_startup PRIVATE
-            ${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Source/startup_${ARM_CPU}.c)
-    endif()
-else()
-    target_sources(cmsis_startup PRIVATE
-        ${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Source/startup_${ARM_CPU}.c
-        ${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Source/system_${ARM_CPU}.c)
-endif()
+add_library(cmsis_startup INTERFACE)
+target_sources(cmsis_startup INTERFACE
+    ${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Source/startup_${ARM_CPU}.c)
 
-set_source_files_properties(${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Source/startup_${ARM_CPU}.c PROPERTIES COMPILE_FLAGS
-    -Wno-redundant-decls)
+set_source_files_properties(${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Source/startup_${ARM_CPU}.c
+    PROPERTIES COMPILE_FLAGS -Wno-redundant-decls)
 
-target_compile_definitions(cmsis_startup PRIVATE ${ARM_CPU}${ARM_FEATURES})
-target_link_libraries(cmsis_startup PRIVATE cmsis_device)
+target_compile_definitions(cmsis_startup INTERFACE ${ARM_CPU}${ARM_FEATURES})
+target_link_libraries(cmsis_startup INTERFACE cmsis_device)
 
-# Install libraries
-install(TARGETS cmsis_startup LIBRARY DESTINATION "lib")
+# CMSIS system
+add_library(cmsis_system INTERFACE)
+target_sources(cmsis_system INTERFACE
+    ${CMSIS_PATH}/Device/ARM/${ARM_CPU}/Source/system_${ARM_CPU}.c)
+target_compile_definitions(cmsis_system INTERFACE ${ARM_CPU}${ARM_FEATURES})
+target_link_libraries(cmsis_system INTERFACE cmsis_startup)