aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorBhavik Patel <bhavik.patel@arm.com>2020-07-16 22:36:02 +0200
committerBhavik Patel <bhavik.patel@arm.com>2020-07-17 16:36:27 +0200
commitf50578199cca79b73596672a4838640130d1aa8f (patch)
tree738f2fa547eb622ac927157b822efc2781f5ab03 /CMakeLists.txt
parentdae5be07b76e5361593d8c2fa4717970c2a5fc19 (diff)
downloadethos-u-core-driver-f50578199cca79b73596672a4838640130d1aa8f.tar.gz
MLBEDSW-2596 Add support to set driver log severity
The driver can log at one of the following levels: 0=emerg, 1=alert, 2=crit, 3=err, 4=warning, 5=notice, 6=info, 7=debug. The logs at or below the set level are printed whereas the higher level logs are not printed. Change-Id: I05a498d4c8c78112207187d9dceaa2386b138c5d
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt26
1 files changed, 21 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4651cf2..0dab28f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,9 +25,9 @@ project(ethosu_core_driver VERSION 0.0.1)
#
option(DRIVER_PMU_AUTOINIT "Enable PMU boot auto-initialization" OFF)
-option(DRIVER_LOG_SUPPORT "Enable logging." OFF)
set(CMSIS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmsis" CACHE PATH "Path to CMSIS.")
+set(DRIVER_LOG_SEVERITY "6" CACHE STRING "Driver log severity level 0=emerg, 1=alert, 2=crit, 3=err, 4=warning, 5=notice, 6=info, 7=debug")
#
# Global settings
@@ -49,9 +49,12 @@ else()
message(FATAL_ERROR "Unsupported compiler ${CMAKE_SYSTEM_PROCESSOR}.")
endif()
-# Enable logging support
-if(DRIVER_LOG_SUPPORT)
- add_compile_definitions(LOG_ENABLED)
+# Check that DRIVER_LOG_SEVERITY has one of the supported
+# levels.
+set(LOG_SEVERITY_VALUE 0 1 2 3 4 5 6 7)
+set(LOG_SEVERITY_NAME EMERG ALERT CRIT ERR WARNING NOTICE INFO DEBUG)
+if(NOT ${DRIVER_LOG_SEVERITY} IN_LIST LOG_SEVERITY_VALUE)
+ message(FATAL_ERROR "Unsupported driver log severity level ${DRIVER_LOG_SEVERITY}")
endif()
# Enable PMU boot auto-initialization
@@ -72,6 +75,19 @@ add_library(ethosu_core_driver STATIC)
target_include_directories(ethosu_core_driver PUBLIC include)
target_sources(ethosu_core_driver PRIVATE src/ethosu_driver.c src/ethosu_device.c src/ethosu_pmu.c)
+# Set the DRIVER_LOG_SEVERITY level for the target
+target_compile_definitions(ethosu_core_driver PRIVATE DRIVER_LOG_SEVERITY=${DRIVER_LOG_SEVERITY})
+
+foreach(S IN ZIP_LISTS LOG_SEVERITY_VALUE LOG_SEVERITY_NAME)
+ # This will add a define in the form of LOG_SEVERITY_INFO=6.
+ # This is to make the conditional check like
+ # (DRIVER_LOG_SEVERITY >= LOG_SEVERITY_INFO) possible.
+ target_compile_definitions(ethosu_core_driver PRIVATE LOG_SEVERITY_${S_1}=${S_0})
+ if(${DRIVER_LOG_SEVERITY} STREQUAL ${S_0})
+ set(DRIVER_LOG_SEVERITY_NAME ${S_1})
+ endif()
+endforeach()
+
#
# Print build status
#
@@ -80,5 +96,5 @@ message(STATUS "*******************************************************")
message(STATUS "PROJECT_NAME : ${PROJECT_NAME}")
message(STATUS "CMAKE_SYSTEM_PROCESSOR : ${CMAKE_SYSTEM_PROCESSOR}")
message(STATUS "CMSIS_PATH : ${CMSIS_PATH}")
-message(STATUS "DRIVER_LOG_SUPPORT : ${DRIVER_LOG_SUPPORT}")
+message(STATUS "DRIVER_LOG_SEVERITY : ${DRIVER_LOG_SEVERITY} (${DRIVER_LOG_SEVERITY_NAME})")
message(STATUS "*******************************************************")