zephyr: fix compilation when no CONFIG_BOOT_ENCRYPTION_KEY_FILE
Fix compilation of zephyr builds when there is no
CONFIG_BOOT_ENCRYPTION_KEY_FILE set.
bug introduced by #1255
Signed-off-by: Wouter Cappelle <wouter.cappelle@crodeon.com>
diff --git a/boot/zephyr/CMakeLists.txt b/boot/zephyr/CMakeLists.txt
index dde8c36..026ce2b 100644
--- a/boot/zephyr/CMakeLists.txt
+++ b/boot/zephyr/CMakeLists.txt
@@ -305,22 +305,21 @@
zephyr_library_sources(${GENERATED_PUBKEY})
endif()
-# CONF_FILE points to the KConfig configuration files of the bootloader.
-unset(CONF_DIR)
-foreach(filepath ${CONF_FILE})
- file(READ ${filepath} temp_text)
- string(FIND "${temp_text}" ${CONFIG_BOOT_ENCRYPTION_KEY_FILE} match)
- if(${match} GREATER_EQUAL 0)
- if(NOT DEFINED CONF_DIR)
- get_filename_component(CONF_DIR ${filepath} DIRECTORY)
- else()
- message(FATAL_ERROR "Encryption key file defined in multiple conf files")
+if(CONFIG_BOOT_ENCRYPTION_KEY_FILE AND NOT CONFIG_BOOT_ENCRYPTION_KEY_FILE STREQUAL "")
+ # CONF_FILE points to the KConfig configuration files of the bootloader.
+ unset(CONF_DIR)
+ foreach(filepath ${CONF_FILE})
+ file(READ ${filepath} temp_text)
+ string(FIND "${temp_text}" ${CONFIG_BOOT_ENCRYPTION_KEY_FILE} match)
+ if(${match} GREATER_EQUAL 0)
+ if(NOT DEFINED CONF_DIR)
+ get_filename_component(CONF_DIR ${filepath} DIRECTORY)
+ else()
+ message(FATAL_ERROR "Encryption key file defined in multiple conf files")
+ endif()
endif()
- endif()
-endforeach()
+ endforeach()
-
-if(NOT CONFIG_BOOT_ENCRYPTION_KEY_FILE STREQUAL "")
if(IS_ABSOLUTE ${CONFIG_BOOT_ENCRYPTION_KEY_FILE})
set(KEY_FILE ${CONFIG_BOOT_ENCRYPTION_KEY_FILE})
elseif((DEFINED CONF_DIR) AND
@@ -329,7 +328,7 @@
else()
set(KEY_FILE ${MCUBOOT_DIR}/${CONFIG_BOOT_ENCRYPTION_KEY_FILE})
endif()
- message("MCUBoot bootloader key file: ${KEY_FILE}")
+ message("MCUBoot bootloader encryption key file: ${KEY_FILE}")
set(GENERATED_ENCKEY ${ZEPHYR_BINARY_DIR}/autogen-enckey.c)
add_custom_command(