Skip to content

Commit 2b52c91

Browse files
nordicjmjhedberg
authored andcommitted
cmake: modules: version: Check that required fields are present
Will throw an error showing what the issue with the VERSION file is if a required field is missing Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
1 parent f26d245 commit 2b52c91

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

cmake/modules/version.cmake

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,17 @@ foreach(type file IN ZIP_LISTS VERSION_TYPE VERSION_FILE)
6767
set(${type}_VERSION_EXTRA ${CMAKE_MATCH_1})
6868

6969
# Validate all version fields fit in a single byte
70-
if(${type}_VERSION_MAJOR GREATER 255)
71-
message(FATAL_ERROR "VERSION_MAJOR must be in the range 0-255 (Current ${${type}_VERSION_MAJOR})")
70+
if(NOT DEFINED ${type}_VERSION_MAJOR OR ${type}_VERSION_MAJOR GREATER 255)
71+
message(FATAL_ERROR "VERSION_MAJOR must be present and in the range of 0-255 (Current: ${${type}_VERSION_MAJOR})")
7272
endif()
73-
if(${type}_VERSION_MINOR GREATER 255)
74-
message(FATAL_ERROR "VERSION_MINOR must be in the range 0-255 (Current ${${type}_VERSION_MINOR})")
73+
if(NOT DEFINED ${type}_VERSION_MINOR OR ${type}_VERSION_MINOR GREATER 255)
74+
message(FATAL_ERROR "VERSION_MINOR must be present and in the range of 0-255 (Current: ${${type}_VERSION_MINOR})")
7575
endif()
76-
if(${type}_PATCHLEVEL GREATER 255)
77-
message(FATAL_ERROR "PATCHLEVEL must be in the range 0-255 (Current ${${type}_PATCHLEVEL})")
76+
if(NOT DEFINED ${type}_PATCHLEVEL OR ${type}_PATCHLEVEL GREATER 255)
77+
message(FATAL_ERROR "PATCHLEVEL must be present and in the range of 0-255 (Current: ${${type}_PATCHLEVEL})")
7878
endif()
79-
if(${type}_VERSION_TWEAK GREATER 255)
80-
message(FATAL_ERROR "VERSION_TWEAK must be in the range 0-255 (Current ${${type}_VERSION_TWEAK})")
79+
if(NOT DEFINED ${type}_VERSION_TWEAK OR ${type}_VERSION_TWEAK GREATER 255)
80+
message(FATAL_ERROR "VERSION_TWEAK must be present and in the range of 0-255 (Current: ${${type}_VERSION_TWEAK})")
8181
endif()
8282

8383
# Temporary convenience variables

0 commit comments

Comments
 (0)