aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorKristofer Jonsson <kristofer.jonsson@arm.com>2020-08-05 11:46:52 +0200
committerKristofer Jonsson <kristofer.jonsson@arm.com>2020-08-11 16:15:09 +0200
commitc05c98831fda3cc1b6138f2a888ce01caebb9983 (patch)
tree050d0d156654fed2bb4140e53e574eaf8e51adae /CMakeLists.txt
parent3c4391763b45c693e54b17b47e9bd65f0b3427c6 (diff)
downloadethos-u-core-driver-c05c98831fda3cc1b6138f2a888ce01caebb9983.tar.gz
Set default log severity in headers
Change-Id: Ia984092db29cc5f1294ecdcf5c2b6b744c6d32b2
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt31
1 files changed, 11 insertions, 20 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0dab28f..b857280 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,7 +27,10 @@ project(ethosu_core_driver VERSION 0.0.1)
option(DRIVER_PMU_AUTOINIT "Enable PMU boot auto-initialization" 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")
+
+set(LOG_NAMES emerg alert crit err warning notice info debug)
+set(ETHOSU_LOG_SEVERITY "info" CACHE STRING "Driver log severity level ${LOG_NAMES}")
+set_property(CACHE ETHOSU_LOG_SEVERITY PROPERTY STRINGS ${LOG_NAMES})
#
# Global settings
@@ -49,12 +52,10 @@ else()
message(FATAL_ERROR "Unsupported compiler ${CMAKE_SYSTEM_PROCESSOR}.")
endif()
-# 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}")
+# Check that ETHOSU_LOG_SEVERITY has one of the supported levels
+list(FIND LOG_NAMES ${ETHOSU_LOG_SEVERITY} LOG_SEVERITY)
+if (${LOG_SEVERITY} EQUAL -1)
+ message(FATAL_ERROR "Unsupported log level ${ETHOSU_LOG_SEVERITY}")
endif()
# Enable PMU boot auto-initialization
@@ -75,18 +76,8 @@ 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()
+# Set the log level for the target
+target_compile_definitions(ethosu_core_driver PRIVATE ETHOSU_LOG_SEVERITY=${LOG_SEVERITY})
#
# Print build status
@@ -96,5 +87,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_SEVERITY : ${DRIVER_LOG_SEVERITY} (${DRIVER_LOG_SEVERITY_NAME})")
+message(STATUS "ETHOSU_LOG_SEVERITY : ${ETHOSU_LOG_SEVERITY}")
message(STATUS "*******************************************************")